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

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 PE extensibility.
 
PANO_API bool PanoUnbind ()
 

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 8 of file dllmain.cpp.

9{
10 switch (dllAction)
11 {
12 case DLL_PROCESS_ATTACH:
13 //DisableThreadLibraryCalls(module);
14 break;
15 case DLL_THREAD_ATTACH:
16 // Code to run when a thread is created
17 break;
18 case DLL_THREAD_DETACH:
19 // Code to run when a thread ends
20 break;
21 case DLL_PROCESS_DETACH:
22 break;
23 }
24 return TRUE;
25}

◆ 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 31 of file dllmain.cpp.

32{
34 if (!client.Hello(ExtensibilityType::EXTENSIBILITY_TYPE_PE, ContainerPort)) {
35 return 0;
36 }
37
38 return ContainerPort;
39}
@ EXTENSIBILITY_TYPE_PE
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_PE, and PanoptesServiceClient::Hello().

◆ PanoEntry()

PANO_API bool PanoEntry ( PeScan data,
MemScan mem_data 
)

The entry point for the PE 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 45 of file dllmain.cpp.

46{
47 if (data->PePath.empty()) {
48 return false;
49 }
50
52 try {
53 std::vector<std::string> imports = pe.GetImports();
54 std::vector<std::pair<std::string, double>> sections = pe.GetSections();
55 bool isSigned = pe.CheckIfSigned();
56
58 peData.imports = imports;
59 for (auto section : sections) {
60 peData.sections.push_back(section.first);
61 peData.section_entropy.push_back(section.second);
62 }
63
64 peData.isSigned = isSigned;
65
67 if (!client.SendResults_PE(data->PePath, peData)) {
68 return false;
69 }
70 }
71 catch (const exception& e) {
72 return false;
73 }
74
75 return true;
76}
bool SendResults_PE(std::string PePath, bool IsPeSigned, std::string PeSignerSubject, std::vector< std::string > PeImports)
bool CheckIfSigned()
Check if the portable executable is signed.
Definition pe-scan.cpp:65
std::vector< std::pair< std::string, double > > GetSections()
Get the sections from the portable executable.
Definition pe-scan.cpp:45
std::vector< std::string > GetImports()
Get the imports from the portable executable.
Definition pe-scan.cpp:20
std::string PePath
The data that is sent to the Panoptes Service.
Definition PanoptesPE.h:11
std::vector< std::string > imports
Definition PanoptesPE.h:12
std::vector< double > section_entropy
Definition PanoptesPE.h:14
std::vector< std::string > sections
Definition PanoptesPE.h:13

References PortableExecutable::CheckIfSigned(), PortableExecutable::GetImports(), PortableExecutable::GetSections(), PortableExecutable::PEScanData::imports, PortableExecutable::PEScanData::isSigned, PeScan::PePath, PortableExecutable::PEScanData::section_entropy, PortableExecutable::PEScanData::sections, and PanoptesServiceClient::SendResults_PE().

◆ PanoUnbind()

PANO_API bool PanoUnbind ( )

Definition at line 78 of file dllmain.cpp.

79{
80 HMODULE hModule = GetModuleHandleA("PanoptesPE.dll");
81 if (hModule != NULL) {
82 FreeLibraryAndExitThread(hModule, 0);
83 }
84 return true;
85}