1#include <grpcpp/grpcpp.h>
2#include "panoptes.grpc.pb.h"
3#include "scanner_ipc.hpp"
6using grpc::ClientContext;
11 std::unique_ptr<PanoptesService::Stub>
Stub;
16#define PANOPTES_REG_ROOT HKEY_CURRENT_USER
18#define PANOPTES_REG_ROOT HKEY_LOCAL_MACHINE
26 DWORD dwType = REG_DWORD;
27 DWORD dwSize =
sizeof(DWORD);
30 LONG lResult = RegOpenKeyExA(
38 if (lResult != ERROR_SUCCESS) {
39 std::cerr <<
"Error opening registry key. Error code: " << lResult << std::endl;
44 lResult = RegQueryValueExA(
49 reinterpret_cast<LPBYTE
>(&portValue),
55 if (lResult != ERROR_SUCCESS) {
56 std::cerr <<
"Error reading registry value. Error code: " << lResult << std::endl;
60 if (dwType != REG_DWORD) {
61 std::cerr <<
"Unexpected value type in registry." << std::endl;
72 std::string server_url =
"localhost:0" + std::to_string(
SERVICE_PORT);
73 std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_url, grpc::InsecureChannelCredentials());
74 m_stub = std::make_unique<PanoptesService_Stub_Holder>();
75 m_stub->Stub = PanoptesService::NewStub(channel);
80 ClientContext context;
82 context.set_deadline(std::chrono::system_clock::now() + std::chrono::seconds(30));
85 request.set_file_hash(FileHash);
86 request.set_portable_executable_path(PePath);
87 request.set_poll(Poll);
89 Status status = m_stub->Stub->QueuePeScan(&context, request, &reply);
91 Error = status.error_message();
94 Reply.
Results = reply.message();
96 Reply.
Pending.assign(reply.pending_scans().begin(), reply.pending_scans().end());
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.
std::unique_ptr< PanoptesService::Stub > Stub
#define PANOPTES_REG_ROOT
bool GetRegistryPortValue(DWORD &portValue)
Get the gRPC port value from the registry.
bool GetRegistryPortValue(DWORD &portValue)
Get the Panoptes Service port value from the registry.
What the service answered a scan request with.
std::vector< std::string > Pending