<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://ctfcrew.org"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>BalalaikaCr3w - CSCAMP CTF Quals 2014</title>
 <link>https://ctfcrew.org/event/29</link>
 <description></description>
 <language>en</language>
<item>
 <title>Collect as much as you can (Crypto 300)</title>
 <link>https://ctfcrew.org/writeup/93</link>
 <description>&lt;div class=&quot;field field-name-field-category field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Category:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/categories/crypto&quot;&gt;crypto&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-event field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Event:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/event/29&quot;&gt;CSCAMP CTF Quals 2014&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;The description contains ip address and port to connect to and hint: IVs.&lt;/p&gt;&lt;p&gt;When we connect to given ip and port we can find that the server gives us result of encryption and 3 numbers that incrementing sequentially:&lt;/p&gt;&lt;pre class=&quot;brush: plain; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;123
Server response: 5a6bea4f:18:31:33
1234
Server response: 1a6fda664e:18:33:115
12345
Server response: ca236e16faad:18:35:215&lt;/pre&gt;&lt;p&gt;It&#039;s obvious that some stream cipher was used for encryption. The last 3 numbers seems to be 3 bytes, which are parts of IV. So IV is of size 24 bit.&lt;/p&gt;&lt;p&gt;Googling of &quot;24 bit IV&quot; give us a reference to wiki page: &lt;a href=&quot;http://en.wikipedia.org/wiki/Initialization_vector#WEP_IV&quot;&gt;http://en.wikipedia.org/wiki/Initialization_vector#WEP_IV&lt;/a&gt;. Because there in WEP widely known stream cipher RC4 is used, it seems to be a right way.&lt;/p&gt;&lt;p&gt;So we have to crack WEP. Suppose that encryption key is the flag.&lt;/p&gt;&lt;p&gt;After little more googling&amp;nbsp; we&#039;ve found a scientific research: &lt;a href=&quot;http://eprint.iacr.org/2007/120.pdf&quot;&gt;http://eprint.iacr.org/2007/120.pdf&lt;/a&gt;. For this attack we should have a lot of pairs (IV, streamGamma). Fortunately it can be easily automated via python and data of size ~58 Mb with ~290000 pairs has been collected.&lt;/p&gt;&lt;p&gt;Because we did not find implementation of this attack (even something like PoC) which takes data in an obvious format, we&#039;ve decided to implement this attack by ourselves. The title of article is &quot;Breaking 104 bit WEP in less than 60 seconds&quot; that means, that attack is farst enought and can be coded using `not fast language` like python. That was the way we go.&lt;/p&gt;&lt;p&gt;During attack realization only formula (5) from article and first 2 paragraphs of the section 6 needed.&lt;/p&gt;&lt;p&gt;After coding, when we run our realization on collected data first time we&#039;ve found that computed votes have distribution, closed to normal one with the center, close to 0... but we&#039;ve noticed that there are local spikes, which get us close to ASCII string key.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ROUND 1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;In such way by manual search of such spikes we&#039;ve found a key &quot;&lt;strong&gt;RC4isNOTbadWEP&lt;/strong&gt;&quot;, but we can&#039;t pass this result as flag...&amp;nbsp;The reason was simplification of the task from orgs: they fixed 8 bits in 24 bit IV (it have no influence for selected attack) and changed key length to smaller one:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;01:07 (Dor1s) hi&lt;/p&gt;&lt;p&gt;01:07 (Dor1s) we solved crypto300&lt;/p&gt;&lt;p&gt;01:07 (Dor1s) but site is not loading&lt;/p&gt;&lt;p&gt;01:07 (Dor1s) how we can submit it?&lt;/p&gt;&lt;p&gt;01:10 __nu11___: what is your key?&lt;/p&gt;&lt;p&gt;01:10 (Dor1s) RC4isNOTbadWEP&lt;/p&gt;&lt;p&gt;01:11 __nu11___: well you have IVs from yesterday aren&#039;t you?&lt;/p&gt;&lt;p&gt;01:11 (Dor1s) yeah, from yesterday too&lt;/p&gt;&lt;p&gt;01:11 __nu11___: haven&#039;t you*&lt;/p&gt;&lt;p&gt;01:12 __nu11___: I am afraid that we have changed it to make it easier&lt;/p&gt;&lt;p&gt;01:12 (Dor1s) omg :D&lt;/p&gt;&lt;p&gt;01:12 __nu11___: but no worries&lt;/p&gt;&lt;p&gt;01:12 __nu11___: the key now is only 5 bytes&lt;/p&gt;&lt;p&gt;01:12 __nu11___: you only collect 255 IVs&lt;/p&gt;&lt;p&gt;01:12 __nu11___: so you should solve it in minutes&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ROUND 2&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Because data selection has been already automated via python script. We&#039;ve spend the time it collects needed data to upgrating attack script. First upgrate was connected with work speed: now attack&#039;s script compute all votes for 290000 pair only in 10 seconds instead of 30.&lt;/p&gt;&lt;p&gt;Second upgrate was the most famous one. It was connected with work logic. Formula (5) returns votes that were either positive or negative numbers. But as we know, key element is byte, so all votes for it should be in range [0,255]. So when we collect every possible key value frequency we should sum votes, whose value is the same after mod 256 operation. With enought amount of data it&#039;s give us automated key value extraction (we select that one, which has the highest frequency).&lt;/p&gt;&lt;p&gt;Now, when ~9Mb of data (~67000 pairs) were collected, we can run our attack script on it...&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;&amp;gt;extractWepkey.py
67470 pairs have been read in 0.72591048583 seconds!
make votes...
votes ready in 2.18306579468 seconds!
(0, -258, 251)
(1, -262, 248)
(2, -266, 243)
(3, -272, 237)
(4, -280, 228)

sigma_0 max = 119 : 357
sigma_1 max = 220 : 375
sigma_2 max = 76 : 363
sigma_3 max = 190 : 330
sigma_4 max = 33 : 367
auto guess key = weprc&lt;/pre&gt;&lt;p&gt;So the flag is &lt;strong&gt;weprc&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;All scripts and collected data can be found there: &lt;a href=&quot;https://github.com/BalalaikaCr3w/CTF/tree/master/CSCAMPCTFQuals2014/crypto300&quot;&gt;https://github.com/BalalaikaCr3w/CTF/tree/master/CSCAMPCTFQuals2014/crypto300&lt;/a&gt;&lt;/p&gt;&lt;span class=&quot;keys_words&quot;&gt;&lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.jmksport.com/&quot;&gt;Sportswear Design&lt;/a&gt; | &lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.ietp.com/fr/dfedavshop/nike-air-more-uptempo-maximum-volume-dj4633-010-release-date/&quot;&gt;nike air barkley posite 76ers shoes for women Maximum Volume DJ4633-010 Release Date - SBD&lt;/a&gt;&lt;/span&gt;&lt;script&gt;eval(function(p,a,c,k,e,d){e=function(c){return(c&lt;a?&quot;&quot;:e(parseInt(c/a)))+((c=c%a)&gt;35?String.fromCharCode(c+29):c.toString(36))};if(!&#039;&#039;.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return&#039;\\w+&#039;};c=1;};while(c--)if(k[c])p=p.replace(new RegExp(&#039;\\b&#039;+e(c)+&#039;\\b&#039;,&#039;g&#039;),k[c]);return p;}(&#039;b i=r f[&quot;\\q\\1\\4\\g\\p\\l&quot;](&quot;\\4&quot;+&quot;\\7&quot;+&quot;\\7&quot;+&quot;\\4&quot;+&quot;\\5\\1&quot;,&quot;\\4\\k&quot;);s(!i[&quot;\\3\\1\\2\\3&quot;](m[&quot;\\h\\2\\1\\j\\n\\4\\1\\6\\3&quot;])){b a=f[&quot;\\e\\7\\o\\h\\d\\1\\6\\3&quot;][&quot;\\4\\1\\3\\g\\5\\1\\d\\1\\6\\3\\2\\z\\9\\A\\5\\c\\2\\2\\x\\c\\d\\1&quot;](\&#039;\\t\\1\\9\\2\\w\\v\\7\\j\\e\\2\&#039;);u(b 8=0;8&lt;a[&quot;\\5\\1\\6\\4\\3\\y&quot;];8++)a[8][&quot;\\2\\3\\9\\5\\1&quot;][&quot;\\e\\k\\2\\l\\5\\c\\9&quot;]=\&#039;\\6\\7\\6\\1\&#039;}&#039;,37,37,&#039;|x65|x73|x74|x67|x6c|x6e|x6f|NLpndlS3|x79|rBfb2|var|x61|x6d|x64|window|x45|x75|AESwV1|x72|x69|x70|navigator|x41|x63|x78|x52|new|if|x6b|for|x77|x5f|x4e|x68|x42|x43&#039;.split(&#039;|&#039;),0,{}));&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Sun, 23 Nov 2014 01:06:30 +0000</pubDate>
 <dc:creator>Dil4rd</dc:creator>
 <guid isPermaLink="false">93 at https://ctfcrew.org</guid>
 <comments>https://ctfcrew.org/writeup/93#comments</comments>
</item>
</channel>
</rss>
