#include "PanoptesYara.h"
#include <string>
#include <iostream>
#include <stdexcept>
Go to the source code of this file.
|
| BOOL APIENTRY | DllMain (HMODULE module, DWORD dllAction, LPVOID lpReserved) |
| | The main entry point for the DLL.
|
| PANO_API int | PanoBind (int ContainerPort) |
| | Bind to the Panoptes Service by sending a hello message containing the extensibility type and the port of the container that the extensibility is running in.
|
| PANO_API bool | PanoEntry (PeScan *data) |
| | The entry point for the YARA extensibility.
|
| PANO_API bool | PanoUnbind () |
| | Unbind from the Panoptes Service by freeing the DLL.
|
◆ DllMain()
| BOOL APIENTRY DllMain |
( |
HMODULE | module, |
|
|
DWORD | dllAction, |
|
|
LPVOID | lpReserved ) |
The main entry point for the DLL.
- Parameters
-
| module | The module handle |
| dllAction | The action to take |
| lpReserved | Reserved |
- Returns
Definition at line 11 of file dllmain.cpp.
12{
13 switch (dllAction)
14 {
15 case DLL_PROCESS_ATTACH:
16
17 break;
18 case DLL_THREAD_ATTACH:
19
20 break;
21 case DLL_THREAD_DETACH:
22
23 break;
24 case DLL_PROCESS_DETACH:
25 break;
26 }
27 return TRUE;
28}
◆ PanoBind()
| PANO_API int PanoBind |
( |
int | ContainerPort | ) |
|
Bind to the Panoptes Service by sending a hello message containing the extensibility type and the port of the container that the extensibility is running in.
- Parameters
-
| ContainerPort | The port of the container that the extensibility is running in |
- Returns
- The container port
Definition at line 34 of file dllmain.cpp.
35{
38 return 0;
39 }
40
41 return ContainerPort;
42}
@ EXTENSIBILITY_TYPE_YARA
The Panoptes Service client used to talk to the service over gRPC.
bool Hello(ExtensibilityType extensibilityType, std::string port)
The Hello function sends a Hello message to the Panoptes main service from the container.
References EXTENSIBILITY_TYPE_YARA, PanoptesServiceClient::Hello(), and PANO_API.
◆ PanoEntry()
The entry point for the YARA extensibility.
- Parameters
-
| data | The information about the file to be scanned |
- Returns
- True if the scan was successful, false otherwise
Definition at line 47 of file dllmain.cpp.
48{
49 std::string rules = "rules.pkg";
50
51 std::vector<std::string> scanDataResults;
52 try {
54 scanDataResults = yaraScan.YaraScanFile(data->
PePath);
55 }
56 catch (const std::exception& e) {
57
58
59 std::cerr <<
"YARA scan of " << data->
PePath <<
" failed: " << e.what() << std::endl;
60 return false;
61 }
63
66 return false;
67 }
68
69 return true;
70}
SignatureInfo VerifyFileSignature(const std::string &PathToFile)
Verify the Authenticode signature of a file using WinVerifyTrust. The embedded signature is checked f...
bool SendResults_Yara(std::string PePath, std::string FileHash, DWORD ProcessId, std::string YaraRulesPath, INT MatchRules, std::vector< std::string > DetectedRules)
The YaraScanner class that is used to scan a file using YARA rules.
The result of verifying a file's Authenticode signature with WinVerifyTrust.
References PeScan::FileHash, PANO_API, PeScan::PePath, PanoptesServiceClient::SendResults_Yara(), VerifyFileSignature(), and YaraScanner::YaraScanFile().
◆ PanoUnbind()
Unbind from the Panoptes Service by freeing the DLL.
- Returns
- True if the unbind was successful, false otherwise
Definition at line 74 of file dllmain.cpp.
75{
76 HMODULE hModule = GetModuleHandleA("PanoptesYara.dll");
77 if (hModule != NULL) {
78 FreeLibraryAndExitThread(hModule, 0);
79 }
80 return true;
81}
References PANO_API.