我在尝试通过其以太网接口转发 RREQ 数据包(通过 MANET 模拟网络接收)时遇到了麻烦。我正在寻找一种将所述数据包(从无线接口接收)发送到通过以太网直接连接的另一台主机的方法。
假设我从主机 A 的无线接口接收到一个数据包,主机 A 也有一个直接连接到主机 B 的以太网接口,我想通过以太网接口转发该数据包,以便主机 B 通过它的以太网接口接收这个数据包。
我不知道要使用什么功能来做到这一点。
我正在从事的项目是一个大项目,因此如果特别需要,我将在需要时包含代码以回答我的问题。
编辑:
因此,最终目标是在 MANET 网络中实施虫洞攻击。简而言之,虫洞攻击涉及两个攻击者(ATTACKER_A 和ATTACKER_B),它们通过高速连接(即以太网)直接相互连接。一旦 ATTACKER_A 的邻居发送一个 RREQ,并且 ATTACKER_A 收到它,它就会通过以太网将 RREQ 转发给 ATTACKER_B,而不是简单地在网络中广播它。当 ATTACKER_B 接收到 RREQ 时,它将通过无线方式将 RREQ 转发到它的邻居,充当 AODV manet 网络中的普通节点。
结果是 ATTACKER_A 的邻居被欺骗认为 ATTACKER_B 附近的主机是它自己邻居的一部分,从而在网络的两个远距离部分之间创建了一个虫洞。
事实上,这个理论并没有那么复杂。
所以,这是网络模式
这是 SimpleWormhole.ned
package nesg.netattacks.simulations.SimpleAttackScenarios.SimpleWormholeAttackScenario;
import inet.networklayer.autorouting.ipv4.IPv4NetworkConfigurator;
import inet.world.radio.ChannelControl;
import ned.DatarateChannel;
import nesg.netattacks.nodes.NA_AttackerAdhocHost;
import nesg.netattacks.nodes.NA_AdhocHost;
network SimpleWormhole
{
@display("bgb=600,477,grey75");
int test_ivo;
types:
channel ethline extends DatarateChannel
{
delay = 50ns;
datarate = 100Mbps;
}
submodules:
nodeA: NA_AdhocHost {
@display("p=79,310");
}
nodeB: NA_AdhocHost {
@display("p=240,366");
}
nodeC: NA_AdhocHost {
@display("p=380,120");
}
nodeD: NA_AdhocHost {
@display("p=518,159");
}
nodeE: NA_AdhocHost {
@display("p=240,186");
}
nodeF: NA_AdhocHost {
@display("p=380,286");
}
attackerA: NA_AttackerAdhocHost {
@display("p=165,310");
}
attackerB: NA_AttackerAdhocHost {
@display("p=450,159");
}
configurator: IPv4NetworkConfigurator {
@display("p=80,20");
}
channelControl: ChannelControl {
@display("p=80,70;i=misc/sun");
}
connections:
attackerA.ethg++ <--> eth_ivo: ethline <--> attackerB.ethg++;
}
NA_ATTACKERADHOCHOST 是一个 ned 文件,它连续继承自其他 ned 文件,回顾继承链,我发现第一个 ned 文件是 NA_NODEBASE,其中包含一些与以太网门相关的部分
NA_NODEBASE.ned
package nesg.netattacks.nodes;
import inet.util.PcapRecorder;
import inet.networklayer.ipv4.RoutingTable;
import inet.networklayer.common.InterfaceTable;
import inet.mobility.IMobility;
import inet.linklayer.IWirelessNic;
import inet.linklayer.IWiredNic;
import inet.linklayer.IExternalNic;
import inet.base.NotificationBoard;
import inet.nodes.inet.NetworkLayer;
import nesg.netattacks.hackedmodules.networklayer.NA_NetworkLayer;
module NA_NodeBase
{
parameters:
@display("bgb=611,448");
@node;
@labels(node,ethernet-node,wireless-node);
int numExtInterfaces = default(0);
int numRadios = default(0); // the number of radios in the router. by default no wireless
int numPcapRecorders = default(0); // no of PcapRecorders.
string mobilityType = default("StationaryMobility");
string routingFile = default("");
bool IPForward = default(true);
gates:
input radioIn[numRadios] @directIn;
inout pppg[] @labels(PPPFrame-conn);
inout ethg[] @labels(EtherFrame-conn);
submodules:
notificationBoard: NotificationBoard {
parameters:
@display("p=53,194");
}
// optional mobility module. Required only if wireless cards are present
mobility: <mobilityType> like IMobility if mobilityType != "" && numRadios > 0 {
parameters:
@display("p=53,121");
}
//# Hacked module replacing the normal NetworkLayer INET module for attack purposes.
networkLayer: NA_NetworkLayer {
parameters:
@display("p=329,287;q=queue");
}
routingTable: RoutingTable {
parameters:
@display("p=53,287");
IPForward = IPForward;
routingFile = routingFile;
}
// linklayer
interfaceTable: InterfaceTable {
parameters:
@display("p=53,386");
}
pcapRecorder[numPcapRecorders]: PcapRecorder {
@display("p=159,259");
}
wlan[numRadios]: <default("Ieee80211Nic")> like IWirelessNic {
parameters:
@display("p=159,386;q=queue");
}
eth[sizeof(ethg)]: <default("EthernetInterface")> like IWiredNic {
parameters:
@display("p=282,386,row,90;q=txQueue");
}
ppp[sizeof(pppg)]: <default("PPPInterface")> like IWiredNic {
parameters:
@display("p=407,386,row,90;q=txQueue");
}
ext[numExtInterfaces]: <default("ExtInterface")> like IExternalNic {
parameters:
@display("p=547,386,row,90;q=txQueue;i=block/ifcard");
}
connections allowunconnected:
// connections to network outside
for i=0..sizeof(radioIn)-1 {
radioIn[i] --> wlan[i].radioIn;
wlan[i].upperLayerOut --> networkLayer.ifIn++;
wlan[i].upperLayerIn <-- networkLayer.ifOut++;
}
for i=0..sizeof(ethg)-1 {
ethg[i] <--> eth[i].phys;
eth[i].upperLayerOut --> networkLayer.ifIn++;
eth[i].upperLayerIn <-- networkLayer.ifOut++;
}
for i=0..sizeof(pppg)-1 {
pppg[i] <--> ppp[i].phys;
ppp[i].upperLayerOut --> networkLayer.ifIn++;
ppp[i].upperLayerIn <-- networkLayer.ifOut++;
}
for i=0..numExtInterfaces-1 {
ext[i].upperLayerOut --> networkLayer.ifIn++;
ext[i].upperLayerIn <-- networkLayer.ifOut++;
}
}
最后,攻击者使用了 AODV 协议的实现,这是我需要编辑以使其工作的代码。代码取自 INET 框架。
我搜索了所有 aodv 代码,以找到我需要编辑的贵重物品功能,以实现该虫洞行为,结果发现我可能需要在此处修改此功能的一部分
NA_AODV_rreq.cc
void NS_CLASS rreq_process(RREQ * rreq, int rreqlen, struct in_addr ip_src,
struct in_addr ip_dst, int ip_ttl,
unsigned int ifindex)
{
-- some code here --
// BEGIN NA_WORMHOLE
// if wormhole is active print it
if (wormholeAttackIsActive) {
LOG << "\n sending rreq forward to other attacker \n";
//send(rreq, "ethg$o");
if (!ev.isDisabled())
ev.printf("ip_src=%s rreq_orig=%s rreq_dest=%s\n",ip_to_str(ip_src),
ip_to_str(rreq_orig), ip_to_str(rreq_dest));
LOG << "\n\nsent\n\n";
LOG << ip_ttl;
//return;
}
// END NA_WORMHOLE
如您所见,真正的问题是所有代码都在 AODV 源文件中,并且由于高度模块化,我在寻找正确的方法来实现它时遇到了麻烦。此外,缺乏文档也无济于事。