Created
August 11, 2021 18:07
-
-
Save Mr-Un1k0d3r/f0ea9d3c298950f2c721646012f0213d to your computer and use it in GitHub Desktop.
spawn an invisible process
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
// To compile: gcc64.exe run.c -o run.exe | |
// To run: run.exe cmd.exe "/c whoami" | |
#include <Windows.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
CHAR cDesktop[] = "hiddendesktop"; | |
HDESK hDesk = CreateDesktop(cDesktop, NULL, NULL, DF_ALLOWOTHERACCOUNTHOOK, GENERIC_ALL, NULL); | |
printf("Desktop HANDLE 0x%08x\n", hDesk); | |
CHAR *process = argv[0]; | |
CHAR *args = argv[1]; | |
STARTUPINFO si; | |
PROCESS_INFORMATION pi; | |
ZeroMemory(&si, sizeof(STARTUPINFO)); | |
si.cb = sizeof(STARTUPINFO); | |
si.lpDesktop = cDesktop; | |
// CREATE_NEW_CONSOLE is used on purpose to show that the process is not visible | |
if(CreateProcess(process, args, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) { | |
printf("Process spawned.\n"); | |
} else { | |
printf("Failed to spawn. Error %d\n", GetLastError()); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment