class NTPHeader(sqlObject): """ Object holding the information for an NTP header """ def __init__(self, pkt: Packet): self.udp = UDP(pkt) self.ref_id = pkt["NTPHeader"].ref_id self.id = pkt["NTPHeader"].id self.version = pkt["NTPHeader"].version @staticmethod def table_sql() -> str: """ Constructs the necessary parameters for the table building as a string :return: str """ return UDP.table_sql() + \ """, ref_id STRING (64) NOT NULL, ntp_id STRING (64) NOT NULL, npt_ver STRING (40) NOT NULL""" def csv(self): """ Creates a list of the arguments required for an INSERT statement :return: list """ return self.udp.csv() + [ str(self.ref_id), str(self.id), str(self.version) ]
def table_sql() -> str: """ Constructs the necessary parameters for the table building as a string :return: str """ return UDP.table_sql() + \ """,
class BOOTP(sqlObject): """ Object representing the information for the BOOTP portion of packets, paired with the DHCP information """ def __init__(self, pkt: Packet): self.udp = UDP(pkt) self.client_ip = pkt["BOOTP"].ciaddr self.assigned_ip = pkt["BOOTP"].yiaddr self.server_ip = pkt["BOOTP"].siaddr self.client_mac = pkt["BOOTP"].chaddr @staticmethod def table_sql() -> str: """ Constructs the necessary parameters for the table building as a string :return: str """ return DHCP.table_sql() def csv(self): """ Creates a list of the arguments required for an INSERT statement :return: list """ return self.udp.csv() + [str(self.client_ip), str(self.assigned_ip), str(self.server_ip), str(self.client_mac)]
def __init__(self, pkt: Packet): if "TCP" in pkt: self.udp_tcp = TCP(pkt) self.is_tcp = True else: self.udp_tcp = UDP(pkt) self.is_tcp = False # Get question record question_record = pkt["DNS"].qd if question_record: self.qname = question_record.qname self.qtype = question_record.qtype self.qclass = question_record.qclass else: self.qname = "" self.qtype = "" self.qclass = ""
class DNS(sqlObject): """ Object representing the information for the DNS information of a packet """ def __init__(self, pkt: Packet): if "TCP" in pkt: self.udp_tcp = TCP(pkt) self.is_tcp = True else: self.udp_tcp = UDP(pkt) self.is_tcp = False # Get question record question_record = pkt["DNS"].qd if question_record: self.qname = question_record.qname self.qtype = question_record.qtype self.qclass = question_record.qclass else: self.qname = "" self.qtype = "" self.qclass = "" @staticmethod def table_sql() -> str: """ Constructs the necessary parameters for the table building as a string :return: str """ return UDP.table_sql() + \ """, is_tcp BOOLEAN NOT NULL, qname STRING (40) NOT NULL, qtype STRING (40) NOT NULL, qclass STRING (40) NOT NULL""" def csv(self): """ Creates a list of the arguments required for an INSERT statement :return: list """ return self.udp_tcp.csv() + [str(self.is_tcp), str(self.qname), str(self.qtype), str(self.qclass)]
def __init__(self, pkt: Packet): self.udp = UDP(pkt) self.ref_id = pkt["NTPHeader"].ref_id self.id = pkt["NTPHeader"].id self.version = pkt["NTPHeader"].version
def __init__(self, pkt: Packet): self.udp = UDP(pkt) self.client_ip = pkt["BOOTP"].ciaddr self.assigned_ip = pkt["BOOTP"].yiaddr self.server_ip = pkt["BOOTP"].siaddr self.client_mac = pkt["BOOTP"].chaddr