-
大小: 413KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-06-10
- 語言: 其他
- 標(biāo)簽: Android??反調(diào)試??動(dòng)態(tài)調(diào)試??
資源簡介
反調(diào)試在代碼保護(hù)中扮演著很重要的角色,雖然不能完全阻止攻擊者,但是還是能加大攻擊者的時(shí)間成本,一般與加殼結(jié)合使用,核心還是加殼部分。

代碼片段和文件信息
#include?“com_example_zbb_jiagu02_Myndk.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“android/log.h“
#include?
#include?
#include?
#include?
#include?
#include?
using?namespace?std;
//ptrace自己使得android_server附加不上
void?anti_debug01()
{
????ptrace(PTRACE_TRACEME?0?0?0);
}
//檢測Tracepid的值
void?anti_debug02()
????????????????????????{
????????????????????????????try
????????????????????????????{
????????????????????????????????const?int?bufsize?=?1024;
????????????????????????????????char?filename[bufsize];
????????????????????????????????char?line[bufsize];
????????????????????????????????int?pid?=?getpid();
????????????????????????????????sprintf(filename?“/proc/%d/status“?pid);
????????????????????????????????FILE*?fd?=?fopen(filename?“r“);
????????????????????????????????if?(fd?!=NULL)
????????????????????????????????{
????????????????????????????????????while?(fgets(line?bufsize?fd))
????????????????????????????????????{
????????????????????????????????????????if?(strncmp(line?“TracerPid“?9)?==?0)
????????????????????????????????????????{
????????????????????????????????????????????int?statue?=?atoi(&line[10]);
????????????????????????????????????????????if?(statue?!=?0)
????????????????????????????????????????????{
????????????????????????????????????????????????fclose(fd);
????????????????????????int?ret?=?kill(pid?SIGKILL);
????????????????????}
????????????????????break;
????????????????}
????????????}
????????????fclose(fd);
????????}?else
????????{
????????????//?LOGD(“open?%s?fail...“?filename);
????????}
????}?catch?(...)
????{
????}
}
//將文件讀入字符串中,c++能用,此處不能包括頭文件
/*jstring?readFileIntoString(char?*?filename)
{
????ifstream?ifile(filename);
????//將文件讀入到ostringstream對(duì)象buf中
????ostringstream?buf;
????char?ch;
????while(buf&&ifile.get(ch))
????????buf.put(ch);
????//返回與流對(duì)象buf關(guān)聯(lián)的字符串
????return?buf.str();
}
?*/
//檢測端口號(hào),針對(duì)android_server這個(gè)端口號(hào)
void?anti_debug03()?{
????const?int?bufsize=512;
????char?filename[bufsize];
????char?line[bufsize];
????int?pid?=getpid();
????sprintf(filename“/proc/net/tcp“);
????FILE*?fd=fopen(filename“r“);
????if(fd!=NULL){
????????while(fgets(linebufsizefd)){
????????????if?(strncmp(line?“5D8A“?4)==0){
????????????????int?ret?=?kill(pid?SIGKILL);
????????????}
????????}
????}
????fclose(fd);
}
//檢測這些調(diào)試進(jìn)程的名字
void?anti_debug04(){
????const?int?bufsize?=?1024;
????char?filename[bufsize];
????char?line[bufsize];
????char?name[bufsize];
????char?nameline[bufsize];
????int?pid?=?getpid();
????//先讀取Tracepid的值
????sprintf(filename?“/proc/%d/status“?pid);
????FILE?*fd=fopen(filename“r“);
????if(fd!=NULL){
????????while(fgets(linebufsizefd)){
????????????????if(strstr(line“TracerPid“)!=NULL)
????????????????{
?????????????????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????9093??2016-09-28?22:08??反調(diào)試代碼.cpp
?????文件??????453026??2017-03-09?11:32??關(guān)于反調(diào)試方法總結(jié)(一)以及源碼實(shí)現(xiàn).pdf
評(píng)論
共有 條評(píng)論