Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insane Proxy hack #329

Open
tj-commits opened this issue Aug 17, 2024 · 3 comments
Open

Insane Proxy hack #329

tj-commits opened this issue Aug 17, 2024 · 3 comments
Labels
new-example A proposal of the new example

Comments

@tj-commits
Copy link

const quoteless = new Proxy({}, {
  get(_, key) {
    if(key === Symbol.unscopables) return {}
    if(key === "__global") return globalThis
    return `${key} `
  },

  has(_, __) {
    return true
  }
})

with (quoteless) {
  __global.console.log(This + is + black + magic)
}

This outputs "This is black magic" to the console.
The way this works is that when a property is accessed then it just gets the name of the property that was accessed. Using with (quoteless) makes all the properties be accessible without quoteless.property. The way we access console.log is by checking if the key is a magic word, such as __global, to access the globalThis.
My explanation is terrible, don't use it in the real repository lol

@tj-commits tj-commits added the new-example A proposal of the new example label Aug 17, 2024
@Rudxain
Copy link

Rudxain commented Oct 15, 2024

I want to puke 💀. Take my upvote, lol.

Now that I think about it, the with (proxy) pattern has so much potential for obfuscation! JS is Turing-Complete and has access to runtime APIs, so a Proxy could be non-deterministic!

@Rudxain
Copy link

Rudxain commented Nov 7, 2024

I've created a monster 💀

@tj-commits
Copy link
Author

@Rudxain wow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-example A proposal of the new example
Projects
None yet
Development

No branches or pull requests

2 participants