Advertisement
eXFq7GJ1cC

Untitled

Mar 30th, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # Admin page finder v0.1
  4.  
  5. import requests
  6. import os
  7.  
  8. # To be expanded upon
  9. builtinWordList = ['admin/', 'admin.php', 'admin/index.php', 'admin/admin.php', 'admin/login.php',
  10.                    'administrator/', 'administrator.php', 'moderator/', 'moderator.php', 'webadmin/',
  11.                    'webadmin.php', 'webadmin/login.php', 'webadmin/webadmin.php', 'webadmin/index.php']
  12.  
  13. def topMenu():
  14.     while True:
  15.         print('Enter your selection:\n')
  16.         print('(1) Use built in file/folder list')
  17.         print('(2) Use custom wordlist \n')
  18.         userChoice = input('$ ')
  19.         if userChoice == '1':
  20.             bruteScan(builtinWordList)
  21.             break
  22.         elif userChoice == '2':
  23.             bruteScan(getTargetFile())
  24.             break
  25.  
  26. def getTargetFile():
  27.     validExtension = ['.txt']
  28.     while True:
  29.         filePath = input('Enter the full path to the word list: ')
  30.         if os.path.isfile(filePath) and os.path.splitext(filePath)[1] in validExtension:
  31.             return open(filePath).read().split()
  32.  
  33. HTTPstatuscodes = { 401: 'Authorisation required', 404: 'Not found', 200: 'OK', 201: 'Created',
  34.                     202: 'Accepted', 203: 'Request fulfilled from cache' }
  35.  
  36. def bruteScan(wordList):
  37.     results = {}
  38.     # Need to do some URL sanity checking here
  39.     target = input('Enter the target: ')
  40.     print('\nScanning...\n')
  41.     # Dir scanning code starts here
  42.     for i in wordList:
  43.         # Construct the URL
  44.         targetURL = target + '/' + i
  45.         # Using requests module
  46.         req = requests.head(targetURL)
  47.         statusCode, statusText = req.status_code, HTTPstatuscodes.get(req.status_code, 'Unknown')
  48.         # Status codes we want to print to screen go here
  49.         if statusCode in (200, 401):
  50.             print('Found:', statusCode, '-', statusText, '|', 'URL:', targetURL)
  51.         # Appends all results to 'results' dictionary
  52.         results[targetURL] = statusCode, statusText
  53.     print(results)
  54.  
  55. topMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement