From 5328f08f0c7e6d9bb0d43f124522213502cff20c Mon Sep 17 00:00:00 2001 From: mh4x0f Date: Mon, 23 Oct 2023 19:21:39 -0300 Subject: [PATCH] fixed: command set dhcpmode console ref. --- wifipumpkin3/core/common/console.py | 2 +- wifipumpkin3/core/servers/dhcp/dhcp.py | 35 ++++++++++++++++++++ wifipumpkin3/core/servers/dns/pyDNSServer.py | 35 +------------------- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/wifipumpkin3/core/common/console.py b/wifipumpkin3/core/common/console.py index 2b2fe0bd..899bf520 100644 --- a/wifipumpkin3/core/common/console.py +++ b/wifipumpkin3/core/common/console.py @@ -95,7 +95,7 @@ def initialize_core(self): "parser_set_security": self.wireless_controller.Settings, "parser_set_hostapd_config": self.wireless_controller.Settings, "parser_set_dhcpconf": self.wireless_controller.Settings, - "parser_set_dhcpmode": self.dns_controller.Active, + "parser_set_dhcpmode": self.dhcp_controller.Active, } self.parser_autcomplete_func = {} diff --git a/wifipumpkin3/core/servers/dhcp/dhcp.py b/wifipumpkin3/core/servers/dhcp/dhcp.py index b1faa32f..59683261 100644 --- a/wifipumpkin3/core/servers/dhcp/dhcp.py +++ b/wifipumpkin3/core/servers/dhcp/dhcp.py @@ -127,6 +127,41 @@ def removeInactivityClient(self, mac: str): def getStaClients(self): return self._connected + def parser_set_dhcpmode(self, status, command): + if len(command.split(".")) == 2: + try: + # command = dhcpmode.pydns_verbose true + dhcpmode, key_setting = ( + command.split(".")[0], + command.split(".")[1].split()[0], + ) + if key_setting in self.conf.get_all_childname("accesspoint"): + self.conf.set("accesspoint", key_setting, status) + else: + print( + display_messages( + "unknown setting: {}".format(key_setting), error=True + ) + ) + except IndexError: + print(display_messages("unknown sintax command", error=True)) + else: + try: + id_dhcp = command.split()[1] + if not id_dhcp in self.parent.dhcp_controller.getInfo().keys(): + print( + display_messages( + "the parameter id {} was not found.".format( + setcolor(id_dhcp, color="red") + ), + error=True, + ) + ) + return + self.parent.dhcp_controller.setDhcpMode(id_dhcp) + except IndexError: + print(display_messages("unknown sintax command", error=True)) + class DHCPSettings(CoreSettings): Name = "WP DHCP" ID = "DHCP" diff --git a/wifipumpkin3/core/servers/dns/pyDNSServer.py b/wifipumpkin3/core/servers/dns/pyDNSServer.py index 2c25be7b..f2644d59 100644 --- a/wifipumpkin3/core/servers/dns/pyDNSServer.py +++ b/wifipumpkin3/core/servers/dns/pyDNSServer.py @@ -49,37 +49,4 @@ def boot(self): self.reactor.sendRequests.connect(self.LogOutput) self.reactor.setObjectName(self.ID) - def parser_set_dhcpmode(self, status, command): - if len(command.split(".")) == 2: - try: - # command = dhcpmode.pydns_verbose true - dhcpmode, key_setting = ( - command.split(".")[0], - command.split(".")[1].split()[0], - ) - if key_setting in self.conf.get_all_childname("accesspoint"): - self.conf.set("accesspoint", key_setting, status) - else: - print( - display_messages( - "unknown setting: {}".format(key_setting), error=True - ) - ) - except IndexError: - print(display_messages("unknown sintax command", error=True)) - else: - try: - id_dhcp = command.split()[1] - if not id_dhcp in self.root.dhcp_controller.getInfo().keys(): - print( - display_messages( - "the parameter id {} was not found.".format( - setcolor(id_dhcp, color="red") - ), - error=True, - ) - ) - return - self.root.dhcp_controller.setDhcpMode(id_dhcp) - except IndexError: - print(display_messages("unknown sintax command", error=True)) +