modifyELF

Introduction: 修改 Android lib*.so(ELF)文件的函数名和 hash
More: Author   ReportBugs   
Tags:

修改 Android lib*.so(ELF)文件的函数名和 hash

文件说明

modify.c 修改 so 文件(ELF 文件)方法对应的 hash

readsymbol.c 取并打印 so 文件内的 symbol

libtest/modify modify.c 编译后的文件(编译环境 OS X,需要在其他环境执行的可以用源码重新编译)

libtest/readsymbol readsymbol.c 编译后的文件(编译环境 OS X,需要在其他环境执行的可以用源码重新编译)

libtest/libxlog.so 用于测试的 so 文件

使用方式

先使用 readsymbol 打印 so 文件内所有的函数名:

readsymbol libxlog.so

打印结果:

Java_com_tendk01_mm_xlog_LogLogicJni_initLogInfo
Java_com_tendk01_mm_xlog_LogLogicJni_setIsAlphaVersion
Java_com_tendk01_mm_xlog_LogLogicJni_getLogLevelFromCfg
Java_com_tendk01_mm_xlog_LogLogicJni_getIPxxLogLevel
Java_com_tendk01_mm_xlog_LogLogicJni_getAppenderModeFromCfg
Java_com_tendk01_mm_xlog_LogLogicJni_setIPxxLogML
Java_com_tendk01_mm_xlog_LogLogicJni_setConsoleLogOpen
Java_com_tendk01_mm_xlog_LogLogicJni_setErrLogOpen
Java_com_tendk01_mm_xlog_Xlog_onCreate
Java_com_tendk01_mm_xlog_Xlog_appenderOpen
Java_com_tendk01_mm_xlog_Xlog_appenderClose
Java_com_tendk01_mm_xlog_Xlog_appenderFlush
Java_com_tendk01_mm_xlog_Xlog_logWrite
Java_com_tendk01_mm_xlog_Xlog_logWrite2
Java_com_tendk01_mm_xlog_Xlog_getLogLevel
Java_com_tendk01_mm_xlog_Xlog_setLogLevel
Java_com_tendk01_mm_xlog_Xlog_setAppenderMode

然后使用 modify 修改函数名的 hash

./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_initLogInfo Java_com_tendk01_mm_xlog_LogLogicJni_initLogInfo
./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_setIsAlphaVersion Java_com_tendk01_mm_xlog_LogLogicJni_setIsAlphaVersion
./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_getLogLevelFromCfg Java_com_tendk01_mm_xlog_LogLogicJni_getLogLevelFromCfg
./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_getIPxxLogLevel Java_com_tendk01_mm_xlog_LogLogicJni_getIPxxLogLevel
./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_getAppenderModeFromCfg Java_com_tendk01_mm_xlog_LogLogicJni_getAppenderModeFromCfg
./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_setIPxxLogML Java_com_tendk01_mm_xlog_LogLogicJni_setIPxxLogML
./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_setConsoleLogOpen Java_com_tendk01_mm_xlog_LogLogicJni_setConsoleLogOpen
./modify libxlog.so Java_com_tencent_mm_xlog_LogLogicJni_setErrLogOpen Java_com_tendk01_mm_xlog_LogLogicJni_setErrLogOpen
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_onCreate Java_com_tendk01_mm_xlog_Xlog_onCreate
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_appenderOpen Java_com_tendk01_mm_xlog_Xlog_appenderOpen
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_appenderClose Java_com_tendk01_mm_xlog_Xlog_appenderClose
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_appenderFlush Java_com_tendk01_mm_xlog_Xlog_appenderFlush
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_logWrite Java_com_tendk01_mm_xlog_Xlog_logWrite
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_logWrite2 Java_com_tendk01_mm_xlog_Xlog_logWrite2
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_getLogLevel Java_com_tendk01_mm_xlog_Xlog_getLogLevel
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_setLogLevel Java_com_tendk01_mm_xlog_Xlog_setLogLevel
./modify libxlog.so Java_com_tencent_mm_xlog_Xlog_setAppenderMode Java_com_tendk01_mm_xlog_Xlog_setAppenderMode

完成。

Support Me
Apps
About Me
Google+: Trinea trinea
GitHub: Trinea