0

我在尝试通过其以太网接口转发 RREQ 数据包(通过 MANET 模拟网络接收)时遇到了麻烦。我正在寻找一种将所述数据包(从无线接口接收)发送到通过以太网直接连接的另一台主机的方法。

假设我从主机 A 的无线接口接收到一个数据包,主机 A 也有一个直接连接到主机 B 的以太网接口,我想通过以太网接口转发该数据包,以便主机 B 通过它的以太网接口接收这个数据包。

我不知道要使用什么功能来做到这一点。

我正在从事的项目是一个大项目,因此如果特别需要,我将在需要时包含代码以回答我的问题。

编辑:

因此,最终目标是在 MANET 网络中实施虫洞攻击。简而言之,虫洞攻击涉及两个攻击者(ATTACKER_A 和ATTACKER_B),它们通过高速连接(即以太网)直接相互连接。一旦 AT​​TACKER_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.n​​ed

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 源文件中,并且由于高度模块化,我在寻找正确的方法来实现它时遇到了麻烦。此外,缺乏文档也无济于事。

4

1 回答 1

1

send()函数用于发送消息。您可以从OMNeT++ 的手册页了解更多信息。

要使用该send()功能,您至少需要两个参数。

  1. 您要发送的消息。
  2. 您要通过其发送它的接口名称。

在您的情况下,消息是 RREQ 数据包,接口是主机 A 的以太网接口。由于您手头有 RREQ 数据包,您只需要找出以太网接口名称。为此,您需要检查.ned您正在模拟的网络文件。

.ned文件将包含以下格式的一些声明。

network Network_Name
{
    parameters:
        ...
    submodules:
        ...
    connections:
        ...
}

这只是一个例子。但是根据您的仿真模型,该.ned文件可能包含更复杂的声明。但是您应该关注connections:.

通常connections:你会在下面找到一些声明之类的。

Host_A.portX <--> Host_B.portY;

portX是您要查找的接口名称。这又是一个简单的例子,下面的声明connections:可能包含更多。因此,如果您自己无法弄清楚,则需要在此处上传您的网络文件connections:部分。.ned

完成后,您可以send()像这样使用。

send(RREQ, "portX")

只需确保在主机 A 的文件中portX声明为inout或门即可。否则行不通。如果在您的 中声明为门使用,则指定使用 的输出接口。out.nedsend()portXinoutportX$osend()send()portX

于 2015-03-17T04:42:36.540 回答