SHARE
TWEET

webscan module - get dirs

a guest Mar 20th, 2013 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #!/usr/bin/env python
  3. # ---
  4. # try_dirs.py
  5. # this 'module' will check if there is a file/dir at remote host.
  6. # files/dirs can be edited (you will find it at dirsToCheck.txt file).
  7. # ---
  8. # More @ http://hauntit.blogspot.com
  9. # version : 2
  10. #
  11.  
  12. import urllib
  13. import sys
  14.  
  15. # defines:
  16. url = sys.argv[1]
  17. dirsToCheck = open('dirsToCheck.txt','r')
  18. try_dir = dirsToCheck.readlines()
  19.  
  20. if len(sys.argv) < 2:
  21.   sys.stderr.write('usage: '+sys.argv[0]+' http://localhost/')
  22.   sys.exit(1)
  23. else:
  24.   print '--------------------------------------------------------------'
  25.   print 'Try enumerate files/dirs at this URL: ',url
  26.   print '--------------------------------------------------------------'
  27.  
  28.   i=0
  29.   for line in try_dir:
  30.     full_url_to_check = url+line
  31. #    print full_url_to_check
  32.     try_page = urllib.urlopen(full_url_to_check)
  33.     i=i+1
  34.  
  35.     if try_page.getcode() == 200:
  36.       print 'Found location: ', line
  37.       print 'Status: ', try_page.getcode()
  38.       print '------------------------------------------'
  39.     elif try_page.getcode() == 401:
  40.       print 'Found location: ', line
  41.       print 'Seems to be authorized only: ', try_page.getcode()
  42.       print '------------------------------------------'
  43.     elif try_page.getcode() >= 500:
  44.       print 'Found server-side problem: ', line
  45.       print 'Status: ', try_page.getcode()
  46.       print '------------------------------------------'
  47.     elif try_page.getcode() == 403:
  48.       print 'Found but you have no permissions to access: ', line
  49.       print 'Status: ', try_page.getcode()
  50.       print '------------------------------------------'
RAW Paste Data
Top