Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. import urllib
  2. from xml.dom import minidom
  3. import os.path
  4. from collections import defaultdict
  5. import random
  6. import sys
  7.  
  8. class bcolors:
  9. HEADER = '\033[95m'
  10. OKBLUE = '\033[94m'
  11. OKGREEN = '\033[92m'
  12. WARNING = '\033[93m'
  13. FAIL = '\033[91m'
  14. ENDC = '\033[0m'
  15. BOLD = '\033[1m'
  16. UNDERLINE = '\033[4m'
  17.  
  18.  
  19. if len(sys.argv) == 1:
  20. print("python amazonroulette.py [file name with buckets names]")
  21. sys.exit()
  22.  
  23.  
  24. file = sys.argv[1]
  25.  
  26.  
  27. with open(file) as f:
  28. for line in f:
  29. line = line.rstrip()
  30. xml_str = urllib.urlopen("http://" + line).read()
  31. extensions = defaultdict(list)
  32. xmldoc = minidom.parseString(xml_str)
  33. obs_values = xmldoc.getElementsByTagName('Key')
  34.  
  35. for i in obs_values:
  36. path = i.firstChild.data
  37. extension = os.path.splitext(i.firstChild.data)[1][1:]
  38. if extensions.has_key(extension):
  39. extensions[extension].append(path)
  40. else:
  41. extensions[extension] = [path]
  42.  
  43. helper = 0
  44. while helper == 0:
  45. print("Founded extensions\n " + line)
  46. for i in (extensions):
  47. print (i, len(extensions[i]))
  48. choosen_ext = raw_input("Type extension or go to [N]ext target\n> ")
  49. while 1:
  50. if choosen_ext in extensions:
  51. for i in extensions[choosen_ext]:
  52. print (i)
  53. decision = raw_input("Check All[A] Roulette[R] [B]ack \n> ")
  54. if decision == "A":
  55. for i in extensions[choosen_ext]:
  56. req = urllib.urlopen("http://" + line + "/" + i)
  57. if req.code == 200:
  58. print(bcolors.OKGREEN + i + " -----> " + str(req.code) + bcolors.ENDC + "\n")
  59. else:
  60. print(bcolors.FAIL + i + " -----> " + str(req.code) + bcolors.ENDC + "\n")
  61.  
  62. elif decision == "R":
  63. ran = random.randint(0,len(extensions[choosen_ext]) -1 )
  64. url = "http://" + line + "/" + extensions[choosen_ext][ran]
  65. req = urllib.urlopen(url)
  66. if req.code == 200:
  67. print(bcolors.OKGREEN + url + " -----> " + str(req.code) + bcolors.ENDC)
  68.  
  69. else:
  70. print (bcolors.FAIL + url + " -----> " + str(req.code) + bcolors.ENDC)
  71. continue
  72. elif decision== "B":
  73. break
  74. else:
  75. print ("Wrong choice1\n ")
  76. continue
  77. if choosen_ext == "N":
  78. helper = helper + 1
  79. break
  80. else:
  81. print ("Wrong choice")
  82. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement