def payloads(self): """Load the payloads from the specified file""" if not self.PAYLOADS_FILE: return [] payloads = [] config_reader = ConfigParser(interpolation=None) config_reader.read_file( open(path_join(self.DATA_DIR, self.PAYLOADS_FILE))) # No time based payloads here so we don't care yet reader = PayloadReader(self.options) for section in config_reader.sections(): clean_payload, flags = reader.process_line( config_reader[section]["payload"]) clean_payload = clean_payload.replace("[SESSION_ID]", self._session_id) rules = config_reader[section]["rules"].splitlines() self.payload_to_rules[section] = rules payloads.append((clean_payload, flags.with_section(section))) return payloads
def payloads(self): """Load the payloads from the specified file""" if not self.PAYLOADS_FILE: return [] payloads = [] config_reader = ConfigParser(interpolation=None) config_reader.read_file( open(path_join(self.CONFIG_DIR, self.PAYLOADS_FILE))) # No time based payloads here so we don't care yet reader = PayloadReader(self.options) for section in config_reader.sections(): clean_payload, original_flags = reader.process_line( config_reader[section]["payload"]) flags = original_flags.with_section(section) rules = config_reader[section]["rules"].splitlines() messages = [ _(message) for message in config_reader[section]["messages"].splitlines() ] self.payload_to_rules[section] = rules self.rules_to_messages.update(dict(zip(rules, messages))) payloads.append((clean_payload, flags)) return payloads
def test_payload_reader(): reader = PayloadReader({ "timeout": 5, "external_endpoint": "http://perdu.com/" }) payload, flags = reader.process_line( "[TAB]\\0[EXTERNAL_ENDPOINT][LF][TIME][TIMEOUT] \n ") assert payload == "\t\0http://perdu.com/\n6" assert flags.payload_type == PayloadType.time