Пример #1
0
class EAPOL(sqlObject):
    """
     Object representing the information for the EAPOL information of a packet
    """
    def __init__(self, pkt: Packet):
        self.ether = Ethernet(pkt)
        self.version = pkt["EAPOL"].version
        self.type = pkt["EAPOL"].type
        self.length = pkt["EAPOL"].len

    @staticmethod
    def table_sql() -> str:
        """
        Constructs the necessary parameters for the table building as a string
        :return: str
        """
        return Ethernet.table_sql() + \
               """,
                  eapol_ver  STRING (40) NOT NULL,
                  type       STRING (40) NOT NULL,
                  eapol_len  INTEGER     NOT NULL"""

    def csv(self):
        """
        Creates a list of the arguments required for an INSERT statement
        :return: list
        """
        return self.ether.csv() + [
            str(self.version),
            str(self.type),
            str(self.length)
        ]
Пример #2
0
class ARP(sqlObject):
    """
    Object holding the information for an ARP packet
    """
    def __init__(self, pkt: Packet):
        self.ether = Ethernet(pkt)

    @staticmethod
    def table_sql() -> str:
        """
        Constructs the necessary parameters for the table building as a string
        :return: str
        """
        return Ethernet.table_sql()

    def csv(self):
        """
        Creates a list of the arguments required for an INSERT statement
        :return: list
        """
        return self.ether.csv()
Пример #3
0
class IP(sqlObject):
    """
    Object holding the information for an IP header
    """
    def __init__(self, pkt: Packet):
        self.ether = Ethernet(pkt)
        if "IP" in pkt:
            self.v6 = False
            key = "IP"
        else:
            self.v6 = True
            key = "IPv6"

        self.src_ip = pkt[key].src
        self.dst_ip = pkt[key].dst

    @staticmethod
    def table_sql() -> str:
        """
        Constructs the necessary parameters for the table building as a string
        :return: str
        """
        return Ethernet.table_sql() + \
               """,
                  src_ip   STRING (64) NOT NULL,
                  dst_ip   STRING (64) NOT NULL,
                  v6       BOOLEAN     NOT NULL"""

    def csv(self):
        """
        Creates a list of the arguments required for an INSERT statement
        :return: list
        """
        return self.ether.csv() + [
            str(self.src_ip), str(self.dst_ip),
            str(self.v6)
        ]