Esempio n. 1
0
def backsmali(sample_tf_dir, sample_file_name):  # Backsmali an apk file
    try:
        if enable_logging:
            u.logger('Backsmali: ' + sample_file_name + ' into ' + sample_tf_dir)
        popen('apktool d --force --no-debug-info ' + sample_file_name + ' ' + sample_tf_dir + '/app')
        if os.path.isdir(u.base_dir()+'/smali/com'):
            u.main_exec_dir = 'com'
        elif os.path.isdir(u.base_dir()+'/smali/org'):
            u.main_exec_dir = 'org'
        else:
            u.main_exec_dir = ''
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to backsmali ' + sample_file_name + ' into ' + sample_tf_dir)
Esempio n. 2
0
def move_string_class(class_name):
    decrypt_class = u.get_string_class()  # Load the decrypt class from file
    decrypt_class = decrypt_class.replace('StringManagerOb',
                                          class_name)  # Random key
    u.write_text_file(u.base_dir() + '/smali/android/content/res/' +
                      class_name + '.smali',
                      decrypt_class)  # Write the class file
Esempio n. 3
0
def backsmali(unpack_dir, apk_path):  # Backsmali an apk file
    try:
        if enable_logging:
            u.logger('Backsmali: ' + apk_path + ' into ' + unpack_dir)
        cmd = "{0} d --force --no-debug-info -o {1} {2}".format(
            config.apktool_path, os.path.join(unpack_dir, 'app'), apk_path)
        popen(cmd)
        if os.path.isdir(os.path.join(u.base_dir(), 'smali', 'com')):
            u.main_exec_dir = 'com'
        elif os.path.isdir(os.path.join(u.base_dir(), 'smali', 'org')):
            u.main_exec_dir = 'org'
        else:
            u.main_exec_dir = ''
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to backsmali ' + sample_file_name + ' into ' +
            sample_tf_dir)
Esempio n. 4
0
def move_asset_class(class_name):
    asset_class = u.get_asset_class()  # Load the decrypt class from file
    asset_class = asset_class.replace('AssetManagerOb',
                                      class_name)  # Random key
    u.write_text_file(
        os.path.join(u.base_dir(), 'smali', 'android', 'content', 'res',
                     class_name + '.smali'),
        asset_class)  # Write the class file
Esempio n. 5
0
def backsmali(sample_tf_dir, sample_file_name):  # Backsmali an apk file
    try:
        if enable_logging:
            u.logger('Backsmali: ' + sample_file_name + ' into ' +
                     sample_tf_dir)
        popen('apktool d --force --no-debug-info ' + sample_file_name + ' ' +
              sample_tf_dir + '/app')
        if os.path.isdir(u.base_dir() + '/smali/com'):
            u.main_exec_dir = 'com'
        elif os.path.isdir(u.base_dir() + '/smali/org'):
            u.main_exec_dir = 'org'
        else:
            u.main_exec_dir = ''
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to backsmali ' + sample_file_name + ' into ' +
            sample_tf_dir)
Esempio n. 6
0
def change_all_res_file(res_file_list):
    """Search in all the resource XML files a resource reference"""
    change_meta(u.load_manifest().getroot())
    for res_file in res_file_list:  # For each XML file
        if u.base_name(res_file) == 'strings.xml':  # Edit only the strings/colors resources
                ori_file_name = res_file
                purge_xml_tag_file(ori_file_name)
                res_file = res_file.replace(u.base_dir(), '')
                res_xml = u.load_xml(res_file)
                res_root = res_xml.getroot()
                change_match_res_string_file(res_root)
                u.save_xml(res_file, res_xml)
        if u.base_name(res_file) == 'arrays.xml' or u.base_name(res_file) == 'plurals.xml':  # Edit only the arrays/plurals resources
                ori_file_name = res_file
                purge_xml_tag_file(ori_file_name)
                res_file = res_file.replace(u.base_dir(), '')
                res_xml = u.load_xml(res_file)
                res_root = res_xml.getroot()
                change_match_res_array_file(res_root)
                u.save_xml(res_file, res_xml)
Esempio n. 7
0
def change_all_res_file(res_file_list):
    """Search in all the resource XML files a resource reference"""
    change_meta(u.load_manifest().getroot())
    for res_file in res_file_list:  # For each XML file
        if u.base_name(
                res_file
        ) == 'strings.xml':  # Edit only the strings/colors resources
            ori_file_name = res_file
            purge_xml_tag_file(ori_file_name)
            res_file = res_file.replace(u.base_dir(), '')
            res_xml = u.load_xml(res_file)
            res_root = res_xml.getroot()
            change_match_res_string_file(res_root)
            u.save_xml(res_file, res_xml)
        if u.base_name(res_file) == 'arrays.xml' or u.base_name(
                res_file
        ) == 'plurals.xml':  # Edit only the arrays/plurals resources
            ori_file_name = res_file
            purge_xml_tag_file(ori_file_name)
            res_file = res_file.replace(u.base_dir(), '')
            res_xml = u.load_xml(res_file)
            res_root = res_xml.getroot()
            change_match_res_array_file(res_root)
            u.save_xml(res_file, res_xml)
Esempio n. 8
0
def move_asset_class(class_name):
    asset_class = u.get_asset_class()  # Load the decrypt class from file
    asset_class = asset_class.replace('AssetManagerOb', class_name)  # Random key
    u.write_text_file(u.base_dir()+'/smali/android/content/res/' + class_name + '.smali', asset_class)  # Write the class file