1#include <grpcpp/grpcpp.h>
2#include "panoptes.grpc.pb.h"
5using grpc::ClientContext;
8std::unique_ptr<PanoptesService::Stub>
stub_;
12#define PANOPTES_REG_ROOT HKEY_CURRENT_USER
14#define PANOPTES_REG_ROOT HKEY_LOCAL_MACHINE
22 DWORD dwType = REG_DWORD;
23 DWORD dwSize =
sizeof(DWORD);
26 LONG lResult = RegOpenKeyExA(
34 if (lResult != ERROR_SUCCESS) {
35 std::cerr <<
"Error opening registry key. Error code: " << lResult << std::endl;
40 lResult = RegQueryValueExA(
45 reinterpret_cast<LPBYTE
>(&portValue),
51 if (lResult != ERROR_SUCCESS) {
52 std::cerr <<
"Error reading registry value. Error code: " << lResult << std::endl;
56 if (dwType != REG_DWORD) {
57 std::cerr <<
"Unexpected value type in registry." << std::endl;
68 std::cerr <<
"Failed to get registry port value." << std::endl;
71 std::string server_url =
"localhost:" + std::to_string(portValue);
72 std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_url, grpc::InsecureChannelCredentials());
73 stub_ = PanoptesService::NewStub(channel);
83 ContainerInfo request;
84 ClientContext g_context;
86 request.set_container_type((ContainerType)extensibilityType);
87 request.set_grpc_port(ContainerPort);
89 Status status =
stub_->Hello(&g_context, request, &reply);
96 return reply.ack_type();
106 ClientContext context;
108 ContainerReply request;
111 request.set_portable_executable_path(pePath);
112 request.set_file_hash(fileHash);
114 for (
auto rule : detectedRules) {
115 results.add_detected_rules(rule);
118 char trustStatus[11];
119 sprintf_s(trustStatus,
"0x%08X",
static_cast<unsigned long>(signature.
trustStatus));
121 ScanSignature* signatureResults = results.mutable_signature();
122 signatureResults->set_signed_(signature.
isSigned);
123 signatureResults->set_trusted(signature.
trusted);
124 signatureResults->set_catalog_signed(signature.
catalogSigned);
125 signatureResults->set_signer(signature.
signer);
126 signatureResults->set_trust_status(trustStatus);
128 request.mutable_yara_scan()->CopyFrom(results);
130 Status status =
stub_->ScanResults(&context, request, &reply);
133 std::cout << status.error_code() <<
": " << status.error_message() << std::endl;
137 return reply.ack_type();
ExtensibilityType
The type of extensibility.
bool SendResults_Yara(std::string PePath, std::string FileHash, DWORD ProcessId, std::string YaraRulesPath, INT MatchRules, std::vector< std::string > DetectedRules)
PanoptesServiceClient()
The PanoptesServiceClient class is a class that implements the PanoptesServiceClient class.
bool Hello(ExtensibilityType extensibilityType, std::string port)
The Hello function sends a Hello message to the Panoptes main service from the container.
#define PANOPTES_REG_ROOT
bool GetRegistryPortValue(DWORD &portValue)
Get the gRPC port value from the registry.
std::unique_ptr< PanoptesService::Stub > stub_
bool GetRegistryPortValue(DWORD &portValue)
Get the Panoptes Service port from the registry.
The result of verifying a file's Authenticode signature with WinVerifyTrust.
bool trusted
True if WinVerifyTrust reported the signature as valid and trusted.
std::string signer
The signing certificate's display name (UTF-8), empty if unsigned.
LONG trustStatus
The WinVerifyTrust result, 0 if trusted.
bool isSigned
True if the file has an embedded or catalog signature.
bool catalogSigned
True if the signature came from a catalog file rather than being embedded.