如何抓取无线网络数据包

简介: 结论: Mac: airport, tcpdump Windows: Omnipeek Linux: tcpdump, airmon-ng 以太网里抓包很简单,各种软件一大把,什么Wireshark,Ethereal,Sniffer Pro 一抓一大把。不过如果是无线数据包,就要稍微麻烦一点了。网上找了一堆罗里吧嗦的文章,绕来绕去的,其实抓无线包一条命令就好了。 Windows

结论:
Mac: airport, tcpdump
Windows: Omnipeek
Linux: tcpdump, airmon-ng

以太网里抓包很简单,各种软件一大把,什么Wireshark,Ethereal,Sniffer Pro 一抓一大把。不过如果是无线数据包,就要稍微麻烦一点了。网上找了一堆罗里吧嗦的文章,绕来绕去的,其实抓无线包一条命令就好了。

Windows下因为无线网卡驱动会拒绝进入混杂模式,所以比较蛋疼,一般是用Omnipeek去弄,不细说了。

Linux和Mac就很方便了。只要用tcpdump就可以,一般系统都自带了。最后-i选项的参数填想抓的网络设备名就行。Mac默认的WiFi网卡是en0。
tcpdump -Ine -i en0

主要就是指定-I参数,进入监控模式。
-I :Put the interface in "monitor mode"; this is supported only on IEEE 802.11 Wi-Fi interfaces, and supported only on some operating systems.
进入监控模式之后计算机用于监控的无线网卡就上不了网了,所以可以考虑买个外置无线网卡来抓包,上网抓包两不误。

抓了包能干很多坏事,比如WEP网络抓几个IV包就可以用aircrack破密码,WPA网络抓到一个握手包就能跑字典破无线密码了。如果在同一个网络内,还可以看到各种未加密的流量……什么小黄图啊,隐私照啊之类的……。

假如我已经知道某个手机的MAC地址,那么只要
tcpdump -Ine -i en0 | grep $MAC_ADDRESS
就过滤出该手机相关的WiFi流量。

具体帧的类型详情参看802.11协议,《802.11无线网络权威指南》等。

顺便解释以下混杂模式与监控模式的区别:
混杂(promiscuous)模式是指:接收同一个网络中的所有数据包,无论是不是发给自己的。
监控(monitor)模式是指:接收某个物理信道中所有传输着的数据包。

RFMON
RFMON is short for radio frequency monitoring mode and is sometimes also described as monitor mode or raw monitoring mode. In this mode an 802.11 wireless card is in listening mode (“sniffer” mode).

The wireless card does not have to associate to an access point or ad-hoc network but can passively listen to all traffic on the channel it is monitoring. Also, the wireless card does not require the frames to pass CRC checks and forwards all frames (corrupted or not with 802.11 headers) to upper level protocols for processing. This can come in handy when troubleshooting protocol issues and bad hardware.

RFMON/Monitor Mode vs. Promiscuous Mode
Promiscuous mode in wired and wireless networks instructs a wired or wireless card to process any traffic regardless of the destination mac address. In wireless networks promiscuous mode requires that the wireless card be associated to an access point or ad-hoc network. While in promiscuous mode a wireless card can transmit and receive but will only captures traffic for the network (SSID) to which it is associated.

RFMON mode is only possible for wireless cards and does not require the wireless card to be associated to a wireless network. While in monitor mode the wireless card can passively monitor traffic of all networks and devices within listening range (SSIDs, stations, access points). In most cases the wireless card is not able to transmit and does not follow the typical 802.11 protocol when receiving traffic (i.e. transmit an 802.11 ACK for received packet).

Both modes have to be supported by the driver of the wired or wireless card.

另外在研究抓包工具时,发现了Mac下有一个很好用的命令行工具airport,可以用来抓包,以及摆弄Macbook的WiFi。
位置在
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

可以创建一个符号链接方便使用:
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport  /usr/sbin/airport

常用的命令有:
显示当前网络信息:airport -I
扫描周围无线网络:airport -s
断开当前无线网络:airport -z
强制指定无线信道:airport -c=$CHANNEL

抓无线包,可以指定信道:
airport en0 sniff [$CHANNEL]
抓到的包放在/tmp/airportSniffXXXXX.cap,可以用tcpdump, tshark, wireshark等软件来读。

最实用的功能还是扫描周围无线网络。

目录
相关文章
|
2月前
|
网络协议 程序员 网络安全
【网络安全】数据包拓展
【网络安全】数据包拓展
72 0
|
2月前
|
网络协议 Shell Linux
【Shell 命令集合 网络通讯 】Linux 追踪数据包在网络中的路径 traceroute命令 使用指南
【Shell 命令集合 网络通讯 】Linux 追踪数据包在网络中的路径 traceroute命令 使用指南
76 0
|
2月前
|
数据采集 大数据 数据安全/隐私保护
掌握网络抓取技术:利用RobotRules库的Perl下载器一览小红书的世界
本文探讨了使用Perl和RobotRules库在遵循robots.txt规则下抓取小红书数据的方法。通过分析小红书的robots.txt文件,配合亿牛云爬虫代理隐藏真实IP,以及实现多线程抓取,提高了数据采集效率。示例代码展示了如何创建一个尊重网站规则的数据下载器,并强调了代理IP稳定性和抓取频率控制的重要性。
掌握网络抓取技术:利用RobotRules库的Perl下载器一览小红书的世界
|
2月前
|
安全 网络协议 Java
网络安全-数据包拓展
【4月更文挑战第2天】数据包拓展
86 0
|
29天前
|
数据采集 存储 数据挖掘
Python网络爬虫实战:抓取并分析网页数据
使用Python的`requests`和`BeautifulSoup`,本文演示了一个简单的网络爬虫,抓取天气网站数据并进行分析。步骤包括发送HTTP请求获取HTML,解析HTML提取温度和湿度信息,以及计算平均温度。注意事项涉及遵守robots.txt、控制请求频率及处理动态内容。此基础爬虫展示了数据自动收集和初步分析的基础流程。【6月更文挑战第14天】
118 9
|
2月前
|
移动开发
使用charles来抓取手机App的网络包
使用charles来抓取手机App的网络包
30 1
|
1月前
|
网络协议 网络架构
计算机网络——计算机网络体系结构(4/4)-计算机网络体系结构中的专用术语(实体、协议、服务,三次握手‘三报文握手’、数据包术语)
计算机网络——计算机网络体系结构(4/4)-计算机网络体系结构中的专用术语(实体、协议、服务,三次握手‘三报文握手’、数据包术语)
24 0
|
2月前
|
Python
使用Python的Requests库进行网络请求和抓取网页数据
【4月更文挑战第20天】使用Python Requests库进行网络请求和网页数据抓取的步骤包括:安装库(`pip install requests`)、导入库、发送GET/POST请求、检查响应状态码、解析内容、处理Cookies、设置请求头以及异常处理。通过`response`对象访问响应信息,如`status_code`、`text`、`content`和`cookies`。可设置`headers`模拟用户代理,用`try-except`处理异常。
36 7
|
2月前
|
Python
如何使用Python的Requests库进行网络请求和抓取网页数据?
【4月更文挑战第19天】使用Python Requests库进行网络请求和网页数据抓取:安装库,导入requests,发送GET/POST请求,检查状态码(如`status_code==200`表示成功),解析响应内容(如`response.text`),处理Cookies和请求头,以及用try-except捕获异常。更多功能可深入学习Requests库。
25 2
|
2月前
|
数据采集 前端开发 Java
利用Scala与Apache HttpClient实现网络音频流的抓取
利用Scala与Apache HttpClient实现网络音频流的抓取