j4k0xb / webcrack

Deobfuscate obfuscator.io, unminify and unpack bundled javascript
https://webcrack.netlify.app
MIT License
647 stars 73 forks source link

Apple Silicon Installation #83

Closed Offroaders123 closed 1 month ago

Offroaders123 commented 1 month ago

Describe the bug

While trying to install webcrack, it seems like there's an issue in regards to building the isolated-vm dependency on arm64 macOS, because it doesn't provide a pre-built binary for it.

I tried to work around this issue by installing isolated-vm with the x86_64 build, but that didn't seem to work out.

Stack Overflow - Installing node.js packages for different architecture

Then I looked into if I could clone the project and fix the issue myself, but then installing the dependencies for that has the same issue as well, so it's like the chicken or the egg problem. Well, maybe the Two Generals problem.

image

Expected Behaviour

The installation would be able to install on arm64 macOS.

Code

npm install --save-dev webcrack

Logs

npm error code 1
npm error path /Users/brandon/Documents/Coding Projects/Minefork/node_modules/isolated-vm
npm error command failed
npm error command sh -c prebuild-install || (node-gyp rebuild --release -j max && node-gyp clean)
npm error CXX(target) Release/obj.target/nortti/src/external_copy/serializer_nortti.o
npm error   CXX(target) Release/obj.target/nortti/src/isolate/allocator_nortti.o
npm error prebuild-install warn install No prebuilt binaries found (target=22.1.0 runtime=node arch=arm64 libc= platform=darwin)
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.1.0
npm error gyp info using node@22.1.0 | darwin | arm64
npm error gyp info find Python using Python version 3.12.3 found at "/opt/homebrew/opt/python@3.12/bin/python3.12"
npm error gyp WARN EACCES current user ("brandon") does not have permission to access the dev dir "/Users/brandon/Library/Caches/node-gyp/22.1.0"
npm error gyp WARN EACCES attempting to reinstall using temporary dev dir "/var/folders/sq/qpffdfds1zs_dd60pmhcbdch0000gn/T/.node-gyp"
npm error gyp info spawn /opt/homebrew/opt/python@3.12/bin/python3.12
npm error gyp info spawn args [
npm error gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/Users/brandon/Documents/Coding Projects/Minefork/node_modules/isolated-vm/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/var/folders/sq/qpffdfds1zs_dd60pmhcbdch0000gn/T/.node-gyp/22.1.0/include/node/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/var/folders/sq/qpffdfds1zs_dd60pmhcbdch0000gn/T/.node-gyp/22.1.0',
npm error gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/var/folders/sq/qpffdfds1zs_dd60pmhcbdch0000gn/T/.node-gyp/22.1.0/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/Users/brandon/Documents/Coding Projects/Minefork/node_modules/isolated-vm',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn make
npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 8 ]
npm error In file included from ../src/external_copy/serializer_nortti.cc:1:
npm error In file included from ../src/external_copy/serializer.h:2:
npm error In file included from ../src/external_copy/external_copy.h:9:
npm error In file included from ../src/isolate/generic/array.h:2:
npm error ../src/isolate/generic/error.h:84:65: error: value of type 'Local<Value> (Local<String>, Local<Value>)' is not implicitly convertible to 'v8::Local<v8::Value> (*)(v8::Local<v8::String>)'
npm error using RuntimeGenericError = detail::RuntimeErrorWithConstructor<v8::Exception::Error>;
npm error                                                                 ^~~~~~~~~~~~~~~~~~~~
npm error ../src/isolate/generic/error.h:85:62: error: value of type 'Local<Value> (Local<String>, Local<Value>)' is not implicitly convertible to 'v8::Local<v8::Value> (*)(v8::Local<v8::String>)'
npm error using RuntimeTypeError = detail::RuntimeErrorWithConstructor<v8::Exception::TypeError>;
npm error                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
npm error ../src/isolate/generic/error.h:86:63: error: value of type 'Local<Value> (Local<String>, Local<Value>)' is not implicitly convertible to 'v8::Local<v8::Value> (*)(v8::Local<v8::String>)'
npm error using RuntimeRangeError = detail::RuntimeErrorWithConstructor<v8::Exception::RangeError>;
npm error                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~
npm error In file included from ../src/isolate/allocator_nortti.cc:2:
npm error In file included from ../src/isolate/environment.h:13:
npm error In file included from ../src/isolate/strings.h:2:
npm error ../src/isolate/generic/error.h:84:65: error: value of type 'Local<Value> (Local<String>, Local<Value>)' is not implicitly convertible to 'v8::Local<v8::Value> (*)(v8::Local<v8::String>)'
npm error using RuntimeGenericError = detail::RuntimeErrorWithConstructor<v8::Exception::Error>;
npm error                                                                 ^~~~~~~~~~~~~~~~~~~~
npm error ../src/isolate/generic/error.h:85:62: error: value of type 'Local<Value> (Local<String>, Local<Value>)' is not implicitly convertible to 'v8::Local<v8::Value> (*)(v8::Local<v8::String>)'
npm error using RuntimeTypeError = detail::RuntimeErrorWithConstructor<v8::Exception::TypeError>;
npm error                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
npm error ../src/isolate/generic/error.h:86:63: error: value of type 'Local<Value> (Local<String>, Local<Value>)' is not implicitly convertible to 'v8::Local<v8::Value> (*)(v8::Local<v8::String>)'
npm error using RuntimeRangeError = detail::RuntimeErrorWithConstructor<v8::Exception::RangeError>;
npm error                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~
npm error In file included from ../src/external_copy/serializer_nortti.cc:1:
npm error ../src/external_copy/serializer.h:101:12: error: use of undeclared identifier 'RuntimeRangeError'; did you mean 'RuntimeError'?
npm error                                         throw RuntimeRangeError("Array buffer allocation failed");
npm error                                               ^
npm error ../src/isolate/generic/error.h:13:7: note: 'RuntimeError' declared here
npm error class RuntimeError : public std::exception {};
npm error       ^
npm error In file included from ../src/external_copy/serializer_nortti.cc:2:
npm error ../src/isolate/functor_runners.h:42:18: error: unknown type name 'RuntimeTypeError'; did you mean 'RuntimeError'?
npm error                 } catch (const RuntimeTypeError& cc_error) {
npm error                                ^~~~~~~~~~~~~~~~
npm error                                RuntimeError
npm error ../src/isolate/generic/error.h:13:7: note: 'RuntimeError' declared here
npm error class RuntimeError : public std::exception {};
npm error       ^
npm error In file included from ../src/external_copy/serializer_nortti.cc:2:
npm error ../src/isolate/functor_runners.h:44:94: error: no member named 'GetMessage' in 'ivm::RuntimeError'
npm error                         fn2(std::make_unique<ExternalCopyError>(ExternalCopyError::ErrorType::TypeError, cc_error.GetMessage().c_str(), cc_error.GetStackTrace()));
npm error                                                                                                          ~~~~~~~~ ^
npm error ../src/isolate/functor_runners.h:44:125: error: no member named 'GetStackTrace' in 'ivm::RuntimeError'
npm error                         fn2(std::make_unique<ExternalCopyError>(ExternalCopyError::ErrorType::TypeError, cc_error.GetMessage().c_str(), cc_error.GetStackTrace()));
npm error                                                                                                                                         ~~~~~~~~ ^
npm error ../src/isolate/functor_runners.h:45:18: error: unknown type name 'RuntimeRangeError'; did you mean 'RuntimeError'?
npm error                 } catch (const RuntimeRangeError& cc_error) {
npm error                                ^~~~~~~~~~~~~~~~~
npm error                                RuntimeError
npm error ../src/isolate/generic/error.h:13:7: note: 'RuntimeError' declared here
npm error class RuntimeError : public std::exception {};
npm error       ^
npm error In file included from ../src/external_copy/serializer_nortti.cc:2:
npm error ../src/isolate/functor_runners.h:46:95: error: no member named 'GetMessage' in 'ivm::RuntimeError'
npm error                         fn2(std::make_unique<ExternalCopyError>(ExternalCopyError::ErrorType::RangeError, cc_error.GetMessage().c_str(), cc_error.GetStackTrace()));
npm error                                                                                                           ~~~~~~~~ ^
npm error ../src/isolate/functor_runners.h:46:126: error: no member named 'GetStackTrace' in 'ivm::RuntimeError'
npm error                         fn2(std::make_unique<ExternalCopyError>(ExternalCopyError::ErrorType::RangeError, cc_error.GetMessage().c_str(), cc_error.GetStackTrace()));
npm error                                                                                                                                          ~~~~~~~~ ^
npm error ../src/isolate/functor_runners.h:47:18: error: unknown type name 'RuntimeGenericError'
npm error                 } catch (const RuntimeGenericError& cc_error) {
npm error                                ^
npm error ../src/isolate/functor_runners.h:45:18: warning: exception of type 'const RuntimeError &' will be caught by earlier handler [-Wexceptions]
npm error                 } catch (const RuntimeRangeError& cc_error) {
npm error                                ^
npm error ../src/isolate/functor_runners.h:42:18: note: for type 'const RuntimeError &'
npm error                 } catch (const RuntimeTypeError& cc_error) {
npm error                                ^
npm error ../src/isolate/functor_runners.h:49:18: warning: exception of type 'const detail::RuntimeErrorWithMessage &' will be caught by earlier handler [-Wexceptions]
npm error                 } catch (const detail::RuntimeErrorWithMessage& cc_error) {
npm error                                ^
npm error ../src/isolate/functor_runners.h:42:18: note: for type 'const RuntimeError &'
npm error                 } catch (const RuntimeTypeError& cc_error) {
npm error                                ^
npm error ../src/isolate/functor_runners.h:51:18: warning: exception of type 'const RuntimeError &' will be caught by earlier handler [-Wexceptions]
npm error                 } catch (const RuntimeError& cc_error) {
npm error                                ^
npm error ../src/isolate/functor_runners.h:42:18: note: for type 'const RuntimeError &'
npm error                 } catch (const RuntimeTypeError& cc_error) {
npm error                                ^
npm error 3 errors generated.
npm error In file included from ../src/external_copy/serializer_nortti.cc:3:
npm error In file included from ../src/module/transferable.h:2:
npm error In file included from ../src/isolate/class_handle.h:6:
npm error In file included from ../src/isolate/generic/../generic/callbacks.h:4:
npm error ../src/isolate/generic/extract_params.h:97:27: error: expected ';' after expression
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires at least "+ std::to_string(adjusted)+ (adjusted == 1 ? " parameter" : " parameters")};
npm error                                                       ^
npm error                                                       ;
npm error ../src/isolate/generic/extract_params.h:97:11: error: use of undeclared identifier 'RuntimeTypeError'
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires at least "+ std::to_string(adjusted)+ (adjusted == 1 ? " parameter" : " parameters")};
npm error                                       ^
npm error ../src/isolate/generic/extract_params.h:97:137: error: expected ';' after expression
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires at least "+ std::to_string(adjusted)+ (adjusted == 1 ? " parameter" : " parameters")};
npm error                                                                                                                                                                     ^
npm error                                                                                                                                                                     ;
npm error make: *** [Release/obj.target/nortti/src/isolate/allocator_nortti.o] Error 1
npm error make: *** Waiting for unfinished jobs....
npm error ../src/isolate/generic/extract_params.h:111:27: error: expected ';' after expression
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires `this` to be "+ ex.type};
npm error                                                       ^
npm error                                                       ;
npm error ../src/isolate/generic/extract_params.h:111:11: error: use of undeclared identifier 'RuntimeTypeError'
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires `this` to be "+ ex.type};
npm error                                       ^
npm error ../src/isolate/generic/extract_params.h:111:76: error: expected ';' after expression
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires `this` to be "+ ex.type};
npm error                                                                                                        ^
npm error                                                                                                        ;
npm error ../src/isolate/generic/extract_params.h:113:27: error: expected ';' after expression
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires parameter "+ std::to_string(ii + 1)+ " to be "+ ex.type};
npm error                                                       ^
npm error                                                       ;
npm error ../src/isolate/generic/extract_params.h:113:11: error: use of undeclared identifier 'RuntimeTypeError'
npm error                                 throw RuntimeTypeError{CalleeName()+ " requires parameter "+ std::to_string(ii + 1)+ " to be "+ ex.type};
npm error                                       ^
npm error fatal error: too many errors emitted, stopping now [-ferror-limit=]
npm error 3 warnings and 20 errors generated.
npm error make: *** [Release/obj.target/nortti/src/external_copy/serializer_nortti.o] Error 1
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm error gyp ERR! System Darwin 23.4.0
npm error gyp ERR! command "/opt/homebrew/Cellar/node/22.1.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" "-j" "max"
npm error gyp ERR! cwd /Users/brandon/Documents/Coding Projects/Minefork/node_modules/isolated-vm
npm error gyp ERR! node -v v22.1.0
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: /Users/brandon/.npm/_logs/2024-05-20T04_17_11_362Z-debug-0.log
j4k0xb commented 1 month ago

by installing isolated-vm with the x86_64 build

Can't use another architecture, it should automatically build the darwin/arm64 version on your system

Try using node 20: https://github.com/laverdet/isolated-vm/issues/468

Offroaders123 commented 1 month ago

Oh I forgot to mention that I was going to try using Rosetta 2 to run the x86_64 build. Thank you for the fix recommendation as well! I'll go try that next.

j4k0xb commented 1 month ago

Did you get it to work?

Offroaders123 commented 1 month ago

Yep, looks like it did work out! So downgrading to Node 20 was the fix.

Reference

brew install node@20
brew unlink node && brew link --force --overwrite node@20