Пример #1
0
def dex2jar(f):
    # 如果操作的是apk,则将apk中全部的dex转换为jar文件输出到在apk同级目录下
    if f.endswith('.apk'):
        output_jar_prefix = os.path.splitext(f)[0] + '_'
        temp_dex_dir = PathManager.get_temp_dir_path()
        ZipManager.unzip_dexFile_to_dest(f, temp_dex_dir)
        filenames = os.listdir(temp_dex_dir)
        for dex_name in filenames:
            if dex_name.endswith('.dex'):
                dex_file_path = os.path.join(temp_dex_dir, dex_name)
                jar_file = output_jar_prefix + os.path.splitext(
                    dex_name)[0] + '.jar'
                retcode, msg = star.runcmd2([
                    PathManager.get_dex2jar_path(), dex_file_path, '-f', '-o',
                    jar_file
                ])
                if retcode == 0:
                    star.run_cmd_asyn([PathManager.get_jdgui_path(), jar_file])
                    print('dex2jar ok')
        shutil.rmtree(temp_dex_dir)
        return retcode, msg
    elif f.endswith('.dex'):
        jarFile = os.path.splitext(f)[0] + '.jar'
        retcode, msg = star.runcmd2(
            [PathManager.get_dex2jar_path(), f, '-f', '-o', jarFile])
        if retcode == 0:
            star.run_cmd_asyn([PathManager.get_jdgui_path(), jarFile])
            print('dex2jar ok')
        return retcode, msg
    else:
        print(u'选择文件不合法,文件格式需要是apk或者dex格式')
        os.system("pause")
        return 0, None
Пример #2
0
def on_command(params):
    ret = 0  # 默认返回成功
    msg = None

    paramCount = len(params)
    isMultiFiles = False
    if params is None or paramCount < 3:
        print(params[0])
        print(params[1])
        return -1, u'参数不对,需要传至少 3 个参数'
    CMD_STR = params[1]
    filesSelected = params[2]
    if paramCount > 3:
        isMultiFiles = True
    if sys.platform == 'win32':
        pass
        # win下命令行参数为gbk编码,转换为UNICODE
        # filesSelected = filesSelected.decode('gbk', 'ignore')
    print(str(paramCount) + ' ' + CMD_STR + ' ' + filesSelected)

    if CMD_STR == 'dex2jar':
        ret, msg = dex2jar(filesSelected)
    elif CMD_STR == 'axml2txt':
        ret, msg = axml2txt(filesSelected)
    elif CMD_STR == 'viewapk':
        ret, msg = viewapk(filesSelected)
    elif CMD_STR == 'viewsign':
        ret, msg = viewsign(filesSelected)
    elif CMD_STR == 'sign':
        ret, msg = sign(filesSelected)
    elif CMD_STR == 'sign_v1_v2':
        ret, msg = sign_v1_v2(filesSelected)
    elif CMD_STR == 'installd':
        ret, msg = installd(filesSelected)
    elif CMD_STR == 'installr':
        ret, msg = installr(filesSelected)
    elif CMD_STR == 'uninstall':
        ret, msg = uninstall(filesSelected)
    elif CMD_STR == 'viewwrapper':
        ret, msg = viewwrapper(filesSelected)
    elif CMD_STR == 'phone':
        ret, msg = viewphone(filesSelected)
        if ret == 0:
            os.system('pause')
    elif CMD_STR == 'photo':
        ret, msg = photo(filesSelected)
    elif CMD_STR == 'icon':
        ret, msg = extracticon(filesSelected)
        os.system('pause')
    elif CMD_STR == 'zipalign':
        ret, msg = zipalign(filesSelected)
        os.system('pause')
    elif CMD_STR == 'baksmali':
        ret, msg = baksmali(filesSelected)
    elif CMD_STR == 'smali':
        ret, msg = smali(filesSelected)
    elif CMD_STR == 'plug_get_neprotect_ver':
        ret, msg = plug_get_neprotect_ver(filesSelected)
        os.system('pause')
    elif CMD_STR == 'md2html':
        ret, msg = md2html(filesSelected)
    elif CMD_STR == 'md2pdf':
        ret, msg = md2pdf(filesSelected)
    elif CMD_STR == 'plug3':
        ret, msg = plug(filesSelected)
    elif CMD_STR == 'about':
        print(u'\n\n右键工具v3.0 by bising(https://github.com/bigsinger)\n\n')
        os.system('pause')
        # star.runcmd2([PathManager.get_about_path()])
    elif CMD_STR == 'notepad':
        ret, msg = star.run_cmd_asyn(['notepad', filesSelected])
    elif CMD_STR == 'hex':
        print('open with hex tool')
        tool = PathManager.get_hextool_path()
        ret, msg = star.run_cmd_asyn([tool, filesSelected])
    elif CMD_STR == 'lua':
        print('open with Lua Editor')
        tool = PathManager.get_luaeditor_path()
        ret, msg = star.run_cmd_asyn([tool, filesSelected])
    elif CMD_STR == 'luyten':
        print('open with luyten')
        tool = PathManager.get_luyten_path()
        ret, msg = star.run_cmd_asyn([tool, filesSelected])
        if ret != 0:  # 说明此时执行命令出错,暂停下让用户能够看到cmd窗口的出错信息
            os.system('pause')
    elif CMD_STR == 'jdgui':
        print('open with jdgui')
        tool = PathManager.get_jdgui_path()
        ret, msg = star.run_cmd_asyn([tool, filesSelected])
    elif CMD_STR == 'md5':
        ret, msg = md5(filesSelected)
        os.system('pause')
    else:
        return -1, u'\n\n未实现命令:' + CMD_STR + u'请检查您输入的命令是否正确\n\n'
    return ret, msg