Skip to content

Commit dfe48fc

Browse files
committed
ImGui & Improvements
ImGui default now, original Windows design still intact, can be changed from a json file, or the file menu. Timing checks are undetected after you toggle them off and toggle them back on now (keeps the detected text showing after a timing check has been triggered without being turned off)
1 parent 7f8fe79 commit dfe48fc

37 files changed

+98335
-78
lines changed

AntiDebugMethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ bool AntiDebugMethod::checkIfDetected() {
7575
char newButtonName[200];
7676
strcpy_s(newButtonName, name.c_str());
7777
strcat_s(newButtonName, "\n ENABLED - DETECTED!");
78+
updated_name = newButtonName;
7879
SendMessageA(enableButtonHwnd, WM_SETTEXT, 0, (LPARAM)newButtonName);
7980
}
8081
} else {
@@ -95,7 +96,6 @@ bool AntiDebugMethod::createGUI(HWND hWnd) {
9596
else {
9697
strcat_s(newButtonName, "\n DISABLED");
9798
}
98-
9999
enableButtonHwnd = CreateWindowA("button", newButtonName, WS_VISIBLE | WS_CHILD | BS_MULTILINE | SS_CENTER, windowPosX, windowPosY, 230, 50, hWnd, (HMENU)(90+id), NULL,NULL);
100100
return 1;
101101
};

AntiDebugMethod.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,26 @@ class AntiDebugMethod
88
{
99
private:
1010
static int current_id;
11-
static std::vector<AntiDebugMethod*> allInstances;
12-
std::string name;
1311
int id;
14-
bool enabled = false;
1512
bool detected = false;
16-
int windowPosX, windowPosY;
1713
HWND enableButtonHwnd;
1814
public:
15+
int windowPosX, windowPosY;
16+
std::string name;
17+
std::string updated_name;
18+
bool enabled = false;
1919
bool (*funcPtr)();
2020
static void toggleThisMethod(int id);
2121
static void mainLoop();
2222
static bool anyDetection;
2323
static AntiDebugMethod* getMethodById(int id);
2424

25-
void toggle();
25+
2626
AntiDebugMethod(bool (*funcPtrParam)(), int windowPosXParam, int windowPosYParam, std::string nameParam);
27+
28+
void toggle();
2729
bool checkIfDetected();
2830
bool createGUI(HWND hWnd);
31+
static std::vector<AntiDebugMethod*> allInstances;
2932
};
3033

Methods/MethodGetLocalTime.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include <Windows.h>
33
#include <iostream>
4+
#include "TimerDetection.h"
45

56
bool MethodGetLocalTime()
67
{
@@ -22,5 +23,10 @@ bool MethodGetLocalTime()
2223
uiEnd.LowPart = fEnd.dwLowDateTime;
2324
uiEnd.HighPart = fEnd.dwHighDateTime;
2425

25-
return (((uiEnd.QuadPart - uiStart.QuadPart) * 100) / 1000000) > 100;
26+
bool detection_value = (((uiEnd.QuadPart - uiStart.QuadPart) * 100) / 1000000) > 100;
27+
static timer_detection local_time_detection(detection_value);
28+
local_time_detection.frame();
29+
local_time_detection.set_condition(!local_time_detection.get_detected());
30+
local_time_detection.update_detection(detection_value);
31+
return local_time_detection.get_detected();
2632
}

Methods/MethodGetTickCount.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
#pragma once
22
#include <Windows.h>
33
#include <iostream>
4-
5-
bool MethodGetTickCount() {
4+
#include "TimerDetection.h"
65

76

7+
bool MethodGetTickCount() {
88
DWORD tickReference = GetTickCount64();
99

1010
Sleep(50);
1111

1212
DWORD currentTick = GetTickCount64();
1313
DWORD elapsedTime = currentTick - tickReference;
1414

15-
if (elapsedTime > 100)
16-
return true;
17-
18-
return false;
15+
bool detection_value = elapsedTime > 100;
16+
static timer_detection tick_detection(detection_value);
17+
tick_detection.frame();
18+
tick_detection.set_condition(!tick_detection.get_detected());
19+
tick_detection.update_detection(detection_value);
20+
return tick_detection.get_detected();
1921
}

Methods/MethodQPC.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include <Windows.h>
33
#include <iostream>
4+
#include <chrono>
5+
#include "TimerDetection.h"
46

57
bool MethodQPC()
68
{
@@ -11,5 +13,13 @@ bool MethodQPC()
1113
Sleep(50);
1214

1315
QueryPerformanceCounter(&end);
14-
return (end.QuadPart - start.QuadPart) * 1000 / frequency.QuadPart > 100;
16+
17+
bool detection_value = (end.QuadPart - start.QuadPart) * 1000 / frequency.QuadPart > 100;
18+
19+
static timer_detection qpc_detection(detection_value);
20+
qpc_detection.frame();
21+
qpc_detection.set_condition(!qpc_detection.get_detected());
22+
qpc_detection.update_detection(detection_value);
23+
return qpc_detection.get_detected();
1524
}
25+

Methods/TimerDetection.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#pragma once
2+
#include <chrono>
3+
4+
// helper static class for things that are detected
5+
// but only for a short duration
6+
class timer_detection
7+
{
8+
public:
9+
timer_detection(bool detected)
10+
{
11+
detection = detected;
12+
last_call_time = std::chrono::steady_clock::now();
13+
}
14+
15+
inline void frame()
16+
{
17+
auto current_time = std::chrono::steady_clock::now();
18+
// short duration, if the button is untoggled the detection will reset
19+
if (std::chrono::duration_cast<std::chrono::milliseconds>(current_time - last_call_time).count() > 250)
20+
{
21+
needs_reset = true;
22+
}
23+
else
24+
{
25+
needs_reset = false;
26+
}
27+
28+
last_call_time = std::chrono::steady_clock::now();
29+
}
30+
31+
inline void set_condition(bool cond)
32+
{
33+
condition = cond;
34+
}
35+
36+
inline void update_detection(bool value)
37+
{
38+
if (condition || needs_reset)
39+
{
40+
detection = value;
41+
}
42+
}
43+
44+
inline bool get_detected()
45+
{
46+
return detection;
47+
}
48+
private:
49+
bool condition;
50+
bool detection;
51+
bool needs_reset;
52+
std::chrono::time_point<std::chrono::steady_clock> last_call_time;
53+
};

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
Implementation of some anti-debugging techniques on a (bad looking) Win32 application. The idea is to cover most used anti-debugging methods.
44

5-
![](preview.png)
5+
ImGui | Windows
6+
:-------------------------:|:-------------------------:
7+
![](new_preview.png) | ![](preview.png)
68

79
## How to use it
810

9-
You can compile yourself with Visual Studio 2019+ (no special instructions needed) or just download the binary on the release tab. Fire it up, attach a debugger and start enabling detection methods. Then, try to bypass some and have fun.
11+
You can compile yourself with Visual Studio 2019+ or just download the binary on the release tab. Fire it up, attach a debugger and start enabling detection methods. Then, try to bypass some and have fun.
12+
When compiling you need to copy the resources folder to the output folder for the images to display.
1013

1114
## How to add a new anti debugging method
1215

0 commit comments

Comments
 (0)