Esempio n. 1
0
 def __init__(self):
     super(AudioHandler, self).__init__()
     self.header_base = construct.BitStruct(
         'ASTRMBaseHeader', construct.BitField('fmt', 3),
         construct.Bit('channel'), construct.Flag('vibrate'),
         construct.Bit('packet_type'), construct.BitField('seq_id', 10),
         construct.BitField('payload_size', 16))
     self.header_aud = construct.Struct('ASTRMAudioHeader',
                                        construct.ULInt32('timestamp'))
     self.header_msg = construct.Struct(
         'ASTRMMsgHeader',
         # This is kind of a hack, (there are two timestamp fields, which one is used
         # depends on packet_type
         construct.ULInt32('timestamp_audio'),
         construct.ULInt32('timestamp'),
         construct.Array(2, construct.ULInt32('freq_0')),  # -> mc_video
         construct.Array(2, construct.ULInt32('freq_1')),  # -> mc_sync
         construct.ULInt8('vid_format'),
         construct.Padding(3))
     self.header = construct.Struct(
         'ASTRMHeader', construct.Embed(self.header_base),
         construct.Switch('format_hdr',
                          lambda ctx: ctx.packet_type, {
                              0: construct.Embed(self.header_aud),
                              1: construct.Embed(self.header_msg),
                          },
                          default=construct.Pass))
Esempio n. 2
0
 def __init__(self):
     self.header_cmd0 = construct.Struct(
         'CMD0Header', construct.UBInt8('magic'), construct.UBInt8('unk_0'),
         construct.UBInt8('unk_1'), construct.UBInt8('unk_2'),
         construct.UBInt8('unk_3'), construct.UBInt8('flags'),
         construct.UBInt8('id_primary'), construct.UBInt8('id_secondary'),
         construct.UBInt16('error_code'),
         construct.UBInt16('payload_size_cmd0'))
     self.header_cmd1 = construct.Struct('CMD1Header',
                                         construct.Padding(48))
     self.header_cmd2 = construct.Struct('CMD2Header',
                                         construct.ULInt16('JDN_base'),
                                         construct.Padding(2),
                                         construct.ULInt32('seconds'))
     self.header = construct.Struct(
         'CMDHeader', construct.ULInt16('packet_type'),
         construct.ULInt16('cmd_id'), construct.ULInt16('payload_size'),
         construct.ULInt16('seq_id'),
         construct.Switch(
             'cmd_hdr',
             lambda ctx: ctx.cmd_id, {
                 0:
                 construct.If(
                     lambda ctx: ctx.payload_size >= self.header_cmd0.
                     sizeof(), construct.Embed(self.header_cmd0)),
                 1:
                 construct.If(
                     lambda ctx: ctx.payload_size == self.header_cmd1.
                     sizeof(), construct.Embed(self.header_cmd1)),
                 2:
                 construct.If(
                     lambda ctx: ctx.payload_size == self.header_cmd2.
                     sizeof(), construct.Embed(self.header_cmd2))
             },
             default=construct.Pass))
     self.cmd_handlers = {0: self.cmd0, 1: self.cmd1, 2: self.cmd2}
     self.cmd0_handlers = {
         5: {
             6: self.cmd0_5_6
         },
     }
Esempio n. 3
0
 def __init__(s):
     super(ServiceASTRM, s).__init__()
     s.header_base = construct.BitStruct('ASTRMBaseHeader',
         construct.BitField('fmt', 3),
         construct.Bit('channel'),
         construct.Flag('vibrate'),
         construct.Bit('packet_type'),
         construct.BitField('seq_id', 10),
         construct.BitField('payload_size', 16)
     )
     s.header_aud = construct.Struct('ASTRMAudioHeader',
         construct.ULInt32('timestamp'),
     #    construct.Array(lambda ctx: ctx.payload_size, construct.UBInt8("data"))
     )
     s.header_msg = construct.Struct('ASTRMMsgHeader',
         # This is kind of a hack, (there are two timestamp fields, which one is used depends on packet_type
         construct.ULInt32('timestamp_audio'),
         construct.ULInt32('timestamp'),
         construct.Array(2, construct.ULInt32('freq_0')), # -> mc_video
         construct.Array(2, construct.ULInt32('freq_1')), # -> mc_sync
         construct.ULInt8('vid_format'),
         construct.Padding(3)
     )
     s.header = construct.Struct('ASTRMHeader',
         construct.Embed(s.header_base),
         construct.Switch('format_hdr', lambda ctx: ctx.packet_type,
             {
                 0 : construct.Embed(s.header_aud),
                 1 : construct.Embed(s.header_msg),
             },
             default = construct.Pass
         )
     )
     s.is_streaming = False
     s.p = pyaudio.PyAudio()
     s.stream = None
     
     s.pa_num_bufs = 15
     s.pa_ring = [array.array('H', '\0' * 416 * 2)] * s.pa_num_bufs
     s.pa_wpos = s.pa_rpos = 0
Esempio n. 4
0
    construct.Rename('description', UNICODE_STRING),
    construct.ULInt32('crypt_alg_id'), construct.ULInt32('crypt_alg_len'),
    construct.ULInt32('salt_len'),
    construct.Bytes('salt', lambda ctx: ctx.salt_len),
    construct.ULInt32('unknown1'), construct.ULInt32('hash_alg_id'),
    construct.ULInt32('hash_alg_len'), construct.ULInt32('hmac_len'),
    construct.Bytes('hmac', lambda ctx: ctx.hmac_len),
    construct.ULInt32('encrypted_len'),
    construct.Bytes('encrypted', lambda ctx: ctx.encrypted_len),
    construct.ULInt32('sign_len'),
    construct.Bytes('sign', lambda ctx: ctx.sign_len))

DPAPI_BLOB_STORE = construct.Struct(
    'DPAPI_BLOB_STORE', construct.ULInt32('size'),
    construct.Embed(
        construct.Union('', construct.Bytes('raw', lambda ctx: ctx.size),
                        construct.Rename('blob', DPAPI_BLOB))))

# VAULT POLICY file structs.

VAULT_POL_STORE = construct.Struct(
    'VAULT_POL_STORE', construct.ULInt32('size'),
    construct.Embed(
        construct.Union(
            '', construct.Bytes('raw', lambda ctx: ctx.size),
            construct.Embed(
                construct.Struct(
                    '', GUID('unknown1'), GUID('unknown2'),
                    construct.Rename('blob_store', DPAPI_BLOB_STORE))))))

VAULT_POL = construct.Struct('VAULT_POL', construct.ULInt32('version'),
Esempio n. 5
0
    cst.Flag('bold_joins_34'),
    cst.Flag('bold_joins_12'),
)

CMD_SEQ = cst.Sequence(
    '_cmd', cst.Magic('\x1c'),
    cst.Enum(cst.Byte('cmd'),
             FLASH='F',
             ENLARGE='E',
             RED='R',
             GREEN='G',
             YELLOW='Y',
             MULTICOLOUR='M',
             DEFAULT='D'))

PAGE = cst.Struct('page', PAGE_IDX, cst.Embed(TEMPO), cst.Embed(PAGE_FUNC),
                  cst.Embed(PAGE_CFG), cst.CString('body', terminators='\x04'))

DATETIME_BODY = cst.Struct(
    'datetime_page',
    cst.Const(PAGE_IDX, '000'),
)
# values as ascii numbers 0x30-0x39

# hours_m
# hours_l
# mins_m
# mins_l
# secs_m
# secs_l
# date_m
Esempio n. 6
0
def MakeRva(name):
    return construct.Embed(construct.Struct('EmbeddedRva',
        construct.ULInt32(name),
        construct.Value('VA', lambda ctx: idaapi.get_imagebase() + ctx[name])
    ))
Esempio n. 7
0
    'page_cfg',
    cst.Magic('\x01'),
    cst.Flag('background_on'),
    cst.Flag('non_english'),
    cst.Flag('autocenter'),
    cst.Flag('bold_joins_78'),
    cst.Flag('bold_joins_56'),
    cst.Flag('bold_joins_34'),
    cst.Flag('bold_joins_12'),
)

CMD_SEQ = cst.Struct(
    '_cmd', cst.Magic('\x1c'),
    cst.Enum(cst.Byte('cmd'), FLASH=70, ENLARGE=69, DEFAULT=68))

PAGE = cst.Struct('page', PAGE_IDX, cst.Embed(TEMPO), cst.Embed(PAGE_FUNC),
                  cst.Embed(PAGE_CFG), cst.Embed(CMD_SEQ),
                  cst.CString('body', terminators='\x04'))

DATETIME_BODY = cst.Struct(
    'datetime_page',
    cst.Const(PAGE_IDX, '000'),
)
# values as ascii numbers 0x30-0x39

MESSAGE = cst.Struct('msg', HEADER, SER_STATUS, PAGE)


class Protocol:
    @staticmethod
    def datetime_page():