CovertChannel.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef COVERTCHANNEL_H
  2. #define COVERTCHANNEL_H
  3. #include <tins/tins.h>
  4. /**
  5. * @class Sniffer
  6. *
  7. * Sniffs the network.
  8. *
  9. * Sniffer class which will sniff on a network interface. It is supposed to
  10. * forward the packets to an analyzer or modifyer so we can hide data in the
  11. * traffic.
  12. */
  13. class CovertChannel {
  14. public:
  15. /**
  16. * Creates a Sniffer.
  17. *
  18. * Creates a Sniffer and sets the network interface for sniffing.
  19. *
  20. * @param interface name of the interface for sniffing
  21. */
  22. CovertChannel(const std::string &innerInterface, const std::string &outerInterface, const std::string &filter);
  23. /**
  24. * Destroys the Sniffer.
  25. *
  26. * Destructor of the Sniffer.
  27. */
  28. virtual ~CovertChannel();
  29. /**
  30. * Start sniffing on the interface.
  31. *
  32. * Starts a sniffing loop which calls handle. The loop will only be stopped if
  33. * handle returns false.
  34. */
  35. void startSniffing();
  36. /**
  37. * Sets a filter for the sniffer.
  38. *
  39. * Sets the filter for a sniffer with a pcap filter string. E.g. "ip
  40. * dst 8.8.8.8".
  41. *
  42. * @param filterString pcap filter string
  43. */
  44. void setFilter(const std::string &filterString);
  45. protected:
  46. /**
  47. * Handler for sniffed packets.
  48. *
  49. * Handles incoming connections and provides data for the package analyzer and
  50. * modifyer.
  51. *
  52. * @param pdu sniffed packet
  53. *
  54. * @return false = stop loop | true = continue loop
  55. */
  56. // bool handle(Tins::PDU &pdu);
  57. bool handleForwardToInner(Tins::PDU &pdu);
  58. bool handleForwardToOuter(Tins::PDU &pdu);
  59. virtual bool handleChannelToInner(Tins::PDU &pdu) = 0;
  60. virtual bool handleChannelToOuter(Tins::PDU &pdu) = 0;
  61. void startInnerForwardSniffing();
  62. void startOuterForwardSniffing();
  63. void startInnerChannelSniffing();
  64. void startOuterChannelSniffing();
  65. /**
  66. * Tins sniffer object.
  67. */
  68. Tins::Sniffer *innerForwardSniffer;
  69. Tins::Sniffer *outerForwardSniffer;
  70. Tins::Sniffer *innerChannelSniffer;
  71. Tins::Sniffer *outerChannelSniffer;
  72. Tins::PacketSender innerSender;
  73. Tins::PacketSender outerSender;
  74. };
  75. #endif