# Payload生成分析

## 分阶段payload

![](/files/-MFYgUjmOnqxdGSOdpZm)

aggressor\dialogs\WindowsExecutableDialog.class

![生成stager shellcode](/files/-MFYgMWscRzAARkQEjRt)

shellcode具体的生成和混淆过程可以自己跟一下getPayloadStrager这个方法(后边有一个混淆的算法)

![](/files/-MFYgz6gVgcex0DneLx_)

把生成好的stager shellcode根据生成类型嵌入到不同的PE文件中然后保存到文件

![](/files/-MFYmKay37W3eSaCheao)

![](/files/-MFZ8vUPRBxQjvARs_-1)

读取PE资源添加shellcode(这里还有一个试用版遗留问题)然后修正PE校验码最后保存到文件

这里就是被替换的地方

![大小一共是1024个字节对于一个stager是绰绰有余](/files/-MFZGmB_47ZgTvq9Tz-h)

修补前后对比

![PE校验码](/files/-MFZOIAP8PdPoJo60N8n)

![shellcode填充](/files/-MFZO4ZfYHaS5XpgcP_p)

其他分阶段payload生成过程大同小异没啥区别包括

![](/files/-MFZLr7Qy_O7N_BJ6RHy)

Payload Generator生成的都是stager shellcode，基本也是这个过程只不过没有嵌入到PE中

## 无阶段Payload生成过程

![](/files/-MFZzmsplxxGP50sUHzN)

无阶段payload生成过程基本上也没太大区别

![](/files/-MFZQh2Qkbt9kAlUhhWL)

![](/files/-MFZSmzWiPuE0BZg9qEe)

![](/files/-MFZUr6VdUh1-g5dN3XV)

![](/files/-MFZWdiaZM3h3f6Q5EME)

![](/files/-MF_24bumZo6n07ntJmT)

大致流程就是读取Beacon.dll，解密完成进行修补然后使用相同的方法将其嵌入到PE中。

![对比修补前后右为原始Beacon.dll，左为修补后](/files/-MF_01WKS_H4Q8s8FFlx)

比对修补前后时，导出格式请选择RAW格式。整体来说Beacon修补了三个地方**PE头**，**Malleable C2通信规则**，**Malleable C2后渗透规则**

4.x与3.x不同的是多了一个资源解密，在3.x时所有资源都是放在resources文件夹内，在4.x后Cobalt Strike将加密的资源都放在了sleeve文件夹内，还有一些不同的是，无阶段payload生成增加了powershell和raw两种格式。至于具体怎么修补通信规则和后渗透规则的自己读一下相关代码吧


---

# 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://wbglil.gitbook.io/cobalt-strike/cobalt-strike-yuan-li-jie-shao/payload-sheng-cheng.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.
