# Beacon加载执行过程

前面粗略的分析了一下stager现在我们来动态调试一下，我也不用啥分析模拟工具了，就一小段也没混淆反调试，直接x32dbg手工走起（随意用啥都行看个人喜好）

shellcode转成exe直接x32dbg打开

![](/files/-MI37KxfURRhDVTiYUcY)

断在系统断点后直接F9来到shellcode入口点

![](/files/-MI37g3flXwyLI5bkuN9)

F7几次来到第一个call ebp看堆栈我们可以看到loadlibrarya api的哈希值第二个就是loadlibrarya函数的参数wininet，很明显是用来加载wininet.dll的，因为后面需要用到wininet.dll里的函数所以必须要先加载wininet.dll

![](/files/-MI3aBwl7-7m3ZvT6__h)

msf和cs的shellcode基本都是这样来调用win api的有兴趣的可以跟一下，我这里直接向下走到VirtualAlloc

![调用VirtualAlloc分配内存可写可读可执行属性](/files/-MI4I1xIXxlC6YoPlyeM)

![调用InternetReadFile循环读取stage到VirtualAlloc分配的空间中](/files/-MI4IS8PnU7cuiTpGpBd)

读取完成后直接ret到stage(shellcode)去执行

![](/files/-MI4Ji-8I_gtgHQGhB8X)

开始运行接收到的stage(shellcode)

![](/files/-MI4PmoSo7VrVCUfOtxG)

跳过来后，还是一个call pop 将call后面的地址放到ebx里

![这里就是循环xor解密我写有注释可以看一下](/files/-MI4PvFMEHGA1MWtfH7c)

![解密完成准备跳转去执行Beacon.dll（可以看到内存中的4D5A一个明显的PE头特征）](/files/-MI4Qa6P5YurX1qPaAHN)

![跳转到Beacon.dll头开始执行](/files/-MI4QmX-W-kFVSFBRmlb)

这个解密出来的stage其实就是Beacon.dll（一个修补过的反射dll）。我们把东西dump出来重建一下看看

![dump记得重建一下PE，dump大小源自上面解密过程中的解密长度](/files/-MI4YpnZBu86FNDdPJ1z)

dump完了用PE工具查看一下

![](/files/-MI4Z8dZCWYIwILhrJDS)

![可以看到两个非常明显的特征](/files/-MI4ZDEr-nlFsPd3-53q)

这个beacon.dll就是核心所在，前面所有的工作都是为了加载执行beacon.dll这个反射dll

关于反射dll的原理请自行谷歌，**反射dll修补技术**可以看我曾经开源的一个项目我这里就不在做详细讲解了\
仅供参考写的比较垃圾 <https://wbglil.github.io/2020/03/27/%E5%85%B3%E4%BA%8E%E5%8F%8D%E5%B0%84dll%E4%BF%AE%E8%A1%A5/>

基本上这块就写这么多吧，写的有些匆忙


---

# 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/beacon-jia-zai-zhi-hang-guo-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.
