|
@@ -2,30 +2,35 @@
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
|
|
|
ProxyChannel::ProxyChannel(const std::string &innerInterface, const std::string &outerInterface, const std::string &ownIP, const std::string &partnerIP,
|
|
ProxyChannel::ProxyChannel(const std::string &innerInterface, const std::string &outerInterface, const std::string &ownIP, const std::string &partnerIP,
|
|
- const std::string &originIP, const std::string &targetIP, const std::string &targetPort, const bool relayOnly)
|
|
|
|
- : CovertChannel(innerInterface, outerInterface, "not (tcp and src host " + originIP + " and dst host " + targetIP + " and dst port " + targetPort + ")",
|
|
|
|
-
|
|
|
|
- "not (tcp and src host " + targetIP + " and dst host " + ownIP + " and src port " + targetPort + ")",
|
|
|
|
-
|
|
|
|
|
|
+ const std::string &originIP, const std::string &targetIP, const std::string &targetPort, const std::string &ownMAC,
|
|
|
|
+ const std::string &originMAC, const std::string &channelGatewayMAC, const std::string &gatewayMAC, const bool relayOnly)
|
|
|
|
+ : CovertChannel(innerInterface, outerInterface,
|
|
|
|
+ "not (tcp and src host " + originIP + " and dst host " + targetIP + " and dst port " + targetPort + ") and not(dst host " + ownIP + ")",
|
|
|
|
+ "not (tcp and src host " + targetIP + " and dst host " + ownIP + " and src port " + targetPort + ") and not(dst host " + ownIP + ")",
|
|
"tcp and src host " + originIP + " and dst host " + targetIP + " and dst port " + targetPort,
|
|
"tcp and src host " + originIP + " and dst host " + targetIP + " and dst port " + targetPort,
|
|
-
|
|
|
|
"tcp and src host " + targetIP + " and dst host " + ownIP + " and src port " + targetPort,
|
|
"tcp and src host " + targetIP + " and dst host " + ownIP + " and src port " + targetPort,
|
|
-
|
|
|
|
"tcp and src host " + partnerIP + " and dst host " + ownIP + " and dst port " + targetPort),
|
|
"tcp and src host " + partnerIP + " and dst host " + ownIP + " and dst port " + targetPort),
|
|
- relayOnly(relayOnly), ownAddress(ownIP), partnerAddress(partnerIP), originAddress(originIP), targetAddress(targetIP) {}
|
|
|
|
|
|
+
|
|
|
|
+ relayOnly(relayOnly), ownAddress(ownIP), partnerAddress(partnerIP), originAddress(originIP), targetAddress(targetIP), ownMAC(ownMAC),
|
|
|
|
+ channelGatewayMAC(channelGatewayMAC), gatewayMAC(gatewayMAC), originMAC(originMAC) {}
|
|
|
|
|
|
ProxyChannel::~ProxyChannel() {}
|
|
ProxyChannel::~ProxyChannel() {}
|
|
|
|
|
|
bool ProxyChannel::handleChannelFromOuter(Tins::PDU &pdu) {
|
|
bool ProxyChannel::handleChannelFromOuter(Tins::PDU &pdu) {
|
|
// TODO: check in a list how to route it and who send the request for this answer
|
|
// TODO: check in a list how to route it and who send the request for this answer
|
|
|
|
|
|
|
|
+ Tins::EthernetII ð = pdu.rfind_pdu<Tins::EthernetII>();
|
|
Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
if (relayOnly) {
|
|
if (relayOnly) {
|
|
// redirect to partner
|
|
// redirect to partner
|
|
|
|
+ eth.src_addr(ownMAC);
|
|
|
|
+ eth.dst_addr(channelGatewayMAC);
|
|
ip.src_addr(ownAddress);
|
|
ip.src_addr(ownAddress);
|
|
ip.dst_addr(partnerAddress);
|
|
ip.dst_addr(partnerAddress);
|
|
outerSender.send(pdu);
|
|
outerSender.send(pdu);
|
|
} else {
|
|
} else {
|
|
|
|
+ eth.src_addr(gatewayMAC);
|
|
|
|
+ eth.dst_addr(originMAC);
|
|
ip.src_addr(targetAddress);
|
|
ip.src_addr(targetAddress);
|
|
ip.dst_addr(originAddress);
|
|
ip.dst_addr(originAddress);
|
|
innerSender.send(pdu);
|
|
innerSender.send(pdu);
|
|
@@ -35,12 +40,15 @@ bool ProxyChannel::handleChannelFromOuter(Tins::PDU &pdu) {
|
|
}
|
|
}
|
|
|
|
|
|
bool ProxyChannel::handleChannelFromInner(Tins::PDU &pdu) {
|
|
bool ProxyChannel::handleChannelFromInner(Tins::PDU &pdu) {
|
|
|
|
+ Tins::EthernetII ð = pdu.rfind_pdu<Tins::EthernetII>();
|
|
Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
if (relayOnly) {
|
|
if (relayOnly) {
|
|
std::cerr << "Fixme: packet cannot be routed back so it's dropped here!!!" << std::endl;
|
|
std::cerr << "Fixme: packet cannot be routed back so it's dropped here!!!" << std::endl;
|
|
// outerSender.send(pdu);
|
|
// outerSender.send(pdu);
|
|
// TODO: add pdu to a list to check later how to route it
|
|
// TODO: add pdu to a list to check later how to route it
|
|
} else {
|
|
} else {
|
|
|
|
+ eth.src_addr(ownMAC);
|
|
|
|
+ eth.dst_addr(channelGatewayMAC);
|
|
ip.src_addr(ownAddress);
|
|
ip.src_addr(ownAddress);
|
|
ip.dst_addr(partnerAddress);
|
|
ip.dst_addr(partnerAddress);
|
|
outerSender.send(pdu);
|
|
outerSender.send(pdu);
|
|
@@ -50,15 +58,17 @@ bool ProxyChannel::handleChannelFromInner(Tins::PDU &pdu) {
|
|
}
|
|
}
|
|
|
|
|
|
bool ProxyChannel::handlePartnerFromOuter(Tins::PDU &pdu) {
|
|
bool ProxyChannel::handlePartnerFromOuter(Tins::PDU &pdu) {
|
|
|
|
+ Tins::EthernetII ð = pdu.rfind_pdu<Tins::EthernetII>();
|
|
Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
if (relayOnly) {
|
|
if (relayOnly) {
|
|
- // redirect to partner
|
|
|
|
|
|
+ // redirect to target
|
|
ip.src_addr(ownAddress);
|
|
ip.src_addr(ownAddress);
|
|
ip.dst_addr(targetAddress);
|
|
ip.dst_addr(targetAddress);
|
|
outerSender.send(pdu);
|
|
outerSender.send(pdu);
|
|
std::cout << "relay" << std::endl;
|
|
std::cout << "relay" << std::endl;
|
|
} else {
|
|
} else {
|
|
- // should already be addressed right
|
|
|
|
|
|
+ eth.src_addr(gatewayMAC);
|
|
|
|
+ eth.dst_addr(ownMAC);
|
|
ip.src_addr(targetAddress);
|
|
ip.src_addr(targetAddress);
|
|
ip.dst_addr(originAddress);
|
|
ip.dst_addr(originAddress);
|
|
innerSender.send(pdu);
|
|
innerSender.send(pdu);
|