Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
dllmain.cpp
Go to the documentation of this file.
1#include <string>
2#include <codecvt>
3#include <locale>
4#include <amsi.h>
5#include "PanoptesAMSI.h"
6#define VERSION "1.0.0"
7
13BOOL APIENTRY DllMain(HMODULE module, DWORD dllAction, LPVOID lpReserved)
14{
15 switch (dllAction)
16 {
17 case DLL_PROCESS_ATTACH:
18 //DisableThreadLibraryCalls(module);
19 break;
20 case DLL_THREAD_ATTACH:
21 // Code to run when a thread is created
22 break;
23 case DLL_THREAD_DETACH:
24 // Code to run when a thread ends
25 break;
26 case DLL_PROCESS_DETACH:
27 break;
28 }
29 return TRUE;
30}
31
35extern "C" PANO_API int PanoBind(int ContainerPort)
36{
38 if (!client.Hello(ExtensibilityType::EXTENSIBILITY_TYPE_AMSI, ContainerPort)) {
39 return 0;
40 }
41
42 return ContainerPort;
43}
44
49extern "C" PANO_API bool PanoEntry(PeScan* data, MemScan* mem_data)
50{
51 if (data->PePath.empty()) {
52 return false;
53 }
54
55 INT amsi_result = 0;
56 HRESULT status = AmsiScanner::AmsiScanFile(data->PePath, "", &amsi_result);
57 if (FAILED(status)) {
58 return false;
59 }
60 else {
62 if (!client.SendResults_AMSI(data->PePath, data->FileHash, amsi_result)) {
63 return false;
64 }
65
66 return true;
67 }
68}
69
72extern "C" PANO_API bool PanoUnbind()
73{
74 HMODULE hModule = GetModuleHandleA("PanoptesAMSI.dll");
75 if (hModule != NULL) {
76 FreeLibraryAndExitThread(hModule, 0);
77 }
78 return true;
79}
#define PANO_API
@ EXTENSIBILITY_TYPE_AMSI
static HRESULT AmsiScanFile(std::string PathToFile, std::string CopyPath, int *AmsiResult)
Scan a file using Windows built in AMSI feature set.
Definition amsi-scan.cpp:10
Panoptes Service Client that is used to communicate with the Panoptes Service via.
bool SendResults_AMSI(std::string PePath, DWORD AmsiResult)
bool Hello(ExtensibilityType extensibilityType, std::string port)
The Hello function sends a Hello message to the Panoptes main service from the container.
ExtensibilityCore::PanoBindPtr PanoBind
Definition container.cpp:11
ExtensibilityCore::PanoEntryPtr PanoEntry
Definition container.cpp:12
BOOL APIENTRY DllMain(HMODULE module, DWORD dllAction, LPVOID lpReserved)
Main entry point for the DLL.
Definition dllmain.cpp:13
PANO_API bool PanoUnbind()
Unbind from the Panoptes Service by freeing the DLL.
Definition dllmain.cpp:72
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