GithubHelp home page GithubHelp logo

zhengfasheng / dexsheller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yongyecc/dexsheller

1.0 0.0 0.0 485 KB

Native层APK保护:一键加固脚本 (Native layer APK protection: One-click hardening script)

C++ 39.70% Python 33.60% Java 26.70%

dexsheller's Introduction

简介

Native层DEX一键加固脚本。(和Java层DEX加固相比,只是将Java层关于动态解密加载原始DEX的代码移到了Native层,加深APK文件防编译保护)

使用说明

python sosheller.py -f xxx.apk

加固原理

将动态加载原DEX的代码放到Native层通过反射来实现。

一键加固脚本实现步骤

  1. 准备原DEX加密算法以及隐藏位置(壳DEX尾部)
        """
        1. 第一步:确定加密算法
        """
        inKey = 0xFF
        print("[*] 确定加密解密算法,异或: {}".format(str(inKey)))
  1. 生成壳DEX。(壳Application动态加载原application中需要原application的name字段)
        """
        2. 第二步:准备好壳App
        """
        # 反编译原apk
        decompAPK(fp)
        # 获取Applicaiton name并保存到壳App源码中
        stSrcDexAppName = getAppName(fp)
        save_appName(stSrcDexAppName)
        # 编译出壳DEX
        compileShellDex()
        print("[*] 壳App的class字节码文件编译为:shell.dex完成")
  1. 修改原APK文件中的AndroidManifest.xml文件的applicationandroid:name字段,实现从壳application启动
        """
        3. 第三步:修改原apk AndroidManifest.xml文件中的Application name字段为壳的Application name字段
        """
        # 替换壳Applicaiton name到原apk的AndroidManifest.xml内
        replaceTag(fp, "cn.yongye.nativeshell.StubApp")
        print("[*] 原apk文件AndroidManifest.xml中application的name字段替换为壳application name字段完成")
  1. 加密原DEX到壳DEX尾部并将壳DEX替换到原APK中
        """
        4. 替换原apk中的DEX文件为壳DEX
        """
        replaceSDexToShellDex(os.path.join(stCurrentPt, "result.apk"))
        print("[*] 壳DEX替换原apk包内的DEX文件完成")
  1. 添加脱壳lib库到原apk中
        """
        5. 添加脱壳lib库到原apk中
        """
        addLib("result.apk")
  1. apk签名
        """
        6. apk签名
        """
        signApk(os.path.join(stCurrentPt, "result.apk"), os.path.join(stCurrentPt, "demo.keystore"))
        print("[*] 签名完成,生成apk文件: {}".format(os.path.join(stCurrentPt, "result.apk")))

dexsheller's People

Contributors

yongyecc avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.