|
@ -21,7 +21,7 @@ from __future__ import absolute_import, division, print_function, \ |
|
|
import socket |
|
|
import socket |
|
|
import struct |
|
|
import struct |
|
|
import logging |
|
|
import logging |
|
|
|
|
|
import binascii |
|
|
|
|
|
|
|
|
def compat_ord(s): |
|
|
def compat_ord(s): |
|
|
if type(s) == int: |
|
|
if type(s) == int: |
|
@ -140,7 +140,7 @@ def pack_addr(address): |
|
|
|
|
|
|
|
|
def pre_parse_header(data): |
|
|
def pre_parse_header(data): |
|
|
datatype = ord(data[0]) |
|
|
datatype = ord(data[0]) |
|
|
if datatype == 0x80 : |
|
|
if datatype == 0x80: |
|
|
if len(data) <= 2: |
|
|
if len(data) <= 2: |
|
|
return None |
|
|
return None |
|
|
rand_data_size = ord(data[1]) |
|
|
rand_data_size = ord(data[1]) |
|
@ -151,7 +151,7 @@ def pre_parse_header(data): |
|
|
data = data[rand_data_size + 2:] |
|
|
data = data[rand_data_size + 2:] |
|
|
elif datatype == 0x81: |
|
|
elif datatype == 0x81: |
|
|
data = data[1:] |
|
|
data = data[1:] |
|
|
elif datatype == 0x82 : |
|
|
elif datatype == 0x82: |
|
|
if len(data) <= 3: |
|
|
if len(data) <= 3: |
|
|
return None |
|
|
return None |
|
|
rand_data_size = struct.unpack('>H', data[1:3])[0] |
|
|
rand_data_size = struct.unpack('>H', data[1:3])[0] |
|
@ -160,6 +160,21 @@ def pre_parse_header(data): |
|
|
'encryption method') |
|
|
'encryption method') |
|
|
return None |
|
|
return None |
|
|
data = data[rand_data_size + 3:] |
|
|
data = data[rand_data_size + 3:] |
|
|
|
|
|
elif datatype == 0x88: |
|
|
|
|
|
if len(data) <= 7 + 7: |
|
|
|
|
|
return None |
|
|
|
|
|
data_size = struct.unpack('>H', data[1:3])[0] |
|
|
|
|
|
ogn_data = data |
|
|
|
|
|
data = data[:data_size] |
|
|
|
|
|
crc = binascii.crc32(data) & 0xffffffff |
|
|
|
|
|
if crc != 0xffffffff: |
|
|
|
|
|
logging.warn('uncorrect CRC32, maybe wrong password or ' |
|
|
|
|
|
'encryption method') |
|
|
|
|
|
return None |
|
|
|
|
|
start_pos = 3 + ord(data[3]) |
|
|
|
|
|
data = data[start_pos:-4] |
|
|
|
|
|
if data_size < len(ogn_data): |
|
|
|
|
|
data += ogn_data[data_size:] |
|
|
return data |
|
|
return data |
|
|
|
|
|
|
|
|
def parse_header(data): |
|
|
def parse_header(data): |
|
|