-
Notifications
You must be signed in to change notification settings - Fork 0
/
HolyScan.py
114 lines (95 loc) · 5.53 KB
/
HolyScan.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# ----- HolyScan --------------------------------------------------------------------------------------------------- #
# HolyScan is a portscanner written in python that lists all the open ports and running services on the host.
# Created by Steven Pereira aka Cursed Cancer
# Github: https://github.com/CursedCancer
# ----- Import Section --------------------------------------------------------------------------------------------- #
import os
import time
import socket
from rich.console import Console
from threading import Thread
from threading import Lock
from queue import Queue
from datetime import datetime
# ----- Global Declaration ----------------------------------------------------------------------------------------- #
console = Console()
N_Thread = 200
q = Queue()
print_lock = Lock()
# ----- Menu ------------------------------------------------------------------------------------------------------- #
class menu():
def clear():
time.sleep(1)
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
# ----- Banner ----------------------------------------------------------------------------------------------------- #
class banner():
def ascii():
console.print(r"""[#79d45e]
┌───────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ [#a484e9]___ ___ ________ ___ ___ ___ ________ ________ ________ ________[#79d45e] │
│ [#a484e9]|\ \|\ \|\ __ \|\ \ |\ \ / /| |\ ____\|\ ____\|\ __ \|\ ___ \ [#79d45e] │
│ [#a484e9]\ \ \\\ \ \ \|\ \ \ \ \ \ \/ / / \ \ \___|\ \ \___|\ \ \|\ \ \ \\ \ \ [#79d45e] │
│ [#a484e9]\ \ __ \ \ \\\ \ \ \ \ \ / / \ \_____ \ \ \ \ \ __ \ \ \\ \ \ [#79d45e] │
│ [#a484e9]\ \ \ \ \ \ \\\ \ \ \____ \/ / / \|____|\ \ \ \____\ \ \ \ \ \ \\ \ \ [#79d45e] │
│ [#a484e9]\ \__\ \__\ \_______\ \_______\__/ / / ____\_\ \ \_______\ \__\ \__\ \__\\ \__\ [#79d45e] │
│ [#a484e9]\|__|\|__|\|_______|\|_______|\___/ / |\_________\|_______|\|__|\|__|\|__| \|__|[#79d45e] │
│ [#a484e9]\|___|/ \|_________|[#79d45e] │
│ │
│ [#31bff3]- WELCOME TO HOLY SCAN -[#79d45e] │
│ Holy Scan is a portscanner written in python that helps to identify open ports │
│ │
│ +-+-+ │
│ [red] Cursed Cancer[#79d45e] │
│ +-+-+ │
└───────────────────────────────────────────────────────────────────────────────────────────────────────┘
""")
# ----- Port Scanner ----------------------------------------------------------------------------------------------- #
def portscan(port):
try:
s = socket.socket()
s.connect((host, port))
except:
with print_lock:
pass
else:
with print_lock:
serviceName = socket.getservbyport(port)
service = serviceName.upper()
console.print(f"\t- {service}: {port}")
finally:
s.close()
# ----- Threading -------------------------------------------------------------------------------------------------- #
def scan_thread():
global q
while True:
worker = q.get()
portscan(worker)
q.task_done()
def scanner(host, ports):
global q
for t in range(N_Thread):
t = Thread(target=scan_thread)
t.daemon = True
t.start()
for worker in ports:
q.put(worker)
q.join()
# ----- Main Function ---------------------------------------------------------------------------------------------- #
if __name__ == '__main__':
menu.clear()
banner.ascii()
console.print("[#5bd2f0]────── [#ffaf68]Performing a Port Scan [#5bd2f0]────────────────────────────────────────────────────────────────────────────────────────\n")
start = datetime.now()
remote_server = console.input("[#f6e683]Enter the Host name: ")
host = socket.gethostbyname(remote_server)
port = console.input("[#f6e683]Enter the port range: ")
port_range = port.split("-")
start = int(port_range[0])
end = int(port_range[1])
ports = [p for p in range(start, end)]
console.print("[#79d45e]Open Ports: ")
scanner(host, ports)
# ----- End -------------------------------------------------------------------------------------------------------- #