def test_handle_multiline_command_shell_ifthen(self): commands = '\n'.join([ 'if condition; then', '# comment', ' # comment', 'innercommand;', 'innercommand2;', 'fi' ]) want = 'if condition; then innercommand; innercommand2; fi' assert AtomicService._handle_multiline_commands(commands, 'sh') == want
def test_handle_multiline_command_shell_loop(self): commands = '\n'.join([ 'for port in {1..65535};', '# comment', ' # comment', 'do ', 'innerloopcommand;', 'innerloopcommand2', 'done' ]) want = 'for port in {1..65535}; do innerloopcommand; innerloopcommand2; done' assert AtomicService._handle_multiline_commands(commands, 'sh') == want
def test_handle_multiline_command_shell_semicolon(self): commands = '\n'.join([ 'command1', '# comment', ' # comment', 'command2; ', 'command3 ;', 'command4;;', 'command5' ]) want = 'command1; command2; command3 ; command4;; command5' assert AtomicService._handle_multiline_commands(commands, 'sh') == want
async def enable(services): atomic_gui = AtomicGUI(services, name, description) app = services.get('app_svc').application app.router.add_route('GET', '/plugin/atomic/gui', atomic_gui.splash) # we only ingest data once, and save new abilities in the data/ folder of the plugin if "abilities" not in os.listdir(data_dir): atomic_svc = AtomicService() await atomic_svc.clone_atomic_red_team_repo() await atomic_svc.populate_data_directory()
def test_handle_multiline_command_cmd_comments(self): commands = '\n'.join([ 'command1', 'REM this is a comment', ' rem this is another comment', 'command2', ' :: another comment', ':: another comment', ' @ REM another comment', 'command3', '@rem more comments' ]) want = 'command1 && command2 && command3' assert AtomicService._handle_multiline_commands(commands, 'cmd') == want
def test_handle_multiline_command_shell_comments(self): commands = '\n'.join([ 'command1', '# comment', ' # comment', 'command2', ';# comment', '; # comment', 'echo thisis#notacomment', 'echo thisis;#a comment', 'command3 # trailing comment', 'command4;#trailing comment', 'command5; #trailing comment', 'echo "this is # not a comment" # but this is', 'echo "\'" can you \'"\' handle "complex # quotes" # but still find the comment; #? ##', ]) want = 'command1; command2; echo thisis#notacomment; echo thisis; command3; command4; command5; ' \ 'echo "this is # not a comment"; echo "\'" can you \'"\' handle "complex # quotes"' assert AtomicService._handle_multiline_commands(commands, 'sh') == want
def test_handle_multiline_command_powershell_comments(self): commands = '\n'.join([ 'command1', '# comment', ' # comment', 'command2', ';# comment', '; # comment', 'echo thisis#notacomment', 'echo thisis;#a comment', 'command3 # trailing comment', 'command4;#trailing comment', 'command5; #trailing comment', 'echo "this is # not a comment" # but this is', 'echo "\'" can you \'"\' han`"dle "complex # quotes" # but still find the comment; #? ##', 'echo `"this is not actually a quote # so this comment should be removed `"', ]) want = 'command1; command2; echo thisis#notacomment; echo thisis; command3; command4; command5; ' \ 'echo "this is # not a comment"; echo "\'" can you \'"\' han`"dle "complex # quotes"; ' \ 'echo `"this is not actually a quote' assert AtomicService._handle_multiline_commands(commands, 'psh') == want
async def enable(services): # we only ingest data once, and save new abilities in the data/ folder of the plugin if "abilities" not in os.listdir(data_dir): atomic_svc = AtomicService() await atomic_svc.clone_atomic_red_team_repo() await atomic_svc.populate_data_directory()
def test_handle_multiline_command_cmd(self, multiline_command): target = 'command1 && command2 && command3' assert AtomicService._handle_multiline_commands( multiline_command, 'cmd') == target
def test_handle_multiline_command_sh(self, multiline_command): target = 'command1; command2; command3' assert AtomicService._handle_multiline_commands( multiline_command, 'sh') == target
def test_normalize_posix_path(self): assert AtomicService._normalize_path('linux/test/path', 'linux') == 'linux/test/path'
def test_normalize_windows_path(self): assert AtomicService._normalize_path('windows\\test\\path', 'windows') == 'windows/test/path'
def atomic_svc(): return AtomicService()