Esempio n. 1
0
def main():
    """
	Function constructs logger, tkinter, and ui_class objects
	"""
    c_logger = log.Logger("client")
    root = tk.Tk()
    c_logger.info("", main.__name__, "Root window created")
    root.resizable(False, False)
    root.title("Cowrie Log Analyzer")
    root.configure()

    user_interface = ui_class.ui(root)
    c_logger.info("", main.__name__, "UI class object created")
    user_interface.start_up()
    c_logger.info("", main.__name__, "UI drawn in root window")
    root.mainloop()
"""
Node definition
"""

import random
import hashlib
from Log import log

logger = log.Logger().get_logger()

NON_ACK_TYPES = ["ACK", "RREQ", "BREQ", "BREP"]
ACK_TYPES = ["JREQ", "MSG1", "MSG2", "MSG3", "MSG4", "JACC", "JDEC", "RREP", "RERR", "RREPAIR"]

class Message():
    def __init__(self, origin, dest, final_dest, msg_type, created_on=None, data=None, sequenznumber=None, checksum=None, hop_count=None):
        self.origin = origin
        self.dest = dest
        self.final_dest = final_dest
        self.created_on = created_on
        self.msg_type = msg_type
        self.data = data or {}
        self.sequenznumber = sequenznumber
        self.hop_count = hop_count or 1

        self.checksum = checksum or self.generate_checksum(self.origin, self.final_dest, self.sequenznumber, self.created_on)

    def __repr__(self):
        # return "MESSAGE: FROM {} WITH FINAL {} CREATED AT {} with Data: {}, {} and SQZ: {} via {}".format(self.origin, self.final_dest, self.created_on, self.msg_type, self.data, self.sequenznumber, self.dest)
        return "{} FROM {} VIA {} TO {} CSM {} DATA {} ".format(self.msg_type, self.origin, self.dest, self.final_dest, self.checksum, self.data)

    def generate_checksum(self, origin, final_dest, sequenznumber, created_on):
__license__ = "GPLv3"
__version__ = "1.0.0"
__maintainer__ = "Jason M. Pittman"
__email__ = "*****@*****.**"
__status__ = "Release"
__dependecies__ = " "

import pathlib

import sqlite3

from sqlite3 import Error

from Log import log

country_db_logger = log.Logger("country_db")
'''
Create a database connection to a SQLite database
Input: Database file name
Output: a connection to the database
'''


def create_connection(db_file="Events/country_lookup.db"):
    """
	Parameters
	----------
	db_file : str
	"""
    conn = None
    try:
Esempio n. 4
0
__copyright__ = "Copyright 2020"
__credits__ = ["Kevin A. Rubin, Jason M. Pittman"]
__license__ = "GPLv3"
__version__ = "1.0.0"
__maintainer__ = "Jason M. Pittman"
__email__ = "*****@*****.**"
__status__ = "Release"
__dependecies__ = "system, log, tkinter"

from Events import system

from Log import log

import tkinter as tk

facade_logger = log.Logger("facade")


class event_handler:
    """
	This acts as an intermediary between the actual functionality of the buttons and the UI component.

	Attributes
	----------
	logic : logic object
	update_screen : function
	export : function
	_alert_window : alert_window object
	"""
    def __init__(self, update_screen, export, alert_window):
        """
__license__ = "GPLv3"
__version__ = "1.0.0"
__maintainer__ = "Jason M. Pittman"
__email__ = "*****@*****.**"
__status__ = "Release"
__dependecies__ = "events_class, events_database, sys, log"

from Events import events_class

from Events import events_database

import sys

from Log import log

system_logger = log.Logger("system")


class logic:
    """
	This class holds functionality code that the facade calls.

	Attributes
	----------
	events_object : events_class object
	"""
    def __init__(self):
        self.events_object = events_class.Events()

    def get_data(self, name):
        """
__status__ = "Release"
__dependecies__ = "sqlite3, json, datetime, country_database, log"

import sqlite3

from sqlite3 import Error

import json

import datetime

from Events import country_database

from Log import log

events_db_log = log.Logger("events_db")


def create_connection(db_file="Events/events.db"):
	"""
	Creates a database connection to a SQLite database (specifically used for events.db)

	Parameters
	----------
	db_file : str
	"""
	conn = None
	try:
		conn = sqlite3.connect(db_file)
		create_table(conn)
		create_command_table(conn)
Esempio n. 7
0
import pandas as pd

matplotlib.use("TkAgg")

from matplotlib.figure import Figure

from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

import matplotlib.pyplot as plt

from Events import events_database

from Log import log

ui_logger = log.Logger("ui_elements")


class StandardButton:
    """
	A button class with basic functionality and consistent look.

	Attributes
	----------
	_button_text : str
	_palette : color object
	_style : ttk.Style object
	_button : ttk.Button object
	"""
    def __init__(self, parent, command_function, button_text, palette):
        """
Esempio n. 8
0
parser.add_argument(
    "--sf",
    default="topologie.json",
    type=str,
    help="Saving into specified topologie file. Default =: topologie.json")

args = parser.parse_args()
msg = "Settings: " + "; Seed:" + str(args.S) + "; Nodes:" + str(
    args.n) + "; Urban:" + str(args.u) + "; Optimized:" + str(args.o)
msg = msg + "; SimTime:" + str(args.sT) + "; Configs:" + str(
    args.cN) + " & " + str(args.cC) + "; Loading:" + str(
        args.l) + "; LoadFile:" + str(args.lf) + "; SaveFile:" + str(args.sf)

random.seed(args.S)

logger = log.Logger(args.n).get_logger()
logger.info("Starting program...")
logger.info(msg)

top_data = None
# Laden einer Topologie falls angegeben und vorhanden
if args.l and storage.is_available(args.lf):
    logger.info("Loading topologie: " + args.lf)
    top_data = storage.read_json(args.lf)
# Generieren einer Topologie und abspeichern
else:
    logger.info("Generating new topologie")
    top_gen = topologie_generator.TopologieGenerator(args.n, args.u)
    top_gen.generate()
    top_data = top_gen.get_topologie_data()
    # TOPOLOGIE SPEICHERN
__status__ = "Release"
__dependecies__ = "ui_elements, facade, tkinter, color_palette, log, events_database"

from UI import ui_elements

import facade

import tkinter as tk

from UI import color_palette

from Log import log

from Events import events_database

ui_class_logger = log.Logger("ui_class")


class ui:
    """
	Attributes
	----------
	palette : color_palette object
	_info_box_col : int
	_info_box_row : int
	root : tk.Tk object
	alert : alert window object
	eh : event handler object
	import_pop : PopUp object
	export_pop : PopUp object
	first_row : tk.Frame object