-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (25 loc) · 1 KB
/
Copy pathmain.py
File metadata and controls
32 lines (25 loc) · 1 KB
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
from icmplib import ping, multiping
from ipaddress import ip_address, ip_network
def discovery_network(ip):
ips_network = [str(ip) for ip in ip.hosts()]
host_live = multiping(ips_network, count=1, timeout=2, interval=1)
for h in host_live:
if h.is_alive:
print(f"[+] Host Live. {h.address} | RTT: {h.avg_rtt}ms | Sent: {h.packets_sent}")
def discovery_host(ip):
ip_str = str(ip)
host_objetivo =ping(ip_str, count=1, timeout=2, interval=1)
if host_objetivo.is_alive:
print(f"[+] Host Live: {host_objetivo.address} | RTT: {host_objetivo.avg_rtt}ms | Sent: {host_objetivo.packets_sent}")
else:
print("Sin respuesta")
ip_obj = input("Ingresa una ip: ")
try:
if "/" in ip_obj:
ip_valida = ip_network(ip_obj, strict = False)
discovery_network(ip_valida)
else:
ip_valida = ip_address(ip_obj)
discovery_host(ip_valida)
except:
print("Ingresa una IP valida o una RED valida")