SHARE
TWEET

Untitled

a guest Jul 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import logging
  2. import sys
  3.  
  4. from pyftpdlib.handlers import FTPHandler
  5. from pyftpdlib.servers import FTPServer
  6. from pyftpdlib.authorizers import UnixAuthorizer
  7. from pyftpdlib.filesystems import UnixFilesystem
  8.  
  9. def main():
  10.      logger = logging.getLogger()
  11.      ch = logging.StreamHandler(sys.stdout)
  12.      logger.setLevel(logging.DEBUG)
  13.      ch.setLevel(logging.DEBUG)
  14.      formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
  15.      ch.setFormatter(formatter)
  16.      logger.addHandler(ch)
  17.  
  18.      authorizer = UnixAuthorizer(allowed_users=['marcelo'], require_valid_shell=True, global_perm='elradfmwMT')
  19.      handler = FTPHandler
  20.      handler.authorizer = authorizer
  21.      handler.abstracted_fs = UnixFilesystem
  22.      handler.passive_ports = (40000, 50000)
  23.  
  24.      handler.log_prefix = '%(username)s@%(remote_ip)s'
  25.  
  26.      server = FTPServer(('',5001), handler)
  27.      server.serve_forever()
  28.  
  29.      if __name__ == '__main__':
  30.          main()
  31.      
  32. from ftplib import FTP
  33.  
  34. ftp = FTP('')
  35. ftp.connect('*****',5001)
  36. ftp.login(user='****',passwd='*****')
  37. ftp.set_debuglevel(2)
  38. ftp.set_pasv(False)
  39. #ftp.cwd('/home/marcelo')
  40. response = ftp.retrlines('LIST')
  41. print("response: %s",response)
  42.  
  43.  
  44. def uploadFile():
  45.   filename = 'arquivo5.txt'
  46.   ftp.storbinary('STOR '+filename, open(filename,'rb'))
  47.  
  48.  
  49.  
  50. def downloadFile():
  51.   filename = 'backup.dmp'
  52.   localfile = open(filename, 'wb')
  53.   ftp.retrbinary('RETR '+filename, localfile.write, 2048)
  54.   localfile.close()
  55.  
  56. #uploadFile()
  57. #downloadFile()
  58.  
  59. ftp.quit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top