Created
May 31, 2019 22:01
-
-
Save alxgmpr/fa7f8bca718d6422f6ac64811809104e to your computer and use it in GitHub Desktop.
Find peoples sequential and arbitrarily secured proxies!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import urllib3 | |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | |
class ProxyFinder: | |
def __init__(self): | |
self.username = 'XXX' | |
self.password = 'XXX' | |
self.port = '8080' | |
self.subnets = [ | |
'xx.xx.xx' | |
] | |
self.good_proxies = list() | |
def test_proxy(self, subnet, index): | |
proxy = str(subnet) + '.' + str(index) | |
try: | |
r = requests.head( | |
url='https://httpbin.org/get', | |
headers={ | |
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, ' | |
'like Gecko) Chrome/71.0.3578.98 Safari/537.36', | |
'accept': '*/*' | |
}, | |
proxies={ | |
'http': 'http://{}:{}'.format(proxy, self.port), | |
'https': 'https://{}:{}'.format(proxy, self.port) | |
}, | |
timeout=1.0, | |
verify=False | |
) | |
except requests.exceptions.ReadTimeout: | |
print('found good proxy {}.{}'.format(subnet, index)) | |
return True | |
except (requests.exceptions.ConnectTimeout, requests.exceptions.ProxyError): | |
return False | |
try: | |
r.raise_for_status() | |
print('found good proxy {}.{}'.format(subnet, index)) | |
return True | |
except requests.exceptions.HTTPError: | |
return False | |
def test_subnets(self): | |
for subnet in self.subnets: | |
for index in range(0, 256): | |
print('testing {}.{}'.format(subnet, index)) | |
if self.test_proxy(subnet, index): | |
self.good_proxies.append('{}.{}:{}\n'.format(subnet, index, self.port)) | |
with open('good_proxies.txt', 'w') as proxyfile: | |
proxyfile.writelines(self.good_proxies) | |
if __name__ == '__main__': | |
pf = ProxyFinder() | |
pf.test_subnets() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment