Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
scanner_ipc.cpp
Go to the documentation of this file.
1#include <grpcpp/grpcpp.h>
2#include "panoptes.grpc.pb.h"
3#include "scanner_ipc.hpp"
4
5using grpc::Channel;
6using grpc::ClientContext;
7using grpc::Status;
8
9std::unique_ptr<PanoptesService::Stub> stub_;
10
14bool GetRegistryPortValue(DWORD& portValue) {
15 HKEY hKey;
16 DWORD dwType = REG_DWORD;
17 DWORD dwSize = sizeof(DWORD);
18
19 // Open the key
20 LONG lResult = RegOpenKeyExA(
21 HKEY_LOCAL_MACHINE,
22 "SOFTWARE\\Panoptes",
23 0,
24 KEY_READ,
25 &hKey
26 );
27
28 if (lResult != ERROR_SUCCESS) {
29 std::cerr << "Error opening registry key. Error code: " << lResult << std::endl;
30 return false;
31 }
32
33 // Read the SRV_PORT value
34 lResult = RegQueryValueExA(
35 hKey,
36 "SRV_PORT",
37 NULL,
38 &dwType,
39 reinterpret_cast<LPBYTE>(&portValue),
40 &dwSize
41 );
42
43 RegCloseKey(hKey);
44
45 if (lResult != ERROR_SUCCESS) {
46 std::cerr << "Error reading registry value. Error code: " << lResult << std::endl;
47 return false;
48 }
49
50 if (dwType != REG_DWORD) {
51 std::cerr << "Unexpected value type in registry." << std::endl;
52 return false;
53 }
54
55 return true;
56}
57
62 std::string server_url = "localhost:0" + std::to_string(SERVICE_PORT);
63 std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_url, grpc::InsecureChannelCredentials());
64 stub_ = PanoptesService::NewStub(channel);
65}
66
72bool PanoptesServiceClient::QueuePeScan(std::string PePath, std::string FileHash, std::string& message) {
73 AckMessage reply;
74 ClientContext g_context;
75
76 PeScanInfo request;
77 request.set_file_hash(FileHash);
78 request.set_portable_executable_path(PePath);
79
80 Status status = stub_->QueuePeScan(&g_context, request, &reply);
81
82 if (!status.ok()) {
83 message = status.error_message();
84 return false;
85 }
86 else {
87 message = reply.message();
88 }
89
90 return true;
91}
#define SERVICE_PORT
std::unique_ptr< PanoptesService::Stub > stub_
bool GetRegistryPortValue(DWORD &portValue)
Get the Panoptes Service port value from the registry.
PanoptesServiceClient()
The PanoptesServiceClient class is a class that implements the PanoptesServiceClient class.
bool QueuePeScan(std::string PePath, std::string FileHash, std::string &message)
Send a request to the Panoptes Service to scan a PE file.
bool GetRegistryPortValue(DWORD &portValue)
Get the gRPC port value from the registry.
Definition container.cpp:24
unsigned long DWORD
Definition inject.h:2
std::unique_ptr< PanoptesService::Stub > stub_