parseapk/parse_apk.py
def parse_signatures(data, offset):
    '''parses length prefixed sequence of signatures (inside APK Signature Scheme v2 Block)
    '''
    # length of sequence of signatures
    total_length = struct.unpack("<L", data[offset: offset+4])[0]
    print "\t\t\tTotal length of signatures: ", total_length
    
    i = 0
    nb = 1
    while i < (total_length + 4):
        # length of signature
        length = struct.unpack("<L", data[offset+i+4: offset+8+i])[0]
        print "\t\t\tSignature struct #%d length=%d" % (nb, length)
        
        # signature algorithm id
        sigalgo_id = struct.unpack("<L", data[offset+i+8: offset+12+i])[0]
        print "\t\t\t\tSignature algo id: %s " % (str_algo_id(sigalgo_id))

        # length of signature
        siglen = struct.unpack("<L", data[offset+i+12: offset+16+i])[0]
        print "\t\t\t\tSignature length : ", siglen

        # then, there is the signature
        sig = data[offset+16+i:offset+16+siglen]
        print "\t\t\t\tSignature: ", sig.encode('hex')
        
        i = i + 16 + siglen
        nb = nb + 1

    if i != (total_length+4):
        print "WARNING: problem parsing the sequence of signatures: total_len=%d i=%d" % (total_length, i)

    return total_length + 4
parses length prefixed sequence of signatures (inside APK Signature Scheme v2 Block)
    
parses length prefixed sequence of signatures (inside APK Signature Scheme v2 Block)
parses length prefixed sequence of signatures ( inside APK Signature Scheme v2 Block )
def parse_signatures(data, offset):
    total_length = struct.unpack("<L", data[offset: offset+4])[0]
    print "\t\t\tTotal length of signatures: ", total_length
    i = 0
    nb = 1
    while i < (total_length + 4):
        length = struct.unpack("<L", data[offset+i+4: offset+8+i])[0]
        print "\t\t\tSignature struct #%d length=%d" % (nb, length)
        sigalgo_id = struct.unpack("<L", data[offset+i+8: offset+12+i])[0]
        print "\t\t\t\tSignature algo id: %s " % (str_algo_id(sigalgo_id))
        siglen = struct.unpack("<L", data[offset+i+12: offset+16+i])[0]
        print "\t\t\t\tSignature length : ", siglen
        sig = data[offset+16+i:offset+16+siglen]
        print "\t\t\t\tSignature: ", sig.encode('hex')
        i = i + 16 + siglen
        nb = nb + 1
    if i != (total_length+4):
        print "WARNING: problem parsing the sequence of signatures: total_len=%d i=%d" % (total_length, i)
    return total_length + 4
def parse_signatures ( data , offset ) : total_length = struct . unpack ( "<L" , data [ offset : offset + 4 ] ) [ 0 ] print "\t\t\tTotal length of signatures: " , total_length i = 0 nb = 1 while i < ( total_length + 4 ) : length = struct . unpack ( "<L" , data [ offset + i + 4 : offset + 8 + i ] ) [ 0 ] print "\t\t\tSignature struct #%d length=%d" % ( nb , length ) sigalgo_id = struct . unpack ( "<L" , data [ offset + i + 8 : offset + 12 + i ] ) [ 0 ] print "\t\t\t\tSignature algo id: %s " % ( str_algo_id ( sigalgo_id ) ) siglen = struct . unpack ( "<L" , data [ offset + i + 12 : offset + 16 + i ] ) [ 0 ] print "\t\t\t\tSignature length : " , siglen sig = data [ offset + 16 + i : offset + 16 + siglen ] print "\t\t\t\tSignature: " , sig . encode ( 'hex' ) i = i + 16 + siglen nb = nb + 1 if i != ( total_length + 4 ) : print "WARNING: problem parsing the sequence of signatures: total_len=%d i=%d" % ( total_length , i ) return total_length + 4
parses length prefixed sequence of signatures (inside APK Signature Scheme v2 Block)
parses length prefixed sequence of signatures ( inside APK Signature Scheme v2 Block )
'''parses length prefixed sequence of signatures (inside APK Signature Scheme v2 Block)
    ''' # length of sequence of signatures # length of signature # signature algorithm id # length of signature # then, there is the signature
data
offset