Skip to content

Commit 2cbb398

Browse files
authored
Add files via upload
1 parent a051ab5 commit 2cbb398

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

ip.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
import platform
3+
4+
def ping(ip):
5+
param = '-n' if platform.system().lower() == 'windows' else '-c'
6+
command = ['ping', param, '1', ip]
7+
return os.system(' '.join(command)) == 0
8+
9+
def main():
10+
print("=== Simple Network Ping Sweep ===")
11+
subnet = input("Enter subnet (example: 192.168.1.): ")
12+
13+
print("\nScanning...\n")
14+
alive = []
15+
16+
for i in range(1, 255):
17+
ip = subnet + str(i)
18+
if ping(ip):
19+
print(f"[+] Reachable: {ip}")
20+
alive.append(ip)
21+
22+
print("\n=== Scan Complete ===")
23+
if alive:
24+
print("Active Hosts:")
25+
for host in alive:
26+
print(host)
27+
else:
28+
print("No active hosts found.")
29+
30+
if __name__ == "__main__":
31+
main()
32+
33+
34+

0 commit comments

Comments
 (0)