frida 16.2.1 → 16.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BSDmakefile +6 -0
- package/Makefile +16 -0
- package/README.md +14 -11
- package/configure +18 -0
- package/configure.bat +22 -0
- package/dist/native.js +0 -8
- package/lib/application.ts +98 -0
- package/lib/authentication.ts +3 -0
- package/lib/build.py +50 -0
- package/lib/bus.ts +30 -0
- package/lib/cancellable.ts +33 -0
- package/lib/child.ts +15 -0
- package/lib/crash.ts +11 -0
- package/lib/device.ts +329 -0
- package/lib/device_manager.ts +69 -0
- package/lib/endpoint_parameters.ts +56 -0
- package/lib/icon.ts +15 -0
- package/lib/index.ts +311 -0
- package/lib/iostream.ts +78 -0
- package/lib/meson.build +53 -0
- package/lib/native.ts +9 -0
- package/lib/portal_membership.ts +10 -0
- package/lib/portal_service.ts +105 -0
- package/lib/process.ts +57 -0
- package/lib/relay.ts +44 -0
- package/lib/script.ts +352 -0
- package/lib/session.ts +113 -0
- package/lib/signals.ts +45 -0
- package/lib/socket_address.ts +35 -0
- package/lib/spawn.ts +4 -0
- package/lib/system_parameters.ts +78 -0
- package/make.bat +23 -0
- package/meson.build +160 -0
- package/meson.options +11 -0
- package/package.json +27 -6
- package/releng/deps.py +1133 -0
- package/releng/deps.toml +391 -0
- package/releng/devkit-assets/frida-core-example-unix.c +188 -0
- package/releng/devkit-assets/frida-core-example-windows.c +197 -0
- package/releng/devkit-assets/frida-core-example.sln +28 -0
- package/releng/devkit-assets/frida-core-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-core-example.vcxproj.filters +27 -0
- package/releng/devkit-assets/frida-gum-example-unix.c +122 -0
- package/releng/devkit-assets/frida-gum-example-windows.c +132 -0
- package/releng/devkit-assets/frida-gum-example.sln +28 -0
- package/releng/devkit-assets/frida-gum-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-gum-example.vcxproj.filters +27 -0
- package/releng/devkit-assets/frida-gumjs-example-unix.c +84 -0
- package/releng/devkit-assets/frida-gumjs-example-windows.c +91 -0
- package/releng/devkit-assets/frida-gumjs-example.sln +28 -0
- package/releng/devkit-assets/frida-gumjs-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-gumjs-example.vcxproj.filters +27 -0
- package/releng/devkit.py +535 -0
- package/releng/env.py +420 -0
- package/releng/env_android.py +150 -0
- package/releng/env_apple.py +176 -0
- package/releng/env_generic.py +373 -0
- package/releng/frida_version.py +69 -0
- package/releng/machine_file.py +44 -0
- package/releng/machine_spec.py +290 -0
- package/releng/meson/meson.py +27 -0
- package/releng/meson/mesonbuild/__init__.py +0 -0
- package/releng/meson/mesonbuild/_pathlib.py +63 -0
- package/releng/meson/mesonbuild/_typing.py +69 -0
- package/releng/meson/mesonbuild/arglist.py +321 -0
- package/releng/meson/mesonbuild/ast/__init__.py +23 -0
- package/releng/meson/mesonbuild/ast/interpreter.py +441 -0
- package/releng/meson/mesonbuild/ast/introspection.py +374 -0
- package/releng/meson/mesonbuild/ast/postprocess.py +109 -0
- package/releng/meson/mesonbuild/ast/printer.py +620 -0
- package/releng/meson/mesonbuild/ast/visitor.py +161 -0
- package/releng/meson/mesonbuild/backend/__init__.py +0 -0
- package/releng/meson/mesonbuild/backend/backends.py +2047 -0
- package/releng/meson/mesonbuild/backend/ninjabackend.py +3808 -0
- package/releng/meson/mesonbuild/backend/nonebackend.py +26 -0
- package/releng/meson/mesonbuild/backend/vs2010backend.py +2078 -0
- package/releng/meson/mesonbuild/backend/vs2012backend.py +35 -0
- package/releng/meson/mesonbuild/backend/vs2013backend.py +34 -0
- package/releng/meson/mesonbuild/backend/vs2015backend.py +35 -0
- package/releng/meson/mesonbuild/backend/vs2017backend.py +59 -0
- package/releng/meson/mesonbuild/backend/vs2019backend.py +54 -0
- package/releng/meson/mesonbuild/backend/vs2022backend.py +54 -0
- package/releng/meson/mesonbuild/backend/xcodebackend.py +1781 -0
- package/releng/meson/mesonbuild/build.py +3249 -0
- package/releng/meson/mesonbuild/cargo/__init__.py +5 -0
- package/releng/meson/mesonbuild/cargo/builder.py +238 -0
- package/releng/meson/mesonbuild/cargo/cfg.py +274 -0
- package/releng/meson/mesonbuild/cargo/interpreter.py +733 -0
- package/releng/meson/mesonbuild/cargo/manifest.py +227 -0
- package/releng/meson/mesonbuild/cargo/version.py +95 -0
- package/releng/meson/mesonbuild/cmake/__init__.py +28 -0
- package/releng/meson/mesonbuild/cmake/common.py +331 -0
- package/releng/meson/mesonbuild/cmake/data/__init__.py +0 -0
- package/releng/meson/mesonbuild/cmake/data/preload.cmake +82 -0
- package/releng/meson/mesonbuild/cmake/executor.py +241 -0
- package/releng/meson/mesonbuild/cmake/fileapi.py +324 -0
- package/releng/meson/mesonbuild/cmake/generator.py +186 -0
- package/releng/meson/mesonbuild/cmake/interpreter.py +1267 -0
- package/releng/meson/mesonbuild/cmake/toolchain.py +248 -0
- package/releng/meson/mesonbuild/cmake/traceparser.py +814 -0
- package/releng/meson/mesonbuild/cmake/tracetargets.py +161 -0
- package/releng/meson/mesonbuild/compilers/__init__.py +86 -0
- package/releng/meson/mesonbuild/compilers/asm.py +307 -0
- package/releng/meson/mesonbuild/compilers/c.py +788 -0
- package/releng/meson/mesonbuild/compilers/c_function_attributes.py +143 -0
- package/releng/meson/mesonbuild/compilers/compilers.py +1388 -0
- package/releng/meson/mesonbuild/compilers/cpp.py +1035 -0
- package/releng/meson/mesonbuild/compilers/cs.py +136 -0
- package/releng/meson/mesonbuild/compilers/cuda.py +806 -0
- package/releng/meson/mesonbuild/compilers/cython.py +91 -0
- package/releng/meson/mesonbuild/compilers/d.py +861 -0
- package/releng/meson/mesonbuild/compilers/detect.py +1396 -0
- package/releng/meson/mesonbuild/compilers/fortran.py +523 -0
- package/releng/meson/mesonbuild/compilers/java.py +113 -0
- package/releng/meson/mesonbuild/compilers/mixins/__init__.py +0 -0
- package/releng/meson/mesonbuild/compilers/mixins/arm.py +167 -0
- package/releng/meson/mesonbuild/compilers/mixins/ccrx.py +113 -0
- package/releng/meson/mesonbuild/compilers/mixins/clang.py +170 -0
- package/releng/meson/mesonbuild/compilers/mixins/clike.py +1330 -0
- package/releng/meson/mesonbuild/compilers/mixins/compcert.py +117 -0
- package/releng/meson/mesonbuild/compilers/mixins/elbrus.py +93 -0
- package/releng/meson/mesonbuild/compilers/mixins/emscripten.py +89 -0
- package/releng/meson/mesonbuild/compilers/mixins/gnu.py +629 -0
- package/releng/meson/mesonbuild/compilers/mixins/intel.py +167 -0
- package/releng/meson/mesonbuild/compilers/mixins/islinker.py +120 -0
- package/releng/meson/mesonbuild/compilers/mixins/metrowerks.py +279 -0
- package/releng/meson/mesonbuild/compilers/mixins/pgi.py +88 -0
- package/releng/meson/mesonbuild/compilers/mixins/ti.py +130 -0
- package/releng/meson/mesonbuild/compilers/mixins/visualstudio.py +458 -0
- package/releng/meson/mesonbuild/compilers/mixins/xc16.py +111 -0
- package/releng/meson/mesonbuild/compilers/objc.py +120 -0
- package/releng/meson/mesonbuild/compilers/objcpp.py +102 -0
- package/releng/meson/mesonbuild/compilers/rust.py +230 -0
- package/releng/meson/mesonbuild/compilers/swift.py +131 -0
- package/releng/meson/mesonbuild/compilers/vala.py +121 -0
- package/releng/meson/mesonbuild/coredata.py +1532 -0
- package/releng/meson/mesonbuild/dependencies/__init__.py +252 -0
- package/releng/meson/mesonbuild/dependencies/base.py +663 -0
- package/releng/meson/mesonbuild/dependencies/boost.py +1083 -0
- package/releng/meson/mesonbuild/dependencies/cmake.py +656 -0
- package/releng/meson/mesonbuild/dependencies/coarrays.py +80 -0
- package/releng/meson/mesonbuild/dependencies/configtool.py +163 -0
- package/releng/meson/mesonbuild/dependencies/cuda.py +295 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakeLists.txt +102 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakeListsLLVM.txt +204 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakePathInfo.txt +31 -0
- package/releng/meson/mesonbuild/dependencies/data/__init__.py +0 -0
- package/releng/meson/mesonbuild/dependencies/detect.py +225 -0
- package/releng/meson/mesonbuild/dependencies/dev.py +707 -0
- package/releng/meson/mesonbuild/dependencies/dub.py +424 -0
- package/releng/meson/mesonbuild/dependencies/factory.py +146 -0
- package/releng/meson/mesonbuild/dependencies/framework.py +111 -0
- package/releng/meson/mesonbuild/dependencies/hdf5.py +168 -0
- package/releng/meson/mesonbuild/dependencies/misc.py +618 -0
- package/releng/meson/mesonbuild/dependencies/mpi.py +231 -0
- package/releng/meson/mesonbuild/dependencies/pkgconfig.py +570 -0
- package/releng/meson/mesonbuild/dependencies/platform.py +52 -0
- package/releng/meson/mesonbuild/dependencies/python.py +431 -0
- package/releng/meson/mesonbuild/dependencies/qt.py +484 -0
- package/releng/meson/mesonbuild/dependencies/scalapack.py +142 -0
- package/releng/meson/mesonbuild/dependencies/ui.py +281 -0
- package/releng/meson/mesonbuild/depfile.py +82 -0
- package/releng/meson/mesonbuild/envconfig.py +480 -0
- package/releng/meson/mesonbuild/environment.py +987 -0
- package/releng/meson/mesonbuild/interpreter/__init__.py +47 -0
- package/releng/meson/mesonbuild/interpreter/compiler.py +900 -0
- package/releng/meson/mesonbuild/interpreter/dependencyfallbacks.py +386 -0
- package/releng/meson/mesonbuild/interpreter/interpreter.py +3595 -0
- package/releng/meson/mesonbuild/interpreter/interpreterobjects.py +1096 -0
- package/releng/meson/mesonbuild/interpreter/kwargs.py +479 -0
- package/releng/meson/mesonbuild/interpreter/mesonmain.py +487 -0
- package/releng/meson/mesonbuild/interpreter/primitives/__init__.py +29 -0
- package/releng/meson/mesonbuild/interpreter/primitives/array.py +108 -0
- package/releng/meson/mesonbuild/interpreter/primitives/boolean.py +52 -0
- package/releng/meson/mesonbuild/interpreter/primitives/dict.py +88 -0
- package/releng/meson/mesonbuild/interpreter/primitives/integer.py +86 -0
- package/releng/meson/mesonbuild/interpreter/primitives/range.py +38 -0
- package/releng/meson/mesonbuild/interpreter/primitives/string.py +247 -0
- package/releng/meson/mesonbuild/interpreter/type_checking.py +853 -0
- package/releng/meson/mesonbuild/interpreterbase/__init__.py +126 -0
- package/releng/meson/mesonbuild/interpreterbase/_unholder.py +25 -0
- package/releng/meson/mesonbuild/interpreterbase/baseobjects.py +174 -0
- package/releng/meson/mesonbuild/interpreterbase/decorators.py +806 -0
- package/releng/meson/mesonbuild/interpreterbase/disabler.py +35 -0
- package/releng/meson/mesonbuild/interpreterbase/exceptions.py +22 -0
- package/releng/meson/mesonbuild/interpreterbase/helpers.py +67 -0
- package/releng/meson/mesonbuild/interpreterbase/interpreterbase.py +665 -0
- package/releng/meson/mesonbuild/interpreterbase/operator.py +32 -0
- package/releng/meson/mesonbuild/linkers/__init__.py +20 -0
- package/releng/meson/mesonbuild/linkers/base.py +39 -0
- package/releng/meson/mesonbuild/linkers/detect.py +229 -0
- package/releng/meson/mesonbuild/linkers/linkers.py +1614 -0
- package/releng/meson/mesonbuild/mcompile.py +380 -0
- package/releng/meson/mesonbuild/mconf.py +368 -0
- package/releng/meson/mesonbuild/mdevenv.py +234 -0
- package/releng/meson/mesonbuild/mdist.py +376 -0
- package/releng/meson/mesonbuild/mesondata.py +38 -0
- package/releng/meson/mesonbuild/mesonlib.py +23 -0
- package/releng/meson/mesonbuild/mesonmain.py +289 -0
- package/releng/meson/mesonbuild/minit.py +204 -0
- package/releng/meson/mesonbuild/minstall.py +864 -0
- package/releng/meson/mesonbuild/mintro.py +667 -0
- package/releng/meson/mesonbuild/mlog.py +542 -0
- package/releng/meson/mesonbuild/modules/__init__.py +270 -0
- package/releng/meson/mesonbuild/modules/cmake.py +442 -0
- package/releng/meson/mesonbuild/modules/cuda.py +377 -0
- package/releng/meson/mesonbuild/modules/dlang.py +117 -0
- package/releng/meson/mesonbuild/modules/external_project.py +306 -0
- package/releng/meson/mesonbuild/modules/fs.py +323 -0
- package/releng/meson/mesonbuild/modules/gnome.py +2215 -0
- package/releng/meson/mesonbuild/modules/hotdoc.py +487 -0
- package/releng/meson/mesonbuild/modules/i18n.py +405 -0
- package/releng/meson/mesonbuild/modules/icestorm.py +123 -0
- package/releng/meson/mesonbuild/modules/java.py +112 -0
- package/releng/meson/mesonbuild/modules/keyval.py +65 -0
- package/releng/meson/mesonbuild/modules/modtest.py +33 -0
- package/releng/meson/mesonbuild/modules/pkgconfig.py +744 -0
- package/releng/meson/mesonbuild/modules/python.py +556 -0
- package/releng/meson/mesonbuild/modules/python3.py +85 -0
- package/releng/meson/mesonbuild/modules/qt.py +621 -0
- package/releng/meson/mesonbuild/modules/qt4.py +23 -0
- package/releng/meson/mesonbuild/modules/qt5.py +23 -0
- package/releng/meson/mesonbuild/modules/qt6.py +22 -0
- package/releng/meson/mesonbuild/modules/rust.py +355 -0
- package/releng/meson/mesonbuild/modules/simd.py +114 -0
- package/releng/meson/mesonbuild/modules/sourceset.py +291 -0
- package/releng/meson/mesonbuild/modules/wayland.py +151 -0
- package/releng/meson/mesonbuild/modules/windows.py +207 -0
- package/releng/meson/mesonbuild/mparser.py +1114 -0
- package/releng/meson/mesonbuild/msetup.py +365 -0
- package/releng/meson/mesonbuild/msubprojects.py +764 -0
- package/releng/meson/mesonbuild/mtest.py +2201 -0
- package/releng/meson/mesonbuild/munstable_coredata.py +107 -0
- package/releng/meson/mesonbuild/optinterpreter.py +276 -0
- package/releng/meson/mesonbuild/programs.py +367 -0
- package/releng/meson/mesonbuild/rewriter.py +1075 -0
- package/releng/meson/mesonbuild/scripts/__init__.py +10 -0
- package/releng/meson/mesonbuild/scripts/clangformat.py +55 -0
- package/releng/meson/mesonbuild/scripts/clangtidy.py +30 -0
- package/releng/meson/mesonbuild/scripts/cleantrees.py +35 -0
- package/releng/meson/mesonbuild/scripts/cmake_run_ctgt.py +103 -0
- package/releng/meson/mesonbuild/scripts/cmd_or_ps.ps1 +17 -0
- package/releng/meson/mesonbuild/scripts/copy.py +19 -0
- package/releng/meson/mesonbuild/scripts/coverage.py +214 -0
- package/releng/meson/mesonbuild/scripts/delwithsuffix.py +27 -0
- package/releng/meson/mesonbuild/scripts/depfixer.py +495 -0
- package/releng/meson/mesonbuild/scripts/depscan.py +198 -0
- package/releng/meson/mesonbuild/scripts/dirchanger.py +20 -0
- package/releng/meson/mesonbuild/scripts/env2mfile.py +402 -0
- package/releng/meson/mesonbuild/scripts/externalproject.py +106 -0
- package/releng/meson/mesonbuild/scripts/gettext.py +86 -0
- package/releng/meson/mesonbuild/scripts/gtkdochelper.py +286 -0
- package/releng/meson/mesonbuild/scripts/hotdochelper.py +40 -0
- package/releng/meson/mesonbuild/scripts/itstool.py +77 -0
- package/releng/meson/mesonbuild/scripts/meson_exe.py +115 -0
- package/releng/meson/mesonbuild/scripts/msgfmthelper.py +29 -0
- package/releng/meson/mesonbuild/scripts/pycompile.py +54 -0
- package/releng/meson/mesonbuild/scripts/python_info.py +121 -0
- package/releng/meson/mesonbuild/scripts/regen_checker.py +55 -0
- package/releng/meson/mesonbuild/scripts/run_tool.py +58 -0
- package/releng/meson/mesonbuild/scripts/scanbuild.py +57 -0
- package/releng/meson/mesonbuild/scripts/symbolextractor.py +322 -0
- package/releng/meson/mesonbuild/scripts/tags.py +44 -0
- package/releng/meson/mesonbuild/scripts/test_loaded_modules.py +14 -0
- package/releng/meson/mesonbuild/scripts/uninstall.py +41 -0
- package/releng/meson/mesonbuild/scripts/vcstagger.py +35 -0
- package/releng/meson/mesonbuild/scripts/yasm.py +24 -0
- package/releng/meson/mesonbuild/templates/__init__.py +0 -0
- package/releng/meson/mesonbuild/templates/cpptemplates.py +143 -0
- package/releng/meson/mesonbuild/templates/cstemplates.py +90 -0
- package/releng/meson/mesonbuild/templates/ctemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/cudatemplates.py +143 -0
- package/releng/meson/mesonbuild/templates/dlangtemplates.py +109 -0
- package/releng/meson/mesonbuild/templates/fortrantemplates.py +101 -0
- package/releng/meson/mesonbuild/templates/javatemplates.py +94 -0
- package/releng/meson/mesonbuild/templates/mesontemplates.py +70 -0
- package/releng/meson/mesonbuild/templates/objcpptemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/objctemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/rusttemplates.py +79 -0
- package/releng/meson/mesonbuild/templates/samplefactory.py +41 -0
- package/releng/meson/mesonbuild/templates/sampleimpl.py +160 -0
- package/releng/meson/mesonbuild/templates/valatemplates.py +82 -0
- package/releng/meson/mesonbuild/utils/__init__.py +0 -0
- package/releng/meson/mesonbuild/utils/core.py +166 -0
- package/releng/meson/mesonbuild/utils/platform.py +27 -0
- package/releng/meson/mesonbuild/utils/posix.py +32 -0
- package/releng/meson/mesonbuild/utils/universal.py +2445 -0
- package/releng/meson/mesonbuild/utils/vsenv.py +126 -0
- package/releng/meson/mesonbuild/utils/win32.py +29 -0
- package/releng/meson/mesonbuild/wrap/__init__.py +59 -0
- package/releng/meson/mesonbuild/wrap/wrap.py +846 -0
- package/releng/meson/mesonbuild/wrap/wraptool.py +198 -0
- package/releng/meson-scripts/BSDmakefile +6 -0
- package/releng/meson-scripts/Makefile +16 -0
- package/releng/meson-scripts/configure +18 -0
- package/releng/meson-scripts/configure.bat +22 -0
- package/releng/meson-scripts/make.bat +23 -0
- package/releng/meson_configure.py +506 -0
- package/releng/meson_make.py +131 -0
- package/releng/mkdevkit.py +107 -0
- package/releng/mkfatmacho.py +54 -0
- package/releng/post-process-oabi.py +97 -0
- package/releng/progress.py +14 -0
- package/releng/sync-from-upstream.py +185 -0
- package/releng/tomlkit/tomlkit/__init__.py +59 -0
- package/releng/tomlkit/tomlkit/_compat.py +22 -0
- package/releng/tomlkit/tomlkit/_types.py +83 -0
- package/releng/tomlkit/tomlkit/_utils.py +158 -0
- package/releng/tomlkit/tomlkit/api.py +308 -0
- package/releng/tomlkit/tomlkit/container.py +875 -0
- package/releng/tomlkit/tomlkit/exceptions.py +227 -0
- package/releng/tomlkit/tomlkit/items.py +1967 -0
- package/releng/tomlkit/tomlkit/parser.py +1141 -0
- package/releng/tomlkit/tomlkit/py.typed +0 -0
- package/releng/tomlkit/tomlkit/source.py +180 -0
- package/releng/tomlkit/tomlkit/toml_char.py +52 -0
- package/releng/tomlkit/tomlkit/toml_document.py +7 -0
- package/releng/tomlkit/tomlkit/toml_file.py +58 -0
- package/releng/winenv.py +140 -0
- package/scripts/adjust-version.py +19 -0
- package/scripts/detect-version.py +40 -0
- package/scripts/fetch-abi-bits.py +343 -0
- package/scripts/install.js +23 -0
- package/scripts/package.py +15 -0
- package/src/addon.cc +76 -0
- package/src/application.cc +148 -0
- package/src/application.h +31 -0
- package/src/authentication.cc +174 -0
- package/src/authentication.h +24 -0
- package/src/bus.cc +167 -0
- package/src/bus.h +33 -0
- package/src/cancellable.cc +117 -0
- package/src/cancellable.h +31 -0
- package/src/child.cc +150 -0
- package/src/child.h +32 -0
- package/src/crash.cc +122 -0
- package/src/crash.h +30 -0
- package/src/device.cc +1302 -0
- package/src/device.h +55 -0
- package/src/device_manager.cc +362 -0
- package/src/device_manager.h +35 -0
- package/src/endpoint_parameters.cc +171 -0
- package/src/endpoint_parameters.h +28 -0
- package/src/glib_context.cc +62 -0
- package/src/glib_context.h +29 -0
- package/src/glib_object.cc +25 -0
- package/src/glib_object.h +37 -0
- package/src/iostream.cc +247 -0
- package/src/iostream.h +30 -0
- package/src/meson.build +26 -0
- package/src/operation.h +94 -0
- package/src/portal_membership.cc +100 -0
- package/src/portal_membership.h +26 -0
- package/src/portal_service.cc +401 -0
- package/src/portal_service.h +40 -0
- package/src/process.cc +135 -0
- package/src/process.h +30 -0
- package/src/relay.cc +139 -0
- package/src/relay.h +31 -0
- package/src/runtime.cc +443 -0
- package/src/runtime.h +64 -0
- package/src/script.cc +301 -0
- package/src/script.h +36 -0
- package/src/session.cc +860 -0
- package/src/session.h +42 -0
- package/src/signals.cc +334 -0
- package/src/signals.h +47 -0
- package/src/spawn.cc +95 -0
- package/src/spawn.h +27 -0
- package/src/usage_monitor.h +117 -0
- package/src/uv_context.cc +118 -0
- package/src/uv_context.h +40 -0
- package/src/win_delay_load_hook.cc +63 -0
- package/subprojects/frida-core.wrap +8 -0
- package/subprojects/nan.wrap +9 -0
- package/subprojects/packagefiles/nan.patch +13 -0
- package/test/data/index.ts +13 -0
- package/test/data/unixvictim-linux-x86 +0 -0
- package/test/data/unixvictim-linux-x86_64 +0 -0
- package/test/data/unixvictim-macos +0 -0
- package/test/device.ts +27 -0
- package/test/device_manager.ts +16 -0
- package/test/labrat.ts +32 -0
- package/test/script.ts +176 -0
- package/test/session.ts +73 -0
- package/tsconfig.json +18 -0
package/src/device.cc
ADDED
|
@@ -0,0 +1,1302 @@
|
|
|
1
|
+
#include "device.h"
|
|
2
|
+
|
|
3
|
+
#include "application.h"
|
|
4
|
+
#include "bus.h"
|
|
5
|
+
#include "child.h"
|
|
6
|
+
#include "crash.h"
|
|
7
|
+
#include "iostream.h"
|
|
8
|
+
#include "operation.h"
|
|
9
|
+
#include "process.h"
|
|
10
|
+
#include "session.h"
|
|
11
|
+
#include "signals.h"
|
|
12
|
+
#include "spawn.h"
|
|
13
|
+
|
|
14
|
+
#include <cstring>
|
|
15
|
+
|
|
16
|
+
#define DEVICE_DATA_CONSTRUCTOR "device:ctor"
|
|
17
|
+
|
|
18
|
+
using std::strcmp;
|
|
19
|
+
using v8::Array;
|
|
20
|
+
using v8::Boolean;
|
|
21
|
+
using v8::DEFAULT;
|
|
22
|
+
using v8::External;
|
|
23
|
+
using v8::Function;
|
|
24
|
+
using v8::Isolate;
|
|
25
|
+
using v8::Local;
|
|
26
|
+
using v8::Number;
|
|
27
|
+
using v8::Object;
|
|
28
|
+
using v8::Persistent;
|
|
29
|
+
using v8::ReadOnly;
|
|
30
|
+
using v8::String;
|
|
31
|
+
using v8::Uint32;
|
|
32
|
+
using v8::Value;
|
|
33
|
+
|
|
34
|
+
namespace frida {
|
|
35
|
+
|
|
36
|
+
Device::Device(FridaDevice* handle, Runtime* runtime)
|
|
37
|
+
: GLibObject(handle, runtime) {
|
|
38
|
+
g_object_ref(handle_);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Device::~Device() {
|
|
42
|
+
frida_unref(handle_);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void Device::Init(Local<Object> exports, Runtime* runtime) {
|
|
46
|
+
auto isolate = Isolate::GetCurrent();
|
|
47
|
+
|
|
48
|
+
auto name = Nan::New("Device").ToLocalChecked();
|
|
49
|
+
auto tpl = CreateTemplate(name, New, runtime);
|
|
50
|
+
|
|
51
|
+
auto instance_tpl = tpl->InstanceTemplate();
|
|
52
|
+
auto data = Local<Value>();
|
|
53
|
+
Nan::SetAccessor(instance_tpl, Nan::New("isLost").ToLocalChecked(), IsLost, 0,
|
|
54
|
+
data, DEFAULT, ReadOnly);
|
|
55
|
+
Nan::SetAccessor(instance_tpl, Nan::New("bus").ToLocalChecked(), GetBus, 0,
|
|
56
|
+
data, DEFAULT, ReadOnly);
|
|
57
|
+
Nan::SetAccessor(instance_tpl, Nan::New("type").ToLocalChecked(), GetType, 0,
|
|
58
|
+
data, DEFAULT, ReadOnly);
|
|
59
|
+
Nan::SetAccessor(instance_tpl, Nan::New("icon").ToLocalChecked(), GetIcon, 0,
|
|
60
|
+
data, DEFAULT, ReadOnly);
|
|
61
|
+
Nan::SetAccessor(instance_tpl, Nan::New("name").ToLocalChecked(), GetName, 0,
|
|
62
|
+
data, DEFAULT, ReadOnly);
|
|
63
|
+
Nan::SetAccessor(instance_tpl, Nan::New("id").ToLocalChecked(), GetId, 0,
|
|
64
|
+
data, DEFAULT, ReadOnly);
|
|
65
|
+
|
|
66
|
+
Nan::SetPrototypeMethod(tpl, "querySystemParameters", QuerySystemParameters);
|
|
67
|
+
Nan::SetPrototypeMethod(tpl, "getFrontmostApplication",
|
|
68
|
+
GetFrontmostApplication);
|
|
69
|
+
Nan::SetPrototypeMethod(tpl, "enumerateApplications", EnumerateApplications);
|
|
70
|
+
Nan::SetPrototypeMethod(tpl, "enumerateProcesses", EnumerateProcesses);
|
|
71
|
+
Nan::SetPrototypeMethod(tpl, "enableSpawnGating", EnableSpawnGating);
|
|
72
|
+
Nan::SetPrototypeMethod(tpl, "disableSpawnGating", DisableSpawnGating);
|
|
73
|
+
Nan::SetPrototypeMethod(tpl, "enumeratePendingSpawn", EnumeratePendingSpawn);
|
|
74
|
+
Nan::SetPrototypeMethod(tpl, "enumeratePendingChildren",
|
|
75
|
+
EnumeratePendingChildren);
|
|
76
|
+
Nan::SetPrototypeMethod(tpl, "spawn", Spawn);
|
|
77
|
+
Nan::SetPrototypeMethod(tpl, "input", Input);
|
|
78
|
+
Nan::SetPrototypeMethod(tpl, "resume", Resume);
|
|
79
|
+
Nan::SetPrototypeMethod(tpl, "kill", Kill);
|
|
80
|
+
Nan::SetPrototypeMethod(tpl, "attach", Attach);
|
|
81
|
+
Nan::SetPrototypeMethod(tpl, "injectLibraryFile", InjectLibraryFile);
|
|
82
|
+
Nan::SetPrototypeMethod(tpl, "injectLibraryBlob", InjectLibraryBlob);
|
|
83
|
+
Nan::SetPrototypeMethod(tpl, "openChannel", OpenChannel);
|
|
84
|
+
Nan::SetPrototypeMethod(tpl, "unpair", Unpair);
|
|
85
|
+
|
|
86
|
+
auto ctor = Nan::GetFunction(tpl).ToLocalChecked();
|
|
87
|
+
Nan::Set(exports, name, ctor);
|
|
88
|
+
runtime->SetDataPointer(DEVICE_DATA_CONSTRUCTOR,
|
|
89
|
+
new Persistent<Function>(isolate, ctor));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Local<Object> Device::New(gpointer handle, Runtime* runtime) {
|
|
93
|
+
auto ctor = Nan::New<Function>(
|
|
94
|
+
*static_cast<Persistent<Function>*>(
|
|
95
|
+
runtime->GetDataPointer(DEVICE_DATA_CONSTRUCTOR)));
|
|
96
|
+
const int argc = 1;
|
|
97
|
+
Local<Value> argv[argc] = { Nan::New<External>(handle) };
|
|
98
|
+
return Nan::NewInstance(ctor, argc, argv).ToLocalChecked();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
NAN_METHOD(Device::New) {
|
|
102
|
+
if (!info.IsConstructCall()) {
|
|
103
|
+
Nan::ThrowError("Use the `new` keyword to create a new instance");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (info.Length() != 1 || !info[0]->IsExternal()) {
|
|
108
|
+
Nan::ThrowTypeError("Bad argument, expected raw handle");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
auto runtime = GetRuntimeFromConstructorArgs(info);
|
|
113
|
+
|
|
114
|
+
auto handle = static_cast<FridaDevice*>(
|
|
115
|
+
Local<External>::Cast(info[0])->Value());
|
|
116
|
+
auto wrapper = new Device(handle, runtime);
|
|
117
|
+
auto obj = info.This();
|
|
118
|
+
wrapper->Wrap(obj);
|
|
119
|
+
auto signals_obj = Signals::New(handle, runtime, TransformSignal, runtime);
|
|
120
|
+
|
|
121
|
+
Nan::Set(obj, Nan::New("signals").ToLocalChecked(), signals_obj);
|
|
122
|
+
|
|
123
|
+
auto signals_wrapper = ObjectWrap::Unwrap<Signals>(signals_obj);
|
|
124
|
+
signals_wrapper->SetConnectCallback(OnConnect, runtime);
|
|
125
|
+
signals_wrapper->SetDisconnectCallback(OnDisconnect, runtime);
|
|
126
|
+
|
|
127
|
+
info.GetReturnValue().Set(obj);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
NAN_PROPERTY_GETTER(Device::GetId) {
|
|
131
|
+
auto handle = ObjectWrap::Unwrap<Device>(
|
|
132
|
+
info.Holder())->GetHandle<FridaDevice>();
|
|
133
|
+
|
|
134
|
+
info.GetReturnValue().Set(
|
|
135
|
+
Nan::New(frida_device_get_id(handle)).ToLocalChecked());
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
NAN_PROPERTY_GETTER(Device::GetName) {
|
|
139
|
+
auto handle = ObjectWrap::Unwrap<Device>(
|
|
140
|
+
info.Holder())->GetHandle<FridaDevice>();
|
|
141
|
+
|
|
142
|
+
info.GetReturnValue().Set(
|
|
143
|
+
Nan::New(frida_device_get_name(handle)).ToLocalChecked());
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
NAN_PROPERTY_GETTER(Device::GetIcon) {
|
|
147
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
148
|
+
auto handle = wrapper->GetHandle<FridaDevice>();
|
|
149
|
+
|
|
150
|
+
GVariant* icon = frida_device_get_icon(handle);
|
|
151
|
+
if (icon != NULL)
|
|
152
|
+
info.GetReturnValue().Set(Runtime::ValueFromVariant(icon));
|
|
153
|
+
else
|
|
154
|
+
info.GetReturnValue().SetNull();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
NAN_PROPERTY_GETTER(Device::GetType) {
|
|
158
|
+
auto handle = ObjectWrap::Unwrap<Device>(
|
|
159
|
+
info.Holder())->GetHandle<FridaDevice>();
|
|
160
|
+
|
|
161
|
+
info.GetReturnValue().Set(Runtime::ValueFromEnum(
|
|
162
|
+
frida_device_get_dtype(handle), FRIDA_TYPE_DEVICE_TYPE));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
NAN_PROPERTY_GETTER(Device::GetBus) {
|
|
166
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
167
|
+
auto handle = wrapper->GetHandle<FridaDevice>();
|
|
168
|
+
|
|
169
|
+
info.GetReturnValue().Set(
|
|
170
|
+
Bus::New(frida_device_get_bus(handle), wrapper->runtime_));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
NAN_PROPERTY_GETTER(Device::IsLost) {
|
|
174
|
+
auto handle = ObjectWrap::Unwrap<Device>(
|
|
175
|
+
info.Holder())->GetHandle<FridaDevice>();
|
|
176
|
+
|
|
177
|
+
info.GetReturnValue().Set(
|
|
178
|
+
Nan::New(static_cast<bool>(frida_device_is_lost(handle))));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
namespace {
|
|
182
|
+
|
|
183
|
+
class QuerySystemParametersOperation : public Operation<FridaDevice> {
|
|
184
|
+
protected:
|
|
185
|
+
void Begin() {
|
|
186
|
+
frida_device_query_system_parameters(handle_, cancellable_, OnReady, this);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void End(GAsyncResult* result, GError** error) {
|
|
190
|
+
parameters_ = frida_device_query_system_parameters_finish(handle_, result,
|
|
191
|
+
error);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
Local<Value> Result(Isolate* isolate) {
|
|
195
|
+
auto value = Runtime::ValueFromParametersDict(parameters_);
|
|
196
|
+
g_hash_table_unref(parameters_);
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private:
|
|
201
|
+
GHashTable* parameters_;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
NAN_METHOD(Device::QuerySystemParameters) {
|
|
207
|
+
auto isolate = info.GetIsolate();
|
|
208
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
209
|
+
|
|
210
|
+
auto operation = new QuerySystemParametersOperation();
|
|
211
|
+
operation->Schedule(isolate, wrapper, info);
|
|
212
|
+
|
|
213
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
namespace {
|
|
217
|
+
|
|
218
|
+
class GetFrontmostApplicationOperation : public Operation<FridaDevice> {
|
|
219
|
+
public:
|
|
220
|
+
GetFrontmostApplicationOperation(FridaFrontmostQueryOptions* options)
|
|
221
|
+
: application_(NULL),
|
|
222
|
+
options_(options) {
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
~GetFrontmostApplicationOperation() {
|
|
226
|
+
g_object_unref(options_);
|
|
227
|
+
g_clear_object(&application_);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
protected:
|
|
231
|
+
void Begin() {
|
|
232
|
+
frida_device_get_frontmost_application(handle_, options_, cancellable_,
|
|
233
|
+
OnReady, this);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
void End(GAsyncResult* result, GError** error) {
|
|
237
|
+
application_ = frida_device_get_frontmost_application_finish(handle_,
|
|
238
|
+
result, error);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
Local<Value> Result(Isolate* isolate) {
|
|
242
|
+
if (application_ == NULL)
|
|
243
|
+
return Nan::Null();
|
|
244
|
+
return Application::New(application_, runtime_);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private:
|
|
248
|
+
FridaApplication* application_;
|
|
249
|
+
FridaFrontmostQueryOptions* options_;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
NAN_METHOD(Device::GetFrontmostApplication) {
|
|
255
|
+
auto isolate = info.GetIsolate();
|
|
256
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
257
|
+
|
|
258
|
+
if (info.Length() < 1) {
|
|
259
|
+
Nan::ThrowTypeError("Missing one or more arguments");
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
auto scope_value = info[0];
|
|
264
|
+
|
|
265
|
+
auto options = frida_frontmost_query_options_new();
|
|
266
|
+
bool valid = true;
|
|
267
|
+
|
|
268
|
+
if (!scope_value->IsNull()) {
|
|
269
|
+
FridaScope scope;
|
|
270
|
+
if (Runtime::ValueToEnum(scope_value, FRIDA_TYPE_SCOPE, &scope))
|
|
271
|
+
frida_frontmost_query_options_set_scope(options, scope);
|
|
272
|
+
else
|
|
273
|
+
valid = false;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (!valid) {
|
|
277
|
+
g_object_unref(options);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
auto operation = new GetFrontmostApplicationOperation(options);
|
|
282
|
+
operation->Schedule(isolate, wrapper, info);
|
|
283
|
+
|
|
284
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
namespace {
|
|
288
|
+
|
|
289
|
+
class EnumerateApplicationsOperation : public Operation<FridaDevice> {
|
|
290
|
+
public:
|
|
291
|
+
EnumerateApplicationsOperation(FridaApplicationQueryOptions* options)
|
|
292
|
+
: applications_(NULL),
|
|
293
|
+
options_(options) {
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
~EnumerateApplicationsOperation() {
|
|
297
|
+
g_object_unref(options_);
|
|
298
|
+
g_clear_object(&applications_);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
protected:
|
|
302
|
+
void Begin() {
|
|
303
|
+
frida_device_enumerate_applications(handle_, options_, cancellable_,
|
|
304
|
+
OnReady, this);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
void End(GAsyncResult* result, GError** error) {
|
|
308
|
+
applications_ = frida_device_enumerate_applications_finish(handle_, result,
|
|
309
|
+
error);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
Local<Value> Result(Isolate* isolate) {
|
|
313
|
+
auto size = frida_application_list_size(applications_);
|
|
314
|
+
auto applications = Nan::New<Array>(size);
|
|
315
|
+
for (auto i = 0; i != size; i++) {
|
|
316
|
+
auto handle = frida_application_list_get(applications_, i);
|
|
317
|
+
auto application = Application::New(handle, runtime_);
|
|
318
|
+
Nan::Set(applications, i, application);
|
|
319
|
+
g_object_unref(handle);
|
|
320
|
+
}
|
|
321
|
+
return applications;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private:
|
|
325
|
+
FridaApplicationList* applications_;
|
|
326
|
+
FridaApplicationQueryOptions* options_;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
NAN_METHOD(Device::EnumerateApplications) {
|
|
332
|
+
auto isolate = info.GetIsolate();
|
|
333
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
334
|
+
|
|
335
|
+
if (info.Length() < 2) {
|
|
336
|
+
Nan::ThrowTypeError("Missing one or more arguments");
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
auto identifiers_value = info[0];
|
|
341
|
+
auto scope_value = info[1];
|
|
342
|
+
|
|
343
|
+
auto options = frida_application_query_options_new();
|
|
344
|
+
bool valid = true;
|
|
345
|
+
|
|
346
|
+
if (identifiers_value->IsArray()) {
|
|
347
|
+
auto array = Local<Array>::Cast(identifiers_value);
|
|
348
|
+
|
|
349
|
+
uint32_t n = array->Length();
|
|
350
|
+
|
|
351
|
+
for (uint32_t i = 0; i != n; i++) {
|
|
352
|
+
auto element_value = Nan::Get(array, i).ToLocalChecked();
|
|
353
|
+
|
|
354
|
+
if (!element_value->IsString()) {
|
|
355
|
+
Nan::ThrowTypeError("Bad argument, not a valid application ID");
|
|
356
|
+
valid = false;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
Nan::Utf8String identifier(element_value);
|
|
360
|
+
|
|
361
|
+
frida_application_query_options_select_identifier(options, *identifier);
|
|
362
|
+
}
|
|
363
|
+
} else {
|
|
364
|
+
Nan::ThrowTypeError("Bad argument, 'identifiers' must be an array of "
|
|
365
|
+
"application IDs");
|
|
366
|
+
valid = false;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (valid && !scope_value->IsNull()) {
|
|
370
|
+
FridaScope scope;
|
|
371
|
+
if (Runtime::ValueToEnum(scope_value, FRIDA_TYPE_SCOPE, &scope))
|
|
372
|
+
frida_application_query_options_set_scope(options, scope);
|
|
373
|
+
else
|
|
374
|
+
valid = false;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (!valid) {
|
|
378
|
+
g_object_unref(options);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
auto operation = new EnumerateApplicationsOperation(options);
|
|
383
|
+
operation->Schedule(isolate, wrapper, info);
|
|
384
|
+
|
|
385
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
namespace {
|
|
389
|
+
|
|
390
|
+
class EnumerateProcessesOperation : public Operation<FridaDevice> {
|
|
391
|
+
public:
|
|
392
|
+
EnumerateProcessesOperation(FridaProcessQueryOptions* options)
|
|
393
|
+
: processes_(NULL),
|
|
394
|
+
options_(options) {
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
~EnumerateProcessesOperation() {
|
|
398
|
+
g_object_unref(options_);
|
|
399
|
+
g_clear_object(&processes_);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
protected:
|
|
403
|
+
void Begin() {
|
|
404
|
+
frida_device_enumerate_processes(handle_, options_, cancellable_, OnReady,
|
|
405
|
+
this);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
void End(GAsyncResult* result, GError** error) {
|
|
409
|
+
processes_ = frida_device_enumerate_processes_finish(handle_, result,
|
|
410
|
+
error);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
Local<Value> Result(Isolate* isolate) {
|
|
414
|
+
auto size = frida_process_list_size(processes_);
|
|
415
|
+
auto processes = Nan::New<Array>(size);
|
|
416
|
+
for (auto i = 0; i != size; i++) {
|
|
417
|
+
auto handle = frida_process_list_get(processes_, i);
|
|
418
|
+
auto process = Process::New(handle, runtime_);
|
|
419
|
+
Nan::Set(processes, i, process);
|
|
420
|
+
g_object_unref(handle);
|
|
421
|
+
}
|
|
422
|
+
return processes;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
private:
|
|
426
|
+
FridaProcessList* processes_;
|
|
427
|
+
FridaProcessQueryOptions* options_;
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
NAN_METHOD(Device::EnumerateProcesses) {
|
|
433
|
+
auto isolate = info.GetIsolate();
|
|
434
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
435
|
+
|
|
436
|
+
if (info.Length() < 2) {
|
|
437
|
+
Nan::ThrowTypeError("Missing one or more arguments");
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
auto pids_value = info[0];
|
|
442
|
+
auto scope_value = info[1];
|
|
443
|
+
|
|
444
|
+
auto options = frida_process_query_options_new();
|
|
445
|
+
bool valid = true;
|
|
446
|
+
|
|
447
|
+
if (pids_value->IsArray()) {
|
|
448
|
+
auto array = Local<Array>::Cast(pids_value);
|
|
449
|
+
|
|
450
|
+
uint32_t n = array->Length();
|
|
451
|
+
|
|
452
|
+
for (uint32_t i = 0; i != n; i++) {
|
|
453
|
+
auto element_value = Nan::Get(array, i).ToLocalChecked();
|
|
454
|
+
|
|
455
|
+
int64_t pid = -1;
|
|
456
|
+
if (element_value->IsNumber()) {
|
|
457
|
+
pid = Nan::To<int64_t>(element_value).FromMaybe(-1);
|
|
458
|
+
}
|
|
459
|
+
if (pid < 0) {
|
|
460
|
+
Nan::ThrowTypeError("Bad argument, not a valid process ID");
|
|
461
|
+
valid = false;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
frida_process_query_options_select_pid(options, pid);
|
|
466
|
+
}
|
|
467
|
+
} else {
|
|
468
|
+
Nan::ThrowTypeError("Bad argument, 'pids' must be an array of process IDs");
|
|
469
|
+
valid = false;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (valid && !scope_value->IsNull()) {
|
|
473
|
+
FridaScope scope;
|
|
474
|
+
if (Runtime::ValueToEnum(scope_value, FRIDA_TYPE_SCOPE, &scope))
|
|
475
|
+
frida_process_query_options_set_scope(options, scope);
|
|
476
|
+
else
|
|
477
|
+
valid = false;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (!valid) {
|
|
481
|
+
g_object_unref(options);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
auto operation = new EnumerateProcessesOperation(options);
|
|
486
|
+
operation->Schedule(isolate, wrapper, info);
|
|
487
|
+
|
|
488
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
namespace {
|
|
492
|
+
|
|
493
|
+
class EnableSpawnGatingOperation : public Operation<FridaDevice> {
|
|
494
|
+
protected:
|
|
495
|
+
void Begin() {
|
|
496
|
+
frida_device_enable_spawn_gating(handle_, cancellable_, OnReady, this);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
void End(GAsyncResult* result, GError** error) {
|
|
500
|
+
frida_device_enable_spawn_gating_finish(handle_, result, error);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
Local<Value> Result(Isolate* isolate) {
|
|
504
|
+
return Nan::Undefined();
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
NAN_METHOD(Device::EnableSpawnGating) {
|
|
511
|
+
auto isolate = info.GetIsolate();
|
|
512
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
513
|
+
|
|
514
|
+
auto operation = new EnableSpawnGatingOperation();
|
|
515
|
+
operation->Schedule(isolate, wrapper, info);
|
|
516
|
+
|
|
517
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
namespace {
|
|
521
|
+
|
|
522
|
+
class DisableSpawnGatingOperation : public Operation<FridaDevice> {
|
|
523
|
+
protected:
|
|
524
|
+
void Begin() {
|
|
525
|
+
frida_device_disable_spawn_gating(handle_, cancellable_, OnReady, this);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
void End(GAsyncResult* result, GError** error) {
|
|
529
|
+
frida_device_disable_spawn_gating_finish(handle_, result, error);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
Local<Value> Result(Isolate* isolate) {
|
|
533
|
+
return Nan::Undefined();
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
NAN_METHOD(Device::DisableSpawnGating) {
|
|
540
|
+
auto isolate = info.GetIsolate();
|
|
541
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
542
|
+
|
|
543
|
+
auto operation = new DisableSpawnGatingOperation();
|
|
544
|
+
operation->Schedule(isolate, wrapper, info);
|
|
545
|
+
|
|
546
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
namespace {
|
|
550
|
+
|
|
551
|
+
class EnumeratePendingSpawnOperation : public Operation<FridaDevice> {
|
|
552
|
+
protected:
|
|
553
|
+
void Begin() {
|
|
554
|
+
frida_device_enumerate_pending_spawn(handle_, cancellable_, OnReady, this);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
void End(GAsyncResult* result, GError** error) {
|
|
558
|
+
pending_spawn_ = frida_device_enumerate_pending_spawn_finish(handle_,
|
|
559
|
+
result, error);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
Local<Value> Result(Isolate* isolate) {
|
|
563
|
+
auto size = frida_spawn_list_size(pending_spawn_);
|
|
564
|
+
auto pending_spawn = Nan::New<Array>(size);
|
|
565
|
+
for (auto i = 0; i != size; i++) {
|
|
566
|
+
auto handle = frida_spawn_list_get(pending_spawn_, i);
|
|
567
|
+
auto spawn = Spawn::New(handle, runtime_);
|
|
568
|
+
Nan::Set(pending_spawn, i, spawn);
|
|
569
|
+
g_object_unref(handle);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
g_object_unref(pending_spawn_);
|
|
573
|
+
|
|
574
|
+
return pending_spawn;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
private:
|
|
578
|
+
FridaSpawnList* pending_spawn_;
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
NAN_METHOD(Device::EnumeratePendingSpawn) {
|
|
584
|
+
auto isolate = info.GetIsolate();
|
|
585
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
586
|
+
|
|
587
|
+
auto operation = new EnumeratePendingSpawnOperation();
|
|
588
|
+
operation->Schedule(isolate, wrapper, info);
|
|
589
|
+
|
|
590
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
namespace {
|
|
594
|
+
|
|
595
|
+
class EnumeratePendingChildrenOperation : public Operation<FridaDevice> {
|
|
596
|
+
protected:
|
|
597
|
+
void Begin() {
|
|
598
|
+
frida_device_enumerate_pending_children(handle_, cancellable_, OnReady,
|
|
599
|
+
this);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
void End(GAsyncResult* result, GError** error) {
|
|
603
|
+
pending_children_ = frida_device_enumerate_pending_children_finish(handle_,
|
|
604
|
+
result, error);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
Local<Value> Result(Isolate* isolate) {
|
|
608
|
+
auto size = frida_child_list_size(pending_children_);
|
|
609
|
+
auto pending_children = Nan::New<Array>(size);
|
|
610
|
+
for (auto i = 0; i != size; i++) {
|
|
611
|
+
auto handle = frida_child_list_get(pending_children_, i);
|
|
612
|
+
auto child = Child::New(handle, runtime_);
|
|
613
|
+
Nan::Set(pending_children, i, child);
|
|
614
|
+
g_object_unref(handle);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
g_object_unref(pending_children_);
|
|
618
|
+
|
|
619
|
+
return pending_children;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
private:
|
|
623
|
+
FridaChildList* pending_children_;
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
NAN_METHOD(Device::EnumeratePendingChildren) {
|
|
629
|
+
auto isolate = info.GetIsolate();
|
|
630
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
631
|
+
|
|
632
|
+
auto operation = new EnumeratePendingChildrenOperation();
|
|
633
|
+
operation->Schedule(isolate, wrapper, info);
|
|
634
|
+
|
|
635
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
namespace {
|
|
639
|
+
|
|
640
|
+
class SpawnOperation : public Operation<FridaDevice> {
|
|
641
|
+
public:
|
|
642
|
+
SpawnOperation(gchar* program, FridaSpawnOptions* options)
|
|
643
|
+
: program_(program),
|
|
644
|
+
options_(options) {
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
~SpawnOperation() {
|
|
648
|
+
g_object_unref(options_);
|
|
649
|
+
g_free(program_);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
protected:
|
|
653
|
+
void Begin() {
|
|
654
|
+
frida_device_spawn(handle_, program_, options_, cancellable_, OnReady,
|
|
655
|
+
this);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
void End(GAsyncResult* result, GError** error) {
|
|
659
|
+
pid_ = frida_device_spawn_finish(handle_, result, error);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
Local<Value> Result(Isolate* isolate) {
|
|
663
|
+
return Nan::New<Uint32>(pid_);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
private:
|
|
667
|
+
gchar* program_;
|
|
668
|
+
FridaSpawnOptions* options_;
|
|
669
|
+
guint pid_;
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
NAN_METHOD(Device::Spawn) {
|
|
675
|
+
auto isolate = info.GetIsolate();
|
|
676
|
+
auto context = isolate->GetCurrentContext();
|
|
677
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
678
|
+
|
|
679
|
+
if (info.Length() < 7) {
|
|
680
|
+
Nan::ThrowTypeError("Missing one or more arguments");
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
auto program_value = info[0];
|
|
685
|
+
auto argv_value = info[1];
|
|
686
|
+
auto envp_value = info[2];
|
|
687
|
+
auto env_value = info[3];
|
|
688
|
+
auto cwd_value = info[4];
|
|
689
|
+
auto stdio_value = info[5];
|
|
690
|
+
auto aux_value = info[6];
|
|
691
|
+
|
|
692
|
+
if (!program_value->IsString()) {
|
|
693
|
+
Nan::ThrowTypeError("Bad argument, 'program' must be a string");
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
Nan::Utf8String program(program_value);
|
|
697
|
+
|
|
698
|
+
auto options = frida_spawn_options_new();
|
|
699
|
+
bool valid = true;
|
|
700
|
+
|
|
701
|
+
if (!argv_value->IsNull()) {
|
|
702
|
+
gchar** argv;
|
|
703
|
+
gint argv_length;
|
|
704
|
+
valid = Runtime::ValueToStrv(argv_value, &argv, &argv_length);
|
|
705
|
+
if (valid) {
|
|
706
|
+
frida_spawn_options_set_argv(options, argv, argv_length);
|
|
707
|
+
g_strfreev(argv);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
if (valid && !envp_value->IsNull()) {
|
|
712
|
+
gchar** envp;
|
|
713
|
+
gint envp_length;
|
|
714
|
+
valid = Runtime::ValueToEnvp(envp_value, &envp, &envp_length);
|
|
715
|
+
if (valid) {
|
|
716
|
+
frida_spawn_options_set_envp(options, envp, envp_length);
|
|
717
|
+
g_strfreev(envp);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (valid && !env_value->IsNull()) {
|
|
722
|
+
gchar** env;
|
|
723
|
+
gint env_length;
|
|
724
|
+
valid = Runtime::ValueToEnvp(env_value, &env, &env_length);
|
|
725
|
+
if (valid) {
|
|
726
|
+
frida_spawn_options_set_env(options, env, env_length);
|
|
727
|
+
g_strfreev(env);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (valid && !cwd_value->IsNull()) {
|
|
732
|
+
if (cwd_value->IsString()) {
|
|
733
|
+
Nan::Utf8String cwd(cwd_value);
|
|
734
|
+
frida_spawn_options_set_cwd(options, *cwd);
|
|
735
|
+
} else {
|
|
736
|
+
Nan::ThrowTypeError("Bad argument, 'cwd' must be a string");
|
|
737
|
+
valid = false;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
if (valid && !stdio_value->IsNull()) {
|
|
742
|
+
FridaStdio stdio;
|
|
743
|
+
valid = Runtime::ValueToEnum(stdio_value, FRIDA_TYPE_STDIO, &stdio);
|
|
744
|
+
if (valid)
|
|
745
|
+
frida_spawn_options_set_stdio(options, stdio);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (valid) {
|
|
749
|
+
if (aux_value->IsObject()) {
|
|
750
|
+
auto object = Local<Object>::Cast(aux_value);
|
|
751
|
+
|
|
752
|
+
Local<Array> keys(object->GetOwnPropertyNames(context).ToLocalChecked());
|
|
753
|
+
uint32_t n = keys->Length();
|
|
754
|
+
|
|
755
|
+
GHashTable* aux = frida_spawn_options_get_aux(options);
|
|
756
|
+
|
|
757
|
+
for (uint32_t i = 0; i != n; i++) {
|
|
758
|
+
auto key = Nan::Get(keys, i).ToLocalChecked();
|
|
759
|
+
auto value = Nan::Get(object, key).ToLocalChecked();
|
|
760
|
+
|
|
761
|
+
Nan::Utf8String key_str(key);
|
|
762
|
+
|
|
763
|
+
GVariant* raw_value;
|
|
764
|
+
if (value->IsBoolean()) {
|
|
765
|
+
raw_value = g_variant_new_boolean(
|
|
766
|
+
Local<Boolean>::Cast(value)->Value());
|
|
767
|
+
} else if (value->IsNumber()) {
|
|
768
|
+
raw_value = g_variant_new_int64(
|
|
769
|
+
static_cast<gint64>(Local<Number>::Cast(value)->Value()));
|
|
770
|
+
} else {
|
|
771
|
+
Nan::Utf8String value_str(value);
|
|
772
|
+
raw_value = g_variant_new_string(*value_str);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
g_hash_table_insert(aux, g_strdup(*key_str),
|
|
776
|
+
g_variant_ref_sink(raw_value));
|
|
777
|
+
}
|
|
778
|
+
} else {
|
|
779
|
+
Nan::ThrowTypeError("Bad argument, 'aux' must be an object");
|
|
780
|
+
valid = false;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (!valid) {
|
|
785
|
+
g_object_unref(options);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
auto operation = new SpawnOperation(g_strdup(*program), options);
|
|
790
|
+
operation->Schedule(isolate, wrapper, info);
|
|
791
|
+
|
|
792
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
namespace {
|
|
796
|
+
|
|
797
|
+
class InputOperation : public Operation<FridaDevice> {
|
|
798
|
+
public:
|
|
799
|
+
InputOperation(guint pid, GBytes* data)
|
|
800
|
+
: pid_(pid), data_(data) {
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
~InputOperation() {
|
|
804
|
+
g_bytes_unref(data_);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
protected:
|
|
808
|
+
void Begin() {
|
|
809
|
+
frida_device_input(handle_, pid_, data_, cancellable_, OnReady, this);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
void End(GAsyncResult* result, GError** error) {
|
|
813
|
+
frida_device_input_finish(handle_, result, error);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
Local<Value> Result(Isolate* isolate) {
|
|
817
|
+
return Nan::Undefined();
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
private:
|
|
821
|
+
const guint pid_;
|
|
822
|
+
GBytes* data_;
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
NAN_METHOD(Device::Input) {
|
|
828
|
+
auto isolate = info.GetIsolate();
|
|
829
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
830
|
+
|
|
831
|
+
if (info.Length() < 2 || !info[0]->IsNumber() ||
|
|
832
|
+
!node::Buffer::HasInstance(info[1])) {
|
|
833
|
+
Nan::ThrowTypeError("Bad argument, expected pid and data");
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
auto pid = Nan::To<int64_t>(info[0]).FromMaybe(0);
|
|
838
|
+
if (pid <= 0) {
|
|
839
|
+
Nan::ThrowTypeError("Bad pid");
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
auto buffer = info[1];
|
|
844
|
+
auto data = g_bytes_new(node::Buffer::Data(buffer),
|
|
845
|
+
node::Buffer::Length(buffer));
|
|
846
|
+
|
|
847
|
+
auto operation = new InputOperation(static_cast<guint>(pid), data);
|
|
848
|
+
operation->Schedule(isolate, wrapper, info);
|
|
849
|
+
|
|
850
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
namespace {
|
|
854
|
+
|
|
855
|
+
class ResumeOperation : public Operation<FridaDevice> {
|
|
856
|
+
public:
|
|
857
|
+
ResumeOperation(guint pid) : pid_(pid) {
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
protected:
|
|
861
|
+
void Begin() {
|
|
862
|
+
frida_device_resume(handle_, pid_, cancellable_, OnReady, this);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
void End(GAsyncResult* result, GError** error) {
|
|
866
|
+
frida_device_resume_finish(handle_, result, error);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
Local<Value> Result(Isolate* isolate) {
|
|
870
|
+
return Nan::Undefined();
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
private:
|
|
874
|
+
const guint pid_;
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
NAN_METHOD(Device::Resume) {
|
|
880
|
+
auto isolate = info.GetIsolate();
|
|
881
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
882
|
+
|
|
883
|
+
if (info.Length() < 1 || !info[0]->IsNumber()) {
|
|
884
|
+
Nan::ThrowTypeError("Bad argument, expected pid");
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
auto pid = Nan::To<int64_t>(info[0]).FromMaybe(0);
|
|
888
|
+
if (pid <= 0) {
|
|
889
|
+
Nan::ThrowTypeError("Bad argument, expected pid");
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
auto operation = new ResumeOperation(static_cast<guint>(pid));
|
|
894
|
+
operation->Schedule(isolate, wrapper, info);
|
|
895
|
+
|
|
896
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
namespace {
|
|
900
|
+
|
|
901
|
+
class KillOperation : public Operation<FridaDevice> {
|
|
902
|
+
public:
|
|
903
|
+
KillOperation(guint pid) : pid_(pid) {
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
protected:
|
|
907
|
+
void Begin() {
|
|
908
|
+
frida_device_kill(handle_, pid_, cancellable_, OnReady, this);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
void End(GAsyncResult* result, GError** error) {
|
|
912
|
+
frida_device_kill_finish(handle_, result, error);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
Local<Value> Result(Isolate* isolate) {
|
|
916
|
+
return Nan::Undefined();
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
private:
|
|
920
|
+
const guint pid_;
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
NAN_METHOD(Device::Kill) {
|
|
926
|
+
auto isolate = info.GetIsolate();
|
|
927
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
928
|
+
|
|
929
|
+
if (info.Length() < 1 || !info[0]->IsNumber()) {
|
|
930
|
+
Nan::ThrowTypeError("Bad argument, expected pid");
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
auto pid = Nan::To<int64_t>(info[0]).FromMaybe(0);
|
|
934
|
+
if (pid <= 0) {
|
|
935
|
+
Nan::ThrowTypeError("Bad argument, expected pid");
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
auto operation = new KillOperation(static_cast<guint>(pid));
|
|
940
|
+
operation->Schedule(isolate, wrapper, info);
|
|
941
|
+
|
|
942
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
namespace {
|
|
946
|
+
|
|
947
|
+
class AttachOperation : public Operation<FridaDevice> {
|
|
948
|
+
public:
|
|
949
|
+
AttachOperation(guint pid, FridaSessionOptions* options)
|
|
950
|
+
: pid_(pid),
|
|
951
|
+
options_(options) {
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
~AttachOperation() {
|
|
955
|
+
g_object_unref(options_);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
protected:
|
|
959
|
+
void Begin() {
|
|
960
|
+
frida_device_attach(handle_, pid_, options_, cancellable_, OnReady, this);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
void End(GAsyncResult* result, GError** error) {
|
|
964
|
+
session_ = frida_device_attach_finish(handle_, result, error);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
Local<Value> Result(Isolate* isolate) {
|
|
968
|
+
auto wrapper = Session::New(session_, runtime_);
|
|
969
|
+
g_object_unref(session_);
|
|
970
|
+
return wrapper;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
private:
|
|
974
|
+
const guint pid_;
|
|
975
|
+
FridaSessionOptions* options_;
|
|
976
|
+
FridaSession* session_;
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
NAN_METHOD(Device::Attach) {
|
|
982
|
+
auto isolate = info.GetIsolate();
|
|
983
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
984
|
+
|
|
985
|
+
if (info.Length() < 3) {
|
|
986
|
+
Nan::ThrowTypeError("Missing one or more arguments");
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
auto pid_value = info[0];
|
|
991
|
+
auto realm_value = info[1];
|
|
992
|
+
auto persist_timeout_value = info[2];
|
|
993
|
+
|
|
994
|
+
int64_t pid = -1;
|
|
995
|
+
if (pid_value->IsNumber()) {
|
|
996
|
+
pid = Nan::To<int64_t>(pid_value).FromMaybe(-1);
|
|
997
|
+
}
|
|
998
|
+
if (pid < 0) {
|
|
999
|
+
Nan::ThrowTypeError("Bad argument, expected pid");
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
auto options = frida_session_options_new();
|
|
1004
|
+
bool valid = true;
|
|
1005
|
+
|
|
1006
|
+
if (!realm_value->IsNull()) {
|
|
1007
|
+
FridaRealm realm;
|
|
1008
|
+
if (Runtime::ValueToEnum(realm_value, FRIDA_TYPE_REALM, &realm))
|
|
1009
|
+
frida_session_options_set_realm(options, realm);
|
|
1010
|
+
else
|
|
1011
|
+
valid = false;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
if (valid && !persist_timeout_value->IsNull()) {
|
|
1015
|
+
if (persist_timeout_value->IsNumber()) {
|
|
1016
|
+
auto persist_timeout =
|
|
1017
|
+
Nan::To<int32_t>(persist_timeout_value).FromMaybe(-1);
|
|
1018
|
+
if (persist_timeout >= 0) {
|
|
1019
|
+
frida_session_options_set_persist_timeout(options, persist_timeout);
|
|
1020
|
+
} else {
|
|
1021
|
+
Nan::ThrowTypeError("Bad argument, invalid 'persistTimeout'");
|
|
1022
|
+
valid = false;
|
|
1023
|
+
}
|
|
1024
|
+
} else {
|
|
1025
|
+
Nan::ThrowTypeError("Bad argument, 'persistTimeout' must be a number");
|
|
1026
|
+
valid = false;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
if (!valid) {
|
|
1031
|
+
g_object_unref(options);
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
auto operation = new AttachOperation(static_cast<guint>(pid), options);
|
|
1036
|
+
operation->Schedule(isolate, wrapper, info);
|
|
1037
|
+
|
|
1038
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
namespace {
|
|
1042
|
+
|
|
1043
|
+
class InjectLibraryFileOperation : public Operation<FridaDevice> {
|
|
1044
|
+
public:
|
|
1045
|
+
InjectLibraryFileOperation(guint pid, gchar* path, gchar* entrypoint,
|
|
1046
|
+
gchar* data)
|
|
1047
|
+
: pid_(pid),
|
|
1048
|
+
path_(path),
|
|
1049
|
+
entrypoint_(entrypoint),
|
|
1050
|
+
data_(data) {
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
~InjectLibraryFileOperation() {
|
|
1054
|
+
g_free(data_);
|
|
1055
|
+
g_free(entrypoint_);
|
|
1056
|
+
g_free(path_);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
protected:
|
|
1060
|
+
void Begin() {
|
|
1061
|
+
frida_device_inject_library_file(handle_, pid_, path_, entrypoint_, data_,
|
|
1062
|
+
cancellable_, OnReady, this);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
void End(GAsyncResult* result, GError** error) {
|
|
1066
|
+
id_ = frida_device_inject_library_file_finish(handle_, result, error);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
Local<Value> Result(Isolate* isolate) {
|
|
1070
|
+
return Nan::New<Uint32>(id_);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
private:
|
|
1074
|
+
const guint pid_;
|
|
1075
|
+
gchar* path_;
|
|
1076
|
+
gchar* entrypoint_;
|
|
1077
|
+
gchar* data_;
|
|
1078
|
+
guint id_;
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
NAN_METHOD(Device::InjectLibraryFile) {
|
|
1084
|
+
auto isolate = info.GetIsolate();
|
|
1085
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
1086
|
+
|
|
1087
|
+
if (info.Length() < 4 || !info[0]->IsNumber() || !info[1]->IsString() ||
|
|
1088
|
+
!info[2]->IsString() || !info[3]->IsString()) {
|
|
1089
|
+
Nan::ThrowTypeError("Bad argument");
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
auto pid = Nan::To<int64_t>(info[0]).FromMaybe(-1);
|
|
1094
|
+
if (pid < 0) {
|
|
1095
|
+
Nan::ThrowTypeError("Bad argument, expected pid");
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
Nan::Utf8String path(info[1]);
|
|
1099
|
+
Nan::Utf8String entrypoint(info[2]);
|
|
1100
|
+
Nan::Utf8String data(info[3]);
|
|
1101
|
+
|
|
1102
|
+
auto operation = new InjectLibraryFileOperation(static_cast<guint>(pid),
|
|
1103
|
+
g_strdup(*path), g_strdup(*entrypoint), g_strdup(*data));
|
|
1104
|
+
operation->Schedule(isolate, wrapper, info);
|
|
1105
|
+
|
|
1106
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
namespace {
|
|
1110
|
+
|
|
1111
|
+
class InjectLibraryBlobOperation : public Operation<FridaDevice> {
|
|
1112
|
+
public:
|
|
1113
|
+
InjectLibraryBlobOperation(guint pid, GBytes* blob, gchar* entrypoint,
|
|
1114
|
+
gchar* data)
|
|
1115
|
+
: pid_(pid),
|
|
1116
|
+
blob_(blob),
|
|
1117
|
+
entrypoint_(entrypoint),
|
|
1118
|
+
data_(data) {
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
~InjectLibraryBlobOperation() {
|
|
1122
|
+
g_free(data_);
|
|
1123
|
+
g_free(entrypoint_);
|
|
1124
|
+
g_bytes_unref(blob_);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
protected:
|
|
1128
|
+
void Begin() {
|
|
1129
|
+
frida_device_inject_library_blob(handle_, pid_, blob_, entrypoint_, data_,
|
|
1130
|
+
cancellable_, OnReady, this);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
void End(GAsyncResult* result, GError** error) {
|
|
1134
|
+
id_ = frida_device_inject_library_blob_finish(handle_, result, error);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
Local<Value> Result(Isolate* isolate) {
|
|
1138
|
+
return Nan::New<Uint32>(id_);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
private:
|
|
1142
|
+
const guint pid_;
|
|
1143
|
+
GBytes* blob_;
|
|
1144
|
+
gchar* entrypoint_;
|
|
1145
|
+
gchar* data_;
|
|
1146
|
+
guint id_;
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
NAN_METHOD(Device::InjectLibraryBlob) {
|
|
1152
|
+
auto isolate = info.GetIsolate();
|
|
1153
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
1154
|
+
|
|
1155
|
+
if (info.Length() < 4 || !info[0]->IsNumber() ||
|
|
1156
|
+
!node::Buffer::HasInstance(info[1]) || !info[2]->IsString() ||
|
|
1157
|
+
!info[3]->IsString()) {
|
|
1158
|
+
Nan::ThrowTypeError("Bad argument");
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
auto pid = Nan::To<int64_t>(info[0]).FromMaybe(-1);
|
|
1163
|
+
if (pid < 0) {
|
|
1164
|
+
Nan::ThrowTypeError("Bad argument, expected pid");
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
auto buffer = info[1];
|
|
1168
|
+
auto blob = g_bytes_new(node::Buffer::Data(buffer),
|
|
1169
|
+
node::Buffer::Length(buffer));
|
|
1170
|
+
Nan::Utf8String entrypoint(info[2]);
|
|
1171
|
+
Nan::Utf8String data(info[3]);
|
|
1172
|
+
|
|
1173
|
+
auto operation = new InjectLibraryBlobOperation(static_cast<guint>(pid),
|
|
1174
|
+
blob, g_strdup(*entrypoint), g_strdup(*data));
|
|
1175
|
+
operation->Schedule(isolate, wrapper, info);
|
|
1176
|
+
|
|
1177
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
namespace {
|
|
1181
|
+
|
|
1182
|
+
class OpenChannelOperation : public Operation<FridaDevice> {
|
|
1183
|
+
public:
|
|
1184
|
+
OpenChannelOperation(gchar* address)
|
|
1185
|
+
: address_(address),
|
|
1186
|
+
stream_(NULL) {
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
~OpenChannelOperation() {
|
|
1190
|
+
g_free(address_);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
protected:
|
|
1194
|
+
void Begin() {
|
|
1195
|
+
frida_device_open_channel(handle_, address_, cancellable_, OnReady, this);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
void End(GAsyncResult* result, GError** error) {
|
|
1199
|
+
stream_ = frida_device_open_channel_finish(handle_, result, error);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
Local<Value> Result(Isolate* isolate) {
|
|
1203
|
+
auto wrapper = IOStream::New(stream_, runtime_);
|
|
1204
|
+
g_object_unref(stream_);
|
|
1205
|
+
return wrapper;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
private:
|
|
1209
|
+
gchar* address_;
|
|
1210
|
+
GIOStream* stream_;
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
NAN_METHOD(Device::OpenChannel) {
|
|
1216
|
+
auto isolate = info.GetIsolate();
|
|
1217
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
1218
|
+
|
|
1219
|
+
if (info.Length() < 1 || !info[0]->IsString()) {
|
|
1220
|
+
Nan::ThrowTypeError("Bad argument");
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
Nan::Utf8String address(info[0]);
|
|
1224
|
+
|
|
1225
|
+
auto operation = new OpenChannelOperation(g_strdup(*address));
|
|
1226
|
+
operation->Schedule(isolate, wrapper, info);
|
|
1227
|
+
|
|
1228
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
namespace {
|
|
1232
|
+
|
|
1233
|
+
class UnpairOperation : public Operation<FridaDevice> {
|
|
1234
|
+
protected:
|
|
1235
|
+
void Begin() {
|
|
1236
|
+
frida_device_unpair(handle_, cancellable_, OnReady, this);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
void End(GAsyncResult* result, GError** error) {
|
|
1240
|
+
frida_device_unpair_finish(handle_, result, error);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
Local<Value> Result(Isolate* isolate) {
|
|
1244
|
+
return Nan::Undefined();
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
NAN_METHOD(Device::Unpair) {
|
|
1251
|
+
auto isolate = info.GetIsolate();
|
|
1252
|
+
auto wrapper = ObjectWrap::Unwrap<Device>(info.Holder());
|
|
1253
|
+
|
|
1254
|
+
auto operation = new UnpairOperation();
|
|
1255
|
+
operation->Schedule(isolate, wrapper, info);
|
|
1256
|
+
|
|
1257
|
+
info.GetReturnValue().Set(operation->GetPromise(isolate));
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
Local<Value> Device::TransformSignal(const gchar* name, guint index,
|
|
1261
|
+
const GValue* value, gpointer user_data) {
|
|
1262
|
+
auto runtime = static_cast<Runtime*>(user_data);
|
|
1263
|
+
|
|
1264
|
+
if (index == 0 && (strcmp(name, "spawn-added") == 0 ||
|
|
1265
|
+
strcmp(name, "spawn-removed") == 0))
|
|
1266
|
+
return Spawn::New(g_value_get_object(value), runtime);
|
|
1267
|
+
|
|
1268
|
+
if (index == 0 && (strcmp(name, "child-added") == 0 ||
|
|
1269
|
+
strcmp(name, "child-removed") == 0))
|
|
1270
|
+
return Child::New(g_value_get_object(value), runtime);
|
|
1271
|
+
|
|
1272
|
+
if (index == 0 && strcmp(name, "process-crashed") == 0)
|
|
1273
|
+
return Crash::New(g_value_get_object(value), runtime);
|
|
1274
|
+
|
|
1275
|
+
return Local<Value>();
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
void Device::OnConnect(const gchar* name, gpointer user_data) {
|
|
1279
|
+
auto runtime = static_cast<Runtime*>(user_data);
|
|
1280
|
+
|
|
1281
|
+
if (ShouldStayAliveToEmit(name))
|
|
1282
|
+
runtime->GetUVContext()->IncreaseUsage();
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
void Device::OnDisconnect(const gchar* name, gpointer user_data) {
|
|
1286
|
+
auto runtime = static_cast<Runtime*>(user_data);
|
|
1287
|
+
|
|
1288
|
+
if (ShouldStayAliveToEmit(name))
|
|
1289
|
+
runtime->GetUVContext()->DecreaseUsage();
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
bool Device::ShouldStayAliveToEmit(const gchar* name) {
|
|
1293
|
+
return strcmp(name, "spawn-added") == 0 ||
|
|
1294
|
+
strcmp(name, "spawn-removed") == 0 ||
|
|
1295
|
+
strcmp(name, "child-added") == 0 ||
|
|
1296
|
+
strcmp(name, "child-removed") == 0 ||
|
|
1297
|
+
strcmp(name, "process-crashed") == 0 ||
|
|
1298
|
+
strcmp(name, "output") == 0 ||
|
|
1299
|
+
strcmp(name, "uninjected") == 0;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
}
|