forked from ayoubfaouzi/al-khaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ayoubfaouzi#215 from LordNoteworthy/Noteworthy
New Anti-Debug: Low Fragmentation Heap
- Loading branch information
Showing
10 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
#### 0.81 | ||
|
||
- Add anti-debug trick: Low Fragmentation Heap. | ||
|
||
#### 0.80 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "pch.h" | ||
#include "LowFragmentationHeap.h" | ||
|
||
|
||
BOOL | ||
LowFragmentationHeap( | ||
VOID | ||
) | ||
/*++ | ||
Routine Description: | ||
Originally found by Souhail Hammou: | ||
http://rce4fun.blogspot.com/2014/02/anti-debugging-trick-checking-for-low.html | ||
Under a debugger, the process does not have a Low Fragmentation Heap (LFH) | ||
The routine simply checks weather the nt!_HEAP.FrontEndHeap is NULL. | ||
Arguments: | ||
None | ||
Return Value: | ||
TRUE - if debugger was detected | ||
FALSE - otherwise | ||
--*/ | ||
{ | ||
|
||
PINT_PTR FrontEndHeap = NULL; | ||
|
||
// Get the default process heap. | ||
HANDLE hHeap = GetProcessHeap(); | ||
|
||
// The FrontEndHeap offset of the _HEAP structure | ||
// is found on different locations depending of the OS. | ||
|
||
if (IsWindowsVista() || IsWindows7()) { | ||
#if defined (ENV64BIT) | ||
FrontEndHeap = (PINT_PTR)((CHAR*)hHeap + 0x178); | ||
|
||
#elif defined(ENV32BIT) | ||
FrontEndHeap = (PINT_PTR)((CHAR*)hHeap + 0xd4); | ||
#endif | ||
} | ||
|
||
if (IsWindows8or8PointOne()) { | ||
#if defined (ENV64BIT) | ||
FrontEndHeap = (PINT_PTR)((CHAR*)hHeap + 0x170); | ||
|
||
#elif defined(ENV32BIT) | ||
FrontEndHeap = (PINT_PTR)((CHAR*)hHeap + 0xd0); | ||
#endif | ||
} | ||
|
||
// In Windows 10. the offset changes very often. | ||
// Ignoring it from now. | ||
if (*FrontEndHeap == NULL) { | ||
return TRUE; | ||
} | ||
|
||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
BOOL | ||
LowFragmentationHeap( | ||
VOID | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters