def From_apk_to_Data_Section(path_of_apk): apk = path_of_apk apk_obj = APK(apk) dalvik_obj = DalvikVMFormat(apk_obj) return dalvik_obj.get_buff( )[dalvik_obj.header. data_off:] # using the offset from the start of file to start of the data section we get can get the data section
def From_Apk_to_Dex_file_bytes(path_of_apk, mode=1): if mode == 1: apk = path_of_apk a, d, dx = AnalyzeAPK(apk) tobytes = d[0].get_buff() tobytes = bytes(tobytes) elif mode == 0: apk = path_of_apk apk_obj = APK(apk) dalvik_obj = DalvikVMFormat(apk_obj) tobytes = dalvik_obj.get_buff() tobytes = bytes(tobytes) return tobytes