Created
June 14, 2021 13:37
-
-
Save bats3c/956bafa22e349ca03dc40ac683825455 to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
#include <windows.h> | |
#include <winternl.h> | |
#define DLL_TO_FAKE_LOAD L"\\??\\C:\\windows\\system32\\calc.exe" | |
BOOL FakeImageLoad() | |
{ | |
HANDLE hFile; | |
SIZE_T stSize = 0; | |
NTSTATUS ntStatus = 0; | |
UNICODE_STRING objectName; | |
HANDLE SectionHandle = NULL; | |
PVOID BaseAddress = NULL; | |
IO_STATUS_BLOCK IoStatusBlock; | |
OBJECT_ATTRIBUTES objectAttributes = { 0 }; | |
RtlInitUnicodeString( | |
&objectName, | |
DLL_TO_FAKE_LOAD | |
); | |
InitializeObjectAttributes( | |
&objectAttributes, | |
&objectName, | |
OBJ_CASE_INSENSITIVE, | |
NULL, | |
NULL | |
); | |
ntStatus = NtOpenFile( | |
&hFile, | |
0x100021, | |
&objectAttributes, | |
&IoStatusBlock, | |
5, | |
0x60 | |
); | |
ntStatus = NtCreateSection( | |
&SectionHandle, | |
0xd, | |
NULL, | |
NULL, | |
0x10, | |
SEC_IMAGE, | |
hFile | |
); | |
ntStatus = NtMapViewOfSection( | |
SectionHandle, | |
(HANDLE)0xFFFFFFFFFFFFFFFF, | |
&BaseAddress, | |
NULL, | |
NULL, | |
NULL, | |
&stSize, | |
0x1, | |
0x800000, | |
0x80 | |
); | |
NtClose(SectionHandle); | |
} | |
void main() | |
{ | |
for (INT i = 0; i < 10000; i++) | |
{ | |
FakeImageLoad(); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment