Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
ext_server.cpp
Go to the documentation of this file.
1#include <grpcpp/grpcpp.h>
2#include "panoptes.pb.h"
3#include "panoptes.grpc.pb.h"
4
5#include "container_ipc.hpp"
6#include <objbase.h>
7#include <iostream>
8#include <vector>
9
14 InitializeCriticalSection(&cs_);
15 InitializeConditionVariable(&cv_);
16}
17
21void PeMessageQueue::enqueue(const PeScan& message) {
22 EnterCriticalSection(&cs_);
23 queue_.push(message);
24 std::cout << "Enqueued item. Queue size: " << queue_.size() << std::endl;
25 LeaveCriticalSection(&cs_);
26 WakeConditionVariable(&cv_);
27}
28
32 EnterCriticalSection(&cs_);
33 while (queue_.empty()) {
34 std::cout << "Queue empty, waiting..." << std::endl;
35 SleepConditionVariableCS(&cv_, &cs_, INFINITE);
36 }
37 PeScan message = queue_.front();
38 queue_.pop();
39 // std::cout << "Dequeued item. Remaining queue size: " << queue_.size() << std::endl;
40 LeaveCriticalSection(&cs_);
41 return message;
42}
43
46class PanoptesImpl : public PanoptesExtensibility::Service {
52 ::grpc::Status PEScan(::grpc::ServerContext* context, const ::PeScanInfo* request, ::AckMessage* response) override {
53 PeScan scanInfo;
54 scanInfo.PePath = request->portable_executable_path();
55 scanInfo.FileHash = request->file_hash();
56
57 if (message_queue_pe_ != NULL) {
58 message_queue_pe_->enqueue(scanInfo);
59 }
60
61 response->set_ack_type(AckType::SUCCESS);
62 return ::grpc::Status::OK;
63 }
64};
65
68void RunContainerServer(LPVOID lpParam)
69{
70 int* ContainerPort = (int*)(lpParam);
71
72 PanoptesImpl service;
73 grpc::ServerBuilder builder;
74 std::string server_url = "localhost:" + std::to_string(*ContainerPort);
75 builder.AddListeningPort(server_url, grpc::InsecureServerCredentials(), ContainerPort);
76 builder.RegisterService(&service);
77 std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
78 server->Wait();
79}
The PanoptesImpl class is a class that implements the PanoptesExtensibility::Service interface from t...
PeMessageQueue()
The PeMessageQueue class is a thread-safe queue for PeScan messages.
PeScan dequeue()
The dequeue function dequeues a PeScan messages from the queue.
void enqueue(const PeScan &message)
The enqueue function is a function that enqueues a PeScan message to the queue.
PeMessageQueue * message_queue_pe_
Definition container.cpp:15
void RunContainerServer(LPVOID lpParam)
The RunContainerServer function is a function that runs the container server.
The information about the file to be scanned that passed between the container, extensibility and the...
std::string FileHash
std::string PePath