gpt4 book ai didi

linux - 如何从 shell 向 msfconsole 发送命令?

转载 作者:太空宇宙 更新时间:2023-11-04 12:27:52 25 4
gpt4 key购买 nike

大家好,我需要一个可以打开例如 msfconsole 然后在其中键入命令的 shell 脚本,我制作了一个非常基本的脚本,但当然它会在 msfconsole 启动时停止...你能给我一些例子吗?

谢谢!

这是我制作的基本的哑脚本:

#!/bin/bash

service postgresql start && sleep 4 && msfconsole && sleep 15 && quit

如您所见,我首先启动 postgresql,然后启动 msfconsole,当我尝试关闭它时,我无法关闭,因为我不在 shell 中,但我进入了 metasploit。

最佳答案

如果您希望脚本中的命令被msfconsole 读取,您需要将它们定向到它的stdin;否则,它们只能由 shell 本身读取(它正在等待 msfconsole 在继续之前退出)。

将一组文本重定向到给定命令的一种方法是使用 heredoc:

#!/bin/bash

service postgresql start || exit

msfconsole <<EOF
sleep 15
quit
EOF

关于linux - 如何从 shell 向 msfconsole 发送命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44136033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com