mysqldb_logger.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:honeyd-python 作者: sookyp 项目源码 文件源码
def insert(self, attack_event):
        """Function inserts attack-related data into the database
        Args:
            attack_event : dictionary containing attack-related information
        """
        cursor = self.connection.cursor()
        try:
            cursor.execute("""
                INSERT INTO events (ethernet_source, ip_source, port_source, ethernet_destination, ip_destination, port_destination, ethernet_type, protocol, info, raw_packet)
                VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)""", (
                    str(attack_event["ethernet_src"]),
                    str(attack_event["ip_src"]),
                    str(attack_event["port_src"]),
                    str(attack_event["ethernet_dst"]),
                    str(attack_event["ip_dst"]),
                    str(attack_event["port_dst"]),
                    str(attack_event["ethernet_type"]),
                    str(attack_event["protocol"]),
                    str(attack_event["info"]),
                    str(attack_event["raw_pkt"])
                    ))
            self.connection.commit()
        except (AttributeError, MySQLdb.OperationalError):
            logger.error('Error: Cannot insert attack event into database.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号