導航:首頁 > 源碼編譯 > 反編譯so調用方法

反編譯so調用方法

發布時間:2022-12-12 08:11:18

A. 關於android開發中java對於.so庫的調用

android掉用c的so包就是通過jni

應該給你的jar包就是用來調用so包的
。不會讓你直接掉so包的放心。so包一般都是為了保證核心代碼不被反編譯
,另外就是效率高才會用,或者就是開發游戲

他們說夠用應該是jar包已經和so包的jni調用介面都調好了

你用jar包就行了

B. 什麼是SO文件

SO文件是linux下共享庫文件,它的文件格式被稱為ELF文件格式。由於Android操作系統的底層基於Linux系統,所以SO文件可以運行在Android平台上。

Android系統也同樣開放了C/C++介面供開發者開發Native程序。由於基於虛擬機的編程語言JAVA更容易被人反編譯,因此越來越多的應用將其中的核心代碼以C/C++為編程語言,並且以SO文件的形式供上層JAVA代碼調用,以保證安全性。

(2)反編譯so調用方法擴展閱讀:

so文件使用方法:

(1)動態庫的編譯。這里有一個頭文件:so_test.h,三個.c文件:test_a.c、test_b.c、test_c.c,我們將這幾個文件編譯成一個動態庫:libtest.so。

命令:$ gcc test_a.c test_b.c test_c.c -fPIC -shared -o libtest.so不用該標志外部程序無法連接。相當於一個可執行文件。

(2)動態庫的鏈接這里有個程序源文件 test.c 與動態庫 libtest.so 鏈接生成執行文件 test:命令:$ gcc test.c -L. -ltest -o test命令:$ ldd test執行test,可以看到它是如何調用動態庫中的函數的。

參考資料來源:網路—SO(軟體編程)

C. Linux .so庫的使用

新建一個sort.c文件,寫一個最簡單的排序

使用 gcc -o libsort.so -fPIC -shared sort.c 產生libsort.so庫。

.so庫有兩種調用方法:

新建main.c文件:

使用命令 gcc -o main main.c -lsort -L. 編譯。

新建main2.c文件:

使用命令 gcc -o main2 main2.c -ldl 編譯。動態載入.so庫的話需要-ldl。
運行./main2後輸出遞增序列,調用成功。

D. 請問安卓的SO文件是怎麼回事,可以反編譯出源碼嗎 是如何生成的用JAVA還是C代碼生成的

如何JAVA代碼調用?
jni吧?
安卓的SO文件是linux下的文件,用c或者c++寫的。

E. Android如何調用反編譯得到的so

反編譯不可以,反匯編可以,這個網路一下你就知道了。反匯編,這沒點功力肯定不行的。
如果你改不了這個so文件,要調用此so文件。那麼你必須按之前工程的包名、類名、方法名來調用,也就是方法路徑必須與原來的一致,因為如果不一致,native方法就不可用了,找不到。

F. 怎樣動態調用.so文件中的類方法

相關介面:
#include <dlfcn.h>void *dlopen(const char *filename, int flag);char *dlerror(void);void *dlsym(void *handle, const char *symbol);int dlclose(void *handle);123456789

eg:
dlapi.c
/*
[root@localhost eg]# gcc main.c -Wl,-rpath=./ -ldl -D_TEST
[root@localhost eg]# g++ main.c -Wl,-rpath=./ -ldl -D_TEST
*/#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <dlfcn.h>#ifdef __cplusplusextern "C" {#endiftypedef int (*PCall_func0)();typedef int (*PCall_func1)(void *);typedef int (*PCall_func2)(void *, void *);typedef int (*PCall_func3)(void *, void *, void *);typedef int (*PCall_func4)(void *, void *, void *, void *);int dynamic_call_library_func0(char *libName, char *funcName)
{
void *handle; void *error;
PCall_func0 selffunc=NULL; int ret; if(libName == NULL)return -9000; if(funcName == NULL)return -9001; //打開動態鏈接庫
handle = dlopen(libName, RTLD_LAZY); if (!handle) { printf("%s\n", dlerror()); return -9000;
}

dlerror(); //獲取一個函數
selffunc = (PCall_func0)dlsym(handle, funcName); if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); return -9001;
}

ret = selffunc(); //dlclose用於關閉指定句柄的動態鏈接庫,只有當此動態鏈接庫的使用計數為0時,才會真正被系統卸載。
dlclose(handle); return ret;
}int dynamic_call_library_func1(char *libName, char *funcName, void *argv1)
{
void *handle; void *error;
PCall_func1 selffunc=NULL; int ret; if(libName == NULL)return -9000; if(funcName == NULL)return -9001; //打開動態鏈接庫
handle = dlopen(libName, RTLD_LAZY); if (!handle) { printf("%s\n", dlerror()); return -9000;
}

dlerror(); //獲取一個函數
selffunc = (PCall_func1)dlsym(handle, funcName); if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); return -9001;
}

ret = selffunc(argv1); //dlclose用於關閉指定句柄的動態鏈接庫,只有當此動態鏈接庫的使用計數為0時,才會真正被系統卸載。
dlclose(handle); return ret;
}int dynamic_call_library_func2(char *libName, char *funcName, void *argv1, void *argv2)
{
void *handle; void *error;
PCall_func2 selffunc=NULL; int ret; if(libName == NULL)return -9000; if(funcName == NULL)return -9001; //打開動態鏈接庫
handle = dlopen(libName, RTLD_LAZY); if (!handle) { printf("%s\n", dlerror()); return -9000;
}

dlerror(); //獲取一個函數
selffunc = (PCall_func2)dlsym(handle, funcName); if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); return -9001;
}

ret = selffunc(argv1, argv2); //dlclose用於關閉指定句柄的動態鏈接庫,只有當此動態鏈接庫的使用計數為0時,才會真正被系統卸載。
dlclose(handle); return ret;
}int dynamic_call_library_func3(char *libName, char *funcName, void *argv1, void *argv2, void *argv3)
{
void *handle; void *error;
PCall_func3 selffunc=NULL; int ret; if(libName == NULL)return -9000; if(funcName == NULL)return -9001; //打開動態鏈接庫
handle = dlopen(libName, RTLD_LAZY); if (!handle) { printf("%s\n", dlerror()); return -9000;
}

dlerror(); //獲取一個函數
selffunc = (PCall_func3)dlsym(handle, funcName); if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); return -9001;
}

ret = selffunc(argv1, argv2, argv3); //dlclose用於關閉指定句柄的動態鏈接庫,只有當此動態鏈接庫的使用計數為0時,才會真正被系統卸載。
dlclose(handle); return ret;
}int dynamic_call_library_func4(char *libName, char *funcName, void *argv1, void *argv2, void *argv3, void *argv4)
{
void *handle; void *error;
PCall_func4 selffunc=NULL; int ret; if(libName == NULL)return -9000; if(funcName == NULL)return -9001; //打開動態鏈接庫
handle = dlopen(libName, RTLD_LAZY); if (!handle) { printf("%s\n", dlerror()); return -9000;
}

dlerror(); //獲取一個函數
selffunc = (PCall_func4)dlsym(handle, funcName); if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); return -9001;
}

ret = selffunc(argv1, argv2, argv3, argv4); //dlclose用於關閉指定句柄的動態鏈接庫,只有當此動態鏈接庫的使用計數為0時,才會真正被系統卸載。
dlclose(handle); return ret;
}#ifdef _TESTint main(int rgvs, char **rgva)
{char buff[]="asdfasdf";int x=8;printf("main gcc build\n");printf("g_path gcc libeggcc.so char *\n");
dynamic_call_library_func1("/home/workspace/eg/libeggcc.so", "show1", buff);printf("g_path g++ libegg++.so char *\n");
dynamic_call_library_func1("/home/workspace/eg/libegg++.so", "show1", buff);printf("../lib path gcc libeggcc.so char *\n");
dynamic_call_library_func1("libeggcc.so", "show1", buff);printf("../lib path g++ libegg++.so char *\n");
dynamic_call_library_func1("libegg++.so", "show1", buff);printf("g_path gcc libeggcc.so int\n");
dynamic_call_library_func1("/home/workspace/eg/libeggcc.so", "show2", &x);printf("g_path g++ libegg++.so int\n");
dynamic_call_library_func1("/home/workspace/eg/libegg++.so", "show2", &x);printf("../lib path gcc libeggcc.so int\n");
dynamic_call_library_func1("libeggcc.so", "show2", &x);printf("../lib path g++ libegg++.so int\n");
dynamic_call_library_func1("libegg++.so", "show2", &x); return 0;
}#endif#ifdef __cplusplus}#

dlapi.h
#ifndef _DL_API_H#define _DL_API_H#ifdef __cplusplusextern "C" {#endif/*
使用g++編譯的.so庫中,函數前必須添加 exter "C"
函數參數類型為指針,不或以為引用
*/int dynamic_call_library_func0(char *libName, char *funcName) ;int dynamic_call_library_func1(char *libName, char *funcName, void *argv1) ;int dynamic_call_library_func2(char *libName, char *funcName, void *argv1, void *argv2) ;int dynamic_call_library_func3(char *libName, char *funcName, void *argv1, void *argv2, void *argv3) ;int dynamic_call_library_func4(char *libName, char *funcName, void *argv1, void *argv2, void *argv3, void *argv4) ;#ifdef __cplusplus}#endif#

eg.c
/*
[root@localhost eg]# gcc eg.c -fPIC -shared -o libeggcc.so[root@localhost eg]# g++ eg.c -fPIC -shared -o libegg++.so*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>int show1(char *src)
{ printf("%s\n", src); return 100;
}int show2(int *x)
{ printf("%2d\n", *x); return 101;
}

eg.cpp
/*
[root@localhost eg]# gcc eg.c -fPIC -shared -o libeggcc.so
[root@localhost eg]# g++ eg.c -fPIC -shared -o libegg++.so
*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>extern "C" int show1(char *src)
{ printf("%s\n", src); return 100;
}extern "C" int show2(int *x)
{ printf("%2d\n", *x); return 101;
}

main.c
/*
[root@localhost eg]# gcc main.c -Wl,-rpath=./ -ldl -D_TEST
[root@localhost eg]# g++ main.c -Wl,-rpath=./ -ldl -D_TEST
*/#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <dlfcn.h>#include "dlapi.h"int main(int rgvs, char **rgva)
{char buff[]="asdfasdf";int x=8;int ret;printf("main gcc build\n");printf("\ng_path gcc libeggcc.so char *\n");
ret = dynamic_call_library_func1("/home/workspace/eg/libeggcc.so", "show1", buff);printf("\ng_path g++ libegg++.so char *\n");
dynamic_call_library_func1("/home/workspace/eg/libegg++.so", "show1", buff);printf("\ncur lib path gcc libeggcc.so char *\n");
dynamic_call_library_func1("libeggcc.so", "show1", buff);printf("\ncur lib path g++ libegg++.so char *\n");
dynamic_call_library_func1("libegg++.so", "show1", buff);printf("\ng_path gcc libeggcc.so int\n");
dynamic_call_library_func1("/home/workspace/eg/libeggcc.so", "show2", &x);printf("\ng_path g++ libegg++.so int\n");
dynamic_call_library_func1("/home/workspace/eg/libegg++.so", "show2", &x);printf("\ncur lib path gcc libeggcc.so int\n");
dynamic_call_library_func1("libeggcc.so", "show2", &x);printf("\ncur path g++ libegg++.so int\n");
dynamic_call_library_func1("libegg++.so", "show2", &x); return 0;
}

makefile
all:
gcc eg.c -fPIC -shared -o libeggcc.so
g++ eg.cpp -fPIC -shared -o libegg++.so
gcc dlapi.c -ldl -fPIC -shared -o libdlapi.so
g++ main.c -L. -ldlapi -Wl,-rpath=./ -Wl,-rpath=./lib
123456

引用:
網路dlopen(3) - Linux man page
http://tldp.org/HOWTO/C++-dlopen/
錯誤:
未找到符合
該函數的定義沒有鏈接進.so文件中時,在鏈接時加上-Wl,-z -Wl,defs參數,可以避免這個問題

G. 安卓軟體包內的.so文件如何反編譯,重編譯

*.so文件是linux平台下的動態鏈接庫,反編譯動態鏈接庫參見windows下*.dll文件的反編譯,類似的。

H. JavaScript能調用Jar包或者.so庫中的代碼嗎

1.將SO文件直接放到libs/armeabi下,然後代碼中System.loadLibrary("xxx");再public native static int xxx_xxx_xxx();接下來就可以直接調用xxx_xxx_xxx()方法;
2.第二種方案,創建自己的SO文件,在自己的SO文件里調用第三方SO,再在程序中調用自己的SO,這種比較復雜,需要建java類文件,生成.h文件,編寫C源文件include之前生成的.h文件並實現相應方法,最後用android NDK開發包中的ndk-build腳本生成對應的.so共享庫。

2. DEX加殼保護,DEX指令動態載入保護和高級源碼混淆保護。其中DEX加殼保護是「愛加密」主推的賣點,該技術通過將DEX文件隱藏,並生成一個類似於虛像的殼文件,阻止黑客利用反編譯工具獲取App源碼。另外,使得C/C++ 層面的代碼安全也得到防護。加上資源文件保護(圖片、音頻等文件的防查看和防修改)、xml 主配文件保護(對主配文件進行二次簽名)、內存保護等措施,可以基本保證App的動態和靜態安全。

I. 請教一下,SO文件如何反編譯最好是WIN環境下搭建。謝謝。

謝謝。。。以前玩過CD版的,我去找找。。。另外SO庫和DLL庫的逆向近似嗎?貌似我查了下,我關注的這個軟體轉碼演算法網上還木有。。。是不是也有殼的說法,或者密鑰?但離線閱讀能實現的功能應該可以逆向,而且是不分文本、通用型轉碼。

閱讀全文

與反編譯so調用方法相關的資料

熱點內容
單片機高電平驅動 瀏覽:115
ios多選文件夾 瀏覽:907
加強行車調度命令管理 瀏覽:241
伺服器已禁用什麼意思 瀏覽:148
部隊命令回復 瀏覽:753
神奇寶貝伺服器地圖怎麼設置 瀏覽:380
加密演算法輸出固定長度 瀏覽:862
程序員去重慶還是武漢 瀏覽:121
伺服器如何撤銷網頁登錄限制 瀏覽:980
微信公眾平台php開發視頻教程 瀏覽:628
怎麼看蘋果授權綁定的app 瀏覽:255
壓縮機單級壓縮比 瀏覽:380
linux測試php 瀏覽:971
什麼時候梁旁邊需要加密箍筋 瀏覽:40
微信清粉軟體源碼 瀏覽:717
matlabdoc命令 瀏覽:550
如何去ping伺服器 瀏覽:75
ecshop安裝php55 瀏覽:817
javaword庫 瀏覽:958
php圖片路徑資料庫中 瀏覽:488