def obfuscate(): """ The main obfuscator function """ try: res_xml = u.load_res_repository() # Load the 'pulbic.xml' resource repository except e.FileNotFound: return res_root = res_xml.getroot() # The root of the XML file edited_res = set( list(change_all_res(res_root)) + list(change_meta(u.load_manifest().getroot())) ) u.save_res_repository(res_xml) # Save the 'pulbic.xml' resource repository back to file change_all_res_file(u.load_xml_file(), edited_res) change_allfile(u.load_resource_file(), edited_res) try: res_xml = u.load_res_repository() # Load the 'pulbic.xml' resource repository except e.FileNotFound: return item_id_list = list(add_id_random_resource(res_root)) u.save_res_repository(res_xml) # Save the 'pulbic.xml' resource repository back to file ids_xml = fix_ids(u.load_res_id_repository()) # Load the 'ids.xml' resource repository ids_root = ids_xml.getroot() # The root of the XML file add_id_random_in_ids(ids_root, item_id_list) u.save_ids_repository(ids_xml) # Save the 'ids.xml' resource repository back to file append_defunct_class()
def obfuscate(): """ The main obfuscator function """ try: res_xml = u.load_res_repository( ) # Load the 'pulbic.xml' resource repository except e.FileNotFound: return res_root = res_xml.getroot() # The root of the XML file edited_res = set( list(change_all_res(res_root)) + list(change_meta(u.load_manifest().getroot()))) u.save_res_repository( res_xml) # Save the 'pulbic.xml' resource repository back to file change_all_res_file(u.load_xml_file(), edited_res) change_allfile(u.load_resource_file(), edited_res) try: res_xml = u.load_res_repository( ) # Load the 'pulbic.xml' resource repository except e.FileNotFound: return item_id_list = list(add_id_random_resource(res_root)) u.save_res_repository( res_xml) # Save the 'pulbic.xml' resource repository back to file ids_xml = fix_ids( u.load_res_id_repository()) # Load the 'ids.xml' resource repository ids_root = ids_xml.getroot() # The root of the XML file add_id_random_in_ids(ids_root, item_id_list) u.save_ids_repository( ids_xml) # Save the 'ids.xml' resource repository back to file append_defunct_class()
def obfuscate(): """ The main obfuscator function """ init_package_name() smali_file_list = u.load_smali_file() # Load the smali files res_file_list = set(list(u.load_xml_file()) + list(smali_file_list)) # Load the XML files edited_class = set(find_all_class(smali_file_list)) change_all_class(edited_class, smali_file_list) change_all_res_file(res_file_list, set(get_res_class(edited_class)), package_name) manifest_xml = u.load_manifest() # Load the Manifest file task_affinity = 'a' + u.get_random(True, 7) + '.' + 'a' + u.get_random( True, 7) rename_list = set( list(change_package_name(manifest_xml)) + list(rename_val(manifest_xml, 'activity', 'label', ['@'], False)) + list(rename_val(manifest_xml, 'activity', 'process', ['@'], False)) + list(rename_val(manifest_xml, 'application', 'label', ['@'], False)) + list(rename_val(manifest_xml, 'provider', 'label', ['@'], False)) + list(rename_val(manifest_xml, 'provider', 'process', ['@'], False)) + list(rename_val(manifest_xml, 'activity-alias', 'name', ['@'], False)) + list(rename_val(manifest_xml, 'activity-alias', 'label', ['@'], False)) + list(rename_val(manifest_xml, 'service', 'label', ['@'], False)) + list(rename_val(manifest_xml, 'service', 'process', ['@'], False)) + list(rename_val(manifest_xml, 'receiver', 'label', ['@'], False)) + list(rename_val(manifest_xml, 'receiver', 'process', ['@'], False)) + list(rename_val(manifest_xml, 'intent-filter', 'label', ['@'], False)) + list(rename_val(manifest_xml, 'permission', 'label', ['@'], False)) + list( rename_val(manifest_xml, 'permission', 'description', ['@'], False) ) + list( rename_val(manifest_xml, 'permission-group', 'label', ['@'], False)) + list( rename_val(manifest_xml, 'permission-group', 'description', ['@'], False)) + list(rename_val(manifest_xml, 'permission-tree', 'label', ['@'], False)) + list(rename_val( manifest_xml, 'instrumentation', 'label', ['@'], False)) + list( rename_val(manifest_xml, 'action', 'name', ['@', 'com.android.', 'android.'], False)) + list( rename_val(manifest_xml, 'activity', 'taskAffinity', ['android.', 'com.android.', '@'], False, 'name', task_affinity)) + list( rename_val(manifest_xml, 'application', 'taskAffinity', ['android.', 'com.android.', '@'], False, 'name', task_affinity))) log_tag_bho(manifest_xml, 'data') change_all_res_file_package(res_file_list, rename_list) u.save_manifest(manifest_xml) # Write back the Manifest file''' fix_safe_test(smali_file_list) change_allfile(smali_file_list) change_alldir(u.load_smali_dirs())
def obfuscate(): """ The main obfuscator function """ change_all_res_file(u.load_xml_file()) append_defunct_class()