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.config import ExperimentConfig
from app.interface_sfx import CommandlineColors
from app.exceptions import ServerError
from app.pluginmanager import PluginManager
from caldera_control import CalderaControl
from machine_control import Machine
from app.exceptions import ServerError
from plugins.base.attack import AttackPlugin
from app.pluginmanager import PluginManager
# TODO: Multi threading at least when starting machines

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

@ -59,7 +59,7 @@ if __name__ == "__main__":
# TODO get meterpreter session
# 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)
print(metasploit.meterpreter_execute(["getuid"], 0))
# client = MsfRpcClient('yourpassword', ssl=True)

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

@ -41,12 +41,12 @@ class BasePlugin():
""" Set the attack logger for this machine """
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' """
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 """
return
@ -71,7 +71,7 @@ class BasePlugin():
self.machine_plugin = machine_plugin
def set_sysconf(self, config):
def set_sysconf(self, config): # pylint:disable=unused-argument
""" Set system config
@param config: A dict with system configuration relevant for all plugins
@ -104,7 +104,7 @@ class BasePlugin():
""" Get a file from the machine """
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
@param command: Command to execute
@ -137,7 +137,7 @@ class BasePlugin():
for i in self.alternative_names:
res.add(i)
if len(res):
if len(res) > 0:
return list(res)
raise NotImplementedError
@ -190,7 +190,7 @@ class BasePlugin():
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 """
app_dir = os.path.dirname(app.exceptions.__file__)

Loading…
Cancel
Save