def pre_attack_init(self):
     self.client = paho.Client(
         random_generated_names.get_random_client_name())
     try:
         self.client.connect(self.address)
     except Exception as e:  # We may fail to connect the broker if the adress is invalid so except it
         self.logger.error("Failed to connect to broker")
 def pre_attack_init(self):
     self.client = paho.Client(
         random_generated_names.get_random_client_name())
     try:
         self.client.connect(self.address)
     except Exception as e:
         self.logger.error("Failed to connect to broker")
Beispiel #3
0
 def pre_attack_init(self):
     try:
         assert self.fuzzing_turn >= 2
     except AssertionError as e:
         raise
     self.client = paho.Client(
         random_generated_names.get_random_client_name())
     try:
         self.client.connect(self.host)
     except Exception as e:
         self.logger.error("Failed to connect to broker")
Beispiel #4
0
 def pre_attack_init(self):
     try:
         assert self.selected_index >= 0
     except AssertionError as _:
         self.logger.error("Invalid selected packet value!")
         raise
     try:
         assert self.selected_index < len(self.captured_packets)
     except AssertionError as _:
         self.logger.error("Input value exceeds captured packets' size!")
         raise
     self.client = paho.Client(
         random_generated_names.get_random_client_name())
Beispiel #5
0
import paho.mqtt.client as paho

import argparse
import logging
import signal
import sys
import threading

from Utils.RandomUtil.random_generated_names import get_random_client_name

DEFAULT_BROKER_HOST = "localhost"
DEFAULT_TOPIC_NAME = "peniot/demo"
DEFAULT_CLIENT_NAME = get_random_client_name()

logging.basicConfig(level=logging.DEBUG,
                    format="%(asctime)s:%(levelname)s:%(name)s : %(message)s")
logger = logging.getLogger("MQTT Demo Subscriber Example")

global_subscriber = None


class DemoSubscriber(object):
    """
    Demo Subscriber that will have limited data storage and error prone code to simulate effects of attacks
    """
    def __init__(self):
        self.message_container = []
        self.start_processing_of_temperatures()

    def on_message(self, client, userdata, message):
        coming_message = str(message.payload.decode("utf-8"))