Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
Yara Namespace Reference

Classes

class  YaraScanTest

Functions

 TEST_F (YaraScanTest, ScanNotePad)
 TEST_F (YaraScanTest, ScanEicar)
 TEST_F (YaraScanTest, MissingFileThrowsAndScannerStillWorks)
 TEST (SignatureTest, NotePadIsTrusted)
 TEST (SignatureTest, EmbeddedSignatureIsTrusted)
 TEST (SignatureTest, EicarIsUnsigned)

Function Documentation

◆ TEST() [1/3]

Yara::TEST ( SignatureTest ,
EicarIsUnsigned  )

Definition at line 64 of file Test_PanoptesYara.cpp.

64 {
66 EXPECT_FALSE(info.isSigned);
67 EXPECT_FALSE(info.trusted);
68 EXPECT_FALSE(info.catalogSigned);
69 EXPECT_TRUE(info.signer.empty());
70 }
SignatureInfo VerifyFileSignature(const std::string &PathToFile)
Verify the Authenticode signature of a file using WinVerifyTrust. The embedded signature is checked f...
#define EICAR_PATH
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.
bool isSigned
True if the file has an embedded or catalog signature.
bool catalogSigned
True if the signature came from a catalog file rather than being embedded.

References SignatureInfo::catalogSigned, EICAR_PATH, SignatureInfo::isSigned, SignatureInfo::signer, SignatureInfo::trusted, and VerifyFileSignature().

◆ TEST() [2/3]

Yara::TEST ( SignatureTest ,
EmbeddedSignatureIsTrusted  )

Definition at line 50 of file Test_PanoptesYara.cpp.

50 {
51 // MpSigStub.exe ships with Defender and has an embedded signature
52 const char* path = "C:\\Windows\\System32\\MpSigStub.exe";
53 if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES) {
54 GTEST_SKIP() << "MpSigStub.exe is not present";
55 }
56
58 EXPECT_TRUE(info.isSigned);
59 EXPECT_TRUE(info.trusted);
60 EXPECT_FALSE(info.catalogSigned);
61 EXPECT_FALSE(info.signer.empty());
62 }

References SignatureInfo::catalogSigned, SignatureInfo::isSigned, SignatureInfo::signer, SignatureInfo::trusted, and VerifyFileSignature().

◆ TEST() [3/3]

Yara::TEST ( SignatureTest ,
NotePadIsTrusted  )

Definition at line 41 of file Test_PanoptesYara.cpp.

41 {
42 SignatureInfo info = VerifyFileSignature("C:\\Windows\\System32\\notepad.exe");
43 EXPECT_TRUE(info.isSigned);
44 EXPECT_TRUE(info.trusted);
45 EXPECT_TRUE(info.catalogSigned);
46 EXPECT_EQ(info.trustStatus, ERROR_SUCCESS);
47 EXPECT_FALSE(info.signer.empty());
48 }
LONG trustStatus
The WinVerifyTrust result, 0 if trusted.

References SignatureInfo::catalogSigned, SignatureInfo::isSigned, SignatureInfo::signer, SignatureInfo::trusted, SignatureInfo::trustStatus, and VerifyFileSignature().

◆ TEST_F() [1/3]

Yara::TEST_F ( YaraScanTest ,
MissingFileThrowsAndScannerStillWorks  )

Definition at line 34 of file Test_PanoptesYara.cpp.

34 {
35 for (int i = 0; i < 3; i++) {
36 EXPECT_THROW(yaraScan->YaraScanFile("C:\\does\\not\\exist.exe"), std::runtime_error);
37 }
38 EXPECT_EQ(yaraScan->YaraScanFile("C:\\Windows\\System32\\notepad.exe").size(), 0);
39 }

◆ TEST_F() [2/3]

Yara::TEST_F ( YaraScanTest ,
ScanEicar  )

Definition at line 27 of file Test_PanoptesYara.cpp.

27 {
28 std::vector<string> result = yaraScan->YaraScanFile(EICAR_PATH);
29 EXPECT_GT(result.size(), 0);
30 }

References EICAR_PATH.

◆ TEST_F() [3/3]

Yara::TEST_F ( YaraScanTest ,
ScanNotePad  )

Definition at line 22 of file Test_PanoptesYara.cpp.

22 {
23 std::vector<string> result = yaraScan->YaraScanFile("C:\\Windows\\System32\\notepad.exe");
24 EXPECT_EQ(result.size(), 0);
25 }