如何在 omnet++ 中使用 AODV 协议实施重放攻击?

How to implement a replay attack using AODV protocol in omnet++?

我需要一段模拟 AODV 网络的 C++ 代码片段,该网络带有进行重播攻击的恶意节点。我需要将它嵌入到我的 OMNet++ 项目中。

我试图在 OMNet++ 中更改示例项目中的原始代码,但我又回到了起点。

很高兴能找到帮助。

我无法包含示例代码,它的字符相当长,如果您需要查看我到目前为止的试验,请告诉我在哪里可以分享我的项目。

由于OP问题缺少一些细节,我将在Wikipedia article's example之后提供一个针对重放攻击的模拟解决方案:

Suppose Alice wants to prove her identity to Bob. Bob requests her password as proof of identity, which Alice dutifully provides (possibly after some transformation like a hash function); meanwhile, Eve is eavesdropping on the conversation and keeps the password (or the hash). After the interchange is over, Eve (posing as Alice) connects to Bob; when asked for a proof of identity, Eve sends Alice's password (or hash) read from the last session, which Bob accepts thus granting access to Eve.


我会创建一个新数据包(扩展 UDPPacket)来满足您的特定应用程序目标,方法是将 sourcedestination 字段添加到UDP 数据包:

cplusplus {{                
#include "<directory_path_for_the_udp_packet_goes_here>/UDPPacket_m.h"      // inheriting the parent class

}}

class ExtendedUDPPacket;    // you can call it whatever you want

message ExtendedUDPPacket extends UDPPacket 
{
    string sourceNode;          // name of the sender
    string destinationNode;         // name of the receiver
}

现在让我们看看给定示例中的 3 个不同角色:

  1. 爱丽丝:需要验证
  2. 鲍勃:身份验证者
  3. 夏娃:窃听者

如果我们考虑到每个节点都有一个保存其名称的特定 ID,我们可以为每个角色执行以下操作:

爱丽丝:

void MalAODVRouter::handleMessage(cMessage *msg)
{
    ExtendedUDPPacket *eUDPmsg = dynamic_cast<UDPPacket *>(msg);
    if (this->myID == eUDPmsg->getDestinationNode())      // myID is "Alice"
    {
        ExtendedUDPPacket *ExtendedUDPPacket= new UDPPacket();
        ExtendedUDPPacket->setSourceAddress(myID.c_str());
        ExtendedUDPPacket->setDestinationAddress(std::string("Bob").c_str());

        send(udpPacket, "ipOut");
    }
}

夏娃:

void MalAODVRouter::handleMessage(cMessage *msg)
{
    ExtendedUDPPacket *eUDPmsg = dynamic_cast<UDPPacket *>(msg);
    if (this->myID != eUDPmsg->getDestinationNode())      // myID is "Eve"
    {
        ExtendedUDPPacket *ExtendedUDPPacket= new UDPPacket();
        ExtendedUDPPacket->setSourceAddress(std::string("Alice").c_str());  // fake the message
        ExtendedUDPPacket->setDestinationAddress(std::string("Bob").c_str());

        send(udpPacket, "ipOut");
    }
}

鲍勃:

void MalAODVRouter::handleMessage(cMessage *msg)
{
    ExtendedUDPPacket *eUDPmsg = dynamic_cast<UDPPacket *>(msg);
    if (eUDPmsg->getSourceNode() == 'Alice')   
    {
        ExtendedUDPPacket *ExtendedUDPPacket= new UDPPacket();
        ExtendedUDPPacket->setSourceAddress(std::string("Bob").c_str());
        ExtendedUDPPacket->setDestinationAddress(std::string("Alice").c_str());


        send(udpPacket, "ipOut");
    }
}

请记住这是一个模拟实现,您可以添加更智能的条件检查以使应用程序运行得更好。