-
-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Expand file tree
/
Copy pathip.py
More file actions
34 lines (25 loc) · 737 Bytes
/
ip.py
File metadata and controls
34 lines (25 loc) · 737 Bytes
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
import os
import platform
def ping(ip):
param = '-n' if platform.system().lower() == 'windows' else '-c'
command = ['ping', param, '1', ip]
return os.system(' '.join(command)) == 0
def main():
print("=== Simple Network Ping Sweep ===")
subnet = input("Enter subnet (example: 192.168.1.): ")
print("\nScanning...\n")
alive = []
for i in range(1, 255):
ip = subnet + str(i)
if ping(ip):
print(f"[+] Reachable: {ip}")
alive.append(ip)
print("\n=== Scan Complete ===")
if alive:
print("Active Hosts:")
for host in alive:
print(host)
else:
print("No active hosts found.")
if __name__ == "__main__":
main()