Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
Macros | Functions
dllmain.cpp File Reference
#include <string>
#include <codecvt>
#include <locale>
#include <amsi.h>
#include "PanoptesAMSI.h"

Go to the source code of this file.

Macros

#define VERSION   "1.0.0"
 

Functions

BOOL APIENTRY DllMain (HMODULE module, DWORD dllAction, LPVOID lpReserved)
 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.
 
PANO_API bool PanoEntry (PeScan *data, MemScan *mem_data)
 The entry point for the AMSI extensibility.
 
PANO_API bool PanoUnbind ()
 Unbind from the Panoptes Service by freeing the DLL.
 

Macro Definition Documentation

◆ VERSION

#define VERSION   "1.0.0"

Definition at line 6 of file dllmain.cpp.

Function Documentation

◆ DllMain()

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

Main entry point for the DLL.

Parameters
moduleThe module handle
dllActionThe action to take
lpReservedReserved
Returns

Definition at line 13 of file dllmain.cpp.

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}

◆ PanoBind()

PANO_API int PanoBind ( int  ContainerPort)

Bind to the Panoptes Service by sending a hello message containing the extensibility type.

Parameters
ContainerPortThe port of the container that the extensibility is running in
Returns
The container port

Definition at line 35 of file dllmain.cpp.

36{
38 if (!client.Hello(ExtensibilityType::EXTENSIBILITY_TYPE_AMSI, ContainerPort)) {
39 return 0;
40 }
41
42 return ContainerPort;
43}
@ EXTENSIBILITY_TYPE_AMSI
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_AMSI, and PanoptesServiceClient::Hello().

◆ PanoEntry()

PANO_API bool PanoEntry ( PeScan data,
MemScan mem_data 
)

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

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}
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
bool SendResults_AMSI(std::string PePath, DWORD AmsiResult)
std::string FileHash
std::string PePath

References AmsiScanner::AmsiScanFile(), PeScan::FileHash, PeScan::PePath, and PanoptesServiceClient::SendResults_AMSI().

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

73{
74 HMODULE hModule = GetModuleHandleA("PanoptesAMSI.dll");
75 if (hModule != NULL) {
76 FreeLibraryAndExitThread(hModule, 0);
77 }
78 return true;
79}