6#include "scanner_ipc.hpp"
7#include "absl/flags/flag.h"
8#include "absl/flags/parse.h"
9#include <nlohmann/json.hpp>
11ABSL_FLAG(std::string, file,
"",
"File for Panoptes To Scan");
12ABSL_FLAG(
int, timeout, 120,
"Seconds to wait for every extension's result (YARA, ML)");
14static std::string Join(
const std::vector<std::string>& Items) {
16 for (
const auto& item : Items) {
17 out += (out.empty() ?
"" :
", ") + item;
39 absl::ParseCommandLine(__argc, __argv);
40 if (absl::GetFlag(FLAGS_file).empty()) {
41 printf(
"ERROR: No file specified\n");
42 printf(
"Usage: PanoptesScanCLI.exe -file <FILE_TO_SCAN> [-timeout <SECONDS>]\n");
46 std::string fileToScan = absl::GetFlag(FLAGS_file);
54 if (!client.
QueuePeScan(fileToScan,
"",
false, reply, error)) {
55 std::cout <<
"An Error Occured:" <<
"\n" << error << std::endl;
59 std::cout <<
"Waiting for: " << Join(reply.
Pending) << std::endl;
61 auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(absl::GetFlag(FLAGS_timeout));
62 while (!reply.
Pending.empty() && std::chrono::steady_clock::now() < deadline) {
64 std::string fileHash = reply.
FileHash;
65 if (!client.
QueuePeScan(fileToScan, fileHash,
true, reply, error)) {
66 std::cout <<
"An Error Occured:" <<
"\n" << error << std::endl;
72 std::cout <<
"No scan results" << (reply.
Pending.empty() ?
"" :
" after " + std::to_string(absl::GetFlag(FLAGS_timeout)) +
" seconds") << std::endl;
75 nlohmann::json j = nlohmann::json::parse(reply.
Results);
76 std::string prettyJson = j.dump(4,
' ',
true);
77 std::cout <<
"Scan Results:" <<
"\n" << prettyJson << std::endl;
79 std::cout <<
"No result yet from: " << Join(reply.
Pending) << std::endl;
The Panoptes Service client used to talk to the service over gRPC.
bool QueuePeScan(std::string PePath, std::string FileHash, std::string &message)
Send a request to the Panoptes Service to scan a PE file.
ABSL_FLAG(std::string, file, "", "File for Panoptes To Scan")
What the service answered a scan request with.
std::vector< std::string > Pending