always scan 192.168.1.0/24
This commit is contained in:
parent
412b87c669
commit
092f9df9cc
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
venv
|
||||
venv/*
|
||||
25
scan.py
Normal file
25
scan.py
Normal file
@ -0,0 +1,25 @@
|
||||
import ipaddress
|
||||
from ping3 import ping
|
||||
import socket
|
||||
|
||||
def get_ip():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.settimeout(0)
|
||||
try:
|
||||
# doesn't even have to be reachable
|
||||
s.connect(('10.254.254.254', 1))
|
||||
IP = s.getsockname()[0]
|
||||
except Exception:
|
||||
IP = '127.0.0.1'
|
||||
finally:
|
||||
s.close()
|
||||
return IP
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("IP:", get_ip())
|
||||
network = ipaddress.ip_network('192.168.1.0/24') # Creates subnet object
|
||||
for ip in network:
|
||||
p = ping(str(ip), timeout=1)
|
||||
if p is not None:
|
||||
print("Found host at:", ip)
|
||||
print("DONE")
|
||||
Loading…
x
Reference in New Issue
Block a user