proxytools

- collection of scripts for harvesting & testing proxies
git clone git://git.acid.vegas/proxytools.git
Log | Files | Refs | Archive | README | LICENSE

floodbl.py (4041B)

      1 #!/usr/bin/env python
      2 # FloodBL - Developed by acidvegas in Python (https://git.acid.vegas/proxytools)
      3 
      4 # This script will check a list of proxies aginst DNS Blackhole (DNSBL) lists to see if they are blackholed.
      5 # Todo: Add support for asynchronous DNSBL lookups and proper IPv6 support.
      6 
      7 import argparse
      8 import concurrent.futures
      9 import ipaddress
     10 import os
     11 import re
     12 
     13 try:
     14 	import dns.resolver
     15 except ImportError:
     16 	raise SystemExit('missing required \'dnspython\' library (https://pypi.org/project/dnspython/)')
     17 
     18 # Globals
     19 good    = list()
     20 bad     = list()
     21 unknown = list()
     22 proxies = list()
     23 
     24 blackholes = {
     25 	'dnsbl.dronebl.org': {
     26 		'2'  : 'Sample',
     27 		'3'  : 'IRC Drone',
     28 		'5'  : 'Bottler',
     29 		'6'  : 'Unknown spambot or drone',
     30 		'7'  : 'DDOS Drone',
     31 		'8'  : 'SOCKS Proxy',
     32 		'9'  : 'HTTP Proxy',
     33 		'10' : 'ProxyChain',
     34 		'11' : 'Web Page Proxy',
     35 		'12' : 'Open DNS Resolver',
     36 		'13' : 'Brute force attackers',
     37 		'14' : 'Open Wingate Proxy',
     38 		'15' : 'Compromised router / gateway',
     39 		'16' : 'Autorooting worms',
     40 		'17' : 'Automatically determined botnet IPs (experimental)',
     41 		'18' : 'DNS/MX type',
     42 		'19' : 'Abused VPN Service',
     43 		'255': 'Uncategorzied threat class'
     44 	},
     45 	'rbl.efnetrbl.org': {
     46 		'1' : "Open Proxy",
     47 		'2' : "spamtrap666",
     48 		'3' : "spamtrap50",
     49 		'4' : "TOR",
     50 		'5' : "Drones / Flooding"
     51 	}
     52 }
     53 
     54 def check(proxy: str):
     55 	'''
     56 	Check if a proxy is blackholed.
     57 
     58 	:param proxy: the proxy to check in the format of ip:port
     59 	'''
     60 	proxy_ip     = proxy.split(':')[0]
     61 	formatted_ip = ipaddress.ip_address(proxy_ip).reverse_pointer
     62 	for blackhole in blackholes:
     63 		try:
     64 			results = dns.resolver.resolve(f'{formatted_ip}.{blackhole}', 'A')
     65 			if results:
     66 				for result in results:
     67 					data  = result.to_text()
     68 					reply = data.split('.')[-1:][0]
     69 					if reply in blackholes[blackhole]:
     70 						print(f'{proxy_ip.ljust(15)} \033[1;30m|\033[0m {blackhole.ljust(17)} \033[1;30m|\033[0m \033[1;31m{blackholes[blackhole][reply]}\033[0m')
     71 						bad.append(proxy)
     72 					else:
     73 						print(f'{proxy_ip.ljust(15)} \033[1;30m|\033[0m {blackhole.ljust(17)} \033[1;30m|\033[0m Unknown ({data})')
     74 						unknown.append(proxy)
     75 			else:
     76 				print(f'{proxy_ip.ljust(15)} \033[1;30m|\033[0m {blackhole.ljust(17)} \033[1;30m|\033[0m Error (No results)')
     77 				unknown.append(proxy)
     78 		except Exception as ex:
     79 			print(f'{proxy_ip.ljust(15)} \033[1;30m|\033[0m {blackhole.ljust(17)} \033[1;30m|\033[0m \033[1;32mGOOD\033[0m')
     80 	if proxy not in bad:
     81 		good.append(proxy)
     82 
     83 
     84 if __name__ == '__main__':
     85 	print('#'*56)
     86 	print('#{0}#'.format(''.center(54)))
     87 	print('#{0}#'.format('FloodBL Blackhole Checker'.center(54)))
     88 	print('#{0}#'.format('Developed by acidvegas in Python'.center(54)))
     89 	print('#{0}#'.format('https://git.acid.vegas/proxytools'.center(54)))
     90 	print('#{0}#'.format(''.center(54)))
     91 	print('#'*56)
     92 
     93 	parser = argparse.ArgumentParser(usage='%(prog)s <input> <output> [options]')
     94 	parser.add_argument('input',           help='file to scan')
     95 	parser.add_argument('output',          help='file to output')
     96 	parser.add_argument('-t', '--threads', help='number of threads (default: 100)', default=100, type=int)
     97 	args = parser.parse_args()
     98 
     99 	if not os.path.isfile(args.input):
    100 		raise SystemExit('no such input file')
    101 
    102 	initial = len(open(args.input).readlines())
    103 	proxies = set([proxy.split(':')[0] for proxy in re.findall('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+', open(args.input).read(), re.MULTILINE)]) # TODO: handle IPv6 better
    104 
    105 	if not proxies:
    106 		raise SystemExit('no proxies found from input file')
    107 
    108 	with concurrent.futures.ThreadPoolExecutor(max_workers=args.threads) as executor:
    109 		checks = {executor.submit(check, proxy): proxy for proxy in proxies}
    110 		for future in concurrent.futures.as_completed(checks):
    111 			checks[future]
    112 
    113 	good.sort()
    114 
    115 	with open(args.output, 'w') as output_file:
    116 		output_file.write('\n'.join(good))
    117 
    118 	print('\033[34mTotal\033[0m : ' + format(len(proxies),           ',d'))
    119 	print('\033[34mGood\033[0m  : ' + format(len(good),              ',d'))
    120 	print('\033[34mBad\033[0m   : ' + format(len(proxies)-len(good), ',d'))