forked from Kourva/V2rayDoprax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
randomVmess.py
104 lines (81 loc) · 2.59 KB
/
randomVmess.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
#!/usr/bin/env python3
# This tool will create random Vmess proxies with random servers
# Imports
import requests, string, random, base64, time, sys
# Random server name generator
def random_name() -> str:
characters = string.ascii_letters + string.digits
return "".join(random.choices(characters, k=6))
# Gets servers
def get_servers():
names = []
addrs = []
# Servers from database
with open("ip/all_result.txt") as data:
targets = [url.split("\n")[0] for url in data.readlines()]
for i in range(int(sys.argv[2])):
addrs.append(targets[random.randint(0, len(targets) - 1)])
names.append(random_name())
return zip(names, addrs)
raise SystemExit("Can't get servers")
# Vmess generator
def vmess_generator():
with open(sys.argv[1].strip(), "r") as config:
lines = config.read()
worker = lines.split("\n")[1]
doprax = lines.split("\n")[4]
uuid = lines.split("\n")[7]
path = lines.split("\n")[13]
alias = lines.split("\n")[16]
names, addrs = [], []
result = []
worker_host = worker.split("/")[2]
for name, addrs in get_servers():
vmess_config = {
"v": "2",
"ps": alias + "-" + name,
"add": addrs,
"port": "443",
"id": uuid,
"aid": "0",
"net": "ws",
"type": "none",
"host": worker_host,
"path": path,
"tls": "tls",
"alpn": "http/1.1",
"sni": worker_host,
"utls": "chrome",
}
message = str(vmess_config).encode("ascii")
vmess_url = base64.b64encode(message).decode("ascii")
result.append("vmess://" + vmess_url)
return result
# Main function
def main():
with open("data/random_result.txt", "a") as result:
for proxy in vmess_generator():
result.write(proxy + "\n\n")
for char in "\033[2;34m{} Servers saved in data/random_result.txt\033[m\n".format(
int(sys.argv[2])
):
print(char, end="", flush=True)
time.sleep(0.01)
# Run the program
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] in ["-h", "--help"]:
print(
"""
Help: python randomVmess.py [config] [How many proxy]
create proxy -> python randomVmess.py config.conf 10
help message -> python randomVmess.py -h/--help
"""
)
elif sys.argv[1]:
main()
else:
print("Invalid argument! run with -h")
else:
print("No argument! run with -h")
# EOF