-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.ts
More file actions
60 lines (52 loc) · 1.73 KB
/
index.ts
File metadata and controls
60 lines (52 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { initWebServer } from "./listener";
import { getFilesDir, getProcessName } from "./utils/common";
import {initEvaluator} from "./evaluator";
import {TargetService} from "./services/TargetService";
import {checkEnv, enableNodeRepl} from "./utils/env";
import repl from "repl"
import {JobService} from "./services/JobService";
import {Target} from "./evaluator/Target";
import {RemoteDebugger} from "./evaluator/impl/remote-debug";
// debug promote
(global as any).exec = (script: string) => {
if (!TargetService.isInitialized() || !TargetService.getInstance().getTarget().isInitialized()) {
console.error(`[eval] target is not initialized`);
return;
}
TargetService.getInstance().getTarget().eval(script, "", (result, error) => {
if (error) {
console.error(`[eval] error: ${error}`);
return;
}
console.log(`[eval] result: ${result}`);
});
}
// debug
(global as any).getDebugObjects = () => {
return [TargetService, JobService];
}
// debug
(global as any).getDebugger = () => {
return (<RemoteDebugger>TargetService.getInstance().getTarget())
.getDebugger();
}
// nodejs REPL
const nodeRepl = () => {
repl.start("[Node.JS @ Local] >>> ");
}
(async () => {
initWebServer();
if (checkEnv() === "FRIDA") {
// running in FRIDA, guessing android
console.log(`[main] running in FRIDA`);
console.log(`[main] app files dir path: ${getFilesDir()}`);
console.log(`[main] process name: ${getProcessName()}`);
} else {
// running in Node.JS, skip android checking
console.log(`[main] running in Node.JS`);
if (enableNodeRepl()) {
nodeRepl();
}
}
await initEvaluator();
})();