-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPulseCheck.py
More file actions
91 lines (76 loc) · 3.67 KB
/
PulseCheck.py
File metadata and controls
91 lines (76 loc) · 3.67 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import platform
import subprocess
from time import sleep
from rich.console import Console
from rich.table import Table
from rich.progress import Progress, SpinnerColumn, TextColumn
from rich import print as rprint
console = Console()
def display_logo():
logo = """
██████╗ ██╗ ██╗██╗ ███████╗███████╗ ██████╗██╗ ██╗███████╗ ██████╗██╗ ██╗
██╔══██╗██║ ██║██║ ██╔════╝██╔════╝██╔════╝██║ ██║██╔════╝██╔════╝██║ ██╔╝
██████╔╝██║ ██║██║ ███████╗█████╗ ██║ ███████║█████╗ ██║ █████╔╝
██╔═══╝ ██║ ██║██║ ╚════██║██╔══╝ ██║ ██╔══██║██╔══╝ ██║ ██╔═██╗
██║ ╚██████╔╝███████╗███████║███████╗╚██████╗██║ ██║███████╗╚██████╗██║ ██╗
╚═╝ ╚═════╝ ╚══════╝╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝
\033[1mразработано @ARTIST для INFLUXION\033[0m
"""
console.print(logo)
# Function to ping an IP address
def is_ip_alive(ip):
if platform.system().lower() == "windows":
command = ["ping", "-n", "1", ip]
else:
command = ["ping", "-c", "1", ip]
try:
response = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return response.returncode == 0
except Exception as e:
console.log(f"[red]Error while pinging {ip}: {e}[/red]")
return False
# Function to check IPs from a file
def check_ips_from_file(filename):
try:
with open(filename, "r") as file:
ip_addresses = file.readlines()
except FileNotFoundError:
console.print(f"[red]File not found: {filename}[/red]")
return
ip_addresses = [ip.strip() for ip in ip_addresses if ip.strip()]
live_ips = []
dead_ips = []
with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}"), console=console) as progress:
task = progress.add_task("Pinging IPs...", total=len(ip_addresses))
for ip in ip_addresses:
if is_ip_alive(ip):
live_ips.append(ip)
else:
dead_ips.append(ip)
progress.update(task, advance=1)
# Display results
console.rule("[green]Results[/green]")
if live_ips:
table = Table(title="Live IPs", style="green")
table.add_column("IP Address", justify="center")
for ip in live_ips:
table.add_row(ip)
console.print(table)
else:
rprint("[red]No live IPs found.[/red]")
if dead_ips:
table = Table(title="Dead IPs", style="red")
table.add_column("IP Address", justify="center")
for ip in dead_ips:
table.add_row(ip)
console.print(table)
else:
rprint("[green]No dead IPs found.[/green]")
# Main script
if __name__ == "__main__":
display_logo()
file_name = "ips.txt" # Replace with your file name
rprint(f"[blue]Reading IPs from:[/blue] [yellow]{file_name}[/yellow]")
sleep(1)
check_ips_from_file(file_name)