Chinaunix
标题:
求教,刚接触perl 要做一个抓包分析
[打印本页]
作者:
懒狒狒
时间:
2012-11-27 09:20
标题:
求教,刚接触perl 要做一个抓包分析
本帖最后由 懒狒狒 于 2012-11-27 09:20 编辑
刚到一家公司,从php转perl吧,现在领导要将pkt文件根据指定时间进行抓包分析
已经根据之前的前辈将pkt文件合并成cap文件,然后不知道怎么分析实现让其生成
我想要的文本,我想的是只要能将cap文件解析成文本就好根据自己需要的规则把他
匹配出来,但是实在学浅,搞了两天停顿了,貌似cap问件是16进制之类的,还劳烦
大牛指点指点,给点思路,谢谢
不知道说的明白不
作者:
sjdy521
时间:
2012-11-27 10:31
本帖最后由 sjdy521 于 2012-11-27 10:33 编辑
不明白 什么是pkt 什么是cap 看天书。。
作者:
懒狒狒
时间:
2012-11-27 10:41
我也不是很清楚,是用一款抓包分析工具wireshark打开的进行syn ack分析
回复
2#
sjdy521
作者:
laputa73
时间:
2012-11-27 10:52
wireshark和tcpdump的包格式是可以兼容的
可以先用tcpdump转成文本,再用perl分析吧
作者:
懒狒狒
时间:
2012-11-27 11:00
win7环境下可以么,我怎么搜都是linux环境哟
回复
4#
laputa73
作者:
laputa73
时间:
2012-11-27 11:02
回复
5#
懒狒狒
win7环境下你可以直接用wireshark的命令行模式tshark
作者:
q1208c
时间:
2012-11-27 11:05
perl应该不能直接分析tcpdump的二进制文件, 转成 文本 再分析吧.
作者:
懒狒狒
时间:
2012-11-27 11:12
我想的也是先将他转成文本,但是貌似到转成文本这一步我比较难实现哦,
这点不知道如何下手,有链接或者需要注意的事项没有呀,大虾
如果能转成文本的话,按照一定的规则应该分析起来比较得心应手一点
回复
7#
q1208c
作者:
懒狒狒
时间:
2012-11-27 11:15
在网上搜了一下有关的例子,貌似比较少哦
大牛么,不吝赐教
作者:
sjdy521
时间:
2012-11-27 11:16
本帖最后由 sjdy521 于 2012-11-27 11:16 编辑
问公司的前辈,他们拿工资的,有责任指导你
作者:
懒狒狒
时间:
2012-11-27 11:18
{:3_186:} 公司就我一个perl哦
回复
10#
sjdy521
作者:
sjdy521
时间:
2012-11-27 11:24
二进制转文本 这个和perl有啥关系
作者:
q1208c
时间:
2012-11-27 11:31
回复
8#
懒狒狒
用 tcpdump的命令转呀. 那个需要 wincap的库的.
作者:
懒狒狒
时间:
2012-11-27 11:40
嗯呐,谢谢了,我在查查文档看看怎么用的哈
回复
13#
q1208c
作者:
wsxedcer
时间:
2012-11-27 11:46
回复
1#
懒狒狒
tshark -r input
-r <infile> set the filename to read from (no pipes or stdin!)
复制代码
作者:
懒狒狒
时间:
2012-11-27 12:18
嗯,也不算是吧,我们部门主要是分析当我们的服务器受到攻击的时候能快速的查询出自己想要的参数
回复
16#
defendre
作者:
dsadjkasd
时间:
2012-11-28 00:43
本帖最后由 dsadjkasd 于 2012-11-28 00:45 编辑
你可以下个010editor帮助你进行16进制或者2进制数据的分析,但数据位数字符型之类都需要自己不断猜测揣摩出规律来,才能进行有效的解码数据成可读的东西。。。比如02FAF080表示50000000,当然你看16进制的时候这个数应该是“80 F0 FA 02”, 抓的包应该分析下报文,报头,需要参考下TCP 和UDP如何封装的。。。
作者:
laputa73
时间:
2012-11-28 08:23
本帖最后由 laputa73 于 2012-11-29 10:08 编辑
那些二进制包是有协议的,不是简单的16进制转转就能识别的
所以tshark是必须的
http://www.wireshark.org/docs/ws ... AppToolstshark.html
TShark 1.7.0 (SVN Rev 39165 from /trunk)
Dump and analyze network traffic.
See http://www.wireshark.org for more information.
Copyright 1998-2011 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Usage: tshark [options] ...
Capture interface:
-i <interface> name or idx of interface (def: first non-loopback)
-f <capture filter> packet filter in libpcap filter syntax
-s <snaplen> packet snapshot length (def: 65535)
-p don't capture in promiscuous mode
-B <buffer size> size of kernel buffer (def: 1MB)
-y <link type> link layer type (def: first appropriate)
-D print list of interfaces and exit
-L print list of link-layer types of iface and exit
Capture stop conditions:
-c <packet count> stop after n packets (def: infinite)
-a <autostop cond.> ... duration:NUM - stop after NUM seconds
filesize:NUM - stop this file after NUM KB
files:NUM - stop after NUM files
Capture output:
-b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs
filesize:NUM - switch to next file after NUM KB
files:NUM - ringbuffer: replace after NUM files
Input file:
-r <infile> set the filename to read from (no pipes or stdin!)
Processing:
-2 perform a two-pass analysis
-R <read filter> packet filter in Wireshark display filter syntax
-n disable all name resolutions (def: all enabled)
-N <name resolve flags> enable specific name resolution(s): "mntC"
-d <layer_type>==<selector>,<decode_as_protocol> ...
"Decode As", see the man page for details
Example: tcp.port==8888,http
Output:
-w <outfile|-> write packets to a pcap-format file named "outfile"
(or to the standard output for "-")
-C <config profile> start with specified configuration profile
-F <output file type> set the output file type, default is libpcap
an empty "-F" option will list the file types
-V add output of packet tree (Packet Details)
-O <protocols> Only show packet details of these protocols, comma
separated
-P print packets even when writing to a file
-S <separator> the line separator to print between packets
-x add output of hex and ASCII dump (Packet Bytes)
-T pdml|ps|psml|text|fields
format of text output (def: text)
-e <field> field to print if -Tfields selected (e.g. tcp.port);
this option can be repeated to print multiple fields
-E<fieldsoption>=<value> set options for output when -Tfields selected:
header=y|n switch headers on and off
separator=/t|/s|<char> select tab, space, printable character as separator
occurrence=f|l|a print first, last or all occurrences of each field
aggregator=,|/s|<char> select comma, space, printable character as
aggregator
quote=d|s|n select double, single, no quotes for values
-t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first)
-u s|hms output format of seconds (def: s: seconds)
-l flush standard output after each packet
-q be more quiet on stdout (e.g. when using statistics)
-X <key>:<value> eXtension options, see the man page for details
-z <statistics> various statistics, see the man page for details
Miscellaneous:
-h display this help and exit
-v display version info and exit
-o <name>:<value> ... override preference setting
-K <keytab> keytab file to use for kerberos decryption
-G [report] dump one of several available reports and exit
default report="fields"
use "-G ?" for more help
复制代码
作者:
wuluoroad
时间:
2012-11-28 12:56
LZ这个工作做好了吗?我也想做类似的事情,一起交流哈
作者:
只爱睡觉
时间:
2012-11-29 15:24
这个工作鄙人早年做过分析cap的包话先用wireshark转成xls,在转成txt,然后在分析。
作者:
feilong_36
时间:
2012-12-10 20:04
wireshark另存为 k12格式就方便perl解析了了
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2