Attacker.py – Attacker

The attacker module is used for simualtion predefined attacks. Messages between clients and servers are passed through the attacker and modified for attacks. The attacker runs as a single process.

Classes

Attacker

class Attacker.Attacker(config, clientConfigs, clientQueues, serverConfigs, serverQueues, writer, counter, attacks, attackerQueue, attackers, verbose=False)[source]

Initializes the Attacker.

Parameters:
  • config – Own config
  • clientConfigs – List of all available client configurations
  • clientQueues – List of all available Client queues to pass messages to the client
  • serverConfigs – List of all available server configurations
  • serverQueues – List of all available Client queues to pass messages to the client
  • writer – Writer queue to pass messages to that are send on the interface or written to the .pcap file
  • conter – Number of attacks to be executed, can be set to 0 to create dumps without attacks
  • attacks – List of attacks that can be executed during runtime, those values can be configured using the configuration file
  • attackerQueue – Own queue messages from all clients and servers are passed to
  • attackers – Other attackers whos messages can be ignored and are not attacked
  • verbose – can be set to True for additional output, default=False
Returns:

configured Attacker Object

setIntervalMax(intervalMax)[source]

Set the maximum Interval an attacker will respond. The interval is given as int im ms.

setIntervalMin(intervalMin)[source]

Set the minimum Interval an attacker will respond. The interval is given as int im ms.

setName(name)[source]

Set the internal Name of the attacker, useful in case more attackers in verbose mode are used. The name is given as string.

setOwnClientID(clientID)[source]

Set the own client ID of the attacker as the attacker is a legitime part of the network. The client id is given as int.

Basic Functions

attacker

Attacker.attacker(a)[source]

Main method of the module that is initializing needed data and executing the attacking loop. The default value to set the minimum attacker response time is 0 ms. The default value to set the maximum attacker response time is 10 ms. Thoose values are used in case nothing is specified.

sendMsg

Attacker.sendMsg(a, msg, msgOrig)[source]

The Message Object is sent to the writer queue putting the Packet into the trace.

forward

Attacker.forward(a, msg)[source]

The message is going to be forwarded to its original receiver.

doAttack

Attacker.doAttack(curAttack, msgOrig, a, attacksSuc)[source]

Execute one of the predefined attacks that are configured to be executed.

Parameters:
  • curAttack – Choosen current attack.
  • msgOrig – Original message the attack is applied to.
  • a – Attacker Object containing all needed configurations and information.
  • attacksSuc – Counter for successfully executed attacks.
Returns:

Triple(Boolean, Boolean, Int), First entry means that the original message is forwarded or not, The second part means attack was successfull, the last value indicates the number of successfully executed attacks.

loadAttacks

Attacker.loadAttacks(attacksToUse)[source]

Dynamically loads modules from attacks folder to perform configured attacks.

randomErrorCode

Attacker.randomErrorCode()[source]

Attack that replaces a correct Error Code with an arbitrary one that might is not correct for the situation.