-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHost-Discovery.py
77 lines (64 loc) · 2.29 KB
/
Host-Discovery.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
import platform, os, sys
if len(sys.argv) != 2 or sys.argv[1] == 'h' or sys.argv[1] == 'help':
print('[+] Usage: python3 Host-Discovery.py "your IP address"')
exit()
nocolor = "\033[0;37;10m"
azul = "\033[0;34;10m"
amarillo = "\033[1;33;10m"
IP = sys.argv[1]
fIP = IP.split('.')
fIP.pop()
mIP = ''
listaIPs = []
df = open('HDtargets.txt', 'w')
for i in fIP:
mIP += i + '.'
for i in range(1, 255):
pIP = mIP + str(i)
listaIPs.append(pIP)
print(azul + '''
Host Discovery made by CronoX
''' + amarillo + '''https://github.com/CronoX1''' + azul + '''
Active machines will be saved at ''' + amarillo + '''HDtargets.txt ''' + azul + '''in the actual directory.
''' + amarillo + '''-----------------------------------------------------------------------
''' + nocolor)
def plataforma(listaIPs):
if platform.system() == 'Windows':
ping = 'ping -n 1 '
ping2 = ping + '-i 1 '
Windows(ping, ping2, listaIPs)
elif platform.system() == 'Linux':
ping = 'timeout 0.2 ping -c 1 '
Linux(ping, listaIPs)
def Windows(ping, ping2, listaIPs):
for i in listaIPs:
if i == IP:
continue
else:
accion = ping + str(i)
output = os.popen(accion)
for line in output:
if 'Received = 1' in str(line):
accion2 = ping2 + i
output2 = os.popen(accion2)
df.write(str(i) + '\n')
for line in output2:
if 'TTL=128' in line:
print(azul + i, ' ---> Windows' + nocolor)
elif 'TTL=64' in line:
print(amarillo + i, ' ---> Linux' + nocolor)
def Linux(ping, listaIPs):
for i in listaIPs:
if i == IP:
continue
else:
accion = ping + str(i)
output = os.popen(accion)
for line in output:
if 'ttl=64' in line:
print(amarillo + i, ' ---> Linux' + nocolor)
df.write(str(i) + '\n')
elif 'ttl=128' in line:
print(azul + i, ' ---> Windows' + nocolor)
df.write(str(i) + '\n')
plataforma(listaIPs)