0
点赞
收藏
分享

微信扫一扫

反调试 —— 时间

基于 c++ 标准库

#include <windows.h>
#include <iostream>
#include <time.h>
using namespace std;

VOID isDebuger() {

time_t Tbefore = time(0);
time_t Tafter = time(0);

while (1) {
Tafter = time(0);
if (Tafter - Tbefore > 5) {
cout << "found Debugger!" << endl;
break;
}
Tbefore = Tafter;
}

return;
}


int main()
{
// 卡死超过 5 秒则判定为被调试状态
isDebuger();

getchar();
return 0;
}

基于汇编指令

​RDTSC​​​ 时钟检测反调试: 使用时钟检测方法是利用​​rdtsc​​​这个汇编指令,它返回至系统重新启动以来的时钟数,并且将其作为一个64位的值存入​​EDX:EAX​​​寄存器中,通过运行两次​​rdstc​​指令,然后计算出他们的差值,来判断是否被调试了.

#include <Windows.h>
#include <stdio.h>

int IsDebug()
{
int Debug = 0;
__asm
{
rdtsc // 调用时钟
xor ecx,ecx
add ecx,eax // 将eax与ecx相加
rdtsc // 再次调用时钟
sub eax,ecx // 两次结果做差值
mov Debug,eax
}
//printf("打印差值: %d \n", Debug);
if (Debug >= 21)
return 1;
return 0;
}

int main(int argc, char * argv[])
{
int ret = IsDebug();
if (ret == 1)
printf("被调试了 \n");

system("pause");
return 0;
}



举报

相关推荐

0 条评论