parseapk/parse_apk.py
def parse_sigv2(data, offset, length):
    '''
    offset where APK Signature Scheme v2 is stored
    length of APK Signature Scheme v2 block
    '''
    total_signers_length = struct.unpack("<L", data[offset:offset+4])[0]
    print "\t\tTotal signers length: ", total_signers_length

    i = 0
    nb = 1
    while i < total_signers_length:
        signer_length = struct.unpack("<L", data[offset+i+4:offset+i+8])[0]
        print "\t\tSigner #%d length=%d --- " % (nb, signer_length)
                
        # parsing each signer
        p1 = parse_signed_data(data, offset+i+8)
        p2 = parse_signatures(data, offset+i+8+p1)
        p3 = parse_public_key(data, offset+i+8+p1+p2)
        i = p1 + p2 + p3 + 4
        nb = nb + 1

    if total_signers_length != i:
        print "WARNING: parsing error: total_signers_length=%d length=%d" % (total_signers_length, i)
        
    return total_signers_length + 4

    offset where APK Signature Scheme v2 is stored
    length of APK Signature Scheme v2 block
    
offset where APK Signature Scheme v2 is stored
length of APK Signature Scheme v2 block
offset where APK Signature Scheme v2 is stored length of APK Signature Scheme v2 block
def parse_sigv2(data, offset, length):
    total_signers_length = struct.unpack("<L", data[offset:offset+4])[0]
    print "\t\tTotal signers length: ", total_signers_length
    i = 0
    nb = 1
    while i < total_signers_length:
        signer_length = struct.unpack("<L", data[offset+i+4:offset+i+8])[0]
        print "\t\tSigner #%d length=%d --- " % (nb, signer_length)
        p1 = parse_signed_data(data, offset+i+8)
        p2 = parse_signatures(data, offset+i+8+p1)
        p3 = parse_public_key(data, offset+i+8+p1+p2)
        i = p1 + p2 + p3 + 4
        nb = nb + 1
    if total_signers_length != i:
        print "WARNING: parsing error: total_signers_length=%d length=%d" % (total_signers_length, i)
    return total_signers_length + 4
def parse_sigv2 ( data , offset , length ) : total_signers_length = struct . unpack ( "<L" , data [ offset : offset + 4 ] ) [ 0 ] print "\t\tTotal signers length: " , total_signers_length i = 0 nb = 1 while i < total_signers_length : signer_length = struct . unpack ( "<L" , data [ offset + i + 4 : offset + i + 8 ] ) [ 0 ] print "\t\tSigner #%d length=%d --- " % ( nb , signer_length ) p1 = parse_signed_data ( data , offset + i + 8 ) p2 = parse_signatures ( data , offset + i + 8 + p1 ) p3 = parse_public_key ( data , offset + i + 8 + p1 + p2 ) i = p1 + p2 + p3 + 4 nb = nb + 1 if total_signers_length != i : print "WARNING: parsing error: total_signers_length=%d length=%d" % ( total_signers_length , i ) return total_signers_length + 4
offset where APK Signature Scheme v2 is stored
length of APK Signature Scheme v2 block
offset where APK Signature Scheme v2 is stored length of APK Signature Scheme v2 block
'''
    offset where APK Signature Scheme v2 is stored
    length of APK Signature Scheme v2 block
    ''' # parsing each signer
data
offset
length