-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfinal
132 lines (111 loc) · 3.85 KB
/
final
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
from netaddr import IPNetwork
import urllib.request
import random
import os.path
import socket
import threading
def method():
# c = input("Enter method number :\n 1-socks4 \n 2-http(80)\n 3-http(8080)\n -> Default is socks4\n ")
# c=int(c)
# if(c==1):
# return 1
# elif(c==2):
# return 2
# elif(c==3):
# return 3
# else:
# print('wrong number, using Default method')
return 1
method_chosen = method()
def work_with_ips():
with open("ips.txt","r") as inp:
ipranges = inp.readlines()
random_range = random.choice(ipranges)
print('selected random range is:',random_range)
with open("selected_ip_range.txt","a") as inp:
for ip in IPNetwork(random_range):
ip = str(ip)
inp.write((ip))
inp.write('\n')
print("ip list created successfully")
def is_ips_port_open(ip):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(0.5)
print(ip)
if(method_chosen==1):
return s.connect_ex((ip,54321)) == 0
# elif(method_chosen==2):
# return s.connect_ex((ip,80)) == 0
# elif(method_chosen==3):
# return s.connect_ex((ip,8080)) == 0
else:
print("eroooooooooooooooooooooooooooooooooooooooor")
def check_alive_ips(count,ip):
conn = is_ips_port_open(ip)
if(conn):
count+=1
print ("Port is open for :))))))))))",ip)
with open("ips_with_open_ports.html","a") as inp:
ip=str(ip)
if(method_chosen==1):
methdname = 'v2ray found!Ip is '
# if(method_chosen==2):
# methdname = 'http(80)'
# if(method_chosen==3):
# methdname = 'http(8080)'
inp.write('<a href="http://')
inp.write(ip)
inp.write(':54321"')
inp.write(' target="_blank" >')
inp.write(ip)
inp.write(':54321 </a>')
inp.write('\n')
inp.write('<br>')
else:
print ("Port is not open for ",ip)
print("======================================")
return count
def ips2array():
f = open('selected_ip_range.txt','r')
lines = f.read().splitlines()
f.close()
return lines
def check_One_By_One(iparray):
for ips in iparray:
count_alive = check_alive_ips(0,ips)
return count_alive
def multi_ip(iparray):
splitlen = len(iparray)//8
print('split len is ', splitlen)
t1 = threading.Thread(target=check_One_By_One, args=(iparray[:splitlen],))
t1.start()
t2 = threading.Thread(target=check_One_By_One, args=(iparray[splitlen:2*splitlen],))
t2.start()
t3 = threading.Thread(target=check_One_By_One, args=(iparray[2*splitlen:3*splitlen],))
t3.start()
t4 = threading.Thread(target=check_One_By_One, args=(iparray[3*splitlen:4*splitlen],))
t4.start()
t5 = threading.Thread(target=check_One_By_One, args=(iparray[4*splitlen:5*splitlen],))
t5.start()
t6 = threading.Thread(target=check_One_By_One, args=(iparray[5*splitlen:6*splitlen],))
t6.start()
t7 = threading.Thread(target=check_One_By_One, args=(iparray[6*splitlen:7*splitlen],))
t7.start()
t8= threading.Thread(target=check_One_By_One, args=(iparray[7*splitlen:8*splitlen],))
t8.start()
def main():
if os.path.isfile('selected_ip_range.txt'):
os.remove("selected_ip_range.txt")
work_with_ips()
iparray = ips2array()
multi_ip(iparray)
print("===========================================================")
print("Iran Proxy BY Nic")
print("===========================================================")
if os.path.isfile('ips_with_open_ports.html'):
alive_num = sum(1 for line in open('ips_with_open_ports.html'))
else:
alive_num = 0
print('alive num is',alive_num)
while (alive_num<100000):
main()