-
Notifications
You must be signed in to change notification settings - Fork 0
/
portscanner.py
54 lines (41 loc) · 1.17 KB
/
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
45
46
47
48
49
50
51
52
53
54
import socket
import threading
import os
from sys import argv,exit
from banner import banner
try:
target_ip = argv[1]
except:
print("Usage : python3 main.py <ip or domain>")
exit()
def clear():
os.system("cls")
os.system("clear")
shape = '\033[34m' + "[" + '\033[91m' + "+" + '\033[34m' + "]"
def scan_port(ip, port):
"""The function who scan
ip ---> The target who will get scan
port ---> The ports
"""
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
result = sock.connect((ip, port))
print(str(shape) + "\033[32m" + f" Port {port} is open")
sock.close()
except:
print(str(shape) + '\033[91m' + f" Port {port} is closed")
def main():
"""This is the function will make every thing work"""
clear()
banner()
for port in range(1, 65553):
scan_port(target_ip, port)
scan_thread = threading.Thread(target=main)
scan_thread.start()
try:
# Keep the main thread running
while scan_thread.is_alive():
scan_thread.join(timeout=0.1)
except KeyboardInterrupt:
print(f"\n\n{shape} Thanks for using :)")