Browse Source

Proxy Channel test

Jonas Pflanzer 4 years ago
parent
commit
4f641f1c16
2 changed files with 21 additions and 10 deletions
  1. 17 7
      daemon/src/CovertChannel/ProxyChannel.cpp
  2. 4 3
      daemon/src/main.cpp

+ 17 - 7
daemon/src/CovertChannel/ProxyChannel.cpp

@@ -3,11 +3,16 @@
 
 ProxyChannel::ProxyChannel(const std::string &innerInterface, const std::string &outerInterface, const std::string &ownIP, const std::string &partnerIP,
                            const std::string &filterIP, const std::string &filterPort, const bool relayOnly)
-    : CovertChannel(innerInterface, outerInterface, "not (proto tcp and dst host " + filterIP + " and dst port " + filterPort + ")",
-                    "not ((proto tcp and src host " + filterIP + " and src port " + filterPort + ") or (proto tcp and src host " + partnerIP +
-                        " and src port " + filterPort + ") or (dst host " + ownIP + "))",
-                    "proto tcp and dst host " + filterIP + " and dst port " + filterPort, "proto tcp and src host " + filterIP + " and src port " + filterPort,
-                    "proto tcp and src host " + partnerIP + " and src port " + filterPort),
+    : CovertChannel(innerInterface, outerInterface, "not (tcp and dst host " + filterIP + " and dst port " + filterPort + ")",
+
+                    "not ((tcp and src host " + filterIP + " and src port " + filterPort + ") or (proto tcp and src host " + partnerIP + " and src port " +
+                        filterPort + ") or (dst host " + ownIP + "))",
+
+                    "tcp and dst host " + filterIP + " and dst port " + filterPort,
+
+                    "tcp and src host " + filterIP + " and src port " + filterPort,
+
+                    "tcp and src host " + partnerIP + " and src port " + filterPort),
       relayOnly(relayOnly), ownAddress(ownIP), partnerAddress(partnerIP), filterAddress(filterIP) {}
 
 ProxyChannel::~ProxyChannel() {}
@@ -20,11 +25,12 @@ bool ProxyChannel::handleChannelFromOuter(Tins::PDU &pdu) {
 		// redirect to partner
 		ip.src_addr(ownAddress);
 		ip.dst_addr(partnerAddress);
-
+		pdu.inner_pdu(ip);
 		outerSender.send(pdu);
 	} else {
 		// should already be addressed right
 		innerSender.send(pdu);
+		std::cout << "channel from outer" << std::endl;
 	}
 	return true;
 }
@@ -37,7 +43,9 @@ bool ProxyChannel::handleChannelFromInner(Tins::PDU &pdu) {
 		// TODO: add pdu to a list to check later how to route it
 	} else {
 		ip.dst_addr(partnerAddress);
+		pdu.inner_pdu(ip);
 		outerSender.send(pdu);
+		std::cout << "channel from inner" << std::endl;
 	}
 	return true;
 }
@@ -48,12 +56,14 @@ bool ProxyChannel::handlePartnerFromOuter(Tins::PDU &pdu) {
 		// redirect to partner
 		ip.src_addr(ownAddress);
 		ip.dst_addr(filterAddress);
-
+		pdu.inner_pdu(ip);
 		outerSender.send(pdu);
 	} else {
 		// should already be addressed right
 		ip.src_addr(filterAddress);
+		pdu.inner_pdu(ip);
 		innerSender.send(pdu);
+		std::cout << "partner" << std::endl;
 	}
 	return true;
 }

+ 4 - 3
daemon/src/main.cpp

@@ -3,6 +3,7 @@
 #include "../include/Config.h"
 #include "../include/CovertChannel/CovertChannel.h"
 #include "../include/CovertChannel/ForwardChannel.h"
+#include "../include/CovertChannel/ProxyChannel.h"
 #include "../include/Server.h"
 #include "../include/UserManager.h"
 
@@ -19,15 +20,15 @@ int main(int argc, char *argv[]) {
 	if (Config::getValue("activateCovertChannel") == "true") {
 		const string innerInterface = Config::getValue("innerInterface");
 		const string outerInterface = Config::getValue("outerInterface");
-		/*
+
 		const string ownIP = Config::getValue("ownIP");
 		const string partnerIP = Config::getValue("partnerIP");
 		const string filterIP = Config::getValue("filterIP");
 		const string filterPort = Config::getValue("filterPort");
 		const string relayMode = Config::getValue("relayMode");
 		covertchannel = new ProxyChannel(innerInterface, outerInterface, ownIP, partnerIP, filterIP, filterPort, relayMode == "true");
-		*/
-		covertchannel = new ForwardChannel(innerInterface, outerInterface);
+
+		// covertchannel = new ForwardChannel(innerInterface, outerInterface);
 		covertchannel->startSniffing();
 	}