Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
Functions
dllmain.cpp File Reference
#include "PanoptesYara.h"
#include <string>

Go to the source code of this file.

Functions

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, MemScan *mem_data)
 The entry point for the YARA extensibility.
 
PANO_API bool PanoUnbind ()
 Unbind from the Panoptes Service by freeing the DLL.
 

Function Documentation

◆ DllMain()

BOOL APIENTRY DllMain ( HMODULE  module,
DWORD  dllAction,
LPVOID  lpReserved 
)

The main entry point for the DLL.

Parameters
moduleThe module handle
dllActionThe action to take
lpReservedReserved
Returns

Definition at line 9 of file dllmain.cpp.

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}

◆ 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
ContainerPortThe port of the container that the extensibility is running in
Returns
The container port

Definition at line 32 of file dllmain.cpp.

33{
35 if (!client.Hello(ExtensibilityType::EXTENSIBILITY_TYPE_YARA, ContainerPort)) {
36 return 0;
37 }
38
39 return ContainerPort;
40}
@ EXTENSIBILITY_TYPE_YARA
Panoptes Service Client that is used to communicate with the Panoptes Service via.
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, and PanoptesServiceClient::Hello().

◆ PanoEntry()

PANO_API bool PanoEntry ( PeScan data,
MemScan mem_data 
)

The entry point for the YARA extensibility.

Parameters
dataThe information about the file to be scanned
mem_dataThe information about the memory to be scanned
Returns
True if the scan was successful, false otherwise

Definition at line 46 of file dllmain.cpp.

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}
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.
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
std::string FileHash
std::string PePath

References PeScan::FileHash, PeScan::PePath, PanoptesServiceClient::SendResults_Yara(), YaraScanner::YaraScanFile(), and YaraScanner::YaraScanner().

◆ PanoUnbind()

PANO_API bool PanoUnbind ( )

Unbind from the Panoptes Service by freeing the DLL.

Returns
True if the unbind was successful, false otherwise

Definition at line 63 of file dllmain.cpp.

64{
65 HMODULE hModule = GetModuleHandleA("PanoptesYara.dll");
66 if (hModule != NULL) {
67 FreeLibraryAndExitThread(hModule, 0);
68 }
69 return true;
70}