-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecports.py
64 lines (55 loc) · 2.44 KB
/
secports.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
import socket
import logging
from concurrent.futures import ThreadPoolExecutor
def check_port(target, port):
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
result = sock.connect_ex((target, port))
if result == 0:
logging.info(f"Port {port} is open on {target}")
sock.close()
except Exception as e:
logging.error(f"Error scanning port {port} on {target}: {e}")
def scan_target(target, start_port, end_port):
logging.info(f"Scanning target {target} from port {start_port} to {end_port}...")
try:
socket.gethostbyname(target)
except socket.error as e:
logging.error(f"Error resolving target {target}: {e}")
return
with ThreadPoolExecutor(max_workers=20) as executor:
for port in range(start_port, end_port + 1):
executor.submit(check_port, target, port)
if __name__ == "__main__":
print("""
Welcome to SecPorts
`
( (
) (
) )
( ( ,
_ _)_ .-Y.
.--._ _.--'.',T.\_.--' (_)`.
.'_. ` _.' `-' __._.--;
/.' `. -' ___.--' ,--. : o ,-. _
: | xX| ,' .-'`.( | ' ( o ,' .-' `,
: `. .' ._'-, \ | \ ||/ `.{ / .' :
.; `' ,',\|\| \ | `.;' .__(()`./.' _.-'
; | ` ` \.'|\\ : ``.-. _ '_.-'
.' ` /|, `|\\ \ -'' \ \
: \`/|,-. `|\\ : ,-'| `-.
: _ \`/ | _ .^.'\ \ -'> \_
`; --`-. \`._| ,' \ | \ : \ )`.\`-
:. .---\ \ ,' | ' \ : . ` `.\_,/
:. __\ `. : | `-.-', : `-'
`:. -' `. `.`---'__.--' /
`: __.\ `---' _'
`:. -' `. __.--'
`:. __`--.--'\
""")
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
target = input("Enter IP address or domain: ")
start_port = int(input("Enter start port: "))
end_port = int(input("Enter end port: "))
scan_target(target, start_port, end_port)