- 9 Şub 2023
- 52
- 19
Python ile yazdığım basit port scanner.
Python:
import socket
import threading
import tkinter as tk
def startscan():
host = hoste.get()
start_port = int(spe.get())
end_port = int(fpe.get())
t = threading.Thread(target=paraleltarama, args=(host, start_port, end_port))
t.start()
def açıkyazdırma(port):
portshow.config(state='normal')
portshow.insert(tk.END, f'[+] port açık : {port} \n')
portshow.config(state='disabled')
def portscan(host, port):
soket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
soket.settimeout(1)
sonuc = soket.connect_ex((host, port))
soket.close()
if sonuc == 0:
açıkyazdırma(str(port))
def paraleltarama(host, start_port, end_port):
for port in range(start_port, end_port + 1):
t = threading.Thread(target=portscan, args=(host, port))
t.start()
scan = tk.Tk()
scan.geometry('350x400')
scan.title('THT Scanner')
scan.config(bg='black')
scan.resizable(False, False)
hostt = tk.Label(scan, text='Target İp :', font=5, bg='black', fg='white')
hostt.place(x=10, y=30)
hoste = tk.Entry(scan, width=20, fg='red', bg='#242424')
hoste.place(x=90, y=32)
spt = tk.Label(scan, text='Start port :', font=5, bg='black', fg='white')
spt.place(x=5, y=70)
spe = tk.Entry(scan, width=5, fg='red', bg='#242424')
spe.place(x=85, y=72)
spe.insert(0, '0')
fpt = tk.Label(scan, text='End Port :', font=5, bg='black', fg='white')
fpt.place(x=150, y=70)
fpe = tk.Entry(scan, width=5, fg='red', bg='#242424')
fpe.place(x=225, y=72)
fpe.insert(0, '65535')
portshow = tk.Text(scan, width=37, height=15, state='disabled', bg='#242424', fg='green')
portshow.place(x=20, y=100)
portshow.config(state='normal')
portshow.insert(tk.END, '[*] açık portlar burada gösterilir.\n\n\n')
portshow.config(state='disabled')
startt = tk.Button(scan, text='Start scan', font=5, width=20, bg='#242424', fg='red', command=startscan)
startt.place(x=70, y=355)
scan.mainloop()