against_modern_football Posted September 5, 2011 Report Posted September 5, 2011 (edited) Am facut un "port-scanner" cu threaduuri in Python. Daca aveti timp si chef sa va dati cu parerea mi-ar fi de mare ajutor.import socketimport threadingimport sysimport stringimport osclass ThreadingScan(threading.Thread): def __init__(self, target): threading.Thread.__init__(self) self.target=target def run(self): ping_parameter='ping '+self.target result=os.popen(ping_parameter) if (result): with open('log.txt', 'a', encoding='utf-8') as log_file: log_string=self.target+ ' is alive \n' log_file.write(log_string) print(self.target, ' is alive\n') port_scan=ThreadingPortScan(self.target) port_scan.start()class ThreadingPortScan(threading.Thread): def __init__(self, port_target): threading.Thread.__init__(self) self.port_target=port_target def run(self): target_ip=socket.gethostbyname(self.port_target) print(target_ip) print('starting port scanning') for i in range(1024): target_sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM) result=target_sock.connect_ex((target_ip, i)) if (result==0): ##log_file=open('log.txt', 'a', encoding='utf-8') log_string=self.port_target+' has port '+ str(i)+ ' opened \n' print(log_string) #log_file.write(log_string) #log_file.close() target_sock.close()if __name__=='__main__': with open('host_file.txt', 'r', encoding='utf-8') as host_file: hosts=host_file.read() host_list=str.split(hosts) for i in range(len(host_list)): scanning=ThreadingScan(host_list[i]) scanning.start()Later edit: aveti nevoie de un fisier host_file.txt in care sa fie hosturile pe care vreti sa le scanati Edited September 5, 2011 by against_modern_football 1 Quote
Xakepatop Posted September 5, 2011 Report Posted September 5, 2011 Complimente pentru initiativa, il voi incerca. Quote