From 8ea0c49b7a8375305279b5f019534393b3610f3b Mon Sep 17 00:00:00 2001 From: dsFejerA <8791818+dsFejerA@users.noreply.github.com> Date: Sun, 28 Dec 2025 19:56:28 +0200 Subject: [PATCH 1/2] include regex --- include/Common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Common.h b/include/Common.h index a4317b8..2794316 100644 --- a/include/Common.h +++ b/include/Common.h @@ -25,5 +25,6 @@ #include #include #include "Log.h" +#include #define VERSION "2.10.0" From f6c3ad7e94b7ee2754a83ea9f85f9e37617e09e3 Mon Sep 17 00:00:00 2001 From: dsFejerA <8791818+dsFejerA@users.noreply.github.com> Date: Sun, 28 Dec 2025 19:56:59 +0200 Subject: [PATCH 2/2] censoring ipconfig output --- src/Diag.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Diag.cpp b/src/Diag.cpp index e1b497a..cf70929 100644 --- a/src/Diag.cpp +++ b/src/Diag.cpp @@ -674,7 +674,39 @@ void Diag::GetDir ( std::string directory ) Log::WriteFileToLog ( files[FILE_TEMP].c_str(), ( directory + " directory listing" ) ); // write the result to the log file with a description } +bool CensorIPv6InFile(const std::string& filePath) +{ + std::ifstream in(filePath, std::ios::in | std::ios::binary); + if (!in.is_open()) + { + Log::WriteStringToLog("**** CensorIPv6InFile: Unable to open file for reading"); + return false; + } + + std::stringstream buffer; + buffer << in.rdbuf(); + std::string content = buffer.str(); + in.close(); + + // It's enough for ipconfig output + static const std::regex ipv6Regex( + R"(\b([0-9a-fA-F]{1,4}:){2,7}[0-9a-fA-F]{1,4}\b)" + ); + + content = std::regex_replace(content, ipv6Regex, "[IPv6 CENSORED]"); + + std::ofstream out(filePath, std::ios::out | std::ios::binary | std::ios::trunc); + if (!out.is_open()) + { + Log::WriteStringToLog("**** CensorIPv6InFile: Unable to open file for writing"); + return false; + } + out << content; + out.close(); + + return true; +} DWORD Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWORD maxTimeMs ) { Log::WriteDividerToLog(); @@ -757,7 +789,12 @@ DWORD Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWO } CloseHandle( h ); - + // Censor IPv6 ONLY if command contains ipconfig + if (command.find("ipconfig") != std::string::npos || + command.find("IPCONFIG") != std::string::npos) + { + CensorIPv6InFile(files[FILE_TEMP]); + } if ( outputType != OUTPUT_UNICODE ) { Log::WriteFileToLog ( files[FILE_TEMP], ss.str() ); // write the result to the log file with the passed command argument as a description