Commit f558482c authored by Eloy Degen's avatar Eloy Degen

Filter only DNS traffic

parent 5659d5f7
......@@ -51,10 +51,12 @@ def insert_db(pkt):
'rcv_date': current_date.strftime('%Y-%m-%d %H:%M:%S'),
}
query = '''INSERT INTO `detection_app_packet` (`src_ip`, `dst_ip`, `src_port`, `dst_port`, `content`, `rcv_date`) VALUES ("{ip_src}","{ip_dst}","{src_port}","{dst_port}","{content}","{rcv_date}");'''
result = cursor.execute(query.format(**format_string))
connection.commit()
print(" IP src " + str(ip_src) + " UDP sport " + str(udp_sport))
print(" IP dst " + str(ip_dst) + " UDP dport " + str(udp_dport))
# Filter only DNS traffic
if udp_dport = 53:
result = cursor.execute(query.format(**format_string))
connection.commit()
print(" IP src " + str(ip_src) + " UDP sport " + str(udp_sport))
print(" IP dst " + str(ip_dst) + " UDP dport " + str(udp_dport))
sniff(filter="ip",prn=insert_db, store=0)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment