|
@@ -2,33 +2,32 @@
|
|
|
#include <iostream>
|
|
|
|
|
|
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 (tcp and dst host " + filterIP + " and dst port " + filterPort + ")",
|
|
|
+ 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 " + filterIP + " and src port " + filterPort + ") or (proto tcp and src host " + partnerIP + " and src port " +
|
|
|
- filterPort + ") or (dst host " + ownIP + "))",
|
|
|
+ "not (tcp and src host " + targetIP + " and dst host " + ownIP + " and src port " + targetPort + ")",
|
|
|
|
|
|
- "tcp and dst host " + filterIP + " and dst port " + filterPort,
|
|
|
+ "tcp and src host " + originIP + " and dst host " + targetIP + " and dst port " + targetPort,
|
|
|
|
|
|
- "tcp and src host " + filterIP + " and src port " + filterPort,
|
|
|
+ "tcp and src host " + targetIP + " and dst host " + ownIP + " and src port " + targetPort,
|
|
|
|
|
|
- "tcp and src host " + partnerIP + " and src port " + filterPort),
|
|
|
- relayOnly(relayOnly), ownAddress(ownIP), partnerAddress(partnerIP), filterAddress(filterIP) {}
|
|
|
+ "tcp and src host " + partnerIP + " and dst host " + ownIP + " and src port " + targetPort),
|
|
|
+ relayOnly(relayOnly), ownAddress(ownIP), partnerAddress(partnerIP), originAddress(originIP), targetAddress(targetIP) {}
|
|
|
|
|
|
ProxyChannel::~ProxyChannel() {}
|
|
|
|
|
|
bool ProxyChannel::handleChannelFromOuter(Tins::PDU &pdu) {
|
|
|
// TODO: check in a list how to route it and who send the request for this answer
|
|
|
|
|
|
- Tins::IP ip = pdu.rfind_pdu<Tins::IP>();
|
|
|
+ Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
|
if (relayOnly) {
|
|
|
// redirect to partner
|
|
|
ip.src_addr(ownAddress);
|
|
|
ip.dst_addr(partnerAddress);
|
|
|
- pdu.inner_pdu(ip);
|
|
|
outerSender.send(pdu);
|
|
|
} else {
|
|
|
- // should already be addressed right
|
|
|
+ ip.src_addr(targetAddress);
|
|
|
+ ip.dst_addr(originAddress);
|
|
|
innerSender.send(pdu);
|
|
|
std::cout << "channel from outer" << std::endl;
|
|
|
}
|
|
@@ -36,14 +35,14 @@ bool ProxyChannel::handleChannelFromOuter(Tins::PDU &pdu) {
|
|
|
}
|
|
|
|
|
|
bool ProxyChannel::handleChannelFromInner(Tins::PDU &pdu) {
|
|
|
- Tins::IP ip = pdu.rfind_pdu<Tins::IP>();
|
|
|
+ Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
|
if (relayOnly) {
|
|
|
std::cerr << "Fixme: packet cannot be routed back so it's dropped here!!!" << std::endl;
|
|
|
// outerSender.send(pdu);
|
|
|
// TODO: add pdu to a list to check later how to route it
|
|
|
} else {
|
|
|
+ ip.src_addr(ownAddress);
|
|
|
ip.dst_addr(partnerAddress);
|
|
|
- pdu.inner_pdu(ip);
|
|
|
outerSender.send(pdu);
|
|
|
std::cout << "channel from inner" << std::endl;
|
|
|
}
|
|
@@ -51,17 +50,16 @@ bool ProxyChannel::handleChannelFromInner(Tins::PDU &pdu) {
|
|
|
}
|
|
|
|
|
|
bool ProxyChannel::handlePartnerFromOuter(Tins::PDU &pdu) {
|
|
|
- Tins::IP ip = pdu.rfind_pdu<Tins::IP>();
|
|
|
+ Tins::IP &ip = pdu.rfind_pdu<Tins::IP>();
|
|
|
if (relayOnly) {
|
|
|
// redirect to partner
|
|
|
ip.src_addr(ownAddress);
|
|
|
- ip.dst_addr(filterAddress);
|
|
|
- pdu.inner_pdu(ip);
|
|
|
+ ip.dst_addr(targetAddress);
|
|
|
outerSender.send(pdu);
|
|
|
} else {
|
|
|
// should already be addressed right
|
|
|
- ip.src_addr(filterAddress);
|
|
|
- pdu.inner_pdu(ip);
|
|
|
+ ip.src_addr(targetAddress);
|
|
|
+ ip.dst_addr(originAddress);
|
|
|
innerSender.send(pdu);
|
|
|
std::cout << "partner" << std::endl;
|
|
|
}
|