[英]Python script to convert snort alert to csv
I'm new to python. 我是python的新手。 So please support me I want to convert from snort alert to csv with some specific value 所以,请支持我,我想从snort警报转换为具有一些特定值的csv
Here are the snort alert (can read by notepad): 这是snort警报(可以通过记事本读取):
[**] [1:2015665:1] ET CURRENT_EVENTS NeoSploit - TDS [**]
[Classification: Attempted User Privilege Gain] [Priority: 1]
03/14-14:13:24.731076 192.168.52.10:1060 -> 67.196.50.144:80
TCP TTL:57 TOS:0x0 ID:34187 IpLen:20 DgmLen:258 DF
***A**** Seq: 0xBB770235 Ack: 0x9A83A217 Win: 0x3CB8 TcpLen: 20
[**] [1:2021076:1] ET INFO SUSPICIOUS Dotted Quad Host MZ Response [**]
[Classification: Potentially Bad Traffic] [Priority: 2]
03/14-14:13:24.845200 67.196.50.144:80 -> 192.168.52.10:1060
TCP TTL:128 TOS:0x0 ID:1442 IpLen:20 DgmLen:5880 DF
***A**** Seq: 0x9A83C2E5 Ack: 0xBB77030F Win: 0xFFFF TcpLen: 20
alert.full , alert.full ,
I want to filter some information such as Alert, Src IP, Src port, Dst IP, Dst port, Protocol DgmLen and save to a csv file. 我想过滤一些信息,如Alert,Src IP,Src端口,Dst IP,Dst端口,Protocol DgmLen并保存到csv文件。
Alert SrcIP Srcport DstIP Dstport Protocol DgmLen
ET Current event... 192.168.52.10 1060 67.196.50.144 80 TCP 258
ET INFO SUSPICIOUS 67.196.50.144 80 192.168.52.10 1060 TCP 5880
array
读取array
6行 dict
to hold the data you want. 创建一个dict
来保存所需的数据。 Alert
from array[0]
从array[0]
提取列Alert
SrcIP, Srcport, DstIP, Dstport, Protocol , DgmLen
from array[2]
and array[3]
从array[2]
和array[3]
提取SrcIP, Srcport, DstIP, Dstport, Protocol , DgmLen
列 csv.DictWriter
使用csv.DictWriter
写入CSV文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.