cobbr / Covenant

Covenant is a collaborative .NET C2 framework for red teamers.

Home Page:https://cobbr.io/Covenant.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] When there are many tasks, smb grunt cannot connect normally

mimidogz opened this issue · comments

Feature Request or Bug
Bug

Describe the feature request or bug
Because of the lack of efficient data query, Memory limitation caused smb grunt cannot be connected normally.

Code location:

List<APIModels.GruntTasking> taskings = _client.GetAllGruntTaskings().ToList();

The following exception may be thrown:
Cannot write more bytes to the buffer than the configured maximum buffer size: 2147483647.
It should be noted that this exception is only when I try {} catch {} the line of code, otherwise it will be caught by the upper layer and eventually become 404 not found.

To Reproduce
Steps to reproduce the behavior:

  1. Generate too much tasks...
  2. Using HTTP grunt to connect SMB grunt

Expected behavior
Only fetch egress grunt tasks

Covenant Server Information:

  • OS: Ubuntu20.04
  • Docker or Native: Native

Additional context
This problem may cause smb grunt to fail to connect, so #224 may also be caused by this problem; in addition to this, it is also recommended that other places take more efficient methods, namely Get only the data you need into the memory.

After modifying the code to these, smb grunt successfully connected:

if (egressGrunt.Id.HasValue)
    taskings = _client.GetGruntTaskings(egressGrunt.Id.Value).ToList();
else
    taskings = _client.GetAllGruntTaskings().ToList();

I am not good at csharp and familiar with this project, so the code is for reference only : ).