diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index de6f401..0f625b1 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -10,6 +10,7 @@ set(LIEF_ELF_CPP_EXAMPLES set(LIEF_PE_CPP_EXAMPLES pe_builder.cpp pe_reader.cpp + pe_authenticode_check.cpp ) set(LIEF_MACHO_CPP_EXAMPLES diff --git a/examples/cpp/pe_authenticode_check.cpp b/examples/cpp/pe_authenticode_check.cpp new file mode 100644 index 0000000..62dc5ad --- /dev/null +++ b/examples/cpp/pe_authenticode_check.cpp @@ -0,0 +1,22 @@ + +#include <iostream> +#include <memory> + +#include <LIEF/PE.hpp> +#include <LIEF/logging.hpp> + +using namespace LIEF::PE; + +int main(int argc, char **argv) { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " <PE binary>" << "\n"; + return 1; + } + std::unique_ptr<const Binary> binary{Parser::parse(argv[1])}; + if (binary->verify_signature() != Signature::VERIFICATION_FLAGS::OK) { + std::cerr << "Signature failed!\n"; + return 1; + } + std::cout << "Signature ok!\n"; + return 0; +}