-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping-sweep.py
More file actions
48 lines (38 loc) · 1.32 KB
/
ping-sweep.py
File metadata and controls
48 lines (38 loc) · 1.32 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
#Created by PepeBigotes
import os
import threading
import time
import socket
os.system('cls' if os.name == 'nt' else 'clear')
print("""\
┌─┐┬┌┐┌┌─┐ ┌─┐┬ ┬┌─┐┌─┐┌─┐
├─┘│││││ ┬───└─┐│││├┤ ├┤ ├─┘
┴ ┴┘└┘└─┘ └─┘└┴┘└─┘└─┘┴
""")
print("Select a target IP (default is 192.168.0.1):")
target = str(input(" > "))
if not target: target = "192.168.0.1"
os.system('cls' if os.name == 'nt' else 'clear')
print(f"[ Ping-Sweeping {target} ... ] Hold CTRL+C to stop")
print()
argument = ('-n 1' if os.name == 'nt' else '-c 1')
nuller = ('>nul' if os.name == 'nt' else '>/dev/null')
dot = target.rfind(".")
target = target[0:dot + 1]
def ping(x):
global target
host = target + str(x)
for i in range(0, 5):
response = os.system(f"ping {argument} -w 1000 {host} {nuller}")
time.sleep(1)
if response == 0:
hostname = socket.getfqdn(host)
hostname = hostname if hostname is not host else "-"
space = " " * (18 -len(host))
print(f"+ {host}{space}Hostname: {hostname}")
return
for y in range(1, 255):
thread = threading.Thread(target=ping, args=[y])
thread.start()
time.sleep(0.1)