main.cpp 2.2 KB

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