Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
dllmain.cpp
Go to the documentation of this file.
1#include "PanoptesYara.h"
2#include <string>
3
9BOOL APIENTRY DllMain(HMODULE module, DWORD dllAction, LPVOID lpReserved)
10{
11 switch (dllAction)
12 {
13 case DLL_PROCESS_ATTACH:
14 //DisableThreadLibraryCalls(module);
15 break;
16 case DLL_THREAD_ATTACH:
17 // Code to run when a thread is created
18 break;
19 case DLL_THREAD_DETACH:
20 // Code to run when a thread ends
21 break;
22 case DLL_PROCESS_DETACH:
23 break;
24 }
25 return TRUE;
26}
27
32extern "C" PANO_API int PanoBind(int ContainerPort)
33{
35 if (!client.Hello(ExtensibilityType::EXTENSIBILITY_TYPE_YARA, ContainerPort)) {
36 return 0;
37 }
38
39 return ContainerPort;
40}
41
46extern "C" PANO_API bool PanoEntry(PeScan* data, MemScan* mem_data)
47{
48 std::string rules = "rules.pkg";
49
50 YaraScanner yaraScan = YaraScanner::YaraScanner(rules.c_str());
51 std::vector<std::string> scanDataResults = yaraScan.YaraScanFile(data->PePath);
52
54 if (!client.SendResults_Yara(data->PePath, data->FileHash, scanDataResults)) {
55 return false;
56 }
57
58 return true;
59}
60
63extern "C" PANO_API bool PanoUnbind()
64{
65 HMODULE hModule = GetModuleHandleA("PanoptesYara.dll");
66 if (hModule != NULL) {
67 FreeLibraryAndExitThread(hModule, 0);
68 }
69 return true;
70}
#define PANO_API
@ EXTENSIBILITY_TYPE_YARA
Panoptes Service Client that is used to communicate with the Panoptes Service via.
bool SendResults_Yara(std::string PePath, std::string FileHash, DWORD ProcessId, std::string YaraRulesPath, INT MatchRules, std::vector< std::string > DetectedRules)
bool Hello(ExtensibilityType extensibilityType, std::string port)
The Hello function sends a Hello message to the Panoptes main service from the container.
The YaraScanner class that is used to scan a file using YARA rules.
YaraScanner(const char *Rules)
Intializes Yara memory and attempts to load supplied yara rules.
Definition yara-scan.cpp:37
std::vector< std::string > YaraScanFile(std::string PathToFile)
Scan a file using YARA rules.
Definition yara-scan.cpp:81
ExtensibilityCore::PanoBindPtr PanoBind
Definition container.cpp:11
ExtensibilityCore::PanoEntryPtr PanoEntry
Definition container.cpp:12
BOOL APIENTRY DllMain(HMODULE module, DWORD dllAction, LPVOID lpReserved)
The main entry point for the DLL.
Definition dllmain.cpp:9
PANO_API bool PanoUnbind()
Unbind from the Panoptes Service by freeing the DLL.
Definition dllmain.cpp:63
int BOOL
Definition inject.h:3
unsigned long DWORD
Definition inject.h:2
The information about the memory to be scanned that passed between the container, extensibility and t...
The information about the file to be scanned that passed between the container, extensibility and the...
std::string FileHash
std::string PePath