BidirectionalChannels.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef BIDIRECTIONALCHANNELS_H
  2. #define BIDIRECTIONALCHANNELS_H
  3. #include "CovertChannel.h"
  4. #include "Protocols/CovertProtocolBidirectional.hpp"
  5. /**
  6. * @class BidirectionalChannels
  7. *
  8. * Abstract class which implements the methods and constructors which are equal in all bidirectional channels.
  9. *
  10. * @param N number of bytes which can be used to transmit data
  11. * @param PASSIVE true - server only reacts to incoming channel | false - server initiates channel
  12. */
  13. template <int N, bool PASSIVE> class BidirectionalChannels : public CovertChannel {
  14. public:
  15. /**
  16. * Sets up a CovertChannel.
  17. *
  18. * Creates a CovertChannel, sets the network interfaces for sniffing and sending and sets the filter.
  19. *
  20. * @param innerInterface name of the interface of the inner network
  21. * @param outerInterface name of the interface of the outer network
  22. * @param targetIP IP of the target server
  23. * @param targetPort Port of the target server
  24. */
  25. BidirectionalChannels(const std::string &innerInterface, const std::string &outerInterface, const std::string &targetIP, const std::string &targetPort)
  26. : CovertChannel(innerInterface, outerInterface, "not (tcp and host " + targetIP + " and port " + targetPort + ")",
  27. "not (tcp and host " + targetIP + " and port " + targetPort + ")", "tcp and host " + targetIP + " and port " + targetPort,
  28. "tcp and host " + targetIP + " and port " + targetPort) {}
  29. /**
  30. * Destroys the CovertChannel.
  31. */
  32. virtual ~BidirectionalChannels() {}
  33. /* ChannelControls */
  34. /**
  35. * Starts sending a file.
  36. *
  37. * Starts sending a file if no transmission is running and the file exists.
  38. *
  39. * @param fileName name of the file in the file directory
  40. * @return true - file will be sent | false - file was not accepted
  41. */
  42. virtual bool sendFile(const std::string &fileName) { return protocol.sendFile(fileName); }
  43. /**
  44. * Get the progress
  45. *
  46. * @return progress counters
  47. */
  48. virtual std::pair<uint32_t, uint32_t> getProgress() { return protocol.getProgress(); }
  49. /**
  50. * Test if a transfer is running
  51. *
  52. * @return true - a transfer runs | false - no transfer runs
  53. */
  54. virtual bool isTransferRunning() { return protocol.isTransferRunning(); }
  55. /**
  56. * Resets state and sets reset flag so a reset signal is sent in the next packet
  57. */
  58. virtual void reset() { protocol.reset(); }
  59. /**
  60. * Test if a transfer is running
  61. *
  62. * @return true - a transfer runs | false - no transfer runs
  63. */
  64. virtual std::time_t getTransferStart() { return protocol.getTransferStart(); }
  65. /**
  66. * Get file name of the file which is currently be sent or received.
  67. *
  68. * @return file name
  69. */
  70. virtual std::string getFileName() { return protocol.getFileName(); };
  71. /* =============== */
  72. protected:
  73. /**
  74. * protocol used to transmit data
  75. */
  76. CovertProtocolBidirectional<N, PASSIVE> protocol;
  77. };
  78. #endif