關于debugserver與lldb的配置

設備:iPhone6 ios11.0.3越獄系統? ?

環(huán)境:Mac 10.13.4? Xcode9.3


1、從手機目錄導出debugsever到電腦? scp root@手機ip:/Developer/usr/bin/debugserver? ...path/debugserver

2、生成權限ent.plist文件 ios11系統上看需要包含platform-application權限文件內容:

權限內容

3、利用ldid 對debugserver進行權限設置 ldid -Sent.plist? debugserver

4、將設置好權限的debugserver執(zhí)行文件 拷貝會手機 scp? ...path/debugsever? root@手機ip:/usr/bin

5、ssh 到手機給剛剛上傳的debugserver加上執(zhí)行權限? ssh root@手機ip? ?然后執(zhí)行 chmod +x /usr/bin/debugserver

6、這個時候如果執(zhí)行、/usr/bin/debugserver localhost:1234 "SpringBoard" 回出現錯誤:error: failed to attach to process named: "" (os/kern) invalid argument? ? 查閱資料后發(fā)現原來是在ios11系統行需要使用jailbreak_client提權

7、提權方式(來源于iosre論壇):通過theos下tool模塊創(chuàng)建一個工程(工程名隨意高興就好)DebugAssist,然后將main.mm中代碼修改為

#include

externchar**environ;

voidrun_cmd(constchar*cmd)

{

? ? pid_t pid;

? ? constchar*argv[] = {"sh","-c", cmd,NULL};

? ? intstatus;

? ? status = posix_spawn(&pid,"/bin/sh",NULL,NULL, (char*const*)argv, environ);

? ? if(status ==0) {

? ? ? ? if(waitpid(pid, &status,0) == -1) {

? ? ? ? ? ? perror("waitpid");

? ? ? ? }

? ? }

}

int? main(intargc,char*argv[],char*envp[])

{

? ? if(argc <2)

? ? {

? ? ? ? fprintf(stderr,"usage: %s program args...\n", argv[0]);

? ? ? ? returnEXIT_FAILURE;

? ? }

? ? intret, status;

? ? pid_t pid;

? ? posix_spawnattr_t attr;

? ? posix_spawnattr_init(&attr);

? ? posix_spawnattr_setflags(&attr, POSIX_SPAWN_START_SUSPENDED);

? ?ret = posix_spawnp(&pid, argv[1],NULL, &attr, &argv[1], envp);

? ? posix_spawnattr_destroy(&attr);

? ? if(ret !=0)

? ? {

? ? ? ? printf("posix_spawnp failed with %d: %s\n", ret, strerror(ret));

? ? ? ? returnret;

? ? }

? ? charbuf[200];

? ? snprintf(buf,sizeof(buf), "/electra/jailbreakd_client %d 1", pid);

? ? run_cmd(buf);

? ? kill(pid, SIGCONT);

? ? waitpid(pid, &status,0);

? ? return 0;

}

8、make上面的DebugAssist工程 生成可執(zhí)行文件DebugAssist ,同樣使用ent.plist 添加權限,然后上傳到手機的/usr/bin 目錄并賦予執(zhí)行權限 ,這樣調用一下 DebugAssist /usr/bin/debugserver localhost:1234 -a "SpringBoard" 就正常了

9、因為debugserver只能綁定iOS設備本地ip localhost 所以我們還需要使用到usbmuxd 進行端口的轉發(fā),可以通過http://cgit.sukimashita.com/usbmuxd.git/snapshot/usbmuxd-1.0.8.tar.gz 下載到

10、打開Mac終端并運行python ...path/usbmuxd-1.0.8/python-client/tcprelay.py 22:2222

11、新建Mac終端并運行python ...path/usbmuxd-1.0.8/python-client/tcprelay.py 1234:1234

12、ssh到手機并執(zhí)行 DebugAssist /usr/bin/debugserver localhost:1234 -a "SpringBoard"

13、新建Mac終端并運行l(wèi)ldb 輸入執(zhí)行process connect connect://localhost:1234

14、等待就可以看到能正常的動態(tài)調試了

?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容