Skip to content

Commit eb7f2b0

Browse files
create repo wlan-decoder-java
0 parents  commit eb7f2b0

File tree

94 files changed

+4854
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+4854
-0
lines changed

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Bertrand Martel
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Wlan 802.11 Decoder in Java #
2+
3+
http://akinaru.github.io/wlan-decoder-java/
4+
5+
<i>Last update 04/05/2015</i>
6+
7+
Decoder for Wlan 802.11 frame preceding with Radiotap header or not
8+
9+
Radiotap header are parsed with project http://akinaru.github.io/pcapng-decoder-java/
10+
11+
All type of Wlan 802.11 frames are parsed :
12+
* MANAGEMENT_FRAME_TYPE
13+
* CONTROL_FRAME_TYPE
14+
* DATA_FRAME_TYPE
15+
16+
But there are a few of "information element" block parsed for now (tagged parameters) :
17+
* SSID
18+
* HT CAPABILITIES
19+
* SUPPORTED RATE
20+
* TIM
21+
* EXTENDED SUPPORTED RATE
22+
* ERP
23+
* DSSS PARAMETER
24+
25+
It lacks a lot of informations element that will be implemented later
26+
27+
<hr/>
28+
29+
<b>USAGE</b>
30+
31+
The following usage show how to decode a Wlan 802.11 frame preceding with Radiotap frames.
32+
33+
You can also decode only wlan802.11 frames if you dont have radiotap header before
34+
35+
First you need a pcapng file containing :
36+
* your wlan 802.11 frames preceding with radiotap frames
37+
38+
You can use to parse this file
39+
* the jnetpcap library
40+
* my own lib in http://akinaru.github.io/pcapng-decoder-java/ (pcapng-decoder-java)
41+
42+
You dont have to take the jar to you it is already in lib folder
43+
44+
So basically this project use 2 external libs pcapngdecoder.jar and radiotapdecoder.jar
45+
46+
<hr/>
47+
48+
<b>COMMAND LINE SYNTAX</b>
49+
50+
``java -cp ../libs/pcapngdecoder-1.0.jar:../libs/radiotapdecoder-1.0.jar:wlandecoder-1.0.jar fr.bmartel.wlandecoder.DecodeMain -f ../pcapfile/exemple.pcapng -v``
51+
52+
-f <file.pcapng> : input file
53+
54+
-v : verbose, will show all section parsing content
55+
56+
This exemple is launched from release folder
57+
58+
<hr/>
59+
60+
<b>PROGRAM SYNTAX for parsing Wlan802.11 frames preceding with radiotap header</b>
61+
62+
``//data parsed from pcapng file``
63+
``byte[] wlanDataPrecedingWithRadiotapHeader = packet.getPacketData();``
64+
65+
``//initiate decoding``
66+
``WlanDecoder dataDecode = new WlanDecoder(packet.getPacketData());``
67+
``dataDecode.decodeWithRadiotap();``
68+
``wlanDecodedFrameList.add(dataDecode);``
69+
70+
You can retrieve radiotap data too if you want. Go check http://akinaru.github.io/radiotap-decoder-java/ for more precision
71+
72+
<b>PROGRAM SYNTAX for parsing Wlan802.11 frames ONLY</b>
73+
74+
``//data parsed from pcapng file``
75+
``byte[] wlanDataPrecedingWithRadiotapHeader = packet.getPacketData();``
76+
77+
``//initiate decoding``
78+
``WlanDecoder dataDecode = new WlanDecoder(packet.getPacketData());``
79+
``dataDecode.decode();``
80+
``wlanDecodedFrameList.add(dataDecode);``
81+
82+
# Output example
83+
84+
``
85+
Wlan frame control
86+
=======protocolVersion : 0
87+
=======type : 0
88+
=======subType : 8
89+
=======toDS : false
90+
=======fromDS : false
91+
=======moreFragmentation : false
92+
=======retry : false
93+
=======powerManagement : false
94+
=======moreData : false
95+
=======wep : false
96+
=======order : false
97+
Wlan management frame
98+
=======duration id : 00 | 00
99+
=======destinationAddr : FF | FF | FF | FF | FF | FF
100+
=======sourceAddr : 00 | 24 | D4 | 6B | 0C | 5D
101+
=======bssid : 00 | 24 | D4 | 6B | 0C | 5D
102+
=======sequenceControl : 00 | E5
103+
=======frameBody : 60 | 01 | 25 | DE | 32 | 03 | 00 | 00 | 60 | 00 | 01 | 04 | 00 | 08 | 46 | 72 | 65 | 65 | 57 | 69 | 66 | 69 | 01 | 08 | 82 | 84 | 8B | 96 | 2C | 0C | 12 | 18 | 03 | 01 | 0C | 05 | 04 | 00 | 02 | 00 | 00 | 2A | 01 | 04 | 32 | 05 | 24 | 30 | 48 | 60 | 6C | 2D | 1A | 6C | 00 | 03 | FF | FF | FF | 00 | 01 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 01 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 3D | 16 | 0C | 00 | 13 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 7F | 08 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 40 | DD | 18 | 00 | 50 | F2 | 02 | 01 | 01 | 00 | 00 | 03 | A4 | 00 | 00 | 27 | A4 | 00 | 00 | 42 | 43 | 5E | 00 | 62 | 32 | 2F | 00
104+
=======fcs : A3 | 26 | 13 | 07
105+
=======MANAGEMENT BEACON FRAME
106+
==============timestamp : 00 | 00 | 03 | 32 | DE | 25 | 01 | 60
107+
==============beaconInterval : 96
108+
==============capability information : 04 | 01
109+
=====================Dynamic Elements
110+
=====================element id : 0
111+
============================SSID : FreeWifi
112+
=====================Dynamic Elements
113+
=====================element id : 1
114+
============================data rates supported : 1000kbps,2000kbps,5500kbps,11000kbps,22000kbps,6000kbps,9000kbps,12000kbps,
115+
=====================Dynamic Elements
116+
=====================element id : 3
117+
============================currentChannel : 12
118+
============================frequency : -1
119+
=====================Dynamic Elements
120+
=====================element id : 5
121+
============================number of beacon frame before next DTIM : 0
122+
============================number of beacon interval between 2 DTIM : 2
123+
============================TIM bitmapControl : 0
124+
============================TIM partialVirtualBitmap : 00 |
125+
=====================Dynamic Elements
126+
=====================element id : 42
127+
============================isErpPresent : false
128+
============================useProtection : false
129+
============================isBarkerPreambleMode : true
130+
=====================Dynamic Elements
131+
=====================element id : 50
132+
============================extended data rates supported : 18000kbps,24000kbps,36000kbps,48000kbps,54000kbps,
133+
=====================Dynamic Elements
134+
=====================element id : 45
135+
============================support short 20Mhz : true
136+
============================support short 40Mhz : true
137+
============================channel width 20MHz supported : false
138+
============================channel width 40MHz supported : true
139+
============================AMPDU paramters : 3
140+
============================MCS Supported : n°0-BPSK
141+
============================MCS Supported : n°1-QPSK
142+
============================MCS Supported : n°2-QPSK
143+
============================MCS Supported : n°3-16-QAM
144+
============================MCS Supported : n°4-16-QAM
145+
============================MCS Supported : n°5-64-QAM
146+
============================MCS Supported : n°6-64-QAM
147+
============================MCS Supported : n°7-64-QAM
148+
============================MCS Supported : n°8-BPSK
149+
============================MCS Supported : n°9-QPSK
150+
============================MCS Supported : n°10-QPSK
151+
============================MCS Supported : n°11-16-QAM
152+
============================MCS Supported : n°12-16-QAM
153+
============================MCS Supported : n°13-64-QAM
154+
============================MCS Supported : n°14-64-QAM
155+
============================MCS Supported : n°15-64-QAM
156+
============================MCS Supported : n°16-BPSK
157+
============================MCS Supported : n°17-QPSK
158+
============================MCS Supported : n°18-QPSK
159+
============================MCS Supported : n°19-16-QAM
160+
============================MCS Supported : n°20-16-QAM
161+
============================MCS Supported : n°21-64-QAM
162+
============================MCS Supported : n°22-64-QAM
163+
============================MCS Supported : n°23-64-QAM
164+
============================HT Extended capabilities : 00 | 00
165+
============================Transmit beam forming capabilities : 00 | 00 | 00 | 00
166+
============================ASEL capabilities : 0
167+
``
168+
169+
Element id not parsed will be displayed at the beginning of the output like this :
170+
* Element id not decoded => 61
171+
172+
<hr/>
173+
174+
* Project is JRE 1.7 compliant
175+
* You can build it with ant => build.xml
176+
* Development on Eclipse
177+
* Specification from http://www.radiotap.org

build.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
3+
<project default="create_run_jar" name="Create Runnable Jar for Project wlandecoder">
4+
5+
<property name="version" value="1.0" />
6+
7+
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
8+
<!--ANT 1.7 is required -->
9+
<target name="create_run_jar">
10+
<jar destfile="${basedir}/release/wlandecoder-${version}.jar" filesetmanifest="mergewithoutmain">
11+
<manifest>
12+
<attribute name="Main-Class" value="fr.bmartel.wlandecoder.DecodeMain"/>
13+
<attribute name="Class-Path" value="."/>
14+
</manifest>
15+
<fileset dir="${basedir}/bin"/>
16+
</jar>
17+
</target>
18+
19+
</project>

libs/pcapngdecoder-1.0.jar

58.3 KB
Binary file not shown.

libs/radiotapdecoder-1.0.jar

19.2 KB
Binary file not shown.

pcapfile/exemple.pcapng

512 Bytes
Binary file not shown.

pcapfile/full.pcapng

2.16 MB
Binary file not shown.

release/wlandecoder-1.0.jar

59.1 KB
Binary file not shown.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package fr.bmartel.protocol.wlan;
2+
3+
/**
4+
* Define MCS object in MCS index table
5+
*
6+
* @author Bertrand Martel
7+
*
8+
*/
9+
public interface IWlanMcs {
10+
11+
/**
12+
* retrieve MCS index in mcs table
13+
*
14+
* @return
15+
*/
16+
public byte getMcsIndex();
17+
18+
/**
19+
* retrieve spatial streams number
20+
*
21+
* @return
22+
*/
23+
public byte getSpatialStreams();
24+
25+
/**
26+
* retrieve modulation type
27+
*
28+
* @return
29+
*/
30+
public String getModulation();
31+
32+
/**
33+
* retrieve data rate for Channel 20 MHz & 800ns guard interval
34+
*
35+
* @return
36+
*/
37+
public double getdataRate_CHANNEL_20MHZ_GI_800NS();
38+
39+
/**
40+
* retrieve data rate for Channel 20 MHz & 400ns guard interval
41+
*
42+
* @return
43+
*/
44+
public double getdataRate_CHANNEL_20MHZ_GI_400NS();
45+
46+
/**
47+
* retrieve data rate for Channel 40 MHz & 800ns guard interval
48+
*
49+
* @return
50+
*/
51+
public double getdataRate_CHANNEL_40MHZ_GI_800NS();
52+
53+
/**
54+
* retrieve data rate for Channel 40 MHz & 400ns guard interval
55+
*
56+
* @return
57+
*/
58+
public double getdataRate_CHANNEL_40MHZ_GI_400NS();
59+
60+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package fr.bmartel.protocol.wlan;
2+
3+
import fr.bmartel.protocol.radiotap.RadioTap;
4+
import fr.bmartel.protocol.radiotap.inter.IRadioTapFrame;
5+
import fr.bmartel.protocol.wlan.frame.IWlanFrame;
6+
import fr.bmartel.protocol.wlan.inter.IWlan802dot11Radiotap;
7+
import fr.bmartel.protocol.wlan.inter.IWlanFrameControl;
8+
import fr.bmartel.utils.RadioTapException;
9+
10+
/**
11+
* Wlan decoder
12+
*
13+
* @author Bertrand Martel
14+
*
15+
*/
16+
public class WlanDecoder implements IWlan802dot11Radiotap {
17+
18+
public final static boolean DISPLAY_ELEMENT_NOT_DECODED = true;
19+
20+
/**
21+
* radio tap object
22+
*/
23+
private IRadioTapFrame radioTap = null;
24+
25+
/**
26+
* wlan frame object
27+
*/
28+
private WlanFrameDecoder wlan802dot11 = null;
29+
30+
private byte[] dataFrame = null;
31+
32+
/**
33+
* initialize wlan driver
34+
*/
35+
public WlanDecoder(byte[] dataFrame) {
36+
this.dataFrame = dataFrame;
37+
}
38+
39+
public void decodeWithRadiotap() {
40+
// decode radioTap protocol
41+
radioTapDecode(dataFrame);
42+
43+
// decode wlan protocol
44+
wlan802dot11Decode(dataFrame, getRadioTap().getRadioTapDataLength());
45+
}
46+
47+
public void decode() {
48+
// decode wlan protocol
49+
wlan802dot11Decode(dataFrame, getRadioTap().getRadioTapDataLength());
50+
}
51+
52+
/**
53+
* Decode radio tap frames
54+
*
55+
* @param frame
56+
*/
57+
public void radioTapDecode(byte[] frame) {
58+
try {
59+
radioTap = new RadioTap(frame);
60+
} catch (RadioTapException e) {
61+
e.printStackTrace();
62+
}
63+
}
64+
65+
/**
66+
* Decode wlan 802.11 frames
67+
*
68+
* @param frame
69+
* byte aray data frames
70+
* @param offset
71+
* offset defined to remove radio tap frames if necessary
72+
*/
73+
public void wlan802dot11Decode(byte[] frame, int offset) {
74+
if ((frame.length - offset) >= 0) {
75+
byte[] frameWlan = new byte[frame.length - offset];
76+
System.arraycopy(frame, offset, frameWlan, 0, frame.length - offset);
77+
wlan802dot11 = new WlanFrameDecoder(frameWlan);
78+
} else {
79+
System.err.println("An error occured while decoding wlan frame");
80+
}
81+
}
82+
83+
@Override
84+
public IRadioTapFrame getRadioTap() {
85+
return radioTap;
86+
}
87+
88+
@Override
89+
public IWlanFrameControl getFrameControl() {
90+
return wlan802dot11.getFrameControl();
91+
}
92+
93+
@Override
94+
public IWlanFrame getFrame() {
95+
return wlan802dot11.getWlanFrame();
96+
}
97+
98+
}

0 commit comments

Comments
 (0)