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

Segmentation fault on arm64 #97

Closed
ViRb3 opened this issue Jun 25, 2024 · 4 comments
Closed

Segmentation fault on arm64 #97

ViRb3 opened this issue Jun 25, 2024 · 4 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@ViRb3
Copy link

ViRb3 commented Jun 25, 2024

Describe the bug

Using a MacBook Pro M3 Max, macOS 14.5, I seem to get segmentation fault unless I run under Docker with x64 emulation.

Crash 1:

brew install node@20
npm install -g webcrack
nano test.js # put sample from https://obfuscator.io/
webcrack test.js

Crash 2:

docker run --rm -it node:20 bash
npm install -g webcrack
nano test.js # put sample from https://obfuscator.io/
webcrack test.js

Works:

docker run --rm --platform linux/amd64 -it node:20 bash
npm install -g webcrack
nano test.js # put sample from https://obfuscator.io/
webcrack test.js

Expected Behaviour

Works

Code

(function(_0x3c38ae,_0x257ca0){var _0x1e3a62=_0x3e7c,_0x3aed1f=_0x3c38ae();while(!![]){try{var _0x235d27=parseInt(_0x1e3a62(0x1c4))/0x1+parseInt(_0x1e3a62(0x1c7))/0x2*(parseInt(_0x1e3a62(0x1bf))/0x3)+parseInt(_0x1e3a62(0x1be))/0x4*(-parseInt(_0x1e3a62(0x1c1))/0x5)+-parseInt(_0x1e3a62(0x1c2))/0x6+-parseInt(_0x1e3a62(0x1bd))/0x7+-parseInt(_0x1e3a62(0x1c5))/0x8+parseInt(_0x1e3a62(0x1c0))/0x9;if(_0x235d27===_0x257ca0)break;else _0x3aed1f['push'](_0x3aed1f['shift']());}catch(_0x258f14){_0x3aed1f['push'](_0x3aed1f['shift']());}}}(_0x2bc4,0x7a037));function hi(){var _0x421681=_0x3e7c;console[_0x421681(0x1c6)](_0x421681(0x1c3));}hi();function _0x3e7c(_0x5e2698,_0xd7c7b3){var _0x2bc450=_0x2bc4();return _0x3e7c=function(_0x3e7cb6,_0x16f751){_0x3e7cb6=_0x3e7cb6-0x1bd;var _0x11de87=_0x2bc450[_0x3e7cb6];return _0x11de87;},_0x3e7c(_0x5e2698,_0xd7c7b3);}function _0x2bc4(){var _0x5ce9ee=['log','86090ZJVrvx','5113934sLXMER','3730616RHmWvu','21GOexsv','23663583iKhaKk','5LtiXIf','3490884jrxCzi','Hello\x20World!','333779AHuTpI','4156672RWUGSQ'];_0x2bc4=function(){return _0x5ce9ee;};return _0x2bc4();}

Logs

  webcrack:transforms prepare: started +0ms
  webcrack:transforms prepare: finished with 4 changes +3ms
  webcrack:transforms deobfuscate: started +0ms
  webcrack:deobfuscate String Array: 11 strings +0ms
  webcrack:deobfuscate String Array Rotate: yes +0ms
  webcrack:deobfuscate String Array Encodings: 1 +1ms
  webcrack:transforms inline-object-props: started +4ms
  webcrack:transforms inline-object-props: finished with 0 changes +0ms
  webcrack:transforms inline-decoder-wrappers: started +0ms
  webcrack:transforms inline-decoder-wrappers: finished with 14 changes +1ms
  webcrack:transforms inline-decoded-strings: started +2ms
[1]    98368 segmentation fault  npx webcrack test.js
@ViRb3 ViRb3 added the bug Something isn't working label Jun 25, 2024
@j4k0xb
Copy link
Owner

j4k0xb commented Jun 26, 2024

looks related to #83 (comment)
can you try the other command as well and make sure the global node version is correct?

@ViRb3
Copy link
Author

ViRb3 commented Jun 26, 2024

That particular issue you linked is webcrack failing compilation on node 22. I ran into that as well, but when I switched to node 20, it compiled and ran fine. It's just during deobfuscation that it hits the segmentation fault. If you look at the docker commands, they run the exact same node version, and one segfaults while the other doesn't, so this must be an arm64 issue. Has anyone ever confirmed this works on arm64?

@j4k0xb
Copy link
Owner

j4k0xb commented Jun 26, 2024

The crash happens in https://github.com/laverdet/isolated-vm
It had an update recently, please try if the example works and otherwise it would be better to create an issue there

@ViRb3
Copy link
Author

ViRb3 commented Jun 26, 2024

Did some more testing and found out a few interesting things:

  1. The segmentation fault comes from isolated-vm as you mentioned; node@20 crashes with the example too.
  2. node@18 does not crash with either.
  3. With node@20, the --no-node-snapshot workaround actually works with both. The correct command is:
    NODE_OPTIONS=--no-node-snapshot webcrack ~/index.js
    You mentioned this workaround in segmentation fault #18, but you missed the -- prefix, which is why it didn't work before. You may want to edit it just in case someone else finds it.
  4. node@22 works with the latest version of isolated-vm. No crash and no workaround necessary.

It may be worthwhile updating isolated-vm and directing users to node@22, and/or documenting the node@20 workaround in README.

Anyway, I'm definitely unblocked now, thanks a lot!

@j4k0xb j4k0xb closed this as completed Jun 27, 2024
@j4k0xb j4k0xb added the dependencies Pull requests that update a dependency file label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants