GithubHelp home page GithubHelp logo

txy0110 / androidnativestringencryptlibrary Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maxwell-nc/androidnativestringencryptlibrary

0.0 1.0 0.0 112 KB

An Android native library (*.so) which encrypt/decrypt string and proguard it to prevent decompile.

Java 10.59% Makefile 2.73% C++ 71.02% C 15.66%

androidnativestringencryptlibrary's Introduction

Android字符串加密库

An Android native library (*.so) which encrypt/decrypt string and proguard it to prevent decompile.

特点 Feature

  • 正版应用调用校验(防止二次打包等问题)
  • 函数名及内容混淆
  • 关键代码及字符串隐藏
  • 支持自定义加密解密扩展
  • 入口防止动态调试等等

预览 Preview

下面是正版应用调用展示:

下面是非法应用调用结果(包名或签名不一致):

下面是反编译后函数列表(混淆):

下面是搜索关键数据(如加密密钥、加密后的数据):

下面是关键代码片段反生成代码(加大反编译难度):

用法 Usage

注意:下面均忽略JNI调用的通用步骤

1.配置你的应用签名及包名

  打开Tools.cpp,修改替换sign和validPackage内容,比如签名为:-498576263,包名为:com.github.maxwell.nc.nativestrencrypt,则可以修改为如下代码:

//正版签名hashcode,换签名请修改这个
//忽略hashcode碰撞问题(另外有包名校验)
//必须是使用tricks写法,直接int可以从so中静态反编译找到(容易被替换)
char* sign = (char[]){'-','4','9','8','5','7','6','2','6','3'};
int vaildSignHash = atoi(sign);

//正版包名
//可以任意分割,见nstrcat
const char* validPackage =  nstrcat("com","co","m",".","gi","thub",".","max","we","ll",
                                    ".","nc",".","native","str","encrypt","com");

  如果你不确定你的包名和签名,可以通过打开日志信息,观察日志中生成的hashcode和sign即为当前应用的签名hashcode及包名。

2.配置你的原生函数

  由于是采用反射获取方法名称,需要通过配置regClazz(调用原生方法的包名)和gMethods(原生方法名、方法签名、函数指针),然后参考getSamplePass函数调用decryptStr方法进行解密:

__attribute__((section ("datas")))
JNICALL jstring getSamplePass(JNIEnv *env, jclass clazz, jobject object){
    //这里的 616263898b8a 为加密后的字符串(可以任意分割)
    return decryptStr(env,object,"616","263","8","98","b8a",fakePass);
}

//要寻找的类:配置你的包名
static char regClazz[] = "com/github/maxwell/nc/encryptlib/EncryptUtils";

//要寻找的方法:配置你的方法
static JNINativeMethod gMethods[] = {
        { "getSamplePass", "(Ljava/lang/Object;)Ljava/lang/String;", (void*)getSamplePass },
};

3.调用原生方法

String samplePass = EncryptUtils.getSamplePass(this);

如果错误则会返回预定义错误的字符串

4.特别注意!!!

源代码中加密解密方法随便写的,十分简单,不能用于实际应用。建议采用高强度加密解密算法(最好修改通用方法,加强安全)

进阶 Advance

打开日志信息

  可以通过修改Tools.h中的宏定义:

#define DEBUG true

修改预定义错误返回字符串

  可以通过修改EncryptUtils.cpp中的decryptStr函数中的:

char* failStr = (char[]){'e','r','r','o','r','\0'};

其他事项

  暂时没想到,以后有空再补充。

  Sorry, I have no empty time to translate this readme file into English.

androidnativestringencryptlibrary's People

Contributors

maxwell-nc avatar

Watchers

 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.