# 红队之外网定向打点

## **基础设施架构设计部署**

* 普通架构：红队人员--》teamserver cs--》目标机 缺点：功能未分离、无潜伏通道、回连日志多、灵活性较低
* 演进架构：DNS/HTTP/HTTPS分离server tips：1\~2cpu 2G内存 10G硬盘，回连数不超过5台，潜伏通道（根据实际目标环境优先）
* 完整架构：域名和IP（VPS）teamserver（CS）前置机（redictor） CS -》teamservers 1/2/3/... 前置层（SMTP/PAYLOAD/C2/隐蔽C2）

## **选择域名**

* 抢注过期域名 expireddomains.net DELETE DOMAIN
  * tips1: 不要包含世界大厂和杀毒厂商相关的域名，以及和目标相关的域名
  * tips2：注册目标相关区域常见的域名，记得开隐私保护
  * 其他：[www.freshdrop.com](https://wiki.iredteam.cn/prophase-interaction/c2-preparation/c2-summary/www.freshdrop.com) [www.domcop.com](https://wiki.iredteam.cn/prophase-interaction/c2-preparation/c2-summary/www.domcop.com)
  * tips3：检查域名是否被分类，金融、医疗、电商、航空、旅游 great
  * tips4：去VT、微步检查，域名是否被标黑
  * tips5：举报滥用规则仔细阅读（freenom 慎用）
* 培养域名（养号）
  * 搭建正常域名，提交至各安全厂商给站点分类
  * tips1：把域名A记录解析到大厂ip，使用时候再解析到C2，不用时候解析回大厂ip
  * tips2：VT 自评， alex 自评
* 域名解析检测
* 域名分类检测
  * domaincheck：
* IP检测
  * 外网IP，通过情报站看是否被标黑
  * 使用CDN隐藏真实IP（部分安全厂商会拦截CDN IP）
* 借鸡生蛋，
  * subdomain takeover：高信誉域名A解析B -》
  * 高信誉肉鸡做前置转发
* C2工具
  * 自定义流量特征：DNS/HTTP/HTTPS/SMB和TCP
  * Payload加载流程：shellcode/Loader/Stageless/beacon
  * DNS：如果用到dns通道默认参数必须修改（容易被设备检测），不要用DNS做数据通道
  * HTTP（S）：不要在uri中的文件后缀设置js、css等静态文件，效果：付费证书>免费证书>自签名证书 （Let's Encrypt 免费 3个月过期，开自动续）
  * CS 3.14
* Redirector

  * Office365、Pastebin、Slack、Facebook、Dropbox、Gmail、Twitter..
  * 缺点：需要硬编码到第三方服务
  * 第三方服务用作C2相关资源汇总

  ```
  https://pentestarmoury.com/2017/07/19/s3-buckets-for-good-and-evil/ 
  https://rhinosecuritylabs.com/aws/hiding-cloudcobalt-strike-beacon-c2-using-amazon-apis/                       
  https://github.com/daniel-infosec/wikipedia-c2                       
  https://unit42.paloaltonetworks.com/aggah-campaign-bit-ly-blogspot-and-pastebin-used-for-c2-in-large-scale-campaign                       https://www.harmj0y.net/blog/powershell/command-and-control-using-active-directory/                       
  https://blog.netspi.com/databases-and-clouds-sql-server-as-a-c2/                       
  https://outflank.nl/blog/2017/09/17/blogpost-cobalt-strike-over-external-c2-beacon-home-in-the-most-obscure-ways                       https://labs.mwrinfosecurity.com/blog/tasking-office-365-for-cobalt-strike-c2                       
  https://github.com/maldevel/canisrufus                       
  https://unit42.paloaltonetworks.com/darkhydrus-delivers-new-trojan-that-can-use-google-drive-for-c2-communications                       https://github.com/byt3bl33d3r/gcat                       
  https://github.com/maldevel/gdog                       
  https://www.welivesecurity.com/wp-content/uploads/2019/05/ESET-LightNeuron.pdf                       
  https://github.com/bkup/SlackShell                       
  https://github.com/j3ssie/c2s                       
  https://github.com/praetorian-code/slack-c2bot                       
  https://github.com/microsoft/skype-dev-bots                       
  https://github.com/PaulSec/twittor                       
  https://blog.talosintelligence.com/2017/04/introducing-rokrat.html                       
  https://www2.fireeye.com/rs/848-DID-242/images/rpt-apt29-hammertoss.pdf                       
  https://github.com/woj-ciech/Social-media-c2
  ```

  * Google App Engine| Amazon |Azure|Aliyun CDN
  * 可见层：DNS、TLS
  * 不可见层：HTTPS
  * URL（高信誉） SNI（高信誉） HOST(C2)
  * <https://github.com/vysecurity/DomainFrontingLists>
  * 代替方案：HTTP pipelining（ >http 1.1 ）
  * 和 domain fronting 效果相同
  * 利用同一个tcp连接发送不同的host的http包
  * tips：good domain + bad domain 包一层同时发过去
  * 建议使用多个判断过来请求，拒绝使用默认uri，对抗全网C2扫描
  * 仅允许目标相关IP访问，对抗云沙盒
  * 限定访问时间段，只在某个时间段请求payload
  * 不要把非payload的uri重定向到google等高信誉域名
  * 建议：在[www.aaa.com](https://wiki.iredteam.cn/prophase-interaction/c2-preparation/c2-summary/www.aaa.com)搭建来养域名，使用c2.aaa.com的二级域名做C2
  * DNS socat|iptables|ssh（tmux和screen选一个）
  * Apache|Nginx
  * Tips：
  * Domain Fronting（隐藏IP、域名的方式）
  * 第三方服务用作C2
* 邮件钓鱼（SMTP）
  * 域名：同C2域名选择
  * 高信誉的邮件发送者：Mailchimp、Sendgrid
  * 正确配置SPF、DKIM\DMARC
  * SSL证书
  * 发送时间和频率
  * 一键部署
  * 钓鱼邮件框架：Gophish (<https://github.com/gophish/gophish>)
* 隐蔽性和安全性
  * 解决方案：V2ray + Nginx + CLoudflare + Freenom+ Websocket 搭建代理
  * 权限最小化：使用iptalbes限定组件通讯，SSH进行端口转发
  * Teamserver：限制端口只能本地访问，限制beacon监听端口只能redirector访问
  * Tips：VPS容易被GFW拦截？
* 基础设施监控系统
  * 记录完整日志，设置告警
  * 自动化部署 LuWu（<https://github.com/QAX-A-Team/LuWu>）
  * 日志中心

## 钓鱼样本制作

* 钓鱼邮件类型
  * 恶意的chm文档：利用easy，但目前比较难过杀软，免杀效果差
  * 带有恶意宏代码的office文档：易于混淆（结合图片模糊之类），但需要手动开宏，进程链可疑
  * 白加黑钓鱼：利用带签名的白程序，通过DLL劫持的方案加载恶意DLL；比较容易过AV，但需要解压执行
  * LNK文件钓鱼：链接对象是Powershell，进程链完善
  * PPT钓鱼样本：PPT超链接，弹出“安全声明”，不用启动宏，但必须全屏播放，启用才执行；不推荐使用
  * 漏洞利用的钓鱼邮件：效率高，同样成本也高
* 写工具自动化生成恶意lnk，关键函数：
  * IShellLink::SetIconLocation()
  * IShellLink::SetShowCmd() 窗口显示
  * IShellLink::SetArguments()
  * IShellLink::SetPath()
  * ...
* LNK钓鱼邮件制作
  * 短文件名 POWERS\~1.EXE
  * 代码混淆 参考赛门铁克的paper
  * 安全类进程检测
  * 遍历进程，获取进程对应的版权信息，与黑名单列表比对
  * 优点：升级版本也不变，通用
  * 进程名检测
  * 窗口标题检测
  * 虚拟机-取证工具-杀软检测-调试器
  * 常规手法
  * 新姿势
  * 如何根据PID获取进程的全路径：ProcessExplorer
  * x86不太可行，x64可以
  * 绕过PCHunter 0RING hook
  * 检测后行为，通知攻击者，及时善后处理
  * 联网下载Word文档
  * 本地释放Word文档
  * 协议内容还原：tcp、http、smtp
  * 文件内容还原：office、pdf、zip
  * 加壳程序还原：upx
  * 加密算法数据还原：base64
  * (New-Object System.Net.WebClient).DownloadFile(url, file\_path);
  * 数据还原引擎
  * 尾部可以追加任意大小的word、PE、PowerShell
  * select -last 1 定位到最后一个对象，以“\n”划分对象
  * select -index 1 也可以
  * ARGUMENT用于LNK中存储命令行参数
  * StringData结构，CountCharacters
  * IShellLink::SetArguments()
  * 塞入数据的最大值是 explorer.exe 对命令行参数长度的限制
  * 实测得出 0x7FC2（31KB）
  * 将Word塞到COMMAND\_LINE\_ARGUMENTS
  * 将Word塞到lnk文件的尾部（推荐使用）
  * 钓鱼简历的编写：内容可选浮夸，让HR打开看完后大概率删除，防止提给技术人员
  * LNK图标的显示：改成各个系统都能默认显示的通用图标
  * 如何隐藏行为：SetShowCmd() 最小化窗口
  * Word文档存放：
  * 杀软对抗


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.iredteam.cn/prophase-interaction/c2-preparation/c2-summary/hong-dui-zhi-wai-wang-ding-xiang-da-dian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
