-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathportscanner.py
More file actions
39 lines (29 loc) · 814 Bytes
/
Copy pathportscanner.py
File metadata and controls
39 lines (29 loc) · 814 Bytes
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
import sys
import socket
import pyfiglet
ascii_banner = pyfiglet.figlet_format("Torada \n Python 4 Pentesters \nPort Scanner")
print(ascii_banner)
ip = '10.10.94.239'
open_ports = []
ports = range(1, 65535)
def probe_port(ip, port, result=1):
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(0.5)
r = sock.connect_ex((ip, port))
if r == 0:
result = r
sock.close()
except Exception as e:
pass
return result
for port in ports:
sys.stdout.flush()
response = probe_port(ip, port)
if response == 0:
open_ports.append(port)
if open_ports:
print("Open Ports are: ")
print(sorted(open_ports))
else:
print("Looks like no ports are open :(")