-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_flag.cpp
54 lines (41 loc) · 1.07 KB
/
get_flag.cpp
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
#include <iostream>
#include <string>
#include <cstring>
#include <memory>
#define INTERFACE "ens33"
#ifdef MULTISERVICE
#define FLAGSUBMIT_URL "http://192.168.1.5:8888/flag/submit/"
#include <unistd.h>
#include <cstdlib>
#include <cstdint>
#include <curl/curl.h>
#include <jsoncpp/json/json.h>
#include "services.h"
#else
#include "crypto.hpp"
#endif
#include "util.hpp"
int main(int argc, char **argv)
{
byte iv[BLOCK_SIZE];
byte *key = (byte *) "c3bb356d542b36ca5a352cd3a6276014";
EVP_add_cipher(EVP_aes_256_cbc());
#ifdef MULTISERVICE
Json::Value jsonData;
Json::Reader jsonReader;
uid_t uid = getuid();
std::string flag = util::getServiceFlag(uid);
std::cout << flag;
#else
crypto::gen_params(iv);
secure_string ptext = util::getLocalIP();
secure_string ctext;
crypto::aes_encrypt(key, iv, ptext, ctext);
ctext.append("::");
ctext.append((char *)iv, BLOCK_SIZE);
OPENSSL_cleanse(iv, BLOCK_SIZE);
secure_string b64text = crypto::base64_encode(ctext);
std::cout << b64text;
#endif
exit(EXIT_SUCCESS);
}