|
@@ -12,6 +12,7 @@ from Attack.AttackParameters import ParameterTypes
|
|
# from ID2TLib import PcapFile
|
|
# from ID2TLib import PcapFile
|
|
# from ID2TLib.PcapFile import PcapFile
|
|
# from ID2TLib.PcapFile import PcapFile
|
|
from ID2TLib.Ports import PortSelectors
|
|
from ID2TLib.Ports import PortSelectors
|
|
|
|
+import ID2TLib.Utility
|
|
|
|
|
|
class MessageType(Enum):
|
|
class MessageType(Enum):
|
|
"""
|
|
"""
|
|
@@ -158,15 +159,14 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
self.add_param_value(Param.BOTNET_DST_PORT_CALCULATION, True)
|
|
self.add_param_value(Param.BOTNET_DST_PORT_CALCULATION, True)
|
|
|
|
|
|
|
|
|
|
- def generate_attack_pcap(self, context):
|
|
|
|
|
|
+ def generate_attack_pcap(self):
|
|
"""
|
|
"""
|
|
Injects the packets of this attack into a PCAP and stores it as a temporary file.
|
|
Injects the packets of this attack into a PCAP and stores it as a temporary file.
|
|
- :param context: the context of the attack, containing e.g. files that are to be created
|
|
|
|
:return: a tuple of the number packets injected and the path to the temporary attack PCAP
|
|
:return: a tuple of the number packets injected and the path to the temporary attack PCAP
|
|
"""
|
|
"""
|
|
|
|
|
|
# create the final messages that have to be sent, including all bot configurations
|
|
# create the final messages that have to be sent, including all bot configurations
|
|
- messages = self._create_messages(context)
|
|
|
|
|
|
+ messages = self._create_messages()
|
|
|
|
|
|
if messages == []:
|
|
if messages == []:
|
|
return 0, []
|
|
return 0, []
|
|
@@ -252,7 +252,8 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
last_packet = packets[-1]
|
|
last_packet = packets[-1]
|
|
|
|
|
|
# write the mapping to a file
|
|
# write the mapping to a file
|
|
- msg_packet_mapping.write_to(context.allocate_file("_mapping.xml"))
|
|
|
|
|
|
+ dest_without_ext = os.path.splitext(ID2TLib.Utility.PCAP_DEST_PATH)[0]
|
|
|
|
+ msg_packet_mapping.write_to(dest_without_ext + "_mapping.xml")
|
|
|
|
|
|
# Store timestamp of last packet
|
|
# Store timestamp of last packet
|
|
self.attack_end_utime = last_packet.time
|
|
self.attack_end_utime = last_packet.time
|
|
@@ -264,10 +265,9 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
def generate_attack_packets(self):
|
|
def generate_attack_packets(self):
|
|
pass
|
|
pass
|
|
|
|
|
|
- def _create_messages(self, context):
|
|
|
|
|
|
+ def _create_messages(self):
|
|
"""
|
|
"""
|
|
Creates the messages that are to be injected into the PCAP.
|
|
Creates the messages that are to be injected into the PCAP.
|
|
- :param context: the context of the attack, containing e.g. files that are to be created
|
|
|
|
:return: the final messages as a list
|
|
:return: the final messages as a list
|
|
"""
|
|
"""
|
|
|
|
|
|
@@ -459,14 +459,13 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
:return: the new filepath to the XML file
|
|
:return: the new filepath to the XML file
|
|
"""
|
|
"""
|
|
|
|
|
|
- pcap_dir = context.get_output_dir()
|
|
|
|
|
|
+ pcap_dir = os.path.dirname(ID2TLib.Utility.PCAP_DEST_PATH)
|
|
xml_name = os.path.basename(filepath_xml)
|
|
xml_name = os.path.basename(filepath_xml)
|
|
if pcap_dir.endswith("/"):
|
|
if pcap_dir.endswith("/"):
|
|
new_xml_path = pcap_dir + xml_name
|
|
new_xml_path = pcap_dir + xml_name
|
|
else:
|
|
else:
|
|
new_xml_path = pcap_dir + "/" + xml_name
|
|
new_xml_path = pcap_dir + "/" + xml_name
|
|
os.rename(filepath_xml, new_xml_path)
|
|
os.rename(filepath_xml, new_xml_path)
|
|
- context.add_other_created_file(new_xml_path)
|
|
|
|
return new_xml_path
|
|
return new_xml_path
|
|
|
|
|
|
# parse input CSV or XML
|
|
# parse input CSV or XML
|