pylinting round 4

pull/10/head
Thorsten Sick 3 years ago
parent 12a481da70
commit 2b6e2a4586

@ -11,11 +11,11 @@ from datetime import datetime
from app.attack_log import AttackLog from app.attack_log import AttackLog
from app.config import ExperimentConfig from app.config import ExperimentConfig
from app.interface_sfx import CommandlineColors from app.interface_sfx import CommandlineColors
from app.exceptions import ServerError
from app.pluginmanager import PluginManager
from caldera_control import CalderaControl from caldera_control import CalderaControl
from machine_control import Machine from machine_control import Machine
from app.exceptions import ServerError
from plugins.base.attack import AttackPlugin from plugins.base.attack import AttackPlugin
from app.pluginmanager import PluginManager
# TODO: Multi threading at least when starting machines # TODO: Multi threading at least when starting machines

@ -167,14 +167,13 @@ class PluginManager():
# Deep checks # Deep checks
result = self.check(plugin) results = self.check(plugin)
for r in result: if len(results) > 0:
print(f"* Issue: {r}") for result in results:
if len(result): print(f"* Issue: {result}")
for r in result: issues.append(result)
issues.append(r) self.attack_logger.vprint(f"{CommandlineColors.BACKGROUND_RED}{result}{CommandlineColors.ENDC}", 1)
self.attack_logger.vprint(f"{CommandlineColors.BACKGROUND_RED}{r}{CommandlineColors.ENDC}", 1)
return issues return issues
# TODO: Add verify command to verify all plugins (or a specific one) # TODO: Add verify command to verify all plugins (or a specific one)

@ -59,7 +59,7 @@ if __name__ == "__main__":
# TODO get meterpreter session # TODO get meterpreter session
# TODO simple command to test # TODO simple command to test
metasploit = Metasploit(PASSWORD, attacker=attacker, username=USER) metasploit = Metasploit(PASSWORD, attack_logger=attack_logger, attacker=attacker, username=USER)
metasploit.start_exploit_stub_for_external_payload(payload=PAYLOAD_TYPE) metasploit.start_exploit_stub_for_external_payload(payload=PAYLOAD_TYPE)
print(metasploit.meterpreter_execute(["getuid"], 0)) print(metasploit.meterpreter_execute(["getuid"], 0))
# client = MsfRpcClient('yourpassword', ssl=True) # client = MsfRpcClient('yourpassword', ssl=True)

@ -1,11 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" Base class for Kali plugins """ """ Base class for Kali plugins """
import os
from plugins.base.plugin_base import BasePlugin from plugins.base.plugin_base import BasePlugin
from app.exceptions import PluginError, ConfigurationError from app.exceptions import PluginError, ConfigurationError
from app.calderacontrol import CalderaControl from app.calderacontrol import CalderaControl
# from app.metasploit import MSFVenom, Metasploit # from app.metasploit import MSFVenom, Metasploit
import os
class AttackPlugin(BasePlugin): class AttackPlugin(BasePlugin):
@ -50,7 +50,7 @@ class AttackPlugin(BasePlugin):
""" Cleanup afterwards """ """ Cleanup afterwards """
pass # pylint: disable=unnecessary-pass pass # pylint: disable=unnecessary-pass
def attacker_run_cmd(self, command, warn=True, disown=False): def attacker_run_cmd(self, command, disown=False):
""" Execute a command on the attacker """ Execute a command on the attacker
@param command: Command to execute @param command: Command to execute
@ -65,7 +65,7 @@ class AttackPlugin(BasePlugin):
res = self.attacker_machine_plugin.__call_remote_run__(command, disown=disown) res = self.attacker_machine_plugin.__call_remote_run__(command, disown=disown)
return res return res
def targets_run_cmd(self, command, warn=True, disown=False): def targets_run_cmd(self, command, disown=False):
""" Execute a command on the target """ Execute a command on the target
@param command: Command to execute @param command: Command to execute
@ -136,7 +136,7 @@ class AttackPlugin(BasePlugin):
""" """
raise NotImplementedError raise NotImplementedError
def install(self): def install(self): # pylint: disable=no-self-use
""" Install and setup requirements for the attack """ Install and setup requirements for the attack
""" """
@ -179,12 +179,12 @@ class AttackPlugin(BasePlugin):
@returns: the machine @returns: the machine
""" """
for t in self.targets: for target in self.targets:
if t.get_name() == name: if target.get_name() == name:
return t return target
for t in self.targets: for target in self.targets:
if name in t.get_nicknames(): if name in target.get_nicknames():
return t return target
raise ConfigurationError(f"No matching machine in experiment config for {name}") raise ConfigurationError(f"No matching machine in experiment config for {name}")

@ -41,12 +41,12 @@ class BasePlugin():
""" Set the attack logger for this machine """ """ Set the attack logger for this machine """
self.attack_logger = attack_logger self.attack_logger = attack_logger
def process_templates(self): def process_templates(self): # pylint: disable=no-self-use
""" A method you can optionally implement to transfer your jinja2 templates into the files yo want to send to the target. See 'required_files' """ """ A method you can optionally implement to transfer your jinja2 templates into the files yo want to send to the target. See 'required_files' """
return return
def copy_to_attacker_and_defender(self): def copy_to_attacker_and_defender(self): # pylint: disable=no-self-use
""" Copy attacker/defender specific files to the machines """ """ Copy attacker/defender specific files to the machines """
return return
@ -71,7 +71,7 @@ class BasePlugin():
self.machine_plugin = machine_plugin self.machine_plugin = machine_plugin
def set_sysconf(self, config): def set_sysconf(self, config): # pylint:disable=unused-argument
""" Set system config """ Set system config
@param config: A dict with system configuration relevant for all plugins @param config: A dict with system configuration relevant for all plugins
@ -104,7 +104,7 @@ class BasePlugin():
""" Get a file from the machine """ """ Get a file from the machine """
self.machine_plugin.get(src, dst) # nosec self.machine_plugin.get(src, dst) # nosec
def run_cmd(self, command, warn=True, disown=False): def run_cmd(self, command, disown=False):
""" Execute a command on the vm using the connection """ Execute a command on the vm using the connection
@param command: Command to execute @param command: Command to execute
@ -137,7 +137,7 @@ class BasePlugin():
for i in self.alternative_names: for i in self.alternative_names:
res.add(i) res.add(i)
if len(res): if len(res) > 0:
return list(res) return list(res)
raise NotImplementedError raise NotImplementedError
@ -190,7 +190,7 @@ class BasePlugin():
return self.get_name() return self.get_name()
def main_path(self): def main_path(self): # pylint:disable=no-self-use
""" Returns the main path of the Purple Dome installation """ """ Returns the main path of the Purple Dome installation """
app_dir = os.path.dirname(app.exceptions.__file__) app_dir = os.path.dirname(app.exceptions.__file__)

Loading…
Cancel
Save