-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxyFind.py
172 lines (151 loc) · 4.31 KB
/
proxyFind.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
from userAgents import *
import requests
from cred import torKey
from bs4 import BeautifulSoup
import random
import re
import time
from stem import Signal
from stem.control import Controller
# // website all url link lists
allWebSiteUrls = []
allUrls = []
proxyList = []
fileName = 'proxy.txt'
# get new tor circuit by probability
percentageProbability = 60
def torIpCheck():
randomNumber = random.randint(1,100)
if (randomNumber > percentageProbability):
renew_tor_ip()
time.sleep(0.01)
session = requests.session()
proxies = {
'http': 'socks5h://localhost:9050',
'https': 'socks5h://localhost:9050'
}
response = session.get(r'http://www.icanhazip.com', headers = {'User-Agent': random.choice(userAgents)}, timeout=100, proxies=proxies)
print('myTorIp :', response.text)
time.sleep(0.00001)
def renew_tor_ip():
with Controller.from_port(port = 9051) as controller:
controller.authenticate(password=str(torKey))
controller.signal(Signal.NEWNYM)
def myIpRealIPCheck():
# response = requests.get(r'http://www.icanhazip.com', headers = {'User-Agent': random.choice(userAgents)}, timeout=100)
# print('myIp :', response.text)
# time.sleep(0.00001)
pass
def urlResponse(url):
myIpRealIPCheck()
torIpCheck()
session = requests.session()
proxies = {
'http': 'socks5h://localhost:9050',
'https': 'socks5h://localhost:9050'
}
response = session.get(url, headers = {'User-Agent': random.choice(userAgents)}, timeout=100, proxies=proxies)
print(response)
return response.text
def urlResponseWithTimeOut(url):
myIpRealIPCheck()
torIpCheck()
session = requests.session()
proxies = {
'http': 'socks5h://localhost:9050',
'https': 'socks5h://localhost:9050'
}
response = session.get(url, headers = {'User-Agent': random.choice(userAgents)}, timeout=100, proxies=proxies)
print(response)
return response.text
def bruteForceAllSiteUrls(url):
response = urlResponse(url)
soup = BeautifulSoup(response, 'html.parser')
h3tags = soup.findAll('a')
for a in h3tags:
if (a.has_attr('href') and (url in str(a))):
a=str(a)
a=a.split('href="')[1]
a=a.split('"')[0]
# print(a)
if (a not in allWebSiteUrls):
allWebSiteUrls.append(a)
def bruteForce(url):
counter = 0
allWebSiteUrls.append(url)
while True:
for urls in allWebSiteUrls:
bruteForceAllSiteUrls(urls.strip())
print('totalUrls', len(allWebSiteUrls))
counter = counter +1
if counter > 1000:
return
def getAllProxyUrls():
for urls in allWebSiteUrls:
response = urlResponse(urls)
soup = BeautifulSoup(response, 'html.parser')
h3tags = soup.findAll('a')
for a in h3tags:
if (a.has_attr('href') and (url in str(a)) and ("proxy-server" in str(a)) and("#" not in (str(a)))) :
a=str(a)
a=a.split('href="')[1]
a=a.split('"')[0]
# print(a)
if (a not in allUrls):
allUrls.append(a)
def proxyFinder(response):
proxys = re.findall("(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3}):(?:[\d]{1,5})",str(response))
if (proxys) and proxys is not None and proxys[0] is not None:
return proxys
def getAllProxyLists():
for u in allUrls:
response = urlResponseWithTimeOut(u)
ips = proxyFinder(response)
for i in ips:
appendProxyIfNotExistsInList(i)
def appendProxyIfNotExistsInList(i):
if i not in proxyList:
proxyList.append(i)
def dailyProxy(url):
response = urlResponseWithTimeOut(url)
soup = BeautifulSoup(response, 'html.parser')
allDivs = soup.findAll('div')
for x in allDivs:
# print(x)
ips = proxyFinder(x)
if (ips):
for y in ips:
appendProxyIfNotExistsInList(y)
def liveSocksNet(url):
bruteForce(url)
# print(allWebSiteUrls)
for val in allWebSiteUrls:
response = urlResponse(val)
ips = proxyFinder(response)
if (ips):
for i in ips:
appendProxyIfNotExistsInList(i)
def writeToFile(proxy, fname):
fw = open(fname, 'a')
data = str(proxy)+'\n';
fw.write(data)
fw.close()
if __name__ == '__main__':
url = "http://www.proxyserverlist24.top/".strip()
bruteForce(url)
getAllProxyUrls()
print('count', len(allUrls))
getAllProxyLists()
#ater getting proxy empty unwanted list
allWebSiteUrls = []
allUrls = []
allWebSiteUrls = []
allUrls = []
url = "http://proxy-daily.com/".strip()
dailyProxy(url)
url = "http://www.live-socks.net/".strip()
liveSocksNet(url)
allWebSiteUrls = []
allUrls = []
for i in proxyList:
writeToFile(i, fileName)