-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
225 lines (177 loc) · 7.7 KB
/
main.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
import socket
import threading
import os
import json
import requests
import asyncio
import platform
import time
from concurrent.futures import ThreadPoolExecutor
from colorama import init, Fore
from discord_webhook import DiscordWebhook, DiscordEmbed
from functions.scrapybacky import socks5scrapy, socks4scrapy, socks4scrapy_no2
banner_text = f"""
{Fore.RED}
⠀⠀⢀⣤⣶⣶⣤⣄⡀
⠀⢀⣿⣿⣿⣿⣿⣿⣿⡆
⠀⠸⣿⣿⣿⣿⣿⡟⡟⡗
⠀⠀⠙⠏⠯⠛⣉⢲⣧⠟
⠀⠀⠠⢭⣝⣾⠿⣴⣿⠇ discord.gg/SecHex
⠀⠀⢐⣺⡿⠁⠀⠈⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⣶⣶⣶⣶⣶⣶⠀
⠀⠀⣚⣿⠃ ⣶⣶⣶⣶
⢀⣿⣿⣿⣷⢒⣢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣶⣶⣄⠄
⢰⣿⣿⡿⣿⣦⠬⢝⡄⠀⠀⠀⠀⠀⠀⢠⣿⠿⠿⠟⠛⠋⠁
⠠⢿⣿⣷⠺⣿⣗⠒⠜⡄⠀⠀⠀⠀⣴⠟⠁
⠀⣰⣿⣷⣍⡛⣯⣯⣙⡁⠀⠀⣠⡾⠁
⠀⠨⢽⣿⣷⢍⣛⣶⢷⣼⣠⣾⠋
⠀⠀⠘⢿⣿⣖⠬⣹⣶⣿⠟⠁
⠀⠀⠀⠚⠿⠿⡒⠨⠛⠋
⠀⠀⠀⠐⢒⣛⣷
⠀⠀⠀⢘⣻⣭⣭
⠀⠀⠀⡰⢚⣺⣿
⠀⠀⢠⣿⣿⣿⣿⣦⡄
⠀⠀⢸⡿⢿⣿⢿⡿⠃
⠀⠀⠘⡇⣸⣿⣿⣿⣆
{Fore.RESET}
"""
banner_bio = f"{Fore.GREEN}Pr0xyHunter V1.1{Fore.RESET}"
banner_server = f"{Fore.GREEN}discord.gg/SecHex{Fore.RESET}"
print(banner_text)
print(banner_bio)
print(banner_server)
init(autoreset=True)
print_lock = threading.Lock()
timer_thread_stop = threading.Event()
def set_title(title):
if platform.system() == "Windows":
os.system(f"title {title}")
else:
print(f"\033]0;{title}\007")
set_title("Pr0xyHunter V1.1")
def test_proxy(ip, port, good_proxies):
current_thread = threading.current_thread().name
thread_identifier = f"{Fore.LIGHTCYAN_EX}Thread: {current_thread[-1]}{Fore.RESET}"
try:
start_time = time.time()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(5)
s.connect((ip, int(port)))
s.sendall(b"\x04\x01" + int(port).to_bytes(2, byteorder='big') + socket.inet_aton(ip) + b"\x00")
response = s.recv(8)
end_time = time.time()
ping_time = int((end_time - start_time) * 1000)
if len(response) < 2:
with print_lock:
print(f"{thread_identifier} | {Fore.RED}[BAD]{Fore.RESET} | {ip}:{port} | {Fore.LIGHTRED_EX}Ping: 404{Fore.RESET}")
return
status = response[1]
if status == 0x5A:
with print_lock:
print(f"{thread_identifier} | {Fore.GREEN}[GOOD]{Fore.RESET} | {ip}:{port} | {Fore.GREEN}Ping: {ping_time}ms{Fore.RESET}")
good_proxies.append(f"{ip}:{port}")
else:
with print_lock:
print(f"{thread_identifier} | {Fore.RED}[BAD]{Fore.RESET} | {ip}:{port} | {Fore.LIGHTRED_EX}Ping: 404{Fore.RESET}")
except:
with print_lock:
print(f"{thread_identifier} | {Fore.RED}[BAD]{Fore.RESET} | {ip}:{port} | {Fore.LIGHTRED_EX}Ping: 404{Fore.RESET}")
finally:
s.close()
def discord_webhook(txt_filename, webhook_url, message=None):
files = {'file': (txt_filename, open(txt_filename, 'rb'), 'text/plain')}
if message:
data = {'content': message}
else:
data = {}
response = requests.post(webhook_url, files=files, data=data)
if response.status_code == 200:
print(f"proxys '{txt_filename}' sent to Discord successfully!")
else:
print(f"Failed to send TXT file to Discord. Status Code: {response.status_code}")
def count_active_threads():
global previous_thread_count
while True:
num_active_threads = threading.active_count()
if num_active_threads != previous_thread_count:
print(f"{Fore.LIGHTCYAN_EX}Active Threads:{Fore.RESET} {num_active_threads}")
previous_thread_count = num_active_threads
time.sleep(5)
def create_pastebin(proxies, pastebin_api_key, webhook_url):
try:
pastebin_url = "https://pastebin.com/api/api_post.php"
proxies_data = "\n".join(proxies)
response = requests.post(pastebin_url, data={
'api_dev_key': pastebin_api_key,
'api_option': 'paste',
'api_paste_code': proxies_data
})
if response.status_code == 200:
pastebin_url = response.text
print(f"Pastebin URL: {pastebin_url}")
discord_webhook(pastebin_url, webhook_url)
else:
print(f"Failed to create Pastebin. Status Code: {response.status_code}")
except Exception as e:
print(f"Failed to create Pastebin: {str(e)}")
async def main():
with open('config.json', 'r') as config_file:
config = json.load(config_file)
webhook_url = config.get('webhook_url', '')
num_threads = config.get('num_threads', 5)
proxy_file = config.get('proxy_file')
proxy_scraper = config.get('proxy_scraper', False)
restart_interval = config.get('restart_interval', None)
active_threads_enabled = config.get('thread_logs', True)
pastebin_api_key = config.get('pastebin_api_key', '')
if active_threads_enabled:
active_thread_checker = threading.Thread(target=count_active_threads)
active_thread_checker.daemon = True
active_thread_checker.start()
await asyncio.sleep(4)
if not webhook_url:
print("Webhook URL is missing in config.json.")
return
start_time = time.time()
while True:
if proxy_scraper:
proxies_socks4 = socks4scrapy(proxy_file)
proxies_socks4_no2 = socks4scrapy_no2(proxy_file)
proxies_socks5 = socks5scrapy(proxy_file)
proxies = proxies_socks4 + proxies_socks4_no2 + proxies_socks5
with open(proxy_file, 'w') as f:
for proxy in proxies:
f.write(f"{proxy['ip']}:{proxy['port']}\n")
file_name = proxy_file
with open(file_name, 'r') as f:
proxies = f.readlines()
good_proxies = []
if num_threads == 1:
for proxy in proxies:
ip, port = proxy.strip().split(':')
test_proxy(ip, port, good_proxies)
else:
with ThreadPoolExecutor(max_workers=num_threads) as executor:
for proxy in proxies:
ip, port = proxy.strip().split(':')
executor.submit(test_proxy, ip, port, good_proxies)
num_threads_used = num_threads
with open("good_proxies.txt", 'w') as f:
for proxy in good_proxies:
f.write(proxy + "\n")
create_pastebin(good_proxies, pastebin_api_key, webhook_url)
num_good_proxies = len(good_proxies)
scan_duration = time.time() - start_time
embed = DiscordEmbed(title="SecHex-Pr0xyHunter V1.1", color=16777215)
embed.set_description(
f"Found **{num_good_proxies}** good proxies in **{scan_duration:.2f}** seconds using **{num_threads_used}** threads\n[SecHex-Pr0xyHunter](https://github.com/SecHex/SecHex-Pr0xyHunter)")
webhook = DiscordWebhook(url=webhook_url)
webhook.add_embed(embed)
webhook.execute()
discord_webhook("good_proxies.txt", webhook_url)
if restart_interval:
print(f"Rebooting in {restart_interval} seconds...")
await asyncio.sleep(restart_interval)
else:
print("Exiting...")
if __name__ == "__main__":
asyncio.run(main())