Exemplo n.º 1
0
def test_load_dex_file_fileobj():
    with open(TEST_DEX_FILEPATH, 'rb') as f:
        dex = Dexparser(fileobj=f.read())
Exemplo n.º 2
0
from dexparser import Dexparser
from dexparser import uleb128_value
import disassembler
import numpy as np
from scipy import sparse
import sys

#dexfile = Dexparser('../apps/com.apporio.glitchr.apk_FILES/classes.dex')
dexfile = Dexparser(sys.argv[1])

opcode_list = []

c_list = dexfile.classdef_list()
class_cnt = 0
for class_idx, flag, superclass_idx, interfaces_off, source_file_idx, annotation_off, class_data_off, static_values_off in c_list:
    #print 'class: ' + str(class_cnt)
    class_cnt = class_cnt + 1
    if class_data_off == 0:
        continue

    [
        static_field_list, instance_field_list, direct_method_list,
        virtual_method_list
    ] = dexfile.classdata_list(class_data_off)
    method_cnt = 0
    ###compute 2-gram for direct method
    for diff, access_flags, code_off in direct_method_list:
        if code_off == 0:
            continue
        #print 'method: ' + str(method_cnt)
        size = ord(dexfile.mmap[code_off + 12]) + (
Exemplo n.º 3
0
from dexparser import Dexparser
import struct


dex = Dexparser('../../classes.dex')

string_list = dex.string_list()


# ----------------------
# 打印类名
type_list = dex.typeid_list()
type_len = len(type_list)
print('type list --> count:', str(type_len))

type_string_list = []
for index in type_list:
    """
    struct DexTypeId {
        u4 descriptionIdx;
    }
    """
    type_string_list.append(str(string_list[index]))

print('\n'.join(type_string_list))

# ----------------------
# 打印原型列表

print('-*-' * 30)
Exemplo n.º 4
0
def test_load_dex_from_filedir():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
Exemplo n.º 5
0
def test_parse_annotations():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
    offset = dex.get_classdef_data()[0]['annotation_off']
    assert dex.get_annotations(offset=offset)
Exemplo n.º 6
0
def test_parse_header():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
    assert dex.header.get('checksum') == 2459812747
Exemplo n.º 7
0
def test_parse_class_data():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
    offset = dex.get_classdef_data()[0]['class_data_off']
    assert dex.get_class_data(offset=offset)
Exemplo n.º 8
0
def test_parse_classdef_data():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
    assert dex.get_classdef_data()
Exemplo n.º 9
0
def test_parse_fieldids():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
    assert dex.get_fieldids()
Exemplo n.º 10
0
def test_parse_methods():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
    assert dex.get_methods()
Exemplo n.º 11
0
def test_parse_strings():
    dex = Dexparser(filedir=TEST_DEX_FILEPATH)
    assert dex.get_strings()