1#include <grpcpp/grpcpp.h>
2#include "panoptes.grpc.pb.h"
5using grpc::ClientContext;
8std::unique_ptr<PanoptesService::Stub>
stub_;
12 DWORD dwType = REG_DWORD;
16 LONG lResult = RegOpenKeyExA(
24 if (lResult != ERROR_SUCCESS) {
25 std::cerr <<
"Error opening registry key. Error code: " << lResult << std::endl;
30 lResult = RegQueryValueExA(
35 reinterpret_cast<LPBYTE
>(&portValue),
41 if (lResult != ERROR_SUCCESS) {
42 std::cerr <<
"Error reading registry value. Error code: " << lResult << std::endl;
46 if (dwType != REG_DWORD) {
47 std::cerr <<
"Unexpected value type in registry." << std::endl;
57 std::cerr <<
"Failed to get registry port value." << std::endl;
60 std::string server_url =
"localhost:" + std::to_string(portValue);
61 std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_url, grpc::InsecureChannelCredentials());
62 stub_ = PanoptesService::NewStub(channel);
67 ContainerInfo request;
68 ClientContext g_context;
70 request.set_container_type((ContainerType)extensibilityType);
71 request.set_grpc_port(ContainerPort);
73 Status status =
stub_->Hello(&g_context, request, &reply);
80 return reply.ack_type();
85 ContainerReply request;
86 ClientContext g_context;
89 request.set_portable_executable_path(PePath);
90 request.set_file_hash(PePath);
92 for (
int i = 0; i < data.
imports.size(); i++) {
93 results.add_imports(data.
imports[i]);
96 for (
int i = 0; i < data.
sections.size(); i++) {
97 results.add_sections(data.
sections[i]);
104 request.mutable_pe_scan()->CopyFrom(results);
106 Status status =
stub_->ScanResults(&g_context, request, &reply);
113 return reply.ack_type();
ExtensibilityType
The type of extensibility.
PanoptesServiceClient()
The PanoptesServiceClient class is a class that implements the PanoptesServiceClient class.
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 GetRegistryPortValue(DWORD &portValue)
Get the gRPC port value from the registry.
std::unique_ptr< PanoptesService::Stub > stub_
std::unique_ptr< PanoptesService::Stub > stub_
bool GetRegistryPortValue(DWORD &portValue)
The data that is sent to the Panoptes Service.
std::vector< std::string > imports
std::vector< double > section_entropy
std::vector< std::string > sections