←︎ proxytools :: faa1804


1
commit faa18045476416d1b0556820e4a940d5fd37553a
2
Author: acidvegas <acid.vegas@acid.vegas>
3
Date:   Fri Jun 28 01:40:22 2019 -0400
4
5
    Initial commit
6
---
7
 LICENSE                  |  15 ++++++
8
 README.md                |   9 ++++
9
 proxytools/cleansocks.py |  70 +++++++++++++++++++++++++++
10
 proxytools/floodbl.py    |  56 ++++++++++++++++++++++
11
 proxytools/sockspot.py   | 121 +++++++++++++++++++++++++++++++++++++++++++++++
12
 5 files changed, 271 insertions(+)
13
14
diff --git a/LICENSE b/LICENSE
15
new file mode 100644
16
index 0000000..b63b809
17
--- /dev/null
18
+++ b/LICENSE
19
@@ -0,0 +1,15 @@
20
+ISC License
21
+
22
+Copyright (c) 2019, acidvegas <acid.vegas@acid.vegas>
23
+
24
+Permission to use, copy, modify, and/or distribute this software for any
25
+purpose with or without fee is hereby granted, provided that the above
26
+copyright notice and this permission notice appear in all copies.
27
+
28
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
29
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
30
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
31
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
32
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
33
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
34
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35
diff --git a/README.md b/README.md
36
new file mode 100644
37
index 0000000..67fc1ab
38
--- /dev/null
39
+++ b/README.md
40
@@ -0,0 +1,9 @@
41
+###### Requirements
42
+* [Python](https://www.python.org/downloads/) *(**Note:** This script was developed to be used with the latest version of Python)*
43
+* [PySocks](https://pypi.python.org/pypi/PySocks) *(Required for cleansocks.py)*
44
+
45
+###### Mirrors
46
+- [acid.vegas](https://acid.vegas/proxytools) *(main)*
47
+- [SuperNETs](https://git.supernets.org/acidvegas/proxytools)
48
+- [GitHub](https://github.com/acidvegas/proxytools)
49
+- [GitLab](https://gitlab.com/acidvegas/proxytools)
50
diff --git a/proxytools/cleansocks.py b/proxytools/cleansocks.py
51
new file mode 100644
52
index 0000000..34fb5dd
53
--- /dev/null
54
+++ b/proxytools/cleansocks.py
55
@@ -0,0 +1,70 @@
56
+#!/usr/bin/env python
57
+# CleanSocks - Developed by acidvegas in Python (https://acid.vegas/proxytools)
58
+
59
+'''
60
+Requirements:
61
+	PySocks (https://pypi.python.org/pypi/pysocks)
62
+
63
+This script will clean a list of proxies by removing duplicates, checking for valid formats (IP:PORT), and testing if the proxies are working
64
+'''
65
+
66
+import argparse
67
+import concurrent.futures
68
+import os
69
+import re
70
+import sys
71
+
72
+sys.dont_write_bytecode = True
73
+
74
+def is_proxy(proxy):
75
+	return re.match('^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):(?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9])$', proxy)
76
+
77
+def test_proxy(proxy):
78
+	global good
79
+	ip, port = proxy.split(':')
80
+	try:
81
+		sock = socks.socksocket()
82
+		sock.set_proxy(socks.SOCKS5, ip, int(port))
83
+		sock.settimeout(args.timeout)
84
+		sock.connect(('www.google.com', 80))
85
+	except:
86
+		print('BAD  | ' + proxy)
87
+	else:
88
+		print('GOOD | ' + proxy)
89
+		good.append(proxy)
90
+	finally:
91
+		sock.close()
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
+parser.add_argument('-x', '--timeout', help='socket timeout seconds (default: 15)',  default=15,  type=int)
98
+args = parser.parse_args()
99
+try:
100
+	import socks
101
+except ImportError:
102
+	raise SystemExit('missing pysocks module (https://pypi.python.org/pypi/pysocks)')
103
+if not os.path.isfile(args.input):
104
+	raise SystemExit('no such input file')
105
+proxies = set([line.strip() for line in open(args.input).readlines() if is_proxy(line)])
106
+if not proxies:
107
+	raise SystemExit('no proxies found from input file')
108
+deduped, ips = list(), list()
109
+for proxy in proxies:
110
+	ip = proxy.split(':')[0]
111
+	if ip not in ips:
112
+		ips.append(ip)
113
+		deduped.append(proxy)
114
+deduped.sort()
115
+good = list()
116
+with concurrent.futures.ThreadPoolExecutor(max_workers=args.threads) as executor:
117
+	checks = {executor.submit(test_proxy, proxy): proxy for proxy in deduped}
118
+	for future in concurrent.futures.as_completed(checks):
119
+		checks[future]
120
+good.sort()
121
+with open(args.output, 'w') as output_file:
122
+	output_file.write('\n'.join(good))
123
+print('Total : ' + format(len(proxies),           ',d'))
124
+print('Good  : ' + format(len(good),              ',d'))
125
+print('Bad   : ' + format(len(proxies)-len(good), ',d'))
126
diff --git a/proxytools/floodbl.py b/proxytools/floodbl.py
127
new file mode 100644
128
index 0000000..5cf43b7
129
--- /dev/null
130
+++ b/proxytools/floodbl.py
131
@@ -0,0 +1,56 @@
132
+#!/usr/bin/env python
133
+# FloodBL - Developed by acidvegas in Python (https://acid.vegas/proxytools)
134
+
135
+'''
136
+This script will test proxies against a set of Domain Name System-based Blackhole Lists (DNSBL) or Real-time Blackhole Lists (RBL)
137
+'''
138
+
139
+import argparse
140
+import concurrent.futures
141
+import os
142
+import re
143
+import socket
144
+
145
+dnsbls = ('dnsbl.dronebl.org','rbl.efnetrbl.org','torexit.dan.me.uk')
146
+
147
+def dnsbl_check(proxy):
148
+	global good
149
+	bad = False
150
+	ip  = proxy.split(':')[0]
151
+	formatted_ip = '.'.join(ip.split('.')[::-1])
152
+	for dnsbl in dnsbls:
153
+		try:
154
+			socket.gethostbyname(f'{formatted_ip}.{dnsbl}')
155
+		except socket.gaierror:
156
+			pass
157
+		else:
158
+			bad = True
159
+			break
160
+	if bad:
161
+		print('BAD  | ' + ip)
162
+	else:
163
+		good.append(proxy)
164
+		print('GOOD | ' + ip)
165
+
166
+# Main
167
+parser = argparse.ArgumentParser(usage='%(prog)s <input> <output> [options]')
168
+parser.add_argument('input',           help='file to scan')
169
+parser.add_argument('output',          help='file to output')
170
+parser.add_argument('-t', '--threads', help='number of threads (default: 100)', default=100, type=int)
171
+args = parser.parse_args()
172
+if not os.path.isfile(args.input):
173
+	raise SystemExit('no such input file')
174
+proxies = re.findall('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+', open(args.input).read(), re.MULTILINE)
175
+if not proxies:
176
+	raise SystemExit('no proxies found from input file')
177
+good = list()
178
+with concurrent.futures.ThreadPoolExecutor(max_workers=args.threads) as executor:
179
+	checks = {executor.submit(dnsbl_check, proxy): proxy for proxy in proxies}
180
+	for future in concurrent.futures.as_completed(checks):
181
+		checks[future]
182
+good.sort()
183
+with open(args.output, 'w') as output_file:
184
+	output_file.write('\n'.join(good))
185
+print('Total : ' + format(len(proxies),           ',d'))
186
+print('Good  : ' + format(len(good),              ',d'))
187
+print('Bad   : ' + format(len(proxies)-len(good), ',d'))
188
diff --git a/proxytools/sockspot.py b/proxytools/sockspot.py
189
new file mode 100644
190
index 0000000..c87b132
191
--- /dev/null
192
+++ b/proxytools/sockspot.py
193
@@ -0,0 +1,121 @@
194
+#!/usr/bin/env python
195
+# SockSpot - Developed by acidvegas in Python (https://acid.vegas/proxytools)
196
+
197
+import datetime
198
+import json
199
+import base64
200
+import os
201
+import re
202
+import threading
203
+import time
204
+import urllib.request
205
+
206
+# Blogspot URLs
207
+blogspot_list = (
208
+	'live-socks.net',
209
+	'newfreshproxies-24.blogspot.sg',
210
+	'proxyserverlist-24.blogspot.sg',
211
+	'socks24.org',
212
+	'sock5us.blogspot.com',
213
+	'sockproxy.blogspot.com',
214
+	'socksproxylist24.blogspot.com',
215
+	'newsocks.info',
216
+	'socksecurelist.ca',
217
+	'canada-socks247.com',
218
+	'sock5us.blogspot.com',
219
+	'socks24.org',
220
+	'sslproxies24.blogspot.com',
221
+	'vip-socks24.blogspot.com'
222
+)
223
+
224
+# Settings
225
+max_results = 100 # Maximum number of results per-page.
226
+post_depth  = 1   # How many days back from the current date to pull posts from. (1 = Today Only)
227
+timeout     = 30  # Timeout for HTTP requests.
228
+
229
+# Globals
230
+proxy_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'proxies.txt')
231
+proxy_list = list()
232
+threads    = dict()
233
+
234
+def debug(msg):
235
+	print(f'{get_time()} | [~] - {msg}')
236
+
237
+def error(msg, reason):
238
+	print(f'{get_time()} | [!] - {msg} ({reason})')
239
+
240
+def get_time():
241
+	return time.strftime('%I:%M:%S')
242
+
243
+def get_date():
244
+	date = datetime.datetime.today()
245
+	return '{0}-{1:02d}-{2:02d}'.format(date.year, date.month, date.day)
246
+
247
+def get_date_range():
248
+	date_range = datetime.datetime.today() - datetime.timedelta(days=post_depth)
249
+	return '{0}-{1:02d}-{2:02d}'.format(date_range.year, date_range.month, date_range.day)
250
+
251
+def get_source(url):
252
+	req = urllib.request.Request(url)
253
+	req.add_header('User-Agent', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)')
254
+	source  = urllib.request.urlopen(req, timeout=timeout)
255
+	charset = source.headers.get_content_charset()
256
+	if charset:
257
+		return source.read().decode(charset)
258
+	else:
259
+		return source.read().decode()
260
+
261
+def parse_blogspot(url):
262
+	global proxy_list
263
+	try:
264
+		source = json.loads(get_source(f'http://{url}/feeds/posts/default?max-results={max_results}&alt=json&updated-min={get_date_range()}T00:00:00&updated-max={get_date()}T23:59:59&orderby=updated'))
265
+		found  = []
266
+		if source['feed'].get('entry'):
267
+			for item in source['feed']['entry']:
268
+				data    = item['content']['$t']
269
+				proxies = re.findall('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+', data, re.MULTILINE)
270
+				if proxies:
271
+					found      += proxies
272
+					proxy_list += proxies
273
+			debug('Found {0} proxies on {1}'.format(format(len(found), ',d'), url))
274
+		else:
275
+			error('No posts found on page!', url)
276
+	except Exception as ex:
277
+		proxy_value = ex
278
+
279
+def scan_blogspots():
280
+	for url in blogspot_list:
281
+		threads[url] = threading.Thread(target=parse_blogspot, args=(url,))
282
+	for thread in threads:
283
+		threads[thread].start()
284
+		time.sleep(10)
285
+	for thread in threads:
286
+		threads[thread].join()
287
+	debug('Found {0} total proxies!'.format(format(len(proxy_list), ',d')))
288
+	with open (proxy_file, 'w') as proxy__file:
289
+		for proxy in proxy_list:
290
+			proxy__file.write(proxy + '\n')
291
+
292
+# Main
293
+print('#'*56)
294
+print('#{0}#'.format(''.center(54)))
295
+print('#{0}#'.format('SockSpot Proxy Scraper'.center(54)))
296
+print('#{0}#'.format('Developed by acidvegas in Python'.center(54)))
297
+print('#{0}#'.format('https://acid.vegas/proxytools'.center(54)))
298
+print('#{0}#'.format(''.center(54)))
299
+print('#'*56)
300
+debug(f'Scanning {len(blogspot_list)} URLs from list...')
301
+threading.Thread(target=scan_blogspots).start()
302
+for url in blogspot_list:
303
+	threads[url] = threading.Thread(target=parse_blogspot, args=(url,))
304
+for thread in threads:
305
+	threads[thread].start()
306
+	time.sleep(10)
307
+for thread in threads:
308
+	threads[thread].join()
309
+if proxy_value = 0:
310
+	error('no socks found')
311
+debug('Found {0} total proxies!'.format(format(len(proxy_list), ',d')))
312
+with open (proxy_file, 'w') as proxy__file:
313
+	for proxy in proxy_list:
314
+		proxy__file.write(proxy + '\n')