Skip to content

Commit

Permalink
[FEATURE] In ETW mode: enable or disable listeners depending on settings
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Sep 7, 2024
1 parent 9e8ff93 commit e0f32a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
12 changes: 6 additions & 6 deletions etw_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ std::string ipv4FromDword(DWORD ip_dword)
return oss.str();
}

bool ETWstart()
bool ETWstart(ETWProfile& settings)
{
krabs::kernel_trace trace(L"HollowsHunter");
g_initTime = time(NULL);
Expand Down Expand Up @@ -419,11 +419,11 @@ bool ETWstart()
});

bool isOk = true;
trace.enable(tcpIpProvider);
trace.enable(objectMgrProvider);
trace.enable(processProvider);
trace.enable(imageLoadProvider);
trace.enable(virtualAllocProvider);
if (settings.tcpip) trace.enable(tcpIpProvider);
if (settings.obj_mgr) trace.enable(objectMgrProvider);
if (settings.process_start) trace.enable(processProvider);
if (settings.img_load) trace.enable(imageLoadProvider);
if (settings.allocation) trace.enable(virtualAllocProvider);
try {
std::cout << "Starting listener..." << std::endl;
trace.start();
Expand Down
24 changes: 23 additions & 1 deletion etw_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@
// ETW includes
#include "krabsetw/krabs/krabs.hpp"

bool ETWstart();
struct ETWProfile {
bool process_start;
bool img_load;
bool allocation;
bool tcpip;
bool obj_mgr;

ETWProfile(bool _process_start = false, bool _img_load = false, bool _allocation = false, bool _tcpip = false, bool _obj_mgr = false)
: process_start(_process_start), img_load(_img_load), allocation(_allocation), tcpip(_tcpip), obj_mgr(_obj_mgr)
{
}

void setAll()
{
this->process_start = true;
this->img_load = true;
this->allocation = true;
this->tcpip = true;
this->obj_mgr = true;
}
};

bool ETWstart(ETWProfile &settings);

#endif
4 changes: 3 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ t_pesieve_res deploy_scan()
if (g_hh_args.etw_scan)
{
#ifdef USE_ETW
if (!ETWstart()) {
ETWProfile profile;
profile.setAll();
if (!ETWstart(profile)) {
return PESIEVE_ERROR;
}
#else
Expand Down

0 comments on commit e0f32a1

Please sign in to comment.