Created
August 22, 2024 10:26
-
-
Save p4yl0ad/ae718feb49f09dc4d8e4628ac57ae01c to your computer and use it in GitHub Desktop.
cl /EHsc /ZW blockdlls.cpp /link /SUBSYSTEM:CONSOLE
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 <iostream> | |
#include <Windows.h> | |
int main( | |
int argc, | |
char *argv[] | |
){ | |
PROCESS_INFORMATION pi = {}; | |
STARTUPINFOEXA si = {}; | |
SIZE_T attributeSize = 0; | |
InitializeProcThreadAttributeList(NULL, 1, 0, &attributeSize); | |
PPROC_THREAD_ATTRIBUTE_LIST attributes = (PPROC_THREAD_ATTRIBUTE_LIST)HeapAlloc( | |
GetProcessHeap(), | |
HEAP_ZERO_MEMORY, | |
attributeSize | |
); | |
InitializeProcThreadAttributeList( | |
attributes, | |
1, | |
0, | |
&attributeSize | |
); | |
DWORD64 policy = PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_ALWAYS_ON; | |
UpdateProcThreadAttribute( | |
attributes, | |
0, | |
PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY, | |
&policy, | |
sizeof(DWORD64), | |
NULL, | |
NULL | |
); | |
si.lpAttributeList = attributes; | |
// CreateProcessA(NULL, (LPSTR)"C:\\Windows\\System32\\notepad", NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, &si.StartupInfo, &pi); | |
CreateProcessA( | |
NULL, | |
(LPSTR)argv[1], | |
NULL, | |
NULL, | |
TRUE, | |
EXTENDED_STARTUPINFO_PRESENT, | |
NULL, | |
NULL, | |
&si.StartupInfo, | |
&pi | |
); | |
HeapFree( | |
GetProcessHeap(), | |
HEAP_ZERO_MEMORY, | |
attributes | |
); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment