-
Notifications
You must be signed in to change notification settings - Fork 2
/
examplemodule.py
127 lines (106 loc) · 4.68 KB
/
examplemodule.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
try:
import os, requests, colorama, threading, time, urllib
except ImportError:
input("Error while importing modules. Please install the modules in requirements.txt")
exit()
colorama.init(convert=True)
lock = threading.Lock()
counter = 0
errorcounter = 0
proxyfilelines = 0
proxies = []
proxy_counter = 0
modulename = "ExampleModule"
moduleowner = "ESU"
class examplemodule:
def __init__(self, proxytype = None, proxy = None):
self.proxy = proxy
self.proxytype = proxytype
def examplemodule2(self): # your loop function
proxies = None
if self.proxy != None:
if self.proxytype == 1:
proxies = {"http": f"http://{self.proxy}","https": f"http://{self.proxy}"}
if self.proxytype == 2:
proxies = {"http": f"socks4://{self.proxy}","https": f"socks4://{self.proxy}"}
if self.proxytype == 3:
proxies = {"http": f"socks5://{self.proxy}","https": f"socks5://{self.proxy}"}
return True
os.system(f"title {modulename} by {moduleowner}")
threads = int(input(f"\n[{modulename}] Threads > "))
print("\n[1] Proxies\n[2] Get Free Proxies(Maybe you get bad proxies)\n[3] Proxyless")
proxyinput = int(input(f"\n[{modulename}] Select Preference > "))
if proxyinput == 1:
print("\n[1] Http\n[2] Socks4\n[3] Socks5")
proxytype = int(input(f"\n[{modulename}] Select Proxy Type > "))
if proxyinput == 2:
print("\n[1] Http\n[2] Socks4\n[3] Socks5")
proxytype = int(input(f"\n[{modulename}] Select Proxy Type > "))
os.system("cls")
script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
rel_path = "../../../proxies.txt"
proxiesdir = os.path.join(script_dir, rel_path)
def load_proxies():
global proxyfilelines
if not os.path.exists(proxiesdir):
print(colorama.Fore.YELLOW + "\nFile proxies.txt not found")
time.sleep(5)
os._exit(0)
with open(proxiesdir, "r", encoding = "UTF-8") as f:
for line in f.readlines():
line = line.replace("\n", "")
proxyfilelines = len(proxies)
proxyfilelines += 1
proxies.append(line)
if not len(proxies):
print(colorama.Fore.YELLOW + "\nNo proxies loaded in proxies.txt")
time.sleep(5)
os._exit(0)
def getfreeproxy():
if proxytype == 1:
# HTTP Proxies
urllib.request.urlretrieve("https://api.proxyscrape.com/v2/?request=getproxies&protocol=http&timeout=10000&country=all&ssl=all&anonymity=all", proxiesdir)
if proxytype == 2:
# Socks4 Proxies
urllib.request.urlretrieve("https://api.proxyscrape.com/v2/?request=getproxies&protocol=socks4&timeout=10000&country=all&ssl=all&anonymity=all", proxiesdir)
if proxytype == 3:
# Socks5 Proxies
urllib.request.urlretrieve("https://api.proxyscrape.com/v2/?request=getproxies&protocol=socks5&timeout=10000&country=all&ssl=all&anonymity=all", proxiesdir)
if proxyinput == 2:
getfreeproxy()
time.sleep(1)
load_proxies()
if proxyinput == 1:
load_proxies()
def safe_print(arg):
lock.acquire()
print(arg)
lock.release()
def count():
os.system(f'title [{modulename} by {moduleowner}] Created-Generated-BlaBla = {counter} / Error = {errorcounter} / Proxy = {proxyfilelines}')
def thread_starter():
global counter, errorcounter
if proxyinput == 1:
obj = examplemodule(proxytype, proxies[proxy_counter])
if proxyinput == 2:
obj = examplemodule(proxytype, proxies[proxy_counter])
else:
obj = examplemodule()
result, message = obj.examplemodule2() # examplemodule2 The name of your module's function that will enter the thread
if result == True:
counter += 1
safe_print(colorama.Fore.MAGENTA + f"[{modulename}] " + colorama.Fore.GREEN + message + colorama.Fore.RESET)
count()
else:
errorcounter += 1
safe_print(colorama.Fore.MAGENTA + f"[{modulename}] " + colorama.Fore.RED + f"Error {message}" + colorama.Fore.RESET)
count()
while True:
if threading.active_count() <= threads:
try:
threading.Thread(target = thread_starter).start()
proxy_counter += 1
except:
pass
if len(proxies) <= proxy_counter: #Loops through proxy file
proxy_counter = 0