-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoring-engine.cpp
More file actions
71 lines (51 loc) · 1.93 KB
/
scoring-engine.cpp
File metadata and controls
71 lines (51 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Written by: Christopher Gholmieh
// Headers:
// Implementations:
#include "configuration-implementation.hpp"
#include "cryptography-implementation.hpp"
#include "cryptography-constants.hpp"
#include "engine-implementation.hpp"
#include "image-globals.hpp"
// Core:
#include <iostream>
#include <unistd.h>
// Main:
int main(void) {
// Validation:
if (geteuid() != 0) {
std::cout << "[!] Please run this binary as root!" << std::endl;
// Logic:
return EXIT_FAILURE;
}
// Variables (Assignment):
// Bytes:
std::vector<unsigned char> file_bytes = read_file("configuration.dat");
if (file_bytes.size() < NONCE_LENGTH) {
throw std::runtime_error("[!] Configuration file is too short!");
}
// Nonce:
std::vector<unsigned char> nonce(file_bytes.begin(), file_bytes.begin() + NONCE_length);
// Cipher:
std::vector<unsigned char> cipher_text(file_bytes.begin() + NONCE_length, file_bytes.end());
// Key:
std::vector<unsigned char> key(AES_ENCRYPTION_KEY, AES_ENCRYPTION_KEY + AES_ENCRYPTION_KEY_length);
// Bytes:
std::vector<unsigned char> plaintext_bytes = decrypt_configuration(key, cipher_text, nonce);
// Text:
std::string plaintext(plaintext_bytes.begin(), plaintext_bytes.end());
// Vulnerabilities:
std::vector<std::unique_ptr<Vulnerability>> vulnerability_vector = parse_yaml_configuration_vulnerabilities(plaintext);
// Penalties:
std::vector<std::unique_ptr<Vulnerability>> penalty_vector = parse_yaml_configuration_penalties(plaintext);
// Title:
const std::string image_title = obtain_image_title(plaintext);
global_image_title = image_title;
// User:
const std::string image_user = obtain_main_user(plaintext);
global_image_user = image_user;
// Engine:
Engine engine(std::move(vulnerability_vector), std::move(penalty_vector), image_title);
// Logic:
engine.activate();
return 0;
}