def build_socket(my_ip=functions.get_ip(), my_port=constants.SENDER_PORT): server_socket = socket.socket() ip = my_ip port = my_port server_socket.bind((ip, port)) server_socket.listen() return server_socket
def show_network(): # (3) Show Network information global lcddata ip_address = functions.get_ip() ip_string = "ip address:" lcddata = [0, 0, ip_string], [1, 0, ip_address] return lcddata
def valide(self, evenement): if self.combo.GetValue() == "TCP": nbr = int(self.sld.GetValue()) port = int(self.spinctrl.GetValue()) target = self.text.GetValue() if functions.tcp_attack(target, port, nbr) == 0: self.label.SetLabel("Done, %i packets sent" % nbr) else: self.label.SetLabel("Error running the script.\nDid you run the script as root ?") if self.combo.GetValue() == "My ip": ip = functions.get_ip() self.label.SetLabel("External IP: %s" % (ip)) if self.combo.GetValue() == "whoami": user = functions.get_username() self.label.SetLabel(user) if self.combo.GetValue() == "ping": if current_os in os1: arg="-c" if current_os in os3: arg="-n" nbr = self.sld.GetValue() host = self.text.GetValue() out = functions.ping(host, arg, nbr) history_write("ping %s " % host) self.label.SetLabel(out) if self.combo.GetValue() == "history": self.label.SetLabel(functions.history_read) if self.combo.GetValue() == "del history": history = open('history.log', 'w') history.write("") history.close() self.label.SetLabel("History deleted") if self.combo.GetValue() == "42": self.label.SetLabel("The answer to life the universe and everything")
def __init__(self, thread_id, name, port, public_key, private_key, sender=False, even=None, app_gui=None, quit_event=None): threading.Thread.__init__(self) self.thread_id = thread_id self.name = name self.ip = functions.get_ip() self.port = port self.server_socket = server.build_socket(my_ip=self.ip, my_port=self.port) self.sender = sender self.public_key = public_key self.private_key = private_key self.event = even self.app = app_gui self.quit_event = quit_event
import os from functions import get_ip, scanner import threading my_ip = get_ip() network = my_ip[:my_ip.rfind(".") + 1] clients = [] threads = [] lock = threading.Lock() for item in range(1, 255): test = network + str(item) t = threading.Thread(target=scanner, args=( test, clients, lock, )) t.start() threads.append(t) for thread in threads: thread.join() print(clients)