OTA(Over The Air)802.11 data capture with wireshark

Zeung-il Kim
3 min readOct 15, 2019

Wireshark으로 802.11 WLAN 데이터를 over the air조건에서 capture하는 방법

먼저 무선 디바이스를 monitor mode로 하나 추가 한다. 
$ sudo iw phy phy0 interface add mon0 type monitor
$ iw dev
phy#2
Interface wlx00e04c0bf7ec
ifindex 8
wdev 0x200000001
addr ab:cd:ee:0b:f7:ec
type managed
phy#0
Interface mon0
ifindex 11
wdev 0x6
addr aa:bb:cc:dd:16:28
type monitor

Unnamed/non-netdev interface
wdev 0x5
addr ab:cd:ef:gg:16:29
type P2P-device
Interface wlp68s0
ifindex 10
wdev 0x4
addr ba:cd:fg:hi:16:28
type managed
모니터모드 세팅을 위해 기존 인터페이스는 지운다. (지우지 않으면 채널 세팅 시 에러가 남.)$ sudo iw dev wlp68s0 del
$ sudo ifconfig mon0 up
데이터를 캡쳐 할 AP의 채널(주파수)로 세팅한다.
(이 세팅을 안해주면 mgmt frame만 보이고 data frame이 보이질 않음)
$ sudo iw dev mon0 set channel 36
또는
$ sudo iw dev mon0 set freq 5180
$ iwconfig mon0
mon0 IEEE 802.11 Mode:Monitor Frequency:5.18 GHz Tx-Power=0 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on

$ iw phy phy0 info 로 디바이스가 지원하는 모드 확인 HT, Frequency 등Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* P2P-client
* P2P-GO
* P2P-device
.....
* 5865 MHz [173] (disabled)
* 5885 MHz [177] (disabled)
* 5905 MHz [181] (disabled)
....
$ iw dev
phy#2
Interface wlx00e04c0bf7ec
ifindex 8
wdev 0x200000001
addr aa:bb:cc:0b:f7:ec
type managed
phy#0
Interface mon0
ifindex 9
wdev 0x3
addr ee:ee:ff:cb:16:28
type monitor
channel 36 (5180 MHz), width: 20 MHz (no HT), center1: 5180 MHz
Wireshark에서 mon0 interface를 통해 모니터링 가능함.
다시 managed mode로 돌아가기
먼저 monitor mode interface 지우기
$ sudo iw dev mon0 delmanaged mode로 디바이스 다시 추가(가능하면 지우기전 이름 알아 둘 것!)$ sudo iw phy phy0 interface add wlp68s0 type managed
$ iw dev
phy#2
Interface wlx00e04c0bf7ec
ifindex 8
wdev 0x200000001
addr ff:ff:ff:0b:f7:ec
type managed
phy#0
Unnamed/non-netdev interface
wdev 0x5
addr ee:ee:ee:cb:16:29
type P2P-device
Interface wlp68s0
ifindex 10
wdev 0x4
addr dd:dd:dd:cb:16:28
type managed
(base) kzi@kzi:~$ iw dev
(base) kzi@kzi:~$ iwconfig wlp68s0
802.11n의 경우 HT 모드를 지원하고 Bandwidth가 40MHz로 AP가 설정된 경우
mon0 디바이스가 Bandwidth 20MHz(no HT)인 경우는 40MHz대역으로 보내는 data frame은 캡쳐가 되지 않는다.
이 경우 mon0 를 40MHz로 설정 해준다.
$ iw dev
phy#2
Interface wlx00e04c0bf7ec
ifindex 8
wdev 0x200000001
addr 00:e0:4c:0b:f7:ec
type managed
phy#0
Interface mon0
ifindex 11
wdev 0x6
addr b4:6b:fc:cb:16:28
type monitor
channel 36 (5180 MHz), width: 20 MHz (no HT), center1: 5180 MHz
$ sudo iw --debug dev mon0 set channel 36 HT40+
-- Debug: Sent Message:
------------ BEGIN NETLINK MESSAGE ---------------------------
[NETLINK HEADER] 16 octets
.nlmsg_len = 44
.type = 28 <0x1c>
.flags = 5 <REQUEST,ACK>
.seq = 1571122554
.port = 1509961118
[GENERIC NETLINK HEADER] 4 octets
.cmd = 2
.version = 0
.unused = 0
[PAYLOAD] 24 octets
08 00 03 00 0b 00 00 00 08 00 26 00 3c 14 00 00 ..........&.<...
08 00 27 00 03 00 00 00 ..'.....
----------------- END NETLINK MESSAGE ---------------------------
-- Debug: Received Message:
---------------- BEGIN NETLINK MESSAGE ---------------------------
[NETLINK HEADER] 16 octets
.nlmsg_len = 36
.type = 2 <ERROR>
.flags = 256 <ROOT>
.seq = 1571122554
.port = 1509961118
[ERRORMSG] 20 octets
.error = 0 "Success"
[ORIGINAL MESSAGE] 16 octets
.nlmsg_len = 16
.type = 28 <0x1c>
.flags = 5 <REQUEST,ACK>
.seq = 1571122554
.port = 1509961118
------------- END NETLINK MESSAGE ---------------------------
$ iw dev
phy#2
Interface wlx00e04c0bf7ec
ifindex 8
wdev 0x200000001
addr 00:e0:4c:0b:f7:ec
type managed
phy#0
Interface mon0
ifindex 11
wdev 0x6
addr b4:6b:fc:cb:16:28
type monitor
channel 36 (5180 MHz), width: 40 MHz, center1: 5190 MHz
Bandwidth를 HT40으로 설정하면 20MHz로 전환 된 경우도 캡쳐됨.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response