def __init__(self, master=None): self.ps = portscanner.PortScanner() super().__init__(master) self["bg"] = "white" self["padx"] = 30 self["pady"] = 30 self.pack(expand=1, fill=tk.BOTH) self.create_widgets() self.set_defaults()
def __init__(self): # Load bot answers and other info with open('data.json', 'r') as f: bot_config = json.load(f) self.token = str(os.getenv('TOKEN')) self.app_port = int(os.getenv('PORT', '8443')) self.replies = bot_config['replies']['eng'] self.scanning_template = self.replies['scanning_template'] self.scanning_completed_template = self.replies['scanning_completed_template'] self.start_scanning_template = self.replies['start_scanning_template'] self.MAX_MESSAGE_SIZE = 4096 # Creating Bot core self.updater = Updater(token=self.token) self.dispatcher = self.updater.dispatcher self.scanner = ps.PortScanner() self.ip_range = [] self.port_range = [] #Adding handlers start_handler = CommandHandler('start', self.start) help_handler = CommandHandler('help', self.help) set_port_handler = CommandHandler('set_port', self.set_port, pass_args=True) set_ip_handler = CommandHandler('set_ip', self.set_ip, pass_args=True) scan_handler = CommandHandler('scan', self.scan) set_timeout_handler = CommandHandler('settimeout', self.set_timeout, pass_args=True) self.dispatcher.add_handler(start_handler) self.dispatcher.add_handler(help_handler) self.dispatcher.add_handler(set_port_handler) self.dispatcher.add_handler(set_ip_handler) self.dispatcher.add_handler(scan_handler) self.dispatcher.add_handler(set_timeout_handler)
#!/usr/bin/python from pony.orm import * from datetime import * from tor_db import * import portscanner import sys @db_session def get_domains(): hostlist = [] domains = select(d for d in Domain if d.is_up == True and d.portscanned_at == NEVER) for domain in domains: hostlist.append(domain.host) return list(set(hostlist)) hostlist = get_domains() p = portscanner.PortScanner(hostlist) sys.exit(0)
def __init__(self): #Criando a janela gráfica e suas diretrizes self.window = tk.Tk() self.window.title('Port Scanner') self.window.geometry("690x700+600+55") # Criando as linhas e colunas do jogo self.window.rowconfigure(0, minsize=20, weight=1) self.window.rowconfigure(1, minsize=90, weight=1) self.window.rowconfigure(2, minsize=90, weight=1) self.window.rowconfigure(3, minsize=90, weight=1) self.window.rowconfigure(4, minsize=90, weight=1) self.window.rowconfigure(5, minsize=90, weight=1) self.window.rowconfigure(6, minsize=200, weight=1) self.window.rowconfigure(7, minsize=20, weight=1) self.window.columnconfigure(0, minsize=20, weight=1) self.window.columnconfigure(1, minsize=100, weight=1) self.window.columnconfigure(2, minsize=100, weight=1) self.window.columnconfigure(3, minsize=20, weight=1) self.window.resizable(width=False, height=False) # Rede ## Label rede = tk.Label(self.window) rede.configure(text = "IP:") rede.grid(row=1, column=1, sticky='ew') ## Escrita exemplo_rede = tk.StringVar() exemplo_rede.set('192.168.50.93') self.entrada_rede = tk.Entry(self.window, textvariable = exemplo_rede) self.entrada_rede.grid(row=1, column=2, sticky="ew") # TCP/UDP self.tcp_value = tk.IntVar() self.tcp_box = tk.Checkbutton(self.window, text='TCP', onvalue = 1, offvalue = 0, variable=self.tcp_value) self.tcp_box.grid(row=2,column=1) self.tcp_box.select() self.udp_value = tk.IntVar() self.udp_box = tk.Checkbutton(self.window, text='UDP', onvalue = 1, offvalue = 0, variable=self.udp_value) self.udp_box.grid(row=2,column=2) # Portas ## Label ports = tk.Label(self.window) ports.configure(text = "Portas:") ports.grid(row=3, column=1, sticky='ew') ## Escrita exemplo_port = tk.StringVar() exemplo_port.set('0-65535') self.entrada_portas = tk.Entry(self.window, textvariable = exemplo_port) self.entrada_portas.grid(row=3, column=2, sticky="ew") self.entrada_portas.bind('<Return>',self.scaner_host) #Botoes self.scanhost = tk.Button(self.window, text="Escanear host") self.scanhost.grid(row=4,column=1, sticky='nsew', columnspan=1) self.scanhost.bind('<1>',self.scaner_host) self.scannet = tk.Button(self.window, text="Escanear rede") self.scannet.grid(row=4,column=2, sticky='nsew') self.scannet.bind('<1>',self.scaner_network) #Saida self.resposta = tkst.ScrolledText(self.window, wrap='word') self.resposta.grid(row=5, column=1, sticky='nsew', rowspan=2, columnspan=2) self.resposta.configure(font='Bodoni 10', bg='white') self.ps = ps.PortScanner() self.servico = {} with open("portas_servicos.json") as json_file: data = json.load(json_file) for p in data: self.servico[p] = data[p]
import portscanner targets_ip = input("[*] Enter the target for vuln scan : ") port_num = int(input("[*] Enter the range of ports : ")) vuln_file = input("[*] Enter the path of the files with vulnerable softwares(txt file) : ") print('\n') target = portscanner.PortScanner(targets_ip, port_num) target.scan() with open(vuln_file, 'r') as file: count = 0 for banner in target.banners: file.seek(0) for line in file.readline(): if line.strip() in banner: print('[!] VULNERABLE BANNER: "' + banner + '" ON PORT:' + str(target.openports)) count += 1
#!/usr/bin/env python import portscanner import subprocess import sys import socket from datetime import datetime ps = portscanner.PortScanner() # Clear the console subprocess.call('clear', shell=True) # Input IPs and ports to scan greeting = ( "-" * 60 + "\n" + "Welcome to the Port Scanner!\n" + "-" * 60 + "\n" + "Please, follow this input format: [IP1 - IP2], [IP/mask], [IP]...\n" + "Type 'quit' for exit") print(greeting) program_running = True while program_running: try: ip_string = input( "Enter range of ip intervals(remote host names): ").strip() if ip_string == 'quit': program_running = False break ip_range = list(ps.get_ip_range(ip_string))