This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIPScan.py
83 lines (69 loc) · 3.92 KB
/
IPScan.py
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
# ----- License ---------------------------------------------------------------------------------------------------- #
#IPScan Copyright (C) 2022 Steven Pereira
#This program comes with ABSOLUTELY NO WARRANTY.
#This is free software, and you are welcome to redistribute it under certain conditions.
# ----- Import Section --------------------------------------------------------------------------------------------- #
import subprocess
import re
from rich.console import Console
# ----- Global Declaration ----------------------------------------------------------------------------------------- #
console = Console()
# ----- Banner Function -------------------------------------------------------------------------------------------- #
def ascii():
console.print(rf"""[bold yellow]
┌────────────────────────────────────────────────────────────────┐
│ │
│ 8888888 8888888b. .d8888b. │
│ 888 888 Y88b d88P Y88b │
│ 888 888 888 Y88b. │
│ 888 888 d88P "Y888b. .d8888b 8888b. 88888b. │
│ 888 8888888P" "Y88b. d88P" "88b 888 "88b │
│ 888 888 "888 888 .d888888 888 888 │
│ 888 888 Y88b d88P Y88b. 888 888 888 888 │
│ 8888888 888 "Y8888P" "Y8888P "Y888888 888 888 │
│ │
│ +-+-+ │
│ [#c61a09]Made by Cursed271[bold yellow] │
│ +-+-+ │
│ │
└────────────────────────────────────────────────────────────────┘
""")
# ----- Validation Functions --------------------------------------------------------------------------------------- #
def subnet_range(ip):
sub = ip.replace("/24", "")
subval = sub.split(".")
for x in subval:
if not x.isdigit():
console.print("You've entered the wrong Subnet Range")
console.print("Please check your Input")
exit()
else:
i = int(x)
if i >= 0 or i <= 255:
pass
else:
console.print("You've entered the wrong Subnet Range")
console.print("Please check your Input")
exit()
# ----- Scanning Function ------------------------------------------------------------------------------------------ #
def scanner(ip):
subnet_range(ip)
network = ip.replace("0/24", "")
ip_values = []
for host in range(1, 6):
ip_val = network + str(host)
process = subprocess.run('ping -c 1 '+ ip_val,stdout=subprocess.PIPE, shell=True)
if process.returncode == 0:
ip_values.append(ip_val)
console.print(f"{ip_val} IS ALIVE!!")
console.print("Ping completed successfully!")
console.print(f"There are {len(ip_values)} hosts available")
# ----- Main Function ---------------------------------------------------------------------------------------------- #
if __name__ == '__main__':
try:
ascii()
ip = input("Please enter a Subnet Range: ")
scanner(ip)
except KeyboardInterrupt:
print("Forcefully terminated IPScan")
# ----- End -------------------------------------------------------------------------------------------------------- #