Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
PanoptesYara.h File Reference
#include "ExtensibilityCore.h"
#include <vector>
#include "yara_x.h"

Go to the source code of this file.

Classes

struct  SignatureInfo
 The result of verifying a file's Authenticode signature with WinVerifyTrust. More...
class  PanoptesServiceClient
 The Panoptes Service client used to talk to the service over gRPC. More...
class  YaraScanner
 The YaraScanner class that is used to scan a file using YARA rules. More...
struct  YaraScanner::ScanData
 The data that is sent to the Panoptes Service. More...

Macros

#define VERSION   "1.0.0"

Functions

SignatureInfo VerifyFileSignature (const std::string &PathToFile)
 Verify the Authenticode signature of a file using WinVerifyTrust. The embedded signature is checked first, falling back to the system catalogs if the file has none.

Macro Definition Documentation

◆ VERSION

#define VERSION   "1.0.0"

Definition at line 8 of file PanoptesYara.h.

Function Documentation

◆ VerifyFileSignature()

SignatureInfo VerifyFileSignature ( const std::string & PathToFile)

Verify the Authenticode signature of a file using WinVerifyTrust. The embedded signature is checked first, falling back to the system catalogs if the file has none.

Parameters
PathToFileThe path to the file
Returns
The signature information

Definition at line 175 of file signature.cpp.

176{
177 SignatureInfo info;
178 std::wstring filePath = ToWide(PathToFile);
179 if (filePath.empty()) {
180 return info;
181 }
182
183 WINTRUST_FILE_INFO fileInfo = {};
184 fileInfo.cbStruct = sizeof(fileInfo);
185 fileInfo.pcwszFilePath = filePath.c_str();
186
187 WINTRUST_DATA trustData = {};
188 trustData.dwUnionChoice = WTD_CHOICE_FILE;
189 trustData.pFile = &fileInfo;
190
191 LONG status = RunWinVerifyTrust(trustData, info.signer);
192 switch (status) {
193 case TRUST_E_NOSIGNATURE:
194 case TRUST_E_SUBJECT_FORM_UNKNOWN:
195 case TRUST_E_PROVIDER_UNKNOWN:
196 // No embedded signature, check if the file is signed through a catalog
197 info.signer.clear();
198 if (!VerifyCatalogSignature(filePath, info)) {
199 info.trustStatus = status;
200 }
201 break;
202 default:
203 info.isSigned = true;
204 info.trustStatus = status;
205 info.trusted = status == ERROR_SUCCESS;
206 break;
207 }
208
209 return info;
210}
The result of verifying a file's Authenticode signature with WinVerifyTrust.
bool trusted
True if WinVerifyTrust reported the signature as valid and trusted.
std::string signer
The signing certificate's display name (UTF-8), empty if unsigned.
LONG trustStatus
The WinVerifyTrust result, 0 if trusted.
bool isSigned
True if the file has an embedded or catalog signature.

References SignatureInfo::isSigned, SignatureInfo::signer, SignatureInfo::trusted, and SignatureInfo::trustStatus.

Referenced by PanoEntry(), Yara::TEST(), Yara::TEST(), and Yara::TEST().