added new command for configure more easily than dhcp server

This commit is contained in:
mh4x0f 2022-02-20 19:34:52 -03:00
parent dc9ea50346
commit 0208df007c
9 changed files with 140 additions and 28 deletions

View File

@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- added improves wifideauth module for support multi targets
- added improves ConsoleUi and added help for command add, rm from wifideauth module
- added hostapd configuration file from wifipumpkin3 console
- added new command `dhcp conf` for configure more easily than dhcp server
### Changed
@ -17,6 +18,7 @@ All notable changes to this project will be documented in this file.
### Removed
### Fixed
- fixed set command for settings sniffkin3, pumpkinproxy, security
## [Released]

View File

@ -0,0 +1,8 @@
set dhcpconf:
Usage: dhcpconf [id]
param id: ID of DHCP configuration option
you can get the list using only `dhcpconf` command
Description:
select a config for configure DHCP Server

View File

@ -91,6 +91,7 @@ class PumpkinShell(Qt.QObject, ConsoleUI):
"parser_set_mode": self.wireless_controller.Settings,
"parser_set_security": self.wireless_controller.Settings,
"parser_set_hostapd_config": self.wireless_controller.Settings,
"parser_set_dhcpconf": self.wireless_controller.Settings,
}
self.parser_autcomplete_func = {}
@ -105,6 +106,9 @@ class PumpkinShell(Qt.QObject, ConsoleUI):
self.parser_autcomplete_func[
"parser_set_hostapd_config"
] = self.wireless_controller.Settings.getCommandsHostapd
self.parser_autcomplete_func[
"parser_set_dhcpconf"
] = self.wireless_controller.Settings.getCommandsDhcpConf
self.commands = {
"interface": "interface",
@ -114,6 +118,7 @@ class PumpkinShell(Qt.QObject, ConsoleUI):
"proxy": None, # only for settings proxy
"plugin": None, # only for settings plugin
"mode": None, # only for settings mdoe
"dhcpconf": None, # only for settings dhcpconf
"security": "enable_security",
"hostapd_config": "enable_hostapd_config",
}
@ -309,10 +314,6 @@ class PumpkinShell(Qt.QObject, ConsoleUI):
"""ap: show all connected clients on AP """
self.uiwid_controller.ui_table_mod.start()
def do_dhcp(self, args):
"""ap: choise dhcp server configuration"""
self.uiwid_controller.ui_dhcp_config.start()
def do_stop(self, args):
"""ap: stop access point service"""
self.killThreads()

View File

@ -5,7 +5,6 @@ from grp import getgrnam
from PyQt5 import QtCore, Qt
from logging import getLogger, ERROR
import wifipumpkin3.core.utility.constants as C
from wifipumpkin3.core.utility.collection import SettingsINI
from wifipumpkin3.core.utility.collection import SettingsINI as SuperSettings
from collections import OrderedDict
from functools import partial
@ -69,6 +68,9 @@ __all__ = [
"deleteObject",
"os",
"sys",
"display_messages",
"display_tabulate",
"setcolor",
"exec_bash",
"LoggerManager",
"StandardLog",

View File

@ -147,19 +147,37 @@ class AccessPointSettings(CoreSettings):
list_commands.append("hostapd_config" + "." + command)
return list_commands
@property
def getCommandsDhcpConf(self):
commands_host = self.conf.get_all_childname("dhcp")
list_commands = []
for command in commands_host:
list_commands.append("dhcpconf" + "." + command)
return list_commands
def parser_set_security(self, value, settings):
try:
# key = security.wpa_sharedkey
name, key = settings.split(".")[0], settings.split(".")[1]
# settings = security.wpa_algorithms TKI
name, key = settings.split(".")[0], settings.split(".")[1].split()[0]
if key in self.conf.get_all_childname("accesspoint"):
return self.conf.set("accesspoint", key, value)
print(display_messages("unknown flag: {}".format(key), error=True))
except IndexError:
print(display_messages("unknown sintax command", error=True))
def parser_set_dhcpconf(self, value, settings):
try:
# settings = settings.netmask 255.0.0.0
name, key = settings.split(".")[0], settings.split(".")[1].split()[0]
if key in self.conf.get_all_childname("dhcp"):
return self.conf.set("dhcp", key, value)
print(display_messages("unknown flag: {}".format(key), error=True))
except IndexError:
print(display_messages("unknown sintax command", error=True))
def parser_set_hostapd_config(self, value, settings):
try:
# key = hostapd_extra.logger_syslog 1
# settings = hostapd_extra.logger_syslog 1
name, key = settings.split(".")[0], settings.split(".")[1].split()[0]
return self.conf.set("hostapd_config", key, value)
except IndexError:

View File

@ -138,25 +138,19 @@ class Sniffkin3(MitmMode):
def parser_set_sniffkin3(self, status, plugin_name):
try:
# plugin_name = pumpkinproxy.no-cache
# plugin_name = sniffkin3.no-cache true
name_plugin, key_plugin = (
plugin_name.split(".")[0],
plugin_name.split(".")[1],
plugin_name.split(".")[1].split()[0],
)
if key_plugin in self.config.get_all_childname("plugins"):
self.config.set("plugins", key_plugin, status)
print(
display_messages(
"sniffkin3: {} status: {}".format(key_plugin, status),
sucess=True,
)
)
else:
print(
display_messages(
"unknown plugin: {}".format(key_plugin), error=True
)
return self.config.set("plugins", key_plugin, status)
print(
display_messages(
"unknown plugin: {}".format(key_plugin), error=True
)
)
except IndexError:
print(display_messages("unknown sintax command", error=True))

View File

@ -104,10 +104,10 @@ class PumpKinProxy(ProxyMode):
def parser_set_pumpkinproxy(self, status, plugin_name):
if len(plugin_name.split(".")) == 2:
try:
# plugin_name = pumpkinproxy.no-cache
# plugin_name = pumpkinproxy.beef true
name_plugin, key_plugin = (
plugin_name.split(".")[0],
plugin_name.split(".")[1],
plugin_name.split(".")[1].split()[0],
)
if key_plugin in self.config.get_all_childname("plugins"):
self.config.set("plugins", key_plugin, status)
@ -121,10 +121,10 @@ class PumpKinProxy(ProxyMode):
print(display_messages("unknown sintax command", error=True))
elif len(plugin_name.split(".")) == 3:
try:
# plugin_name = pumpkinproxy.beef.url_hook
# plugin_name = pumpkinproxy.beef.url_hook URL
name_plugin, key_plugin = (
plugin_name.split(".")[1],
plugin_name.split(".")[2],
plugin_name.split(".")[2].split()[0],
)
if key_plugin in self.config.get_all_childname(
"set_{}".format(name_plugin)

View File

@ -96,8 +96,8 @@ def setcolor(text, color="", underline=False):
return strcolored[color]
def display_tabulate(header=[], content=[], tablefmt="presto", newline=True):
print(tabulate(content, header, tablefmt=tablefmt))
def display_tabulate(header=[], content=[], tablefmt="presto", newline=True, **kwargs):
print(tabulate(content, header, tablefmt=tablefmt, **kwargs))
if newline:
print("\n")

View File

@ -0,0 +1,87 @@
from ast import arg
from wifipumpkin3.core.common.terminal import ExtensionUI
from wifipumpkin3.core.utility.printer import (
setcolor,
display_messages,
display_tabulate,
)
# This file is part of the wifipumpkin3 Open Source Project.
# wifipumpkin3 is licensed under the Apache 2.0.
# Copyright 2020 P0cL4bs Team - Marcos Bomfim (mh4x0f)
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Dhcpconf(ExtensionUI):
""" show/choise dhcp server configuration """
Name = "dhcpconf"
def __init__(self, parse_args=None, root=None):
self.parse_args = parse_args
self.root = root
self.register_command("do_dhcpconf", self.do_dhcpconf)
self.register_command("help_dhcpconf", self.help_dhcpconf)
self.ip_class = ["Class-A-Address","Class-B-Address", "Class-C-Address"]
super(Dhcpconf, self).__init__(parse_args=self.parse_args, root=self.root)
def help_dhcpconf(self):
self.show_help_command("help_dhcpconf_command")
def do_dhcpconf(self, args):
"""ap: show/choise dhcp server configuration """
status_ap = self.root.conf.get("accesspoint", "status_ap", format=bool)
if args:
try:
id_dhcp_option = int(args.split()[0])
selected_id_option = self.ip_class[id_dhcp_option]
for key in self.root.conf.get_all_childname(selected_id_option):
self.root.conf.set("dhcp", key,self.root.conf.get(selected_id_option, key))
if status_ap:
print(display_messages("OBS: this settings require restart the AP",error=True))
return
except Exception:
return print(
display_messages(
"the parameter id {} was not found.".format(
setcolor(args, color="orange")
),
error=True,
)
)
headers_table, output_table = (
["Id","Class", "IP address range", "Netmask" , "Router"],
[],
)
print(display_messages("DHCP Server Option:", info=True, sublime=True))
for ip_class in self.ip_class:
output_table.append(
[
self.ip_class.index(ip_class),
ip_class.split("-")[1],
self.root.conf.get(ip_class,"range"),
self.root.conf.get(ip_class, "netmask"),
self.root.conf.get(ip_class, "router"),
])
display_tabulate(headers_table, output_table, tablefmt="presto", newline=False)
print(display_messages("DHCP Server Settings:", info=True, sublime=True))
for config in self.root.conf.get_all_childname("dhcp"):
print(
" {}={}".format(setcolor(config, color="purple"), self.root.conf.get("dhcp", config))
)
print("\n")