@ -18,7 +18,11 @@ class TestMachineConfig(unittest.TestCase):
""" The init is empty """
""" The init is empty """
al = AttackLog ( )
al = AttackLog ( )
self . assertIsNotNone ( al )
self . assertIsNotNone ( al )
self . assertEqual ( al . get_dict ( ) , [ ] )
default = { " boilerplate " : { ' log_format_major_version ' : 1 , ' log_format_minor_version ' : 1 } ,
" system_overview " : [ ] ,
" attack_log " : [ ] }
self . assertEqual ( al . get_dict ( ) , default )
def test_caldera_attack_start ( self ) :
def test_caldera_attack_start ( self ) :
""" Starting a caldera attack """
""" Starting a caldera attack """
@ -39,16 +43,16 @@ class TestMachineConfig(unittest.TestCase):
description = description
description = description
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " caldera " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " caldera " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target_paw " ] , paw )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target_paw " ] , paw )
self . assertEqual ( data [ 0 ] [ " target_group " ] , group )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target_group " ] , group )
self . assertEqual ( data [ 0 ] [ " ability_id " ] , ability_id )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " ability_id " ] , ability_id )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ 0 ] [ " name " ] , name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " name " ] , name )
self . assertEqual ( data [ 0 ] [ " description " ] , description )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " description " ] , description )
def test_caldera_attack_stop ( self ) :
def test_caldera_attack_stop ( self ) :
""" Stopping a caldera attack """
""" Stopping a caldera attack """
@ -69,16 +73,16 @@ class TestMachineConfig(unittest.TestCase):
description = description
description = description
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " caldera " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " caldera " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target_paw " ] , paw )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target_paw " ] , paw )
self . assertEqual ( data [ 0 ] [ " target_group " ] , group )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target_group " ] , group )
self . assertEqual ( data [ 0 ] [ " ability_id " ] , ability_id )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " ability_id " ] , ability_id )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ 0 ] [ " name " ] , name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " name " ] , name )
self . assertEqual ( data [ 0 ] [ " description " ] , description )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " description " ] , description )
def test_kali_attack_start ( self ) :
def test_kali_attack_start ( self ) :
""" Starting a kali attack """
""" Starting a kali attack """
@ -93,13 +97,13 @@ class TestMachineConfig(unittest.TestCase):
ttp = ttp ,
ttp = ttp ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " kali " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " kali " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " kali_name " ] , attack_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " kali_name " ] , attack_name )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
def test_kali_attack_stop ( self ) :
def test_kali_attack_stop ( self ) :
""" Stopping a kali attack """
""" Stopping a kali attack """
@ -114,13 +118,107 @@ class TestMachineConfig(unittest.TestCase):
ttp = ttp ,
ttp = ttp ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " kali " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " kali " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " kali_name " ] , attack_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " kali_name " ] , attack_name )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
def test_narration_start ( self ) :
""" Starting a narration """
al = AttackLog ( )
text = " texttextext "
al . start_narration ( text
)
data = al . get_dict ( )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " narration " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " user defined narration " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " text " ] , text )
def test_build_start ( self ) :
""" Starting a build """
al = AttackLog ( )
dl_uri = " asource "
dl_uris = " a target "
payload = " 1234 "
platform = " a name "
architecture = " arch "
lhost = " lhost "
lport = 8080
filename = " afilename "
encoding = " encoded "
encoded_filename = " ef "
sRDI_conversion = True
for_step = 4
comment = " this is a comment "
al . start_build ( dl_uri = dl_uri ,
dl_uris = dl_uris ,
payload = payload ,
platform = platform ,
architecture = architecture ,
lhost = lhost ,
lport = lport ,
filename = filename ,
encoding = encoding ,
encoded_filename = encoded_filename ,
sRDI_conversion = sRDI_conversion ,
for_step = for_step ,
comment = comment
)
data = al . get_dict ( )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " build " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " dl_uri " ] , dl_uri )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " dl_uris " ] , dl_uris )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " payload " ] , payload )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " platform " ] , platform )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " architecture " ] , architecture )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " lhost " ] , lhost )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " lport " ] , lport )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " filename " ] , filename )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " encoding " ] , encoding )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " encoded_filename " ] , encoded_filename )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sRDI_conversion " ] , sRDI_conversion )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " for_step " ] , for_step )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " comment " ] , comment )
def test_build_start_default ( self ) :
""" Starting a build default values """
al = AttackLog ( )
al . start_build ( )
data = al . get_dict ( )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " build " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " dl_uri " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " dl_uris " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " payload " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " platform " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " architecture " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " lhost " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " lport " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " filename " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " encoding " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " encoded_filename " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sRDI_conversion " ] , False )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " for_step " ] , None )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " comment " ] , None )
def test_build_stop ( self ) :
""" Stopping a build """
al = AttackLog ( )
logid = " lid "
al . stop_build ( logid = logid )
data = al . get_dict ( )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " build " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " logid " ] , logid )
def test_metasploit_attack_start ( self ) :
def test_metasploit_attack_start ( self ) :
""" Starting a metasploit attack """
""" Starting a metasploit attack """
@ -135,13 +233,13 @@ class TestMachineConfig(unittest.TestCase):
ttp = ttp ,
ttp = ttp ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " metasploit " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " metasploit " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " metasploit_command " ] , attack_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " metasploit_command " ] , attack_name )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
def test_metasploit_attack_stop ( self ) :
def test_metasploit_attack_stop ( self ) :
""" Stopping a metasploit attack """
""" Stopping a metasploit attack """
@ -156,13 +254,13 @@ class TestMachineConfig(unittest.TestCase):
ttp = ttp ,
ttp = ttp ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " metasploit " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " metasploit " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " metasploit_command " ] , attack_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " metasploit_command " ] , attack_name )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
def test_attack_plugin_start ( self ) :
def test_attack_plugin_start ( self ) :
""" Starting a attack plugin """
""" Starting a attack plugin """
@ -177,13 +275,13 @@ class TestMachineConfig(unittest.TestCase):
ttp = ttp ,
ttp = ttp ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " attack_plugin " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " attack_plugin " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " plugin_name " ] , attack_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " plugin_name " ] , attack_name )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
def test_attack_plugin_stop ( self ) :
def test_attack_plugin_stop ( self ) :
""" Stopping a attack plugin """
""" Stopping a attack plugin """
@ -198,13 +296,13 @@ class TestMachineConfig(unittest.TestCase):
ttp = ttp ,
ttp = ttp ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " attack " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " attack_plugin " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " attack_plugin " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " plugin_name " ] , attack_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " plugin_name " ] , attack_name )
self . assertEqual ( data [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " hunting_tag " ] , " MITRE_ " + ttp )
def test_file_write_start ( self ) :
def test_file_write_start ( self ) :
""" Starting a file write """
""" Starting a file write """
@ -217,12 +315,12 @@ class TestMachineConfig(unittest.TestCase):
file_name = file_name ,
file_name = file_name ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ 0 ] [ " type " ] , " dropping_file " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " dropping_file " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " file_name " ] , file_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " file_name " ] , file_name )
def test_file_write_stop ( self ) :
def test_file_write_stop ( self ) :
""" Stopping a file write """
""" Stopping a file write """
@ -235,12 +333,12 @@ class TestMachineConfig(unittest.TestCase):
file_name = file_name ,
file_name = file_name ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ 0 ] [ " type " ] , " dropping_file " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " dropping_file " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " file_name " ] , file_name )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " file_name " ] , file_name )
def test_execute_payload_start ( self ) :
def test_execute_payload_start ( self ) :
""" Starting a execute payload """
""" Starting a execute payload """
@ -253,12 +351,12 @@ class TestMachineConfig(unittest.TestCase):
command = command ,
command = command ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " start " )
self . assertEqual ( data [ 0 ] [ " type " ] , " execute_payload " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " execute_payload " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " command " ] , command )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " command " ] , command )
def test_execute_payload_stop ( self ) :
def test_execute_payload_stop ( self ) :
""" Stopping a execute payload """
""" Stopping a execute payload """
@ -271,12 +369,12 @@ class TestMachineConfig(unittest.TestCase):
command = command ,
command = command ,
)
)
data = al . get_dict ( )
data = al . get_dict ( )
self . assertEqual ( data [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " event " ] , " stop " )
self . assertEqual ( data [ 0 ] [ " type " ] , " execute_payload " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " type " ] , " execute_payload " )
self . assertEqual ( data [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " sub_type " ] , " by PurpleDome " )
self . assertEqual ( data [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " source " ] , source )
self . assertEqual ( data [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " target " ] , target )
self . assertEqual ( data [ 0 ] [ " command " ] , command )
self . assertEqual ( data [ " attack_log " ] [ 0 ] [ " command " ] , command )
def test_mitre_fix_ttp_is_none ( self ) :
def test_mitre_fix_ttp_is_none ( self ) :
""" Testing the mitre ttp fix for ttp being none """
""" Testing the mitre ttp fix for ttp being none """
@ -285,3 +383,64 @@ class TestMachineConfig(unittest.TestCase):
def test_mitre_fix_ttp_is_MITRE_SOMETHING ( self ) :
def test_mitre_fix_ttp_is_MITRE_SOMETHING ( self ) :
""" Testing the mitre ttp fix for ttp being MITRE_ """
""" Testing the mitre ttp fix for ttp being MITRE_ """
self . assertEqual ( app . attack_log . __mitre_fix_ttp__ ( " MITRE_FOO " ) , " MITRE_FOO " )
self . assertEqual ( app . attack_log . __mitre_fix_ttp__ ( " MITRE_FOO " ) , " MITRE_FOO " )
# tests for a bunch of default data covering caldera attacks. That way we will have some fallback if no data is submitted:
def test_get_caldera_default_name_missing ( self ) :
""" Testing getting the caldera default name """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_name ( " missing " ) , None )
def test_get_caldera_default_name ( self ) :
""" Testing getting the caldera default name """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_name ( " bd527b63-9f9e-46e0-9816-b8434d2b8989 " ) , " whoami " )
def test_get_caldera_default_description_missing ( self ) :
""" Testing getting the caldera default description """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_description ( " missing " ) , None )
def test_get_caldera_default_description ( self ) :
""" Testing getting the caldera default description """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_description ( " bd527b63-9f9e-46e0-9816-b8434d2b8989 " ) , " Obtain user from current session " )
def test_get_caldera_default_tactics_missing ( self ) :
""" Testing getting the caldera default tactics """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_tactics ( " missing " ) , None )
def test_get_caldera_default_tactics ( self ) :
""" Testing getting the caldera default tactics """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_tactics ( " bd527b63-9f9e-46e0-9816-b8434d2b8989 " ) , " System Owner/User Discovery " )
def test_get_caldera_default_tactics_id_missing ( self ) :
""" Testing getting the caldera default tactics_id """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_tactics_id ( " missing " ) , None )
def test_get_caldera_default_tactics_id ( self ) :
""" Testing getting the caldera default tactics_id """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_tactics_id ( " bd527b63-9f9e-46e0-9816-b8434d2b8989 " ) , " T1033 " )
def test_get_caldera_default_situation_description_missing ( self ) :
""" Testing getting the caldera default situation_description """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_situation_description ( " missing " ) , None )
def test_get_caldera_default_situation_description ( self ) :
""" Testing getting the caldera default situation_description """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_situation_description ( " bd527b63-9f9e-46e0-9816-b8434d2b8989 " ) , None )
def test_get_caldera_default_countermeasure_missing ( self ) :
""" Testing getting the caldera default countermeasure """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_countermeasure ( " missing " ) , None )
def test_get_caldera_default_countermeasure ( self ) :
""" Testing getting the caldera default countermeasure """
al = AttackLog ( )
self . assertEqual ( al . get_caldera_default_countermeasure ( " bd527b63-9f9e-46e0-9816-b8434d2b8989 " ) , None )