) EncryptedTLMFrame = Struct("encrypted_data" / Array(12, Byte), "salt" / Int16ul, "mic" / Int16ul) EddystoneTLMFrame = Struct( "tlm_version" / Byte, "data" / Switch( lambda ctx: ctx.tlm_version, { EDDYSTONE_TLM_UNENCRYPTED: UnencryptedTLMFrame, EDDYSTONE_TLM_ENCRYPTED: EncryptedTLMFrame, })) EddystoneEIDFrame = Struct("tx_power" / Int8sl, "eid" / Array(8, Byte)) ServiceData = Struct( "service_identifier" / OneOf(Bytes(2), [EDDYSTONE_UUID, ESTIMOTE_UUID]), "frame_type" / Byte, "frame" / Switch( lambda ctx: ctx.service_identifier, { # eddystone frames EDDYSTONE_UUID: Switch( lambda ctx: ctx.frame_type, { EDDYSTONE_UID_FRAME: EddystoneUIDFrame, EDDYSTONE_URL_FRAME: EddystoneURLFrame, EDDYSTONE_TLM_FRAME: EddystoneTLMFrame, EDDYSTONE_EID_FRAME: EddystoneEIDFrame, }), # estimote frames ESTIMOTE_UUID:
"funcInfos" / ObjectList(func_sig_t) # list of func_sig_t ) RpcMessage_PULL_MD_RESULT = con.Struct( "found" / ObjectList( IdaVarInt32 ), # list of boolean for each request in PULL_MD (1 if matching/found) "results" / ObjectList(func_info_t) # list of func_info_t for each matching result ) RpcMessage_PUSH_MD = con.Struct( "field_0x10" / IdaVarInt32, "idb_filepath" / CString("utf-8"), # absolute file path of current idb "input_filepath" / CString("utf-8"), # absolute file path of input file "input_md5" / Bytes(16), # input file md5 "hostname" / CString("utf-8"), # machine name "funcInfos" / ObjectList(func_md_t), # list of func_md_t to push "funcEas" / ObjectList(IdaVarInt64), # absolute (!?) address of each pushed function ) RpcMessage_PUSH_MD_RESULT = con.Struct( "resultsFlags" / ObjectList(IdaVarInt32), # status for each function pushed ) # Generic RPC message 'union' RpcMessage = con.Switch( this.code, {
def control_partitions(self, partitions, command) -> bool: raise NotImplementedError("override control_partitions in a subclass") def control_outputs(self, outputs, command) -> bool: raise NotImplementedError("override control_outputs in a subclass") def dump_memory(self): raise NotImplementedError("override dump_memory in a subclass") InitiateCommunication = Struct( "fields" / RawCopy( Struct( "po" / BitStruct("command" / Const(7, Nibble), "reserved0" / Const(2, Nibble)), "reserved1" / Padding(35))), "checksum" / Checksum(Bytes(1), lambda data: calculate_checksum(data), this.fields.data)) InitiateCommunicationResponse = Struct( "fields" / RawCopy( Struct( "po" / BitStruct("command" / Const(7, Nibble), "message_center" / Nibble), "new_protocol" / Const(0xFF, Int8ub), "protocol_id" / Int8ub, "protocol" / Struct("version" / Int8ub, "revision" / Int8ub, "build" / Int8ub), "family_id" / Int8ub, "product_id" / ProductIdEnum, "talker" / Enum(Int8ub, BOOT_LOADER=0, CONTROLLER_APPLICATION=1, MODULE_APPLICATION=2), "application" / Struct("version" / Int8ub, "revision" / Int8ub, "build" / Int8ub),
"""Slab data stucture that is used to represent Order book.""" from __future__ import annotations from enum import IntEnum from construct import Switch # type: ignore from construct import Bytes, Int8ul, Int32ul, Int64ul, Padding from construct import Struct as cStruct from .account_flags import ACCOUNT_FLAGS_LAYOUT KEY = Bytes(16) SLAB_HEADER_LAYOUT = cStruct( "bump_index" / Int32ul, Padding(4), "free_list_length" / Int32ul, Padding(4), "free_list_head" / Int32ul, "root" / Int32ul, "leaf_count" / Int32ul, Padding(4), ) class NodeType(IntEnum): UNINTIALIZED = 0 INNER_NODE = 1 LEAF_NODE = 2 FREE_NODE = 3 LAST_FREE_NODE = 4
# offset and size need to be multiplied by LOG_BLOCK_SZ FlashFileEntry = Struct("offset" / Int32ul, "size" / Int32ul, "unknown" / Int64ul) FlashHeader = Struct( "magic" / Int32ul, # HEADER_MAGIC "format_version" / Int8ul, "sequence_version" / Int8ul, "layout_version" / Int16ul, "unknown_1" / Int64ul, "unknown_2" / Int64ul, "unknown_3" / Int64ul, "files" / Array(FLASH_FILES_COUNT, FlashFileEntry), Padding(544), "guid" / Bytes(GUID_SIZE), "hash" / Bytes(HEADER_HASH_SIZE) # SHA256 checksum ) class DurangoXbfsTable(object): _files = {} _notfound_files = [] def __init__(self, header_offset, format, sequence, layout, guid, hash, is_hash_valid): self._header_off = header_offset self._format = format self._sequence = sequence self._layout = layout self._guid = guid
""" Declaration of the header of MFT Records """ from construct import Struct, Bytes, Int16ul, Int32ul from .record_reference import RECORD_REFERENCE RECORD_HEADER = Struct( "signature" / Bytes(4), "update_sequence_array_offset" / Int16ul, "update_sequence_array_size" / Int16ul, "reserved1" / Bytes(8), "sequence_number" / Int16ul, "reserved2" / Bytes(2), "first_attribute_offset" / Int16ul, "flags" / Bytes(2), "reserved3" / Bytes(8), "base_record_segment" / RECORD_REFERENCE, "reserved4" / Bytes(2))
PT_SET_SLICE = 0x19 PT_DEL_SLICE = 0x1A PT_SLICE_STATUS_RESPONSE = 0x1B PT_SLICE_STATUS_REQUEST = 0x1C PT_IGMP_REPORT = 0xE0 PT_INCOMING_MCAST_ADDR = 0xE1 HEADER = Struct( "version" / Int8ub, "type" / Int8ub, "length" / Int32ub, "seq" / Int32ub, "xid" / Int32ub, "device" / Bytes(6), ) HEADER.name = "header" HELLO_REQUEST = Struct( "version" / Int8ub, "type" / Int8ub, "length" / Int32ub, "seq" / Int32ub, "xid" / Int32ub, "device" / Bytes(6), "period" / Int32ub, ) HELLO_REQUEST.name = "hello_request" HELLO_RESPONSE = Struct(
class Microsoft_Windows_WebServices_12_0(Etw): pattern = Struct( "correlationId" / Int64ul, "length" / Int16ul, "message" / Bytes(lambda this: this.length) )
"""Shared layouts.""" from construct import Bytes, Int32ul, Int64ul, PaddedString, Padding # type: ignore from construct import Struct as cStruct FEE_CALCULATOR_LAYOUT = cStruct("lamports_per_signature" / Int64ul) HASH_LAYOUT = Bytes(32) PUBLIC_KEY_LAYOUT = Bytes(32) RUST_STRING_LAYOUT = cStruct( "length" / Int32ul, Padding(4), "chars" / PaddedString(lambda this: this.length, "utf-8"), )
from empower.lvapp.lvappserver import ModuleLVAPPWorker from empower.core.app import EmpowerApp from empower.datatypes.etheraddress import EtherAddress from empower.core.module import Module from empower.core.resourcepool import CQM from empower.core.resourcepool import ResourceBlock from empower.lvapp import PT_VERSION from empower.main import RUNTIME PT_BUSYNESS_REQUEST = 0x36 PT_BUSYNESS_RESPONSE = 0x37 BUSYNESS_REQUEST = Struct("busyness_request", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band")) BUSYNESS_RESPONSE = Struct("busyness_response", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), UBInt32("busyness")) class Busyness(Module): """ A maps poller. """ MODULE_NAME = "busyness" REQUIRED = ['module_type', 'worker', 'tenant_id', 'block'] def __init__(self):
class Microsoft_Windows_WebServices_20_0(Etw): pattern = Struct( "length" / Int16ul, "traceString" / Bytes(lambda this: this.length) )
"""Scenario.""" from construct import (Array, Float32l, Int16ul, Int32sl, Int32ul, Padding, PascalString, Peek, String, Struct, Bytes, If, IfThenElse) from mgz.enums import DifficultyEnum, PlayerTypeEnum, AgeEnum from mgz.util import Find, Version, find_save_version # pylint: disable=invalid-name, bad-continuation # Scenario header. scenario_header = "scenario_header" / Struct( "next_uid" / Int32ul, "constant" / Bytes(4), Array(16, "names" / String(256)), Array(16, "player_ids" / Int32ul), Array( 16, "player_data" / Struct( "active" / Int32ul, "human" / Int32ul, "civilization" / Int32ul, "constant" / Int32ul, # 0x04 0x00 0x00 0x00 )), Padding(5), "elapsed_time" / Float32l, "scenario_filename" / PascalString(lengthfield="scenario_filename_length" / Int16ul), If( lambda ctx: ctx._._.version == Version.DE,
Bit of a hack to make running status support work. """ setattr(ctx._root, '_last_command_byte', obj) class Struct(BaseStruct): """Adds `create()`, a friendlier `build()` method.""" def create(self, **kwargs): return self.build(kwargs) AppleMIDIExchangePacket = Struct( '_name' / Computed('AppleMIDIExchangePacket'), 'preamble' / Const(b'\xff\xff'), 'command' / Bytes(2), 'protocol_version' / Int32ub, 'initiator_token' / Int32ub, 'ssrc' / Int32ub, 'name' / Optional(CString('utf8')), ) AppleMIDITimestampPacket = Struct( '_name' / Computed('AppleMIDITimestampPacket'), 'preamble' / Const(b'\xff\xff'), 'command' / Bytes(2), 'ssrc' / Int32ub, 'count' / Int8ub, 'padding' / Padding(3), 'timestamp_1' / Int64ub, 'timestamp_2' / Int64ub,
ip_message = Struct( "header" / Aligned( 16, Struct( "sof" / Const(0xaa, Int8ub), "length" / Int16ul, "unknown0" / Default(Int8ub, 0x01), "flags" / Int8ub, "command" / Int8ub, "sub_command" / Default(Int8ub, 0x00), 'unknown1' / Default(Int8ub, 0x00), 'encrypt' / Default(Int8ub, 0x03), ), b'\xee'), "payload" / Aligned(16, GreedyBytes, b'\xee')) ip_payload_connect_response = Struct( 'command' / Const(0x00, Int8ub), 'key' / Bytes(16), 'major' / Int8ub, 'minor' / Int8ub, 'ip_major' / Default(Int8ub, 5), 'ip_minor' / Default(Int8ub, 2), 'unknown' / Default(Int8ub, 0x00), 'unknown2' / Default(Int8ub, 0x00), 'unknown3' / Default(Int8ub, 0x00), 'unknown4' / Default(Int8ub, 0xee)) class ClientConnection(): def __init__(self, reader, writer, alarm, key): self.client_writer = writer self.client_reader = reader self.alarm = alarm self.interface_password = key self.connection_key = key async def handle_panel_message(self, data):
from construct import Array from empower.lvapp import PT_VERSION from empower.datatypes.etheraddress import EtherAddress from empower.lvapp.lvappserver import LVAPPServer from empower.datatypes.etheraddress import EtherAddress from empower.lvapp.lvappserver import ModuleLVAPPWorker from empower.core.module import Module from empower.core.app import EmpowerApp from empower.main import RUNTIME PT_WTP_STATS_REQUEST = 0x41 PT_WTP_STATS_RESPONSE = 0x42 WTP_STATS = Sequence("stats", Bytes("lvap", 6), UBInt16("bytes"), UBInt32("count")) WTP_STATS_REQUEST = Struct("stats_request", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id")) WTP_STATS_RESPONSE = \ Struct("stats_response", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), UBInt16("nb_tx"), UBInt16("nb_rx"),
from empower.main import RUNTIME PT_NIF_REQUEST = 0x90 PT_NIF_RESPONSE = 0x91 NIF_STATS_ENTRY = Sequence( "rates", UBInt8("rate"), BitStruct("flags", Padding(6), Bit("mcs"), Padding(9)), UBInt32("prob"), UBInt32("cur_prob"), UBInt64("hist_successes"), UBInt64("hist_attempts"), UBInt32("last_successes"), UBInt32("last_attempts"), UBInt64("last_acked_bytes"), UBInt64("hist_acked_bytes")) NIF_STATS_REQUEST = Struct("nif_request", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("sta", 6)) NIF_STATS_RESPONSE = Struct("nif_response", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), UBInt16("nb_entries"), Array(lambda ctx: ctx.nb_entries, NIF_STATS_ENTRY)) class NIFStats(ModulePeriodic): """ NIFStats object. """ MODULE_NAME = "nif_stats" REQUIRED = ['module_type', 'worker', 'tenant_id', 'lvap'] def __init__(self):
class Microsoft_Windows_WER_Diag_3_0(Etw): pattern = Struct("ProcessId" / Int32ul, "ModuleNameLength" / Int32ul, "ModuleName" / Bytes(lambda this: this.ModuleNameLength))
EventDescriptor = Struct("Id" / Int16ul, "Version" / Int8ul, "Channel" / Int8ul, "Level" / Int8ul, "Opcode" / Int8ul, "Task" / Int16ul, "Keyword" / Int64ul) EventHeader = Struct("marker" / wmi_trace_marker(EventHeaderType), "flags" / EventHeaderFlag, "event_property" / EventHeaderPropertyFlag, "thread_id" / Int32ul, "process_id" / Int32ul, "timestamp" / Int64ul, "provider_id" / Guid, "event_descriptor" / EventDescriptor, "processor_time" / Int64ul, "activity_id" / Guid) EventHeaderExtendedDataItem = Struct( "reserved1" / Int16ul, "ext_type" / Int16ul, "reserved2" / Int16ul, "data_size" / Int16ul, "data_item" / Bytes(lambda this: this.data_size)) EventRecord = AlignedStruct( 8, "mark1" / Computed(lambda this: this._io.tell()), "event_header" / EventHeader, "extended_data" / If( lambda this: this.event_header.flags.EVENT_HEADER_FLAG_EXTENDED_INFO, RepeatUntil(lambda el, lst, this: not lst[-1].reserved2 & 0x1, Aligned(8, EventHeaderExtendedDataItem))), "mark2" / Computed(lambda this: this._io.tell()), "user_data" / Bytes(lambda this: this.event_header.marker.version - (this.mark2 - this.mark1))) class Event: """ This is a python wrapper around construct struct to access interesting fields
OP_UNDEFINED = 0 OP_UPDATE = 1 OP_CREATE = 2 OP_DELETE = 3 OP_RETRIEVE = 4 PT_HELLO_SERVICE = 0x00 PT_CAPABILITIES_SERVICE = 0x01 PT_UE_REPORTS_SERVICE = 0x02 PT_UE_MEASUREMENTS_SERVICE = 0x03 TLVS = Struct( "type" / Int16ub, "length" / Int16ub, "value" / Bytes(this.length - 4), ) HEADER = Struct( "version" / Int8ub, "flags" / BitStruct( "msg_type" / Flag, "padding" / Padding(7) ), "tsrc" / BitStruct( "crud_result" / BitsInteger(2), "action" / BitsInteger(14), ), "length" / Int32ub, "padding" / Bytes(2), "device" / Bytes(6),
def FixedBytes(size_func): """At parse time parses a fixed sized byte array, and at build time builds the byte array with its given size. """ return IfThenElse(lambda this: this._parsing, Bytes(size_func), GreedyBytes)
Struct, this, Bytes, Embedded, IfThenElse) from mgz.body.achievements import achievements from mgz.enums import (DiplomacyStanceEnum, FormationEnum, GameActionModeEnum, OrderTypeEnum, ReleaseTypeEnum, ResourceEnum, ResourceLevelEnum, RevealMapEnum, StanceEnum, AgeEnum, VictoryEnum) from mgz.util import TimeSecAdapter, check_flags # pylint: disable=invalid-name, bad-continuation # Not all actions are defined, not all actions are complete. interact = "interact" / Struct( "player_id" / Byte, Const(b"\x00\x00"), "target_id" / Int32ul, "selected" / Int32ul, "x" / Float32l, "y" / Float32l, "next" / Peek(Bytes(4)), "flags" / If(lambda ctx: check_flags(ctx.next), Bytes(4)), "unit_ids" / If(lambda ctx: ctx.selected < 0xff, Array(lambda ctx: ctx.selected, "unit_ids" / Int32ul))) give_attribute = "give_attribute" / Struct( "player_id" / Byte, "target_id" / Byte, "attribute" / Byte, "amount" / Float32l) add_attribute = "add_attribute" / Struct( "player_id" / Byte, "attribute" / Byte, Padding(1), "amount" / Float32l) ai_interact = "ai_interact" / Struct( Padding(3), "target_id" / Int32ul, "selected" / Byte, Padding(3), "x" / Float32l, "y" / Float32l, If(lambda ctx: ctx.selected < 0xff,
alfred_status_error = Struct( 'transaction_id' / Int16ub, 'error_code' / Int16ub ) alfred_mode_switch = Struct( 'mode' / Int8ub ) alfred_data_block = Struct( 'source_mac_address' / MACAdapter(Byte[6]), 'type' / Int8ub, 'version' / Int8ub, 'length' / Int16ub, 'data' / Bytes(lambda ctx: ctx.length) ) alfred_transaction_mgmt = Struct( 'transaction_id' / Int16ub, 'sequence_number' / Int16ub, ) alfred_push_data = Struct( 'transaction_id' / Int16ub, 'sequence_number' / Int16ub, 'alfred_data' / Array(1, alfred_data_block) ) alfred_packet = Struct( 'alfred_tlv' / alfred_tlv,
The header of the PML file. """ * Struct( "signature" / Const(b"PML_"), "version" / PMLVersionNumberValidator(Int32ul), "is_64bit" / Int32ul, "host_name" / PaddedString(0x20, "UTF_16_le"), "windows_path" / PaddedString(0x208, "UTF_16_le"), "number_of_events" / Int32ul, "reserved1" / Int64ul * "!!Unknown field!!", "events_offset" / Int64ul, "events_offsets_array_offset" / Int64ul, "process_table_offset" / Int64ul, "strings_table_offset" / Int64ul, "unknown_table_offset" / Int64ul, "reserved2" / Int64ul * "!!Unknown field!!", "reserved3" / Bytes(0x46) * "!!Unknown field!!", "reserved4" / Bytes(0xd6) * "!!Unknown field!!", "reserved5" / Int32ul * "!!Unknown field!!", "reserved6" / Int64ul * "!!Unknown field!!", "header_size" / Int64ul, "hosts_and_ports_tables_offset" / Int64ul, CheckCustom(lambda this: this.events_offset == this.header_size, RuntimeError, "events offset is not like header size."), CheckCustom(lambda this: 0 != this.events_offset and 0 != this.events_offsets_array_offset and 0 != this.process_table_offset and 0 != this.strings_table_offset and 0 != this.hosts_and_ports_tables_offset and 0 != this.unknown_table_offset, RuntimeError, "Procmon was probably not closed properly.") ) StringsTable = """
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Contains type definition to help with thread credentials. # Generally thread credentials are assumed to be binary objects, however for # testing purposes, we expose the internal structure here. from construct import BitStruct, Byte, Bytes, Enum, Flag, Int16ul, Int32ul, Int64ul, PaddedString, Padding, Struct ThreadNetworkInfo = Struct( "ActiveTimestamp" / Int64ul, "MasterKey" / Bytes(16), "PSKc" / Bytes(16), "ExtendedPanId" / Bytes(8), "MeshPrefix" / Bytes(8), "PanId" / Int16ul, "NetworkName" / PaddedString(17, 'utf8'), "Channel" / Byte, )
from construct import Struct, Bytes, CheckError, Aligned, Select, GreedyRange, Container, Computed, RepeatUntil from etl.error import InvalidEtlFileHeader from etl.wintrace import WinTrace, WinTraceRecord from etl.event import EventRecord, Event from etl.parsers.kernel.core import Mof from etl.parsers.kernel.header import EventTraceHeader, EventTrace_V0_Header from etl.perf import PerfInfoTraceRecord, PerfInfo from etl.system import SystemTraceRecord, System from etl.trace import Trace, TraceRecord from etl.wmi import WmiBufferHeader EtlChunk = Struct( "header" / WmiBufferHeader, "payload" / Bytes(lambda this: this.header.wnode.saved_offset - WmiBufferHeader.sizeof()), "padding" / Bytes(lambda this: this.header.wnode.buffer_size - this.header. wnode.saved_offset)) # An ETL file is structured by ETL chunks until the end EtlLogFile = GreedyRange(EtlChunk) # This is a common way to select any type of chunks # We add name selecting as computed to handle typing during parsing Chunk = Aligned( 8, Select( Struct("type" / Computed("PerfInfoTraceRecord"), "value" / PerfInfoTraceRecord), Struct("type" / Computed("EventRecord"), "value" / EventRecord), Struct("type" / Computed("TraceRecord"), "value" / TraceRecord),
class Microsoft_Windows_WCN_Config_Registrar_Secure_9000_0(Etw): pattern = Struct( "MessageGuid" / Guid, "MessageBlobLength" / Int16ul, "MessageBlob" / Bytes(lambda this: this.MessageBlobLength))
from empower.persistence.persistence import TblTenant from empower.persistence.persistence import TblAccount from empower.core.account import Account from empower.core.account import ROLE_ADMIN from empower.core.account import ROLE_USER from empower.core.tenant import Tenant from empower.core.acl import ACL from empower.persistence.persistence import TblAllow from empower.core.tenant import T_TYPES import empower.logger import empower.apps DEFAULT_PERIOD = 5000 CTRL_ADV = Struct("ctrl_adv", Bytes("dst", 6), Bytes("src", 6), UBInt16("eth_type"), Bytes("ctrl", 4), UBInt16("port")) def generate_default_accounts(): """Generate default accounts. Three default accounts (one root account and two user accounts are created the first time the controller is started. """ if not Session().query(TblAccount).all(): session = Session() session.add( TblAccount(username="******",
) ElfHeaderTables = Struct( 'elf_header' / ElfHeader, 'program_headers' / Pointer(this.elf_header.e_phoff, ProgramHeader[this.elf_header.e_phnum]), 'section_headers' / Pointer(this.elf_header.e_shoff, SectionHeader[this.elf_header.e_shnum]), ) NoteSection = AlignedStruct( 4, 'namesz' / Int32ul, 'descsz' / Int32ul, 'type' / Int32ul, 'name' / Bytes(this.namesz), 'desc' / Bytes(this.descsz), ) NoteSections = GreedyRange(NoteSection) class ElfFile(object): """ Elf class to a single elf file """ SHN_UNDEF = 0x00 SHT_PROGBITS = 0x01 SHT_STRTAB = 0x03 SHT_NOBITS = 0x08
PT_ASSOC_RESPONSE = 0x10 PT_ADD_LVAP = 0x11 PT_DEL_LVAP = 0x12 PT_STATUS_LVAP = 0x13 PT_SET_PORT = 0x14 PT_STATUS_PORT = 0x15 PT_CAPS = 0x16 PT_ADD_VAP = 0x31 PT_DEL_VAP = 0x32 PT_STATUS_VAP = 0x33 HEADER = Struct("header", UBInt8("version"), UBInt8("type"), UBInt32("length")) SSIDS = Range( 1, 10, Struct("ssids", UBInt8("length"), Bytes("ssid", lambda ctx: ctx.length))) HELLO = Struct("hello", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), Bytes("wtp", 6), UBInt32("period")) PROBE_REQUEST = Struct("probe_request", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), Bytes("wtp", 6), Bytes("sta", 6), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), Bytes("ssid", lambda ctx: ctx.length - 30)) PROBE_RESPONSE = Struct("probe_response", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), Bytes("sta", 6)) AUTH_REQUEST = Struct("auth_request", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), Bytes("wtp", 6),
PascalString(lengthfield="scenario_filename_length" / Int16ul), If( lambda ctx: ctx._._.version == Version.DE, Struct(Padding(64), If(lambda ctx: find_save_version(ctx) >= 13.34, Padding(64))))) # Scenarios have intro text, a bitmap, and cinematics. messages = "messages" / Struct( "instruction_id" / Int32ul, "hints_id" / Int32ul, "victory_id" / Int32ul, "defeat_id" / Int32ul, "history_id" / Int32ul, "scouts_id" / If(lambda ctx: ctx._._.version != Version.AOK, Int32ul), "instructions_length" / Int16ul, "instructions" / Bytes(lambda ctx: ctx.instructions_length), "hints" / PascalString(lengthfield="hints_length" / Int16ul), "victory" / PascalString(lengthfield="victory_length" / Int16ul), "defeat" / PascalString(lengthfield="defeat_length" / Int16ul), "history" / PascalString(lengthfield="history_length" / Int16ul), "scouts" / If(lambda ctx: ctx._._.version != Version.AOK, PascalString(lengthfield="scouts_length" / Int16ul)), "pg_cin" / PascalString(lengthfield="pg_cin_length" / Int16ul), "vict_cin" / PascalString(lengthfield="vict_cin_length" / Int16ul), "loss_cin" / PascalString(lengthfield="loss_cin_length" / Int16ul), "background" / PascalString(lengthfield="background_length" / Int16ul), "bitmap_included" / Int32ul, "bitmap_x" / Int32ul, "bitmap_y" / Int32ul, Padding(2), # bitmap here if it is included