# 关于BeaconEye里的一点小bug

BeaconEye这个工具很好通过检查程序heap中的特征来查看CS Payload效果也是非常好，但是这个工具有一个小bug在某些时候会无法查找到CS Payload

这个bug出现的主要是因为如下原因

![](/files/-Mie8mukOdNq_H2y9HRH)

这是它收集heap块的算法看似好像没有啥问题，PEB里找到heap数组和数组个数后就开始循环读取。但是作者没有考虑到另一种情况作者认为每个heap都是只有一个heap段

我们来从windbg查看

![](/files/-Mie8mue2QrBg2G8mr6s)

![](/files/-Mie8mufCgQ_YeJ_ShGt)

![](/files/-Mie8mugy2zGHEJKdXz3)

![](/files/-Mie8muhdfH-bWgpFySD)

问题就出现在这里，很明显这里某个堆中存在两个heap Segment，如果按照作者那样我们就只能收集到3个内存块，如果只是收集到三个内存块还好，怕就怕在如果CS Payload调用malloc分配内存时刚好使用了这第二个segment没有使用第一个那就会造成BeaconEye漏掉了这块内存也就无法扫到特征

我们来试着修复这个问题，先查看\_HEAP结构体

![](/files/-Mie8muiL3t3-Tm9fIpd)

![](/files/-Mie8muji7lfni4laVBS)

这是一个双向链表连接着所有的heap Segment，所以应该去遍历这个链表（忽视这个代码的垃圾吧）\
原先的遍历代码有问题这里我直接引用D\_infinite师傅的代码了

![](/files/-MiyGc1zWFu342cXy9eR)

然后原先扫不到的现在就能扫到了

同时D\_infinite师傅也发现一个新的问题之前堆块并未遍历导致如果批量分配大量的heap会产生新的绕过，这块并不好搞因为堆的机制比较复杂而且部分地方heap结构是加密的最好的办法是扫全内存，因为heap实现本身就微软内部的事

D\_infinite师傅的文章：<https://mp.weixin.qq.com/s/_gSPWVb1b-xuvhU6ynmw0Q>


---

# 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-gong-ji-fang-yu/untitled-1.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.
