Guest User

Untitled

a guest
Aug 15th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.06 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import ftplib
  3. import os
  4.  
  5. username = "ftp"
  6. password = "me@me.com"
  7. ftp_server_path = "/"
  8.  
  9. def serverList(ftp_servers_file):
  10.     fdesc = open(ftp_servers_file,"r")
  11.     for line in fdesc.readlines():
  12.         ftp_server = line.strip()
  13.         suckFTP(ftp_server)
  14.  
  15. def suckFTP(ftp_server):
  16.     global username
  17.     global password
  18.     global ftp_server_path
  19.     getFTP = ftplib.FTP(ftp_server, username, password)
  20.     print "Getting listing from: %s" % ftp_server
  21.     print "Using path: %s" % ftp_server_path
  22.     getFTP.dir(ftp_server_path)
  23.     print "End of listing from: %s\n" % ftp_server
  24.     getFTP.close()
  25.  
  26.  
  27. if __name__ == '__main__':
  28.     ftp_servers_file = "./ftpServers"
  29.     serverList(ftp_servers_file)
  30.  
  31. ------------------------------------------------------------------
  32. phantasm@patina:~/exploit-central/py/module3/m3s02$ cat ftpServers
  33. ftp.mozilla.org
  34. ftp.debian.org
  35. openbsd.org.ar
  36. ftp5.eu.openbsd.org
  37. ftp.crans.org
  38. ------------------------------------------------------------------
  39. phantasm@patina:~/exploit-central/py/module3/m3s02$ python getFTP.py
  40. Getting listing from: ftp.mozilla.org
  41. Using path: /
  42. -rw-r--r--    1 ftp      ftp           528 Nov 01  2007 README
  43. -rw-r--r--    1 ftp      ftp           560 Sep 28  2007 index.html
  44. drwxr-xr-x   40 ftp      ftp          4096 May 23 11:00 pub
  45. End of listing from: ftp.mozilla.org
  46.  
  47. Getting listing from: ftp.debian.org
  48. Using path: /
  49. drwxr-xr-x    8 1176     1176         4096 May 23 21:05 debian
  50. End of listing from: ftp.debian.org
  51.  
  52. Getting listing from: openbsd.org.ar
  53. Using path: /
  54. total 20
  55. drwxr-xr-x   2 1005  1005  512 Mar 20  2009 etc
  56. -rw-r--r--   1 1005  1005  101 Apr 24  2009 index.html
  57. dr-xr-xr-x   3 1005  1005  512 Dec  3  2009 pub
  58. drwxr-xr-x  31 1005  1005  512 Aug 10  2011 pub2
  59. End of listing from: openbsd.org.ar
  60.  
  61. Getting listing from: ftp5.eu.openbsd.org
  62. Using path: /
  63. total 4
  64. drwxr-xr-x  3 0  1  512 Aug 10  2007 pub
  65. End of listing from: ftp5.eu.openbsd.org
  66.  
  67. Getting listing from: ftp.crans.org
  68. Using path: /
  69. End of listing from: ftp.crans.org
Add Comment
Please, Sign In to add comment