-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_PortScanner.py
43 lines (32 loc) · 1.07 KB
/
simple_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
import pyfiglet
import sys
import socket
from datetime import datetime
import getopt
ascii_banner = pyfiglet.figlet_format("Basit Port Tarayıcı")
print(ascii_banner)
if len(sys.argv) == 2:
target = socket.gethostbyname(sys.argv[1])
else:
print("Hatalı Kullanım (python simple_PortScanner.py xx.xx.xx.xx)")
print("-" * 50)
print("Taranacak Hedef: " + target)
print("Tarih:" + str(datetime.now()))
print("-" * 50)
try:
for port in range(1,65535):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.setdefaulttimeout(1)
result = s.connect_ex((target,port))
if result ==0:
print("[{}] Numaralı Port Açık".format(port), "Banner = {}".format(s.recv(1024).decode()))
s.close()
except KeyboardInterrupt:
print("\n Programdan Çıkılıyor")
sys.exit()
except socket.gaierror:
print("\n Hostname Bulunamadı")
sys.exit()
except socket.error:
print("\ Server yanıt vermiyor")
sys.exit()