-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportscanner.py
44 lines (34 loc) · 920 Bytes
/
portscanner.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
import cyclopts, logging
from typing import Literal
import scanner.scanner as scanner
logging.basicConfig(format = "%(levelname)s :: %(message)s", level = logging.DEBUG)
app = cyclopts.App()
@app.command
def scan(
host: str = "localhost",
start : int = 0,
stop : int = 500,
protocol : Literal["TCP", "UDP"] = "TCP"
):
"""Scan ports on a host
Parameters
----------
host
host address to scan.
start
port to start scanning from
stop
port to stop scanning at
protocol
internet protocol to be used
"""
if protocol == "TCP":
protocol = scanner.Protocol.TCP
elif protocol == "UDP":
protocol = scanner.Protocol.UDP
scan_obj = scanner.Scanner(host, protocol)
logging.debug("scanning for openned ports...")
for port in scan_obj.scan(start, stop):
print(port)
if __name__ == "__main__":
app()