main.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include <iostream>
  2. #include "../include/Config.h"
  3. #include "../include/CovertChannel/Channels/TCPAppendChannel.hpp"
  4. #include "../include/CovertChannel/Channels/TCPOptionCustomChannel.hpp"
  5. #include "../include/CovertChannel/Channels/TCPOptionTimestampChannel.hpp"
  6. #include "../include/CovertChannel/Channels/TCPUrgencyChannel.hpp"
  7. #include "../include/CovertChannel/CovertChannel.h"
  8. #include "../include/CovertChannel/ForwardChannel.h"
  9. #include "../include/Queue.h"
  10. #include "../include/Server.h"
  11. #include "../include/UserManager.h"
  12. using namespace std;
  13. int main(int argc, char *argv[]) {
  14. // load config int namespace
  15. if (!Config::init("config.txt")) {
  16. cerr << "configuration could not be loaded properly" << endl;
  17. exit(EXIT_FAILURE);
  18. }
  19. CovertChannel *covertchannel = nullptr;
  20. const std::string covertChannelMode = Config::getValue("covertChannelMode");
  21. if (covertChannelMode == "tcpurgency") {
  22. const string innerInterface = Config::getValue("innerInterface");
  23. const string outerInterface = Config::getValue("outerInterface");
  24. const string targetIP = Config::getValue("targetIP");
  25. const string targetPort = Config::getValue("targetPort");
  26. const string passiveMode = Config::getValue("passiveMode");
  27. if (passiveMode == "true") {
  28. covertchannel = new TCPUrgencyChannel<true>(innerInterface, outerInterface, targetIP, targetPort);
  29. } else {
  30. covertchannel = new TCPUrgencyChannel<false>(innerInterface, outerInterface, targetIP, targetPort);
  31. }
  32. // covertchannel = new ForwardChannel(innerInterface, outerInterface);
  33. covertchannel->startSniffing();
  34. } else if (covertChannelMode == "tcpappend") {
  35. const string innerInterface = Config::getValue("innerInterface");
  36. const string outerInterface = Config::getValue("outerInterface");
  37. const string targetIP = Config::getValue("targetIP");
  38. const string targetPort = Config::getValue("targetPort");
  39. const string passiveMode = Config::getValue("passiveMode");
  40. if (passiveMode == "true") {
  41. covertchannel = new TCPAppendChannel<8, true>(innerInterface, outerInterface, targetIP, targetPort);
  42. } else {
  43. covertchannel = new TCPAppendChannel<8, false>(innerInterface, outerInterface, targetIP, targetPort);
  44. }
  45. // covertchannel = new ForwardChannel(innerInterface, outerInterface);
  46. covertchannel->startSniffing();
  47. } else if (covertChannelMode == "tcpoptiontimestamp") {
  48. const string innerInterface = Config::getValue("innerInterface");
  49. const string outerInterface = Config::getValue("outerInterface");
  50. const string targetIP = Config::getValue("targetIP");
  51. const string targetPort = Config::getValue("targetPort");
  52. const string passiveMode = Config::getValue("passiveMode");
  53. if (passiveMode == "true") {
  54. covertchannel = new TCPOptionTimestampChannel<true>(innerInterface, outerInterface, targetIP, targetPort);
  55. } else {
  56. covertchannel = new TCPOptionTimestampChannel<false>(innerInterface, outerInterface, targetIP, targetPort);
  57. }
  58. // covertchannel = new ForwardChannel(innerInterface, outerInterface);
  59. covertchannel->startSniffing();
  60. } else if (covertChannelMode == "tcpoptioncustom") {
  61. const string innerInterface = Config::getValue("innerInterface");
  62. const string outerInterface = Config::getValue("outerInterface");
  63. const string targetIP = Config::getValue("targetIP");
  64. const string targetPort = Config::getValue("targetPort");
  65. const string passiveMode = Config::getValue("passiveMode");
  66. if (passiveMode == "true") {
  67. covertchannel = new TCPOptionCustomChannel<8, true>(innerInterface, outerInterface, targetIP, targetPort);
  68. } else {
  69. covertchannel = new TCPOptionCustomChannel<8, false>(innerInterface, outerInterface, targetIP, targetPort);
  70. }
  71. // covertchannel = new ForwardChannel(innerInterface, outerInterface);
  72. covertchannel->startSniffing();
  73. } else if (covertChannelMode == "forward") {
  74. const string innerInterface = Config::getValue("innerInterface");
  75. const string outerInterface = Config::getValue("outerInterface");
  76. covertchannel = new ForwardChannel(innerInterface, outerInterface);
  77. covertchannel->startSniffing();
  78. }
  79. // check if userStorage is add specified location
  80. // if not create one
  81. UserManager::init(Config::getValue("userdatabase"));
  82. // Init queue so the file transfers can be executed
  83. Queue::channel = covertchannel;
  84. try {
  85. io_service io_service;
  86. Server server(io_service);
  87. io_service.run();
  88. } catch (exception &e) {
  89. cerr << e.what() << endl;
  90. }
  91. if (covertchannel == nullptr) {
  92. delete (covertchannel);
  93. }
  94. return 0;
  95. }