【发布时间】:2019-02-04 20:22:39
【问题描述】:
我正在尝试了解https://github.com/nemesisqp/al-khaser/blob/0f74c40dde8ba060807e031271f81457a187fa08/DebuggerDetection.cpp#L603中的一些反调试器功能
会
__asm {
mov eax, fs:[30h]
mov al, [eax + 2h]
mov IsDbg, al
}
功能相同
__asm mov IsDbg, [fs:[0x30] + 0x2]
如果没有,为什么不呢?
另外,如何将其转换为纯 C/C++?如何获取线程信息(特别是 fs:[30h])?
并且会
BOOL Int2DCheck()
{
// The Int2DCheck function will check to see if a debugger
// is attached to the current process. It does this by setting up
// SEH and using the Int 2D instruction which will only cause an
// exception if there is no debugger. Also when used in OllyDBG
// it will skip a byte in the disassembly and will create
__try
{
__asm
{
int 2dh
xor eax, eax
add eax, 2
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
return true;
}
同
__try
{
__asm
{
xor eax, eax
int 0x2d
inc eax
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
如果没有,为什么不呢?
【问题讨论】:
-
mov IsDbg, [fs:[0x30] + 0x2]有 2 个内存操作数,因此不可编码。源寻址模式也是不可编码的; x86 机器代码没有双重间接寻址模式。 (x86 asm 只是 x86 机器码的文本表示,因此每条指令都可以汇编成一条机器指令。) -
好的@PeterCordes,关于
mov al, [ eax + 2h ]\nmov bDebuggerPresence, al,它会像mov bDebuggerPresence, [ eax + 2h ]一样工作吗?其他int 0x2dop 会在发布的 c/c++ 中工作吗? -
不,
int 0x2d是一个系统调用(但您尚未为其设置输入寄存器,因此没有更多上下文作为 sn-p 毫无意义)。 felixcloutier.com/x86/INTn:INTO:INT3:INT1.html。您在 Windows 上,因此int ??系统调用 ABI 不稳定或没有正式记录,并且可能会随着更新/服务包而改变。 -
@Steve 它是反调试的东西,所以我不能完全测试它并确定它有效。
-
@PeterCordes 这就是我所拥有的所有上下文。 github.com/nemesisqp/al-khaser/blob/…
标签: c++ windows assembly x86 reverse-engineering