main.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <iostream>
  2. #include "../include/Config.h"
  3. #include "../include/CovertChannel/CovertChannel.h"
  4. #include "../include/CovertChannel/ForwardChannel.h"
  5. #include "../include/CovertChannel/ProxyChannel.h"
  6. #include "../include/Server.h"
  7. #include "../include/UserManager.h"
  8. using namespace std;
  9. int main(int argc, char *argv[]) {
  10. // load config int namespace
  11. if (!Config::init("config.txt")) {
  12. cerr << "configuration could not be loaded properly" << endl;
  13. exit(EXIT_FAILURE);
  14. }
  15. CovertChannel *covertchannel = nullptr;
  16. const std::string covertChannelMode = Config::getValue("covertChannelMode");
  17. if (covertChannelMode == "proxy") {
  18. const string innerInterface = Config::getValue("innerInterface");
  19. const string outerInterface = Config::getValue("outerInterface");
  20. const string ownIP = Config::getValue("ownIP");
  21. const string partnerIP = Config::getValue("partnerIP");
  22. const string originIP = Config::getValue("originIP");
  23. const string targetIP = Config::getValue("targetIP");
  24. const string targetPort = Config::getValue("targetPort");
  25. const string relayMode = Config::getValue("relayMode");
  26. covertchannel = new ProxyChannel(innerInterface, outerInterface, ownIP, partnerIP, originIP, targetIP, targetPort, relayMode == "true");
  27. // covertchannel = new ForwardChannel(innerInterface, outerInterface);
  28. covertchannel->startSniffing();
  29. } else if (covertChannelMode == "forward") {
  30. const string innerInterface = Config::getValue("innerInterface");
  31. const string outerInterface = Config::getValue("outerInterface");
  32. covertchannel = new ForwardChannel(innerInterface, outerInterface);
  33. covertchannel->startSniffing();
  34. }
  35. // check if userStorage is add specified location
  36. // if not create one
  37. UserManager::init(Config::getValue("userdatabase"));
  38. try {
  39. io_service io_service;
  40. Server server(io_service);
  41. io_service.run();
  42. } catch (exception &e) {
  43. cerr << e.what() << endl;
  44. }
  45. if (covertchannel == nullptr) {
  46. delete (covertchannel);
  47. }
  48. return 0;
  49. }