NETWORK ATTACKS FRAMEWORK
1.0.0
A NETwork Attacks framework. Making network attacks impact evaluation easier!
|
Base class containing the base functionality for all attacks controllers. More...
#include <NA_Attack.h>
Protected Member Functions | |
virtual void | initialize () |
Method from cSimpleModule class, to initialize the simple module. | |
void | getAttackModules () |
Get the modules (hacked modules) in which the attack should be activated (saved in modList) | |
void | scheduleAttack () |
Schedule the activation/deactivation time of the attack. | |
void | sendMessageToHackedModules (cMessage *msg) |
For send the corresponding message to the specifics hacked modules implied in the attack. | |
virtual void | activateModules () |
Activate the attack in the hacked modules. | |
virtual void | deactivateModules () |
Deactivate the attack in the hacked modules. | |
virtual void | handleMessage (cMessage *msg) |
Method from cSimpleModule that is listening all messages scheduling by the scheduleAt method. | |
virtual cMessage * | generateAttackMessage (const char *name) |
Generate the specific message for an attack. | |
Protected Attributes | |
NA_NesgLog | log |
Log reference. | |
Private Attributes | |
char * | attackType |
String identifying the kind of attack to be striked. | |
vector< cModule * > | modList |
List of modules for activation of the attack. |
Base class containing the base functionality for all attacks controllers.
This is in charge of the communications between the attack controller and the hacked modules (modules that should be modified to build the attack)
Among others functionalities, this class is in charge of discover all modules that will be modified (hacked modules) and activated for a specific attack implementation. Each of this modules have the attackType parameter to identify them. Is also in charge of activate and deactivate the attack, scheduling it (from startime and stoptime parameters), among other funcionalities.
Definition at line 91 of file NA_Attack.h.
void NA_Attack::activateModules | ( | ) | [protected, virtual] |
Activate the attack in the hacked modules.
Definition at line 98 of file NA_Attack.cc.
{ char msgCaption[30]; // Concatenate the <attackType> + Activate opp_strcpy(msgCaption, attackType); strcat(msgCaption, NA_ATTACK_ACTIVATE_TAG); // Generate the specific attack controller message. // This method belongs to the specific attack controller. cMessage *msg = check_and_cast<cMessage *>( generateAttackMessage(msgCaption)); EV << "\n\n"; LOG << "-----------------------------------\n"; LOG << "ACTIVATING HACKED MODULES\n"; LOG << "-----------------------------------\n"; sendMessageToHackedModules(msg); }
void NA_Attack::deactivateModules | ( | ) | [protected, virtual] |
Deactivate the attack in the hacked modules.
Definition at line 117 of file NA_Attack.cc.
{ char msgCaption[30]; // Concatenate the <attackType> + Activate opp_strcpy(msgCaption, attackType); strcat(msgCaption, NA_ATTACK_DEACTIVATE_TAG); // Generate the specific attack controller message. // This method belongs to the specific attack controller. cMessage *msg = check_and_cast<cMessage *>( generateAttackMessage(msgCaption)); EV << "\n\n"; LOG << "-----------------------------------\n"; LOG << "DEACTIVATING HACKED MODULES\n"; LOG << "-----------------------------------\n"; sendMessageToHackedModules(msg); }
cMessage * NA_Attack::generateAttackMessage | ( | const char * | name | ) | [protected, virtual] |
Generate the specific message for an attack.
This must be overridden by all attack controllers subclasses. The name of the message, will be automatic generated by NA_Attack in the following way:
<attackType> + <Activate/Deactivate>
For example, in the dropping attack case, the name of the activation message is "droppingActivate".
name | char, name of the message. |
Reimplemented in NA_DroppingAttack, NA_DelayAttack, and NA_SinkholeAttack.
Definition at line 159 of file NA_Attack.cc.
{ LOG << "ERROR: EN NA_ATTACK GENERATE ATTACK MESSAGE\n"; cMessage *msg = new cMessage(name); return msg; }
void NA_Attack::getAttackModules | ( | ) | [protected] |
Get the modules (hacked modules) in which the attack should be activated (saved in modList)
Definition at line 47 of file NA_Attack.cc.
{ cTopology topo; //Used to discover the topology of the node and find modules for activating the attack cTopology::Node *node; string nodeName; // extract all modules with the @attackType property set in the simulation topo.extractByProperty(par(NA_ATTACK_TYPE).stringValue()); LOG << "------------------------------------\n"; LOG << "Found " << topo.getNumNodes() << " possible modules for attack\n"; LOG << "------------------------------------\n"; // Now, only the modules contained in the parent module of this NA_Attack object are activated. string prefix = this->getParentModule()->getFullPath(); // First we get the full path of the parent node int numModules = 0; for (int i = 0; i < topo.getNumNodes(); i++) { node = topo.getNode(i); nodeName = node->getModule()->getFullPath(); if (not nodeName.compare(0, prefix.size(), prefix)) { LOG << "--->Inserting module in list: " << nodeName << "\n"; modList.push_back(node->getModule()); numModules++; } } LOG << "-----------------------------------\n"; LOG << "Inserted " << numModules << " modules in list\n"; LOG << "-----------------------------------\n"; }
void NA_Attack::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Method from cSimpleModule that is listening all messages scheduling by the scheduleAt method.
msg | cMessage, the received message. |
Definition at line 88 of file NA_Attack.cc.
{ LOG << "Message received: " << msg->getFullName() << "\n"; if (not strcmp(msg->getFullName(), NA_ATTACK_START_MESSAGE)) { activateModules(); } else { deactivateModules(); } delete (msg); }
void NA_Attack::initialize | ( | ) | [protected, virtual] |
Method from cSimpleModule class, to initialize the simple module.
Definition at line 34 of file NA_Attack.cc.
{ // Get the type of attack to be launched attackType = (char*) par(NA_ATTACK_TYPE).stringValue(); // Activate the attack only if defined in the active parameter in module (.ned) if (par(NA_ATTACK_ACTIVE).boolValue() == true) { getAttackModules(); scheduleAttack(); } }
void NA_Attack::scheduleAttack | ( | ) | [protected] |
Schedule the activation/deactivation time of the attack.
Definition at line 77 of file NA_Attack.cc.
{ cMessage *msg = new cMessage(NA_ATTACK_START_MESSAGE); LOG << "Scheduling the attack \n"; scheduleAt(par(NA_ATTACK_START_TIME).doubleValue(), msg); if (par("endTime").doubleValue()) //When the value differs from 0 { cMessage *msgEnd = new cMessage(NA_ATTACK_END_MESSAGE); scheduleAt(par(NA_ATTACK_END_TIME).doubleValue(), msgEnd); } }
void NA_Attack::sendMessageToHackedModules | ( | cMessage * | msg | ) | [protected] |
For send the corresponding message to the specifics hacked modules implied in the attack.
msg | cMessage, the message of the specific attack and with its specific attributes. |
Definition at line 138 of file NA_Attack.cc.
{ unsigned int i; NA_HackedModule *modHacked; for (i = 0; i < modList.size(); i++) { LOG << "Module: " << modList[i]->getFullPath() << "\n"; if (modList[i]->isSimple()) { // Activation is only done in simple modules (implemented in C++ classes). modHacked = dynamic_cast<NA_HackedModule *>(modList[i]); LOG << "--> Sending message: " << msg->getFullName() << "\n"; // Send the message to the specific hacked module modHacked->handleMessageFromAttackController(msg); } else { LOG << "--> Message not sent. Not a simple module.\n"; } } LOG << "-----------------------------------\n"; }
char* NA_Attack::attackType [private] |
String identifying the kind of attack to be striked.
Definition at line 97 of file NA_Attack.h.
NA_NesgLog NA_Attack::log [protected] |
Log reference.
Definition at line 109 of file NA_Attack.h.
vector<cModule *> NA_Attack::modList [private] |
List of modules for activation of the attack.
Definition at line 102 of file NA_Attack.h.