-
Notifications
You must be signed in to change notification settings - Fork 2
/
LAN_IP_Scanner_V2.py
175 lines (133 loc) · 5.31 KB
/
LAN_IP_Scanner_V2.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
import os , subprocess , threading , keyboard , time
import concurrent , requests
from concurrent import futures
from colorama import Fore , init
init()
G = Fore.LIGHTGREEN_EX # Defining colors
R = Fore.LIGHTRED_EX
Cyn = Fore.LIGHTCYAN_EX
Ylw = Fore.LIGHTYELLOW_EX
banner = """
█ ▄▀█ █▄ █ █ █▀█ █▀ █▀▀ ▄▀█ █▄ █ █▄ █ █▀▀ █▀█
█▄▄ █▀█ █ ▀█ █ █▀▀ ▄█ █▄▄ █▀█ █ ▀█ █ ▀█ ██▄ █▀▄
---------------- [+] GHOSTH4CK3R --------------------
"""
def print_banner():
print(Cyn + banner)
print_banner()
input("Press \'Enter\' To Scan > ")
def anim() : # Scanning animation
os.system('cls')
print_banner()
print("\nScanning.../ ")
time.sleep(0.1)
os.system('cls')
print_banner()
print("\nScanning...- ")
time.sleep(0.1)
os.system('cls')
print_banner()
print("\nScanning...\ ")
time.sleep(0.1)
os.system('cls')
print_banner()
print("\nScanning...| ")
time.sleep(0.1)
os.system('cls')
def anim2() :
print_banner()
print("Scan complete...")
def ping_range(start,count) :
prefix = "192.168.1."
condition = "Destination host unreachable"
condition2 = "Request timed out"
list1 = []
#list2 = []
for xxx in range(start,start+count) :
if keyboard.is_pressed('space') == True :
exit()
ip = prefix + str(xxx)
code = "ping " + ip + " -n 1 -l 1"
code2 = "arp -a " + ip
ping = os.popen(code).read()
if condition not in ping and condition2 not in ping: # Checking if IP's are alive
#print(G + ip)
#list1.append(ip)
try:
arp = os.popen(code2).read().split('\n') # Getting MAC Address
arpS = str(arp[3])
mac_loc = arpS.find('-')
mac = arpS[(mac_loc-2):(mac_loc+15)]
macsite_url = "https://macvendors.com/query/" + mac
vendor_res = requests.get(macsite_url) # Getting MAC Vendor
if vendor_res.status_code == 200 :
vendor = vendor_res.text
else:
vendor = "[Not Found]"
IPnMACnVendor = ip + " " + mac + " " + vendor
list1.append(IPnMACnVendor)
except Exception as e : # #GH0STH4CK3R
#IPnNon = ip + " [Not Found]"
#list1.append(IPnNon)
getmac = os.popen("getmac /V /FO LIST").read().split('\n\n')
for x in range(int(len(getmac))) :
if 'Wi-Fi' in getmac[x] :
getmc = getmac[x]
ps_adrs = getmc.find('Physical Address:')
mac2 = getmc[(ps_adrs+18):(ps_adrs+35)]
macsite_url = "https://macvendors.com/query/" + mac2
vendor_res = requests.get(macsite_url)
if vendor_res.status_code == 200 :
vendor = vendor_res.text
else:
vendor = "[Not Found]"
IPnMACnVendor = ip + " " + mac2 + " " + vendor
list1.append(IPnMACnVendor)
return list1
tasks = []
with concurrent.futures.ThreadPoolExecutor(max_workers=30) as executor : # Multi Threading
for start in [0,11]:
tasks.append(executor.submit(ping_range,start,10))
for start in [21,31]:
tasks.append(executor.submit(ping_range,start,10))
for start in [41,51]:
tasks.append(executor.submit(ping_range,start,10))
for start in [61,71]:
tasks.append(executor.submit(ping_range,start,10))
for start in [81,91]:
tasks.append(executor.submit(ping_range,start,10))
for start in [101,111]:
tasks.append(executor.submit(ping_range,start,10))
for start in [121,131]:
tasks.append(executor.submit(ping_range,start,10))
#GH0STH4CK3R
for start in [141,151]:
tasks.append(executor.submit(ping_range,start,10))
for start in [161,171]:
tasks.append(executor.submit(ping_range,start,10))
for start in [181,191]:
tasks.append(executor.submit(ping_range,start,10))
for start in [201,211]:
tasks.append(executor.submit(ping_range,start,10))
for start in [221,231]:
tasks.append(executor.submit(ping_range,start,10))
for start in [241,248]:
tasks.append(executor.submit(ping_range,start,7))
for v in range(40):
anim()
anim2()
print(Cyn + "\nResults :")
print(G + "")
empty_tsk = 0
for task in tasks: # Outputting Returned Values From each thread
if len(task.result()) == 1 :
print(task.result()[0])
elif len(task.result()) > 1 :
for elmnt in range(len(task.result())) :
print(task.result()[elmnt])
elif len(task.result()) == 0 :
empty_tsk += 1
if empty_tsk >= 254 :
print(R + "No IP's Found !")
print(Cyn + "")
input("Exit >>")