-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortScanner.py
More file actions
54 lines (39 loc) Β· 3.13 KB
/
PortScanner.py
File metadata and controls
54 lines (39 loc) Β· 3.13 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
print(" βββββββββββ βββββ βββββββββ ")
print("βββββββββββββ βββββ βββββββββββ ")
print(" ββββ ββββ ββββββ ββββββββ βββββββ ββββ βββ ββββββ ββββββ ββββββββ ββββββββ ββββββ ββββββββ ")
print(" βββββββββββ βββββββββββββββββββββββββ βββββββββββ ββββββββ ββββββββ ββββββββββ ββββββββββ ββββββββββββββββββ")
print(" ββββββββββ ββββ ββββ ββββ βββ ββββ βββββββββββββββ βββ βββββββ ββββ ββββ ββββ ββββ ββββββββ ββββ βββ ")
print(" ββββ ββββ ββββ ββββ ββββ βββ βββ ββββββββ βββ ββββββββ ββββ ββββ ββββ ββββ βββββββ ββββ ")
print(" βββββ ββββββββ βββββ βββββββ βββββββββββ ββββββββ ββββββββββ ββββ βββββ ββββ βββββββββββββ βββββ ")
print("βββββ ββββββ βββββ βββββ βββββββββ ββββββ ββββββββ ββββ βββββ ββββ βββββ ββββββ βββββ ")
import socket
import threading
import queue
Target = input("Enter Target IP Address: ") or "192.168.1.1"
try:
number_threads = int(input("Enter The Number Of Threads (Default Value = 100): ") or 100)
except ValueError:
number_threads = 100
port_queue = queue.Queue()
for port in range(1, 1024):
port_queue.put(port)
def worker():
while not port_queue.empty():
port = port_queue.get()
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
if sock.connect_ex((Target, port)) == 0:
print(f"[+] Port {port} is open on {Target}")
sock.close()
except:
pass
port_queue.task_done() #Task Done
threads = []
for _ in range(number_threads):
thread = threading.Thread(target=worker, daemon=True)
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
print("[*] Port scan complete.")