Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
pe-scan.cpp
Go to the documentation of this file.
1#include <LIEF/PE.hpp>
2#include <LIEF/errors.hpp>
3#include <LIEF/PE/signature/Signature.hpp>
4#include "PanoptesPE.h"
5
6
7using namespace LIEF::PE;
8std::unique_ptr<const Binary> binary;
9
12PortableExecutable::PortableExecutable(std::string PortableExecutablePath)
13{
14 binary = Parser::parse(PortableExecutablePath);
15 return;
16}
17
20std::vector<std::string> PortableExecutable::GetImports()
21{
22 std::vector<std::string> results;
23 if (binary == NULL) {
24 throw std::runtime_error("Not a PE");
25 }
26
27 if (binary->imports().size() > 0) {
28 auto it_imports = binary->imports();
29 for (LIEF::PE::Import import : it_imports)
30 {
31 std::string moduleName = import.name();
32 for (auto entry : import.entries())
33 {
34 std::string entryName = entry.name();
35 std::string entryJoined = moduleName + "!" + entryName;
36 results.push_back(entryJoined);
37 }
38 }
39 }
40 return results;
41}
42
45std::vector<std::pair<std::string, double>> PortableExecutable::GetSections()
46{
47 std::vector<std::pair<std::string, double>> results;
48 if (binary == NULL) {
49 throw std::runtime_error("Not a PE");
50 }
51
52 if (binary->sections().size() > 0) {
53 for (LIEF::PE::Section section : binary->sections())
54 {
55 std::string sectionName = section.name();
56 double sectionEntropy = section.entropy();
57 results.push_back(std::make_pair(sectionName, sectionEntropy));
58 }
59 }
60 return results;
61}
62
66{
67 if (binary == NULL) {
68 throw std::runtime_error("Not a PE");
69 }
70
71 if (!binary->has_signatures())
72 return false;
73
74 Signature::VERIFICATION_FLAGS sigCheck = binary->verify_signature();
75 if (sigCheck == Signature::VERIFICATION_FLAGS::OK)
76 return true;
77
78 return false;
79}
bool CheckIfSigned()
Check if the portable executable is signed.
Definition pe-scan.cpp:65
std::vector< std::pair< std::string, double > > GetSections()
Get the sections from the portable executable.
Definition pe-scan.cpp:45
std::vector< std::string > GetImports()
Get the imports from the portable executable.
Definition pe-scan.cpp:20
PortableExecutable(std::string PortableExecutablePath)
Constructor for the PortableExecutable class.
Definition pe-scan.cpp:12
std::unique_ptr< const Binary > binary
Definition pe-scan.cpp:8