Skip to content

Commit

Permalink
[FEATURE] In ETW: print the destination IP of the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Sep 2, 2024
1 parent cf83f5b commit ee2dd92
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion etw_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ void printAllProperties(krabs::parser &parser)
}
}

std::string ipv4FromDword(DWORD ip_dword)
{
std::ostringstream oss;
unsigned int octet1 = (ip_dword >> 24) & 0xFF;
unsigned int octet2 = (ip_dword >> 16) & 0xFF;
unsigned int octet3 = (ip_dword >> 8) & 0xFF;
unsigned int octet4 = ip_dword & 0xFF;

oss << ip_dword & 0xFF << '.' << octet3 << '.' << octet2 << '.' << octet1;
return oss.str();
}

bool ETWstart()
{
krabs::kernel_trace trace(L"HollowsHunter");
Expand Down Expand Up @@ -374,9 +386,17 @@ bool ETWstart()
krabs::parser parser(schema);
std::uint32_t pid = parser.parse<std::uint32_t>(L"PID");
if (!isWatchedPid(pid)) return;

krabs::ip_address daddr = parser.parse<krabs::ip_address>(L"daddr");

if (!g_hh_args.quiet) {
const std::lock_guard<std::mutex> stdOutLock(g_stdOutMutex);
std::wcout << std::dec << pid << " : " << schema.task_name() << " : " << schema.opcode_name() << "\n";
std::wcout << std::dec << pid << " : " << schema.task_name() << " : " << schema.opcode_name();
if (!daddr.is_ipv6) {
long ipv4 = daddr.v4;
std::cout << " -> " << ipv4FromDword(ipv4);
}
std::wcout <<"\n";
}
runHHScan(pid);
});
Expand Down

0 comments on commit ee2dd92

Please sign in to comment.