Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
dllmain.cpp
Go to the documentation of this file.
1#include "PanoptesPE.h"
2
8BOOL APIENTRY DllMain(HMODULE module, DWORD dllAction, LPVOID lpReserved)
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}
26
31extern "C" PANO_API int PanoBind(int ContainerPort)
32{
34 if (!client.Hello(ExtensibilityType::EXTENSIBILITY_TYPE_PE, ContainerPort)) {
35 return 0;
36 }
37
38 return ContainerPort;
39}
40
45extern "C" PANO_API bool PanoEntry(PeScan* data, MemScan* mem_data)
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}
77
78extern "C" PANO_API bool PanoUnbind()
79{
80 HMODULE hModule = GetModuleHandleA("PanoptesPE.dll");
81 if (hModule != NULL) {
82 FreeLibraryAndExitThread(hModule, 0);
83 }
84 return true;
85}
#define PANO_API
@ EXTENSIBILITY_TYPE_PE
Panoptes Service Client that is used to communicate with the Panoptes Service via.
bool SendResults_PE(std::string PePath, bool IsPeSigned, std::string PeSignerSubject, std::vector< std::string > PeImports)
bool Hello(ExtensibilityType extensibilityType, std::string port)
The Hello function sends a Hello message to the Panoptes main service from the container.
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
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:8
PANO_API bool PanoUnbind()
Definition dllmain.cpp:78
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 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