Skip to content

Instantly share code, notes, and snippets.

@spnow
Forked from evernick/TrapFlag.cpp
Created August 1, 2017 23:05
Show Gist options
  • Save spnow/772c191dcf1773c5c71a420b37aeac22 to your computer and use it in GitHub Desktop.
Save spnow/772c191dcf1773c5c71a420b37aeac22 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <excpt.h>
#include <stdio.h>
BOOL anti_debug_flag = TRUE;
void anti_debug()
{
__try
{
__asm
{
pushfd
or dword ptr ss:[esp+1], 1 // or dword ptr ss:[esp], 0x100
popfd
nop
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
anti_debug_flag = FALSE;
}
}
int main(int argc, char **argv)
{
anti_debug();
if(anti_debug_flag)
printf("Debugger Detected\n");
else
printf("No Debugger...\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment