巩鹏军的博客

HOME

tcpdump抓包http流量

27 Nov 2022

tcpdum http 常用命令

命令一:

$ tcpdump -A -s 0 '[src]/[dst] host {HOST} and port {PORT} and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) !=0)'

抓取和baidu.com的80端口之间的HTTP包:

$ tcpdump -A -s 0 'host baidu.com and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

抓取8080端口的HTTP包:

$ tcpdump -A -s 0 'tcp port 8080 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) !=0)'

ASCII Code

gongpengjun@mbp cheatsheat-tcpdump$ echo -n "GET " | hexdump -C
00000000  47 45 54 20                                       |GET |
00000004
gongpengjun@mbp cheatsheat-tcpdump$ echo -n "POST" | hexdump -C
00000000  50 4f 53 54                                       |POST|
00000004
gongpengjun@mbp cheatsheat-tcpdump$ echo -n "PUT" | hexdump -C
00000000  50 55 54                                          |PUT|
00000003
gongpengjun@mbp cheatsheat-tcpdump$ echo -n "HTTP" | hexdump -C
00000000  48 54 54 50                                       |HTTP|
00000004
gongpengjun@mbp cheatsheat-tcpdump$ echo -n "HEAD" | hexdump -C
00000000  48 45 41 44                                       |HEAD|
00000004

【命令解析】

参考资料

关于我

专注于IM即时通讯全技术栈的程序员,关注获取更多IM技术文章。

gongpengjunblog

IM小蓝天

微信扫描二维码,关注我的公众号