<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Explore Security &#187; wpa</title>
	<atom:link href="http://www.exploresecurity.com/tag/wpa/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.exploresecurity.com</link>
	<description>IT security tools, techniques and commentary</description>
	<lastBuildDate>Wed, 15 Jun 2022 09:21:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6.1</generator>
		<item>
		<title>William &#8211; WPA/WPA2 4-way handshake extraction script</title>
		<link>http://www.exploresecurity.com/william-wpawpa2-4-way-handshake-extraction-script/</link>
		<comments>http://www.exploresecurity.com/william-wpawpa2-4-way-handshake-extraction-script/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 23:12:03 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[aircrack]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[wpa]]></category>
		<category><![CDATA[wpa2]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=14</guid>
		<description><![CDATA[Download v.0.1 If you&#8217;ve ever tested Aircrack against a packet capture containing a handshake from a network whose WPA/WPA2 passphrase is known, you may have sometimes frowned at the &#8220;Passphrase not in dictionary&#8221; message. One possibility for this is noted on the (excellent) Aircrack website – http://www.aircrack-ng.org/doku.php?id=aircrack-ng#wpa_wpa2_handshake_analysis_fails. Essentially Aircrack hasn&#8217;t parsed the handshake from the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="/wp-content/uploads/custom/william.sh">Download v.0.1</a></p>
<p>If you&#8217;ve ever tested Aircrack against a packet capture containing a handshake from a network whose WPA/WPA2 passphrase is known, you may have sometimes frowned at the &#8220;Passphrase not in dictionary&#8221; message. One possibility for this is noted on the (excellent) Aircrack website – <a title="http://www.aircrack-ng.org/doku.php?id=aircrack-ng#wpa_wpa2_handshake_analysis_fails" href="http://www.aircrack-ng.org/doku.php?id=aircrack-ng#wpa_wpa2_handshake_analysis_fails">http://www.aircrack-ng.org/doku.php?id=aircrack-ng#wpa_wpa2_handshake_analysis_fails</a>. Essentially Aircrack hasn&#8217;t parsed the handshake from the capture correctly because there is too much “noise”. If Aircrack picks packets from <em>different</em> 4-way handshake exchanges then the passphrase will not be found, even if it&#8217;s in the dictionary. A tool called &#8220;wpaclean&#8221; (which is included in Backtrack) tidies up four-way handshake captures but, in my experiments, it didn&#8217;t always work so I wrote an alternative clean-up script, called William, that gives you more control. <span id="more-14"></span>The usage is:</p>
<p><code>william.sh &lt;output_file&gt; &lt;input_file&gt; [&lt;input_file_2&gt;...] [&lt;mth_packet_2&gt; [&lt;nth_packet_1&gt;]] [-f | -a] [-A &lt;dict_file&gt;] [-d]</code></p>
<p><code>m mth second packet of 4-way handshake (default 1)<br />
n nth first packet of 4-way handshake that precedes the chosen second packet (default 1)<br />
-f seek first message from start of capture working forwards<br />
-a pair up ALL message 1s that precede the chosen message 2 (multiple output files)<br />
-A run aircrack-ng against output files using the supplied dictionary file<br />
-d don't skip duplicate packets<br />
--help extra help</code></p>
<p>William is a bash script. If I&#8217;d known how it would turn out, I would have chosen another programming route, but never mind, it still works as a proof of concept. Let me explain how it works, which in turn will explain what the switches do. Here&#8217;s a messy capture file from attempts to crack the WPA2 key of a client using Airbase as a rogue access point. (In my experiments, using Airbase against clients as opposed to sniffing legitimate 4-way handshakes tended to make noisier capture files.) As a client-side attack, only the first 2 of the 4 messages in the 4-way handshake were captured (but that&#8217;s enough for Aircrack to work on):</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss1.png"><img class="alignnone size-full wp-image-15" alt="ss1" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss1.png" width="932" height="504" /></a></p>
<p>The first EAPOL frame is selected, which Wireshark informs us is the first of the 4 messages in the 4-way handshake. Note the &#8220;WPA Key Nonce&#8221; value. Now let&#8217;s move to the second EAPOL frame:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss2.png"><img class="alignnone size-full wp-image-16" alt="ss2" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss2.png" width="932" height="502" /></a></p>
<p>The &#8220;WPA Key Nonce&#8221; is exactly the same. So the packet was either transmitted twice or recorded twice, which can happen when you&#8217;re sniffing on an interface that&#8217;s also engaged in active testing. Let&#8217;s move to the third EAPOL frame:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss3.png"><img class="alignnone size-full wp-image-17" alt="ss3" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss3.png" width="939" height="503" /></a></p>
<p>Now the &#8220;WPA Key Nonce&#8221; is different, so this constitutes a second attempt at sending a first handshake message. Now let&#8217;s look at the first instance of a second message in the 4-way handshake:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss4.png"><img class="alignnone size-full wp-image-18" alt="ss4" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss4.png" width="931" height="498" /></a></p>
<p>It turns out that there have been 14 unique first packets sent up to this point so the question is, which of them does this second message correspond to? Park that problem for now and note the &#8220;WPA Key MIC&#8221; value above instead. Let&#8217;s move to the next second message:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss5.png"><img class="alignnone size-full wp-image-19" alt="ss5" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss5.png" width="937" height="499" /></a></p>
<p>It&#8217;s apparently the same &#8211; no surprise, given what we saw earlier. But it turns out the third instance of the second handshake message is the same too.  And so is the fourth, the fifth, the sixth&#8230;When all these first and second handshake messages are mixed up, it&#8217;s no wonder that Aircrack can sometimes produce false negatives. When I ran wpaclean it picked the 14th (i.e. the last) first message and the 1st second message. In other words it picks the first instance of a second message and works backwards to pick the first handshake message. Perfectly reasonable &#8211; but in this particular case Aircrack failed to find the passphrase from this pairing. Like Aircrack, wpaclean&#8217;s logic is fixed, so I wrote William to give you more options. The default is that it works just like wpaclean, as there&#8217;s nothing wrong with its logic. If you use the -f switch, however, William picks the first handshake message by working <em>forwards</em> from the start of the capture.</p>
<p>The n and m switches give you the freedom to try out your own pairings. If you run William with a single number 2 (i.e. <code>william.sh &lt;out_file&gt; &lt;in_file&gt; 2</code>) it picks the 2nd instance of a second handshake message and works backwards to find the first handshake message. The second message is always counted forwards from the start of the capture file. If you run William with the numbers 2 4, it picks the 4th first handshake message working backwards from the 2nd instance of a second handshake message. Adding -f to this would count the 4th first message from the start of the capture file. The &#8211;help switch gives more examples.</p>
<p>If you think about it, the second message of the handshake must correspond to one of the first messages that preceded it (assuming the capture is complete). So William informs you of how many unique first messages there were as a guide. If you select the -a option, William will generate capture files that pair the chosen second message with all the preceding first messages (working backwards from the second message), each file containing a different pairing. This brute-force method should succeed, assuming the passphrase is in your dictionary, but it will be more time-consuming.</p>
<p>AUTOMATED AIRCRACK</p>
<p>If you use the -A switch followed by the path to a dictionary file, William will run all output files through Aircrack automatically. It&#8217;s especially worth running this with -a because William will run Aircrack as the message pairs are written to file, so you may find the passphrase without having to wait for all the combinations to be generated. A successful screenshot follows:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss6.png"><img class="alignnone size-full wp-image-20" alt="ss6" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/ss6.png" width="747" height="353" /></a></p>
<p>DUPLICATES</p>
<p>As noted above, it&#8217;s possible that your capture file contains duplicate messages. By default, duplicates are ignored when counting the packet positions. If you use the -d option, duplicates are not ignored, i.e. the nth first packet and mth second packet are counted based entirely on their order of appearance in the file. As before, the second message is always counted forwards from the start of the capture file and the direction in which the first message is counted is set by the presence or absence of -f. The -d option won&#8217;t have much practical effect, it&#8217;s really just for experimentation.</p>
<p>THE NEED FOR A CORRECT SSID</p>
<p>When Aircrack parses a capture file, it first looks for the SSID of the network(s) whose traffic has been sniffed, and if it doesn&#8217;t find any it gives up. Why? Because the SSID is used with the passphrase to generate the Pairwaise Master Key. So even if you have the correct first and second handshake packets, without the correct SSID Aircrack will fail. William looks for packets that disclose the SSID based on the BSSID of the chosen second EAPOL message. If for some reason you&#8217;re unlucky enough to miss this, the script will ask you for a SSID and create a fake probe response packet to satisfy Aircrack.</p>
<p>INPUT</p>
<p>Multiple input files can be specified. If you&#8217;ve used Airodump with &#8211;write wpa, for example, it&#8217;s best to run William with the input wpa*.cap.</p>
<p>OUTPUT</p>
<p>The output file is the first parameter. If the -a switch has been used, the output filenames include a number to distinguish them. The number is an ordinal reflecting the position of the first message in the capture file so, as William works backwards from the second message, the number starts high and counts down to 1.</p>
<p>THE REAL WORLD</p>
<p>On a pentest job, outside the comfort of a known test environment, if Aircrack tells you the password isn&#8217;t in the dictionary, you have to believe it. Hopefully this posting will give you a few more ideas and you may want to run a few iterations of William just in case. I would suggest the following order, using <code>-A &lt;dictionary_file&gt;</code> each time:</p>
<ol>
<li><span style="line-height: 1.714285714; font-size: 1rem;">Try REVERSE mode to mimic wpaclean (default, don&#8217;t specify -f or -a)</span></li>
<li><span style="line-height: 1.714285714; font-size: 1rem;">Try FORWARD mode with -f</span></li>
<li><span style="line-height: 1.714285714; font-size: 1rem;">Run ALL mode with -a</span></li>
</ol>
<p>DOWNLOAD</p>
<p><a href="/wp-content/uploads/custom/william.sh">Download v.0.1</a></p>
<p>NODS</p>
<p>This script is an extension of wpaclean and owes everything to the fantastic Wireshark command-line toolset, specifically tshark, mergecap and text2pcap.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploresecurity.com/william-wpawpa2-4-way-handshake-extraction-script/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>
