88 lines
1.8 KiB
C++
88 lines
1.8 KiB
C++
#include "aes.hpp"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
#include "profiler.hpp"
|
|
|
|
using namespace std;
|
|
|
|
string prompt(char separator = '>')
|
|
{
|
|
PROFILER_RECORD;
|
|
string input;
|
|
cout << separator << ' ';
|
|
cin >> input;
|
|
if (!cin.good())
|
|
{
|
|
cout << "OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!" << endl;
|
|
exit(1);
|
|
}
|
|
return input;
|
|
}
|
|
|
|
void print_help()
|
|
{
|
|
PROFILER_RECORD;
|
|
// TODO Verify whether there are more/less commands
|
|
cout << "The following commands are available: help, login, exit" << endl;
|
|
}
|
|
|
|
void login()
|
|
{
|
|
PROFILER_RECORD;
|
|
uint8_t key[16] = {0xA0,0x7C,0x3D,0x99,0xFA,0x00,0x02,0x46,0x97,0x33,0x73,0x50,0x31,0x7C,0xD3,0xDC}; // TODO Load me from a file
|
|
cout << "Username";
|
|
string username = prompt(':');
|
|
cout << "Password";
|
|
string password = prompt(':');
|
|
uint8_t encrypted_password[16];
|
|
if (password.length() != 16)
|
|
{
|
|
cout << "Password format error" << endl;
|
|
return;
|
|
}
|
|
for (int i = 0;i < 16;i++)
|
|
{
|
|
encrypted_password[i] = password[i];
|
|
}
|
|
AES::encrypt_ecb(encrypted_password, key);
|
|
// TODO Validate encrypted password
|
|
}
|
|
|
|
bool execute_command(const string &input)
|
|
{
|
|
PROFILER_RECORD;
|
|
if (input == "exit")
|
|
{
|
|
cout << "Thank you for visiting the Secutech customer portal. Please visit us again soon!" << endl;
|
|
return false;
|
|
}
|
|
if (input == "login")
|
|
{
|
|
login();
|
|
}
|
|
else if (input == "help")
|
|
{
|
|
print_help();
|
|
}
|
|
else if (!profiler.command_line(input))
|
|
{
|
|
cout << "Invalid command '" << input << "'" << endl;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
PROFILER_RECORD;
|
|
cout << "Welcome to the Secutech customer portal." << endl;
|
|
cout << "How can we help you today? (type 'help' for help)" << endl;
|
|
string input;
|
|
do
|
|
{
|
|
input = prompt();
|
|
} while (execute_command(input));
|
|
|
|
return 0;
|
|
}
|