-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
Mar 19, 2024
1 parent
35ba4a6
commit c370729
Showing
10 changed files
with
186 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "releng"] | ||
path = releng | ||
url = https://github.com/frida/releng.git | ||
[submodule "src/cshell/frida-cshell"] | ||
path = src/cshell/frida-cshell | ||
url = https://github.com/WorksButNotTested/frida-cshell.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[resource-compiler] | ||
namespace = Frida.Data.Cshell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Frida { | ||
public class CShellScript : Object { | ||
public static string get_source () { | ||
string runtime_js = (string) Frida.Data.Cshell.get_frida_cshell_js_blob ().data; | ||
return runtime_js; | ||
} | ||
} | ||
} |
Submodule frida-cshell
added at
58dd04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from pathlib import Path | ||
import platform | ||
import shutil | ||
from subprocess import PIPE, STDOUT, CalledProcessError | ||
import subprocess | ||
import sys | ||
|
||
|
||
def generate_runtime(input_dir, output_dir): | ||
output_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
runtime_reldir = Path("frida-cshell") | ||
runtime_srcdir = input_dir / runtime_reldir | ||
runtime_intdir = output_dir / runtime_reldir | ||
if runtime_intdir.exists(): | ||
shutil.rmtree(runtime_intdir) | ||
shutil.copytree(runtime_srcdir, runtime_intdir) | ||
|
||
npm = os.environ.get("NPM", make_script_filename("npm")) | ||
try: | ||
subprocess.run([npm, "install"], stdout=PIPE, stderr=STDOUT, cwd=runtime_intdir, check=True) | ||
shutil.copy(runtime_intdir / "frida-cshell.js", output_dir) | ||
except CalledProcessError as e: | ||
message = "\n".join([ | ||
"", | ||
"***", | ||
"Failed to bootstrap the CShell backend script runtime:", | ||
"\t" + str(e), | ||
"It appears Node.js is not installed.", | ||
"We need it for processing JavaScript code at build-time.", | ||
"Check PATH or set NPM to the absolute path of your npm binary.", | ||
"***\n", | ||
e.stdout.decode("utf-8") | ||
]) | ||
raise EnvironmentError(message) | ||
|
||
|
||
def make_script_filename(name): | ||
build_os = platform.system().lower() | ||
extension = ".cmd" if build_os == "windows" else "" | ||
return name + extension | ||
|
||
|
||
if __name__ == "__main__": | ||
input_dir, output_dir = [Path(d).resolve() for d in sys.argv[1:3]] | ||
|
||
try: | ||
generate_runtime(input_dir, output_dir) | ||
except Exception as e: | ||
print(e, file=sys.stderr) | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
backend_sources += files( | ||
'cshell.vala', | ||
) | ||
cshell_script_runtime = custom_target('frida-cshell', | ||
input: [ | ||
'frida-cshell/package.json', | ||
'frida-cshell/package-lock.json', | ||
'frida-cshell/tsconfig.json', | ||
'frida-cshell/src/char.ts', | ||
'frida-cshell/src/cmdlets/assembly.ts', | ||
'frida-cshell/src/cmdlets/bt.ts', | ||
'frida-cshell/src/cmdlets/copy.ts', | ||
'frida-cshell/src/cmdlets/dump.ts', | ||
'frida-cshell/src/cmdlets/exit.ts', | ||
'frida-cshell/src/cmdlets/help.ts', | ||
'frida-cshell/src/cmdlets/history.ts', | ||
'frida-cshell/src/cmdlets/math.ts', | ||
'frida-cshell/src/cmdlets/mod.ts', | ||
'frida-cshell/src/cmdlets/read.ts', | ||
'frida-cshell/src/cmdlets/sym.ts', | ||
'frida-cshell/src/cmdlets/thread.ts', | ||
'frida-cshell/src/cmdlets.ts', | ||
'frida-cshell/src/cmdlets/var.ts', | ||
'frida-cshell/src/cmdlets/vm.ts', | ||
'frida-cshell/src/cmdlets/write.ts', | ||
'frida-cshell/src/cmdlet.ts', | ||
'frida-cshell/src/command.ts', | ||
'frida-cshell/src/entrypoint.ts', | ||
'frida-cshell/src/history.ts', | ||
'frida-cshell/src/input.ts', | ||
'frida-cshell/src/line.ts', | ||
'frida-cshell/src/numeric.ts', | ||
'frida-cshell/src/output.ts', | ||
'frida-cshell/src/parser.ts', | ||
'frida-cshell/src/token.ts', | ||
'frida-cshell/src/util.ts', | ||
'frida-cshell/src/var.ts', | ||
'frida-cshell/src/vars.ts', | ||
], | ||
output: [ | ||
'frida-cshell.js', | ||
], | ||
command: [ | ||
find_program('generate-frida-cshell.py'), | ||
meson.current_source_dir(), | ||
meson.current_build_dir(), | ||
], | ||
) | ||
backend_sources += custom_target('frida-data-cshell', | ||
input: [ | ||
'cshell.resources', | ||
cshell_script_runtime, | ||
], | ||
output: [ | ||
'frida-data-cshell.vapi', | ||
'frida-data-cshell.h', | ||
'frida-data-cshell.c', | ||
'frida-data-cshell-blob.S', | ||
], | ||
command: [ | ||
resource_compiler, | ||
'--toolchain=' + host_toolchain, | ||
'-c', '@INPUT0@', | ||
'-o', join_paths(meson.current_build_dir(), 'frida-data-cshell'), | ||
'@INPUT1@', | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters