Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.72 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. ''' proxyscan v1 - scan random networks for proxys '''
  4.  
  5. from socket import *
  6. from netaddr import IPNetwork
  7. from colorama import Fore, Style
  8. from datetime import datetime
  9. import random, os, pause, sys
  10. from servcheck import is_prox
  11.  
  12. # some pretty colors for the TERM
  13. red = Fore.RED
  14. blue = Fore.BLUE
  15. green = Fore.GREEN
  16. yellow = Fore.YELLOW
  17. bold = Style.BRIGHT
  18. reset = Style.RESET_ALL
  19.  
  20. start = datetime.now()
  21.  
  22. def scan(network):
  23. host_list = []
  24. ip = IPNetwork(network)
  25. print("{}{}{}{}: {}{}{}{} available IPs".format(bold, blue, network, reset, bold, green, len(ip), reset))
  26. for n in range(len(ip)):
  27. host_list.append(str(ip[n]))
  28.  
  29. for host in host_list:
  30. target(host)
  31.  
  32. def target(ip):
  33. # scan most used proxy ports. more can be added, note: more ports = longer scan time.
  34. pports = [80, 83, 88, 1080, 3128, 4444, 5800, 6588, 6666, 6800, 8080, 8088, 8118, 8888, 9000, 9999, 45554]
  35. pcount = 0
  36. proxys = []
  37. for port in pports:
  38. # print("Scanning port: {}{}{}".format(yellow, port, reset))
  39. s = socket(AF_INET, SOCK_STREAM)
  40. s.settimeout(0.01)
  41. result = s.connect_ex((ip, port))
  42. proto = 'tcp'
  43.  
  44. if result == 0:
  45. print("{}{}{}{}:{} is {}{}OPEN{}".format(bold, blue, ip, reset, port, bold, green, reset))
  46. try:
  47. pserv = getservbyport(int(port), proto)
  48. print("Service: {}{}{}{}".format(bold, green, pserv, reset))
  49. check_host = "http://" + str(ip) + ":" + str(port)
  50. print('Checking if proxy is available..')
  51. pcheck = is_prox(check_host)
  52. if pcheck == 200:
  53. print("{}{}{}: Proxy server available. Saving..".format(green, check_host, reset))
  54. pserv = 'http'
  55. with open('proxy.lst', 'a') as f:
  56. f.write(pserv + " " + str(ip) + " " + str(port) +"n")
  57.  
  58. elif pcheck is None:
  59. print("{}{}{}: Unable to establish remote connection. Ignoring IP".format(red, ip, reset))
  60.  
  61. except OSError as e:
  62. print("Service: {}{}{}{}".format(bold, red, e, reset))
  63.  
  64. elif result != 0:
  65. pass
  66. s.close()
  67.  
  68. if pcount < 25:
  69. pass
  70.  
  71. elif pcount == 25:
  72. print("Found {}{}{} available proxy servers.".format(green, str(len(proxys)), reset))
  73. end = datetime.now()
  74. print("Scan took approximately {}{}{}{} seconds".format(bold, blue, (end - start).seconds, reset))
  75. print("Proxy servers have been saved to {}{}'proxy.lst'{}".format(bold, green, reset ))
  76. sys.exit(0)
  77.  
  78. if __name__ == '__main__':
  79.  
  80. with open('ip_ranges_US.txt', 'r') as f:
  81. subnets = f.readlines()
  82.  
  83. netlist = []
  84. num_ips = len(subnets)
  85. while len(netlist) < 30:
  86. rand_ip = random.randint(0, num_ips)
  87. try:
  88. netlist.append(subnets[rand_ip])
  89. except IndexError:
  90. pass
  91.  
  92. print("{}{}_-=-_{}".format(bold, yellow, reset)*5)
  93. print("{}{} ProxyScan.py v1 {}".format(bold, blue, reset))
  94. print("{}{}_-=-_{}".format(bold, yellow, reset)*5)
  95. need_spoof = input("nWould you like to spoof your MAC address?(y/n):")
  96. if need_spoof is 'y':
  97. if os.geteuid() != 0 or os.path.isfile("mac-spoof.py") is False:
  98. exit("{} This options requires root access and the script {}mac-spoof.py{}n"
  99. "{} if you do not have the {}MacSpoof script{}{}, please install by typing:n"
  100. "{} sudo -H pip3 install MacSpoof"{}{} and then re-run proxyscan.py as root{}n".format(bold, red, reset, bold, red, reset, bold, red, reset, bold, reset))
  101. try:
  102. print(os.system("spoof-mac.py list"))
  103. net_dev = input("Please enter the {}device{} you wish to spoof: ".format(red, reset))
  104. print("Randomizing MAC address. Please wait..n")
  105. pause.seconds(10)
  106. os.system("spoof-mac.py randomize " + net_dev)
  107. pause.seconds(15)
  108. except Exception as e:
  109. print("Unable to spoof MAC. Skipping..")
  110.  
  111. print("{}{}Initializing scanner..nPlease wait this may take some time.{}".format(bold, yellow, reset))
  112. for net in netlist:
  113. ip = net.lstrip().strip('n')
  114.  
  115. try:
  116. scan("192.168.2.0/24")
  117. except KeyboardInterrupt:
  118. print("nExiting..")
  119. sys.exit(0)
  120.  
  121. #!/usr/bin/env python3
  122. ''' Proxy server checker for proxyscan.py '''
  123.  
  124. import requests
  125.  
  126. def is_prox(proxy_server):
  127. proxyDict = {"http": proxy_server,
  128. "https": proxy_server,
  129. "socks": proxy_server}
  130.  
  131. test_site = {"http://www.google.com", "http://whatsmyip.org", "http://www.facebook.com"}
  132. headers = {'user-agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)'}
  133.  
  134. for site in test_site:
  135. try:
  136. r = requests.get(site, headers=headers, proxies=proxyDict)
  137. status = r.status_code
  138. if status is 200:
  139. return status
  140. else:
  141. return None
  142. except Exception:
  143. return
  144.  
  145.  
  146. if __name__ == '__main__':
  147. is_prox()
  148.  
  149. skywalker@endor:~/scripts/python/proxyupdate$ python3 proxyscan.py
  150. _-=-__-=-__-=-__-=-__-=-_
  151. ProxyScan.py v1
  152. _-=-__-=-__-=-__-=-__-=-_
  153.  
  154. Would you like to spoof your MAC address?(y/n):n
  155. Initializing scanner..
  156. Please wait this may take some time.
  157. 192.168.2.0/24: 256 available IPs
  158. 192.168.2.2:8080 is OPEN
  159. Service: http-alt
  160. Checking if proxy is available..
  161. 192.168.2.2: Unable to establish remote connection. Ignoring IP
  162. 192.168.2.5:80 is OPEN
  163. Service: http
  164. Checking if proxy is available..
  165. http://192.168.2.5:80: Proxy server available. Saving..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement