1#include <grpcpp/grpcpp.h>
2#include "panoptes.grpc.pb.h"
5using grpc::ClientContext;
8std::unique_ptr<PanoptesService::Stub>
stub_;
15 DWORD dwType = REG_DWORD;
19 LONG lResult = RegOpenKeyExA(
27 if (lResult != ERROR_SUCCESS) {
28 std::cerr <<
"Error opening registry key. Error code: " << lResult << std::endl;
33 lResult = RegQueryValueExA(
38 reinterpret_cast<LPBYTE
>(&portValue),
44 if (lResult != ERROR_SUCCESS) {
45 std::cerr <<
"Error reading registry value. Error code: " << lResult << std::endl;
49 if (dwType != REG_DWORD) {
50 std::cerr <<
"Unexpected value type in registry." << std::endl;
62 std::cerr <<
"Failed to get registry port value." << std::endl;
65 std::string server_url =
"localhost:" + std::to_string(portValue);
66 std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_url, grpc::InsecureChannelCredentials());
67 stub_ = PanoptesService::NewStub(channel);
76 ContainerInfo request;
77 ClientContext g_context;
79 request.set_container_type((ContainerType)extensibilityType);
80 request.set_grpc_port(ContainerPort);
82 Status status =
stub_->Hello(&g_context, request, &reply);
85 std::cout << status.error_code() <<
": " << status.error_message() << std::endl;
89 return reply.ack_type();
103 ContainerReply request;
104 ClientContext g_context;
107 request.set_portable_executable_path(PePath);
108 request.set_file_hash(FileHash);
109 results.set_amsi_result(AmsiResult);
111 request.mutable_amsi_scan()->CopyFrom(results);
113 Status status =
stub_->ScanResults(&g_context, request, &reply);
116 std::cout << status.error_code() <<
": " << status.error_message() << std::endl;
120 return !reply.ack_type();
ExtensibilityType
The type of extensibility.
PanoptesServiceClient()
The PanoptesServiceClient class is a class that implements the PanoptesServiceClient class.
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.
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)
Get the Panoptes Service port from the registry.