Anti-debugging technology in Android

Source: Internet
Author: User

It's easier to have both of the following

Debug port Detection, 23946 (0x5d8a)

Demo:

void CheckPort23946ByTcp(){    FILE* pfile=NULL;    char buf[0x1000]={0};    // 执行命令    char* strCatTcp= "cat /proc/net/tcp |grep :5D8A";    //char* strNetstat="netstat |grep :23946";    pfile=popen(strCatTcp,"r");    if(NULL==pfile)    {       LOGA("CheckPort23946ByTcp popen打开命令失败!\n");       return;    }     // 获取结果    while(fgets(buf,sizeof(buf),pfile))    {        // 执行到这里,判定为调试状态        LOGA("执行cat /proc/net/tcp |grep :5D8A的结果:\n");        LOGB("%s",buf);     }//while     pclose(pfile);}
Debugger process name detection in Android device, Android_server, Gdbserver, GDB, etc.

Demo:

void SearchObjProcess(){    FILE* pfile=NULL;    char buf[0x1000]={0};    // 执行命令    //pfile=popen("ps | awk ‘{print $9}‘","r"); // 部分不支持awk命令    pfile=popen("ps","r");    if(NULL==pfile)    {        LOGA("SearchObjProcess popen打开命令失败!\n");        return;    }     // 获取结果    LOGA("popen方案:\n");    while(fgets(buf,sizeof(buf),pfile))    {        // 打印进程        LOGB("遍历进程:%s\n",buf);        // 查找子串        char* strA=NULL,strB=NULL,strC=NULL,strD=NULL;        strA=strstr(buf,"android_server");        strB=strstr(buf,"gdbserver");        strC=strstr(buf,"gdb");        strD=strstr(buf,"fuwu");        if(strA || strB ||strC || strD)        {            // 执行到这里,判定为调试状态            LOGB("发现目标进程:%s\n",buf);        }//if    }//while    pclose(pfile);}

Anti-debugging technology in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.