<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dominic White on Medium]]></title>
        <description><![CDATA[Stories by Dominic White on Medium]]></description>
        <link>https://medium.com/@notsinge?source=rss-8c24fecf2d1c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9s6WXAnOfPHNw5gLj8dYfw@2x.jpeg</url>
            <title>Stories by Dominic White on Medium</title>
            <link>https://medium.com/@notsinge?source=rss-8c24fecf2d1c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 02:14:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@notsinge/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Hacker’s Introduction to WebAssembly]]></title>
            <link>https://medium.com/@notsinge/a-hackers-introduction-to-webassembly-63718a6e9b00?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/63718a6e9b00</guid>
            <category><![CDATA[introduction]]></category>
            <category><![CDATA[reversing]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Tue, 07 May 2019 13:05:45 GMT</pubDate>
            <atom:updated>2019-05-07T13:05:45.342Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*fXdFlcYYGAPJtviyingAdA.png" /></figure><p>I’ve started seeing WebAssemly (WASM) stuff popping up in a few places, most notably <a href="https://blog.cloudflare.com/cloud-computing-without-containers/">CloudFlare’s recent anti-container isolated v8 workload stuff</a> and I wanted to understand it a little better.</p><p>Essentially, WebAssembly is a way to compile stuff to a browser-native binary format .wasm, which you can then load with JavaScript and interact with.</p><h3>Simplest C</h3><p>Since this is binary, I wanted to start with a C program. Since it’s C, to avoid includes or C&lt;-&gt;JS string handling, I’m just going to return 42 like other tutorials start with :)</p><pre>int main() {<br>  return 42;<br>}</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/simple/42.c">github</a></p><p>If we compile and run it as usual:</p><pre>&gt; gcc -o 42 -O1 42.c<br>&gt; ./42<br>&gt; echo $?<br>42</pre><p>If we disassemble 42, we get:</p><pre>push rbp<br>mov  rbp, rsp<br>mov  eax, 0x2a<br>pop  rbp<br>ret</pre><h3>Now as WASM</h3><p>Right, now let’s see what it looks like as WASM. The easiest way to get started is to use an online fiddle tool such as:<br><a href="https://mbebenita.github.io/WasmExplorer/?state={%22options%22:{%22dialect%22:%22C99%22,%22optimizationLevel%22:%22s%22},%22source%22:%22int%20main()%20{\n%20return%2042;\n}%22}">https://mbebenita.github.io/WasmExplorer/?state={“options”:{“dialect”:”C99″,”optimizationLevel”:”s”},”source”:”int main() {\n return 42;\n}”}</a><br>or<br><a href="https://wasdk.github.io/WasmFiddle/?q1rr6">https://wasdk.github.io/WasmFiddle/?q1rr6</a></p><p>There is a human readable intermedia form wasm can be represented as (a .wat). For our 42 program this looks like:</p><pre>(module<br> (table 0 anyfunc)<br> (memory $0 1)<br> (export &quot;memory&quot; (memory $0))<br> (export &quot;main&quot; (func $main))<br> (func $main (; 0 ;) (result i32)<br>  (i32.const 42)<br> )<br>)</pre><p>If we look at WasmExplorer, it also shows the asm of the resulting binary .wasm:</p><pre>sub rsp, 8      ; 0x000000 48 83 ec 08<br>mov eax, 0x2a  ; 0x000004 b8 2a 00 00 00<br>nop            ; 0x000009 66 90<br>add rsp, 8     ; 0x00000b 48 83 c4 08<br>ret</pre><p>I’ve no idea why that nop is in there.</p><h3>Compiling and Running it Yourself</h3><p>Online tools are nice, but what if we wanted to compile and host it oursleves?</p><p>First you need emscripten. Hopefully your OS has a nice package. On macOS the homebrew version broke badly, so I followed the <a href="https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html">manual installation instructions</a> which were super easy.</p><p>Once you’ve got it installed, you can compile a “<a href="https://github.com/sensepost/wasm-demos/blob/master/emscripten/hello.c">hello world</a>” to wasm with:</p><pre>emcc hello.c -o hello.html -s WASM=1</pre><p>This will generate <a href="https://github.com/sensepost/wasm-demos/tree/master/emscripten">three files</a>, the .wasm binary, a .js loader, and a .html emscripten front-end. Put them up on a webserver of your choice and access the .html, and you’ll see ‘hello world’ in the console. Alternativley, you can have emscripten host a webserver and run it for you with:</p><pre>emrun --browser firefox --port 8080 .</pre><p>Or try it at <a href="https://sensepost.github.io/wasm-demos/emscripten/hello.html">https://sensepost.github.io/wasm-demos/emscripten/hello.html</a></p><h3>Going manual</h3><p>It’s nice that emscripten automates a bunch of stuff for us, like the JS, but I wanted to see what the simplest calls are. So let’s make our own. Mozilla documents this <a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API">here</a>.</p><p>The .wasm emcc compiles is rather large, so I used the <a href="https://github.com/sensepost/wasm-demos/blob/master/simple/42-simple.wasm">.wasm</a> from <a href="https://wasdk.github.io/WasmFiddle/?q1rr6">the fiddler above</a> (click the download icon next to “Wasm”).</p><p>The simplest loader for our 42 program that I can come up with is this:</p><pre>&lt;html&gt;<br>  &lt;body&gt;<br>    &lt;script&gt;<br>      var wasmCode = new Uint8Array([0,97,115,109,1,0,0,0,1,133,128,128,128,0,1,96,0,1,127,3,130,128,128,128,0,1,0,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,6,129,128,128,128,0,0,7,145,128,128,128,0,2,6,109,101,109,111,114,121,2,0,4,109,97,105,110,0,0,10,138,128,128,128,0,1,132,128,128,128,0,0,65,42,11]);<br>      var m = new WebAssembly.Instance(new WebAssembly.Module(wasmCode));<br>      console.log(m.exports.main())<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/simple/42-simple.html">github</a>, <a href="https://sensepost.github.io/wasm-demos/simple/42-simple.html">demo</a></p><p>The buffer is simply a decimal representation of the .wasm file’s bytes. WebFiddle can do it for you if you change from “Text Format” to “Code Buffer” in the dropdown. You can also generate it with this horrible one liner:</p><pre>out=&quot;&quot;;for x in $(xxd -ps -c1 42.wasm); do out=&quot;$out,$(( 16#$x ))&quot;; done; echo $out|sed &quot;s/^,\(.*\)$/var wasmCode = new Uint8Array([\1]);/&quot;</pre><p>or expanded to a script:</p><pre>#!/bin/sh<br># Usage: ./wasm2cb.sh &lt;filename&gt;.wasm<br>out=&quot;&quot;<br>for x in $(xxd -ps -c1 $1)<br>  do out=&quot;$out,$(( 16#$x ))&quot;<br>done<br>echo $out|sed &quot;s/^,\(.*\)$/var wasmCode = new Uint8Array([\1]);/&quot;</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/wasm2cb.sh">github</a></p><h3>Simple IO &amp; Function Calling</h3><p>Just running binaries and logging to the console isn’t very interesting. The good news is that passing parameters in and out is very simple.</p><p>Here’s the binary code I’m going to use, note that it doesn’t *need* a main():</p><pre>int foo(int x) {<br>  return x+1;<br>}</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/simple-io/simple-io.c">github</a></p><p>Throwing the resulting code buffer into some HTML looks like:</p><pre>&lt;html&gt;<br>  &lt;body&gt;<br>    &lt;script&gt;<br>      function calc(num) {<br>        var wasmCode = new Uint8Array([0,97,115,109,1,0,0,0,1,134,128,128,128,0,1,96,1,127,1,127,3,130,128,128,128,0,1,0,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,6,129,128,128,128,0,0,7,144,128,128,128,0,2,6,109,101,109,111,114,121,2,0,3,102,111,111,0,0,10,141,128,128,128,0,1,135,128,128,128,0,0,32,0,65,1,106,11]);<br>        var m = new WebAssembly.Instance(new WebAssembly.Module(wasmCode));<br>        document.getElementById(&#39;out&#39;).innerHTML = m.exports.foo(num);<br>      }<br>    &lt;/script&gt;<br>    &lt;input id=&quot;in&quot; /&gt;<br>    &lt;button onclick=&quot;calc(document.getElementById(&#39;in&#39;).value)&quot; &gt;Go&lt;/button&gt;<br>    &lt;div id=&quot;out&quot;&gt;&lt;/div&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/simple-io/simple-io.html">github</a>, <a href="https://sensepost.github.io/wasm-demos/simple-io/simple-io.html">demo</a></p><p>And voila, we can now pass input to our binary and get a response.</p><h3>Including Remote .wasm’s</h3><p>You don’t need to use a code buffer each time, browsers provide <a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API">WebAssembly.instantiateStreaming()</a> to do it on the fly for you. Here’s the calc() function from above rewritten to call an external .wasm file with fancy Promise style code I don’t really grok:</p><pre>function calc(num) {<br>  WebAssembly.instantiateStreaming(fetch(&#39;io-simple.wasm&#39;)).then(obj =&gt; <br>    obj.instance.exports.foo(num)<br>  ).then(res =&gt; <br>    document.getElementById(&#39;out&#39;).innerHTML = res<br>  );<br>}</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/stream/simple-io-stream.html">github</a></p><p>Although this doesn’t work on Safari.</p><h3>Calling JS Functions</h3><p>You can also call JavaScript functions from inside your binary! You do that with imports. For example, given the following C:</p><pre>int foo(int x) {<br>  bar(x);<br>  return x+1;<br>}</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/dual-io/dual-io.c">github</a></p><p>You can define a function bar() in the JavaScript and import it to the WebAssembly like this (building on from the calc() example earlier):</p><pre>function calc(num) {<br>  var importObj = {<br>    env: { bar: arg =&gt; console.log(&#39;Got it: &#39;+arg) }<br>  };<br>  WebAssembly.instantiateStreaming(fetch(&#39;io-adv.wasm&#39;),importObj).then(obj =&gt; <br>    obj.instance.exports.foo(num)<br>  ).then(res =&gt; <br>    document.getElementById(&#39;out&#39;).innerHTML = res<br>  );<br>}</pre><p><a href="https://github.com/sensepost/wasm-demos/blob/master/dual-io/dual-io.html">github</a>, <a href="https://sensepost.github.io/wasm-demos/dual-io/dual-io.html">demo</a></p><p>The importObj dictionary’s “env” and “bar” entries were from the resulting .wat, which included the line:</p><pre>(import &quot;env&quot; &quot;bar&quot; (func (;0;) (type 1)))</pre><p>So I knew how to build the import.</p><h3>Disassembling</h3><p>We’re hackers, and we’re probably going to need to reverse this at some point. <a href="https://www.fireeye.com/blog/threat-research/2018/10/reverse-engineering-webassembly-modules-using-the-idawasm-ida-pro-plugin.html">This article</a> from the Flare-On challenge pointed me to the <a href="https://github.com/WebAssembly/wabt">WebAssembly Binary Toolkit</a> (wabt pronounced wabbit). It includes the wasm-objdump and wasm2wat tools. wasm2wat will convert the binary to the human readable .wat stack language and is probably the most useful dissasembly. wasm-objdump will give you much the same info, but in more of a typical disasm format. To get actual asm, IDA does some magic with SpiderMonkey that I haven’t looked into yet.</p><h3>Conclusion</h3><p>I hope this was useful to you and helped give you a hacker rather than dev intro to wasm.</p><p><em>Originally published at </em><a href="https://sensepost.com/blog/2018/introduction-to-webassembly/"><em>https://sensepost.com/blog/2018/introduction-to-webassembly/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63718a6e9b00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Efficient HTTP Scripting in the Shell]]></title>
            <link>https://medium.com/@notsinge/efficient-http-scripting-in-the-shell-3e3d2b9bd86?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e3d2b9bd86</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[scripting]]></category>
            <category><![CDATA[efficency]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[bash]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Tue, 07 May 2019 12:54:04 GMT</pubDate>
            <atom:updated>2019-05-07T12:54:04.384Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*P74xRZV3q-FtnQrz3EmanA.png" /></figure><p>Javier had a simple shell script he posted to our internal chat a few days ago. It’s goal was to pull all the IP ranges for a country in preparation for a footprint from <a href="https://ipinfo.io/">https://ipinfo.io/</a> (Let’s use PL as an example). Given this involved pulling multiple webpages, I was interested to know what the most efficient approach to this in the shell would be. Truthfully, the actual problem, pulling data from the site or gathering BGP routes, didn’t interest me, I wanted to look at how to do mass HTTP enum most efficiently with curl.</p><p>As with all shell scripts, his initial approach had some … problems, and took over 4hrs to pull all the data, we’ll leave that version out, and use the following one Javier, Rogan and I came up with as the baseline:</p><pre>seq 1 3 \<br>| xargs -I% curl -s &quot;https://ipinfo.io/countries/pl/%&quot; \<br>| grep -oE &quot;AS[0-9]{1,9}&quot; \<br>| sort -u \<br>| xargs -I% curl -s &quot;https://ipinfo.io/%&quot; \<br>| grep -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39; \<br>| sort -u</pre><p>The script:</p><ol><li>Fetches three pages: <a href="https://ipinfo.io/countries/pl/1,">https://ipinfo.io/countries/pl/1,</a> <a href="https://ipinfo.io/countries/pl/2">https://ipinfo.io/countries/pl/2</a> &amp; <a href="https://ipinfo.io/countries/pl/3">https://ipinfo.io/countries/pl/3</a></li><li>Then grep’s out the routing AS numbers e.g. <a href="https://ipinfo.io/AS5617">AS5617</a></li><li>Each of those have their details fetched e.g. <a href="https://ipinfo.io/AS5617">https://ipinfo.io/AS5617</a></li><li>Those are then grep’ed for CIDR addresses e.g. <a href="https://ipinfo.io/AS5617/178.42.0.0/15">178.42.0.0/15</a>.</li></ol><p>If you aren’t familiar with xargs, it simple lets you execute something across an input e.g.:</p><pre>&gt; ls<br>foo bar baz<br>&gt; file *<br>foo: empty<br>bar: empty<br>baz: empty<br>&gt; ls | xargs file<br>foo: empty<br>bar: empty<br>baz: empty<br>&gt; ls | xargs echo file<br>file foo bar baz<br>&gt; ls | xargs -L1 echo file<br>file foo<br>file bar<br>file baz</pre><p>The -L1 just says to execute it for each item, this is necessary to understand for later.</p><h3>The Test Environment</h3><p>I didn’t want to keep pulling hundreds of megs of data from ipinfo, so I pulled all the data to my own machine, and served it with npm’s http-server. This means I just replaced the links with <a href="https://127.0.0.1:8080/">https://127.0.0.1:8080/.</a> It also meant I could remove the inconsistencies added by moving data over the Internet. All in all, the 5 706 files were 276M of raw bytes. The vast majority of them were the AS pages, which averaged 49K in size with the largest being 892K and the smallest being 12K.</p><p>To record the execution of the script, I used the Unix time utility. To record the network traffic I used tshark. I also used tshark to generate stats with its “-z conv,ip” summary.</p><p>So, our base run, executed on my MBP, looks like this, with the important summary at the end.</p><pre>seq 1 3  0.00s user 0.00s system 44% cpu 0.010 total<br>xargs -I% curl -s &quot;http://127.0.0.1:8080/%&quot;  0.02s user 0.02s system 40% cpu 0.108 total<br>grep --color -oE &quot;AS[0-9]{1,9}&quot;  0.03s user 0.00s system 33% cpu 0.108 total<br>sort -u  0.01s user 0.01s system 14% cpu 0.113 total<br>xargs -I% curl -s &quot;http://127.0.0.1:8080/%&quot;  35.07s user 30.07s system 50% cpu 2:07.74 total<br>grep --color -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39;  16.09s user 0.19s system 12% cpu 2:07.74 total<br>sort -u  0.15s user 0.06s system 0% cpu 2:07.94 total</pre><pre><strong>2:07.94 total time</strong><br><strong>94 764 frames</strong><br><strong>295 926 465 bytes</strong></pre><p>You can see this took over 2 mins to execute, generated 94k frames, and 282M of data.</p><h3>Approach 1: Parallelism</h3><p>Multi processing a problem is often the easiest way to speed something up. This can simply be done by passing the -P switch to xargs above. Using an arbitrary value of 20 parallel processes gives the following code:</p><pre>time seq 1 3\                     <br>| xargs -P20 -I% curl -s &quot;http://127.0.0.1:8080/%&quot; \<br>| grep -oE &quot;AS[0-9]{1,9}&quot; \<br>| sort -u \                  <br>| xargs -P20 -I% curl -s &quot;http://127.0.0.1:8080/%&quot; \<br>| grep -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39; \<br>| sort -u</pre><p>This produces the following stats:</p><pre>seq 1 3  0.00s user 0.00s system 46% cpu 0.009 total<br>xargs -P20 -I% curl -s &quot;http://127.0.0.1:8080/%&quot;  0.03s user 0.03s system 83% cpu 0.068 total<br>grep --color -oE &quot;AS[0-9]{1,9}&quot;  0.03s user 0.00s system 56% cpu 0.068 total<br>sort -u  0.01s user 0.00s system 22% cpu 0.073 total<br>xargs -P20 -I% curl -s &quot;http://127.0.0.1:8080/%&quot;  48.46s user 46.47s system 304% cpu 31.160 total<br>grep --color -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39;  23.50s user 0.58s system 77% cpu 31.163 total<br>sort -u  0.16s user 0.05s system 0% cpu 31.337 total</pre><pre><strong>31.337 total time</strong><br><strong>94 777 frames</strong><br><strong>296 116 785 bytes</strong></pre><p>Excellent, that cuts the time down to a quarter of the original, and should have no impact on the number of frames or the bytes transferred, but in reality, that stuff is slightly less deterministic.</p><h3>Approach 2: Pipelining</h3><p>Most HTTP servers support pipelining, where multiple requests are made and served within the same TCP connection. This saves having to set up and tear down a new TCP connection each time.</p><p>Rogan figured out a neat approach for pipelining with curl using the config option, the resulting code looks like this:</p><pre>time curl -s --config \<br>  &lt;(for x in \<br>    $(curl -s --config \<br>      &lt;(for i in `seq 1 3`<br>          do echo &quot;url=http://127.0.0.1:8080/$i&quot;<br>        done) \<br>      | grep -oE &quot;AS[0-9]{1,9}&quot; \<br>      | sort -u)<br>    do echo &quot;url=http://127.0.0.1:8080/$x&quot;<br>  done) \<br>| grep -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39; \<br>| sort -u</pre><p>This creates a list of url=… with newlines between them, and feeds that to curl as a config file with a shell redirect &lt;.</p><p>It’s a bit less readable, and much of the execution time gets hidden in the first curl process, but let’s check how it performs:</p><pre>curl -s --config 0.69s user 0.60s system 9% cpu 14.336 total<br>grep --color -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39; 13.97s user 0.10s system 98% cpu 14.339 total<br>sort -u 0.14s user 0.05s system 1% cpu 14.522 total</pre><pre><strong>14.522 total time</strong><br><strong>44 867 frames</strong><br><strong>292 995 529 bytes</strong></pre><p>Whoa, that’s half the time and more than half the number of frames of the multi process version. It’s only 1% smaller when looking at total bytes though. So the extra packets really do provide a lot of processing overhead, despite not resulting in much of a data increase.</p><h3>Approach 3: Hybrid</h3><p>Next up I wanted to if we could combine both approaches, which lead to some fun scripting. Here’s the result:</p><pre>for x in $(for i in $(seq 1 3)<br>      do echo &quot;http://127.0.0.1:8080/$i&quot;<br>    done \<br>    | xargs -L1 -P3 curl -s \<br>    | grep -oE &quot;AS[0-9]{1,9}&quot; \<br>    | sort -u)<br>  do echo &quot;http://127.0.0.1:8080/$x&quot;<br>done \<br>  | xargs -L287 -P20 curl -s \<br>  |grep -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39; \<br>  | sort -u</pre><p>This doesn’t use Rogan’s nifty –config trick for curl, but rather just passes the URLs as input, and controls how many URLs will be pipelined with -L. I think it’s a little more readable. Given the first loop pulls three pages, it makes sense to do those simultaneously, hence -L1 -P3. For the latter one, I took the 5 703 pages that would need to be fetched, and divided them by our 20 processes from earlier, which gave me the 287.</p><p>This gives the following results:</p><pre>for x in ; do; echo &quot;http://127.0.0.1:8080/$x&quot;; done 0.13s user 0.06s system 128% cpu 0.146 total<br>xargs -L287 -P20 curl -s 0.83s user 1.16s system 13% cpu 14.541 total<br>grep --color -Eo &#39;[0-9\.]{7,15}\/[0-9]{1,2}&#39; 13.64s user 0.28s system 95% cpu 14.543 total<br>sort -u 0.13s user 0.05s system 1% cpu 14.704 total</pre><pre><strong>14.704 total time</strong><br><strong>48 318 frames</strong><br><strong>293 187 882 bytes</strong></pre><p>So this ends up with much the same performance as the pipelined version, with a few thousand more frames and a few hundred more kilobytes.</p><h3>Conclusion</h3><pre>+-------------+---------+----------+-----------+--------+<br>|    Test     |  Base   | Parallel | Pipelined | Hybrid |<br>+-------------+---------+----------+-----------+--------+<br>| Time m:s.ms | 2:07.94 | 31.337   | 14.522    | 14.704 |<br>| Frames      | 94 764  | 94 777   | 44 867    | 48 318 |<br>| Data M      | 282.21  | 282.39   | 279.42    | 279.60 |<br>+-------------+---------+----------+-----------+--------+</pre><p>If you need to make lots of smaller HTTP requests, use curl’s pipelining for maximum speed and bandwidth. If you find yourself needing a quick speed up for your average shell script, xargs -P is your friend. You could also use parallel (which ended up much slower in these tests), which would let you run the work across multiple hosts. Hopefully, you also picked up some shell script-fu.</p><p><em>Originally published at </em><a href="https://sensepost.com/blog/2018/efficient-http-scripting-in-the-shell/"><em>https://sensepost.com/blog/2018/efficient-http-scripting-in-the-shell/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e3d2b9bd86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding PEAP In-Depth]]></title>
            <link>https://medium.com/@notsinge/understanding-peap-in-depth-a8d679c72438?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8d679c72438</guid>
            <category><![CDATA[wifi]]></category>
            <category><![CDATA[eap]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[mschapv2]]></category>
            <category><![CDATA[peap]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Tue, 07 May 2019 11:49:34 GMT</pubDate>
            <atom:updated>2019-05-07T13:07:33.326Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zaUfTtyjtzorRVspHzmW-w.png" /></figure><h3><em>tl;dr<br> We reported a long standing PEAP bug in all Apple devices that would allow an attacker to force any Apple device (iOS, macOS or tvOS) to associate with a malicious access point, even if the authentication server (RADIUS) couldn’t prove knowledge of the password. To understand it fully, we go on a deep dive into EAP and MSCHAPv2.</em></h3><p>While prepping for our Defcon talk last year, <a href="https://twitter.com/_cablethief">Michael</a> kept pushing me to implement <a href="https://tools.kali.org/wireless-attacks/hostapd-wpe">hostapd-wpe</a> ‘s EAP success attack. In this attack, the authentication server will accept any username, then skip the step where it proves knowledge of the password back to the station (because it doesn’t know the password), and instead sends an EAP-success message back to the station. I refused for a long time, because I thought it was a dumb attack that would never work. This is because in MSCHAPv2 the authentication server also proves knowledge of the password back to the station, and if it couldn’t, I assumed the station would just refuse to continue, after all, that’s the whole point.</p><p>Eventually, I caved and tested hostapd-wpe’s “always send EAP success” attack against a few devices, and bizarrely, my Apple devices (iPads, iPhones, Macbooks) all successfully connected to the malicious access point. Huh?</p><p>Since WPE is written by Brad Antoniewicz, I asked him if he was aware of the bug, to which he replied:</p><h3>Brad Antoniewicz on Twitter</h3><p>@singe Interesting! It&#39;s been awhile but it sounds like the client is failing to validate server&#39;s proof and giving priority to EAP Success. Nice! I def didn&#39;t report this!</p><p>So I wrote up a bug report and sent it off to Apple. It was a weird one, because Brad did the technical work that lead to discovery of the vulnerability, plus it had been a feature in hostapd-wpe for a few years already. The disclosure timeline and original report are at the end of this post.</p><p>To understand the vulnerability, we need to know how MSCHAPv2 in PEAP works and that requires a deep dive into some concepts. I’m writing them up and releasing the toy code to validate what I’m saying, because there are no good recent writeups of how this works, and how to see it for yourself.</p><h3>PEAP at a High Level</h3><p>The first “P” in PEAP stands for “Protected” and practically that means the whole exchange is wrapped in TLS. This part is called the outer tunnel. Within that tunnel, a MSCHAPv2 challenge response happens where the station (or the client, or the peer) and the authentication server (or RADIUS or AAA) prove knowledge of an identified user’s password to each other. This is done via the AP (because most often it isn’t also the RADIUS authentication server). If you’re familiar with wifi hacking, this is the part where if you person-in-the-middle it, you get the challenge:response hash to send to JtR/hashcat/asleap.</p><p>After this, the normal WPA/2 4-way handshake occurs. But, instead of using a typical pre-shared key, it uses a key (the pairwise master key or PMK) negotiated during the outer TLS session. This means, while you can capture these handshakes, you won’t be able to crack them.</p><h3>MSCHAPv2</h3><p>MSCHAPv2 is a challenge response protocol. The station and authenticator first identify themselves (to make sure that user is authorised). Then both share a random challenge (peer and authenticator challenge) which is combined with things like the username and password hash to prove to each other that they both know the password, without ever sending the password across the wire.</p><p>There are several RFCs that cover <a href="https://tools.ietf.org/html/rfc3748">EAP</a>, <a href="https://tools.ietf.org/html/draft-josefsson-pppext-eap-tls-eap-06">PEAP</a>, <a href="https://tools.ietf.org/html/rfc1994">CHAP</a>, <a href="https://tools.ietf.org/html/rfc2433">MSCHAPv1</a>, <a href="https://tools.ietf.org/html/rfc2759">MSCHAPv2</a>, <a href="https://tools.ietf.org/html/rfc3078">MPEE</a> and <a href="https://tools.ietf.org/html/rfc3079">MPEE key derivation</a>. These are pretty frustrating to read as they refer to eachother, and no one document puts it all together. I did, in the code at <a href="https://github.com/sensepost/understanding-eap">https://github.com/sensepost/understanding-eap</a>.</p><h4>Decrypting the Inner Tunnel</h4><p>This is typically where packet captures would come in. However, the whole MSCHAPv2 exchange is encrypted by TLS. Years ago, <a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/319183">Michal</a> wrote <a href="https://community.cisco.com/kxiwq67737/attachments/kxiwq67737/4561-blogs-security/821/4/141647-dump.pl.zip">a perl script</a> to decrypt this inner session and display it in Wireshark as well as <a href="https://community.cisco.com/t5/security-blogs/eap-peap-with-mschapv2-decrypted-and-decoded/ba-p/3106761">documenting what was happening in the inner tunnel</a>. However, modern TLS isn’t so easily decrypted thanks to perfect forward secrecy, and I wanted to see how things changed when we made the <a href="https://github.com/sensepost/hostapd-mana">mana authenticator</a> act differently. So instead, I told wpa_supplicant and hostapd to use the openssl eNULL cipher. This provides no encryption, only authentication of the data. Which means we can see the data in the clear. This, combined with the hexdump’s provided by hostapd-mana run with debugging (-d), let me see what was happening in the inner tunnel.</p><p>You can enable eNULL in wpa_supplicant and hostapd by adding the following line to the respective config (use quotes for wpa_supplicant’s config, no quotes for hostapd’s):</p><pre>openssl_ciphers=&quot;eNULL&quot;</pre><h4>The Inner MSCHAPv2 Exchange</h4><p>A packet capture of a successful association looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PIIBVVmAvPI4Wq8xY2ntdQ.png" /></figure><p>You can see the following happening:</p><ul><li>Frames 5–6: The authenticator asking the stations for it’s outer identity.</li><li>Frame 7: Starting PEAP</li><li>Frames 8–13: TLS initiation</li><li>Frames 15–21: MSCHAPv2 in the inner tunnel</li><li>Frames 22–23: PEAP and EAP end</li><li>Frames 24–27: The WPA2 4-way handshake</li></ul><p>As you can see the MSCHAPv2 exchange happens over seven frames. These are listed here, and the specific bytes described after:</p><ol><li>Authenticator -&gt; Station — <strong>Initiation</strong>: let’s do this</li><li>Station -&gt; Authentication — <strong>Username</strong>: sure, this is my id</li><li>Authenticator -&gt; Station — <strong>Authenticator Challenge</strong>: nice, here’s my challenge and hostname</li><li>Station -&gt; Authenticator <strong>— Peer Challenge &amp; NTResponse</strong>: cool, cool, here’s my challenge and I heard you like DES so I encrypted our challenges with the password hash as a key.</li><li>Authenticator -&gt; Station — <strong>Authenticator Response</strong>: I see your response, and raise you a sha1 hash of all of that with some static magic bytes from the RFC, oh and I double hashed the password for reasons</li><li>Station -&gt; Authenticator — <strong>Success</strong></li><li>Authenticator -&gt; Station — <strong>Success</strong>: Me too</li></ol><p>If you look at the encrypted data within the first frame, wireshark helpfully “decrypts” it for you:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRVAHEG13t1QKuBCErOMtQ.png" /></figure><h4>Byte-Level Description of the MSCHAPv2 Exchange</h4><p><strong>MSCHAPv2 Frame 1</strong>: Authenticator -&gt; Station — Initiation. <br>This is a EAP/CHAP format, which is made up of the following. All bytes are in hex except where they conform to ASCII strings.</p><pre>• Code: 01 — This is a challenge<br>• Identifier: 61 00 — This is the challenge’s ID<br>• Value-Size: 05 — aka length<br>• Value: 01</pre><p><strong>MSCHAPV2 Frame 2</strong>: Station -&gt; Authentication — Username</p><pre>• Code: 02 — This is a response<br>• Identifier: 61 00 — Response to Frame 1’s ID<br>• Value-Size: 12<br>• Value: 01<br>• Name: Oliver.Parker</pre><p><strong>MSCHAPV2 Frame 3</strong>: Authenticator -&gt; Station — Authenticator Challenge</p><pre>• Code: 01 — Challenge<br>• Identifier: 62 00 — Response to previous new ID<br>• Value-Size: 21<br>• Value: 1a — Seems to indicate start of a new CHAP frame<br>  • Code: 01<br>  • Identifier: 62 00<br>  • Value-Size: 1c<br>  • Length: 10 — Authenticator Challenge length<br>  • AuthenticatorChallenge: f5 b8 ad ee e9 ff 08 15 dd 83 e8 2d 89 6e eb 2a<br>  • Authenticator Name: hostapd</pre><p><strong>MSCHAPV2 Frame 4</strong>: Station -&gt; Authenticator — Peer Challenge &amp; NTResponse</p><pre>• Code: 02<br>• Identifier: 62 00<br>• Value-Size: 48<br>• Value: 1a<br>  • Code: 02<br>  • Identifier: 62 00<br>  • Value-Size: 43–67 in decimal<br>  • Length: 31<br>  • PeerChallenge: e3 32 bf 8e c5 37 e5 72 1d 0d 9a 0e e4 40 46 d6<br>  • Padding?: 00 00 00 00 00 00 00 00<br>  • NTResponse: 6c da db 80 dd 53 10 b8 05 f2 a0 da 9b b4 5e ad 51 ee 65 34 4c 95 e6 00<br>  • Padding?: 00<br>  • Name: Oliver.Parker</pre><p><strong>MSCHAPV2 Frame 5</strong>: Authenticator -&gt; Station — Authenticator Response</p><pre>• Code: 01<br>• Identifier: 63 00 — New Challenge ID<br>• Value-Size: 38<br>• Value: 1a<br>  • Code: 03 — Success?<br>  • Identifier: 62 00<br>  • Value-Size: 33–51 in decimal<br>  • AuthenticatorResponse: S=3EC7654786779579D27FCB870C93670D66E5AFB7 M=OK</pre><p><strong>MSCHAPV2 Frame 6</strong>: Station -&gt; Authenticator — Success</p><p><strong>MSCHAPV2 Frame 7:</strong> Authenticator -&gt; Station — Success</p><h4>MSCHAPv2 Calculations</h4><p>We can check the above by implementing the code described in the <a href="https://tools.ietf.org/html/rfc2759#section-8">RFC 2759 Section 8</a> which you can grab from our repo at <a href="https://github.com/sensepost/understanding-eap">https://github.com/sensepost/understanding-eap</a>.</p><p><strong>The Station/Client Side</strong><br>Both the authenticator and the station send each other some random data (the challenges’s). The authenticator sends its challenge first (the Authenticator Challenge), so the client gets to kick off the computations. Using the values from above and the code I just posted, it looks like this from the python3 interpreter:</p><pre>from <a href="https://github.com/sensepost/understanding-eap/">eap</a> import MSCHAPV2<br>UserName = b&#39;Oliver.Parker&#39;<br>Password=&#39;123456Seven&#39;<br>AuthenticatorChallenge = b&#39;&#39;.fromhex(&#39;f5 b8 ad ee e9 ff 08 15 dd 83 e8 2d 89 6e eb 2a&#39;)<br>PeerChallenge = b&#39;&#39;.fromhex(&#39;e3 32 bf 8e c5 37 e5 72 1d 0d 9a 0e e4 40 46 d6&#39;)<br>chap = MSCHAPV2(UserName, Password, AuthenticatorChallenge, PeerChallenge)<br>PasswordHash = chap.NtPasswordHash(Password)<br>Challenge = chap.ChallengeHash(PeerChallenge, AuthenticatorChallenge, UserName)<br>NTResponse = chap.ChallengeResponse(Challenge, PasswordHash)<br>print (&#39;Challenge : &#39;+Challenge.hex())<br>print (&#39;NTResponse: &#39;+NTResponse.hex())</pre><pre>Challenge : ada74b1fca661d15<br>NTResponse: 6cdadb80dd5310b805f2a0da9bb45ead51ee65344c95e600</pre><p>The station then sends the NTResponse and its peer challenge to the authenticator. You can see the calculated NTResponse matches that from frame 4 above.</p><p><strong>A WPE Interlude</strong></p><p>That challenge and response should look familiar. It’s basically the same as a NetNTLMv1 hash. However, in NetNTLMv1 the challenge is just sent over the network, in MSCHAPv2 the challenge is computed from the two challenges and the username. This is also what freeradius-wpe, hostapd-wpe and hostapd-mana give you when they PitM (Person in the Middle) a PEAP session and capture a challenge response.</p><p>We can test this is correct using asleap/hashcat/JtR, I’ll use asleap:</p><pre>&gt; asleap -C ad:a7:4b:1f:ca:66:1d:15 -R 6c:da:db:80:dd:53:10:b8:05:f2:a0:da:9b:b4:5e:ad:51:ee:65:34:4c:95:e6:00 -W passwords<br> asleap 2.2 - actively recover LEAP/PPTP passwords. <a href="/service/mailto:jwright@hasborg.com">jwright@hasborg.com</a><br> Using wordlist mode with &quot;passwords&quot;.<br> hash bytes: 2b6f<br> NT hash: 79337ad5724e777b41e8fc81ad232b6f<br> password: 123456Seven</pre><p>And indeed, if we check the value of PasswordHash in our python, it will match asleap’s “NT hash”.</p><p><strong>The Authenticator/RADIUS Side</strong><br>At this point, the authenticator now has the stations challenge (the peer challenge) and can do similar calculations. They look like this:</p><pre>from <a href="https://github.com/sensepost/understanding-eap/blob/master/eap.py">eap</a> import MSCHAPV2<br>UserName = b&#39;Oliver.Parker&#39;<br>Password=&#39;123456Seven&#39;<br>AuthenticatorChallenge = b&#39;&#39;.fromhex(&#39;f5 b8 ad ee e9 ff 08 15 dd 83 e8 2d 89 6e eb 2a&#39;)<br>PeerChallenge = b&#39;&#39;.fromhex(&#39;e3 32 bf 8e c5 37 e5 72 1d 0d 9a 0e e4 40 46 d6&#39;)<br>chap = MSCHAPV2(UserName, Password, AuthenticatorChallenge, PeerChallenge)<br>NTResponse = b&#39;&#39;.fromhex(&#39;6c da db 80 dd 53 10 b8 05 f2 a0 da 9b b4 5e ad 51 ee 65 34 4c 95 e6 00&#39;)<br>PasswordHash = chap.NtPasswordHash(Password)<br>AuthenticatorResponse = chap.GenerateAuthenticatorResponse(Password, NTResponse, PeerChallenge, AuthenticatorChallenge, UserName)<br>print(&#39;Authenticator Response: &#39; + AuthenticatorResponse)</pre><pre>Authenticator Response: S=3EC7654786779579D27FCB870C93670D66E5AFB7</pre><p>The authenticator then sends the authenticator response to the stations, along with a success or failure code. You can see that the calculated response matches that from frame 5 above.</p><h3>MSCHAPv2 Failure Behaviour</h3><p>In the case of a normal access point and authenticator, the station would send its username, and if the authenticator has a record for that user, authentication will continue. That failure condition isn’t particularly interesting.</p><p>However, if you set up a malicious authenticator, that will accept any username, you can capture the two challenges as well as the NTResponse from the station, which you can crack as detailed above. This was what Joshua Wright and Brad Antoniewicz published in 2008 with their<a href="https://www.willhackforsushi.com/presentations/PEAP_Shmoocon2008_Wright_Antoniewicz.pdf"> initial freeradius-wpe work</a>.</p><p>Interestingly however, the exchange ends, <strong>because the authenticator ended it</strong>, not the station. It can’t validate the NTResponse from the station (because it doesn’t have the right password). So the authenticator can’t compute an Authenticator Response, and instead sends a failure response in frame 5 along the lines of:</p><pre>E=691 R=0 C=00000000000000000000000000000000 V=3 M=FAILED</pre><p><strong>WPE’s EAP-Success<br></strong> In the case of WPE’s -s switch, to implement the “always return EAP-Success” attack, the authenticator skips sending the authenticator response, and jumps ahead to a success frame, much like frame 7 above.</p><p>If a normal station/client/supplicant sees this, it will end the exchange, because it was expecting the authenticator response. In wpa_supplicant’s case, it will hard stop and send a deauthentication frame at the AP.</p><h3>The Apple Vulnerability</h3><p>In the case of unpatched Apple devices, the authenticator would skip sending the authenticator response and just send a MSCHAPv2 success frame as per frame 7 above. A vulnerable Apple device happily jumps ahead in its state machine, accepts that, and exits out of the inner MSCHAPv2 tunnel. It then sends a PEAP response, to which hostapd-wpe sends the EAP-Success.</p><p>Earlier, when introducing PEAP, we said that by default (i.e,. if there’s no cryptobinding), the pairwise master key used for starting the WPA2 4-way handshake is taken from the outer TLS session. The authenticator sends this to the AP at this point, and the AP and Apple device happily complete the 4-way handshake and the device connects. Here’s an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAq4KUHERWJOxY59PLYtWQ.png" /></figure><p>If you’d like to read the original vulnerability report, it’s at the bottom of this post.</p><p><strong>The Risk</strong><br>This means that if an Apple device connects to a rogue AP that doesn’t know the user’s password, not only will it get the NetNTLMv1 challenge response, the device will also connect to the network. Because EAP’ed networks are typically corporate networks, the Apple device will think it’s connected to that (sans user interaction), at which point Responder style attacks are also possible.</p><p>That said, this isn’t exactly CVSS 10 territory, and we rated the initial vulnerability as a <a href="https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:A/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L">CVSS3 5.5</a></p><p>However, the vulnerability seemed to affect multiple iOS and macOS versions, as well as multiple Apple devices such as Macbooks, iPhones and iPads. Apple’s advisory confirm it also affected Apple TVs.</p><h3>Apple’s Fix</h3><p>Apple released three <a href="https://support.apple.com/en-us/HT201222">updates</a> for <a href="https://support.apple.com/en-za/HT209600">macOS</a>, <a href="https://support.apple.com/en-za/HT209599">iOS</a> and <a href="https://support.apple.com/en-za/HT209601">tvOS</a> to fix this, and assigned it <a href="https://nvd.nist.gov/vuln/detail/CVE-2019-6203">CVE-2019–6203</a>. It took them approximately 8 months from the time of reporting to the fix. We don’t always appreciate the engineering effort that goes into fixing the vulns we fling at these teams, especially one that affects so many devices. A big thanks to anyone involved in getting it fixed.</p><p>That said, the way Apple fixed this confuses me to no end. Devices that have been patched exhibit <strong>the exact same behaviour</strong> at a PEAP, MSCHAPv2 and WPA2 level i.e. the device still connects to the network, and in some cases will even request DHCP. Here’s an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2bzCeYJl8DTrPoa41M5Hw.png" /></figure><p>Instead, Apple made the devices disconnect from the network <strong>after connecting</strong>. The device displays a “cannot connect” error, and a log entry shows up on the device saying:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MuzwfdtIMiAK8-q-7ojm7A.png" /></figure><p>This is a little bit like a security guard letting someone in the building, then chasing them out once they’re inside. While it has the same end effect, I’d be a little worried about what could be exposed during that time. That said, different chips may be doing different things, and maybe this is a temporary fix until it can get fixed in firmware. I can only imagine it’s an engineering nightmare and wish the people dealing with it luck.</p><p>However, while testing the new fix, I did notice one outlier, when the device connected but derived a different PMK, evidenced by the MIC in the second message of the handshake. (That’s what the WPA code in the repo is for.) I haven’t been able to get it to repeat, but it should be impossible since the PMK is taken from the outer TLS session and cryptobinding wasn’t enabled. I also haven’t tested extensively across different devices. So there may be updates to my understanding of this fix later.</p><h4>Disclosure Timeline &amp; Details</h4><ul><li>2 Aug 2018 — Vulnerability report submitted</li><li>6 Aug 2018 — Akila @ Apple confirm receipt of 696428427</li><li>23 Oct 2018 — I asked for an update on progress</li><li>24 Oct 2018 — Akila said still investigating</li><li>4 Feb 2019 — I asked for progress update</li><li>6 Feb 2019 — Akila confirmed they will be addressing this in a future update.</li><li>6 Feb 2019 — I asked for an ETA</li><li>13 Feb 2019 — Akila said it won’t be getting a CVE</li><li>14 Feb 2019 — I asked why no CVE</li><li>20 Feb 2019 — Akila confirmed it will get a CVE after internal discussion</li><li>29 Mar 2019 — I saw the issue had been patched, but not disclosed in security notes.</li><li>2 April 2019 — Akila said will update security notes.</li><li>15 April 2019 — March 25 <a href="https://support.apple.com/en-za/HT209600">macOS</a>, <a href="https://support.apple.com/en-za/HT209599">iOS</a> and <a href="https://support.apple.com/en-za/HT209601">tvOS</a> security notes updated. CVE-2019–6203 assigned.</li></ul><p>I’d also like to thank the anonymous Apple employee who spoke to me off the record about progress.</p><p>While it’s lovely to see my name credited to this, <a href="https://twitter.com/brad_anton">Brad Antoniewicz</a> deserves most of the credit as he wrote the initial exploit, I just spotted the specifics and reported it.</p><h3>Original Vulnerability Report</h3><h4>Overview</h4><p>iOS and macOS will connect to a malicious wifi access point using PEAP/MSCHAPv2 if an EAP-Success message is sent with an invalid authenticator MSCHAPv2 response.</p><h4>Vulnerable Version</h4><p>Only a few versions were tested, these were:</p><p>iOS 11.4.1 (iPhone)<br> iOS 9.3.5 (iPad)<br> macOS 10.13.6 (MBP Pro 2017)</p><h4>Detail</h4><p>PEAP establishes an outer TLS tunnel, and typically MSCHAPv2 is used within the tunnel to authenticate a supplicant (client iOS device) to an authenticator (backend RADIUS server). With MSCHAPv2 a challenge is sent to the supplicant, the supplicant combines this challenge and their password to send a nt-response. The authenticator generates the same expected nt-response based on its knowledge of the password, and compares them. If they match, an EAP-Success frame is sent to allow the supplicant to authenticate. However, this EAP-Success frame is sent with a 42-byte message authenticator based on the authenticator’s knowledge of the password (aka authenticator response). The supplicant should validate this message authenticator.</p><p>iOS and macOS do not. This makes it possible to stand up a fake access point, that will accept any username and password, and merely send an EAP-Success back. iOS/macOS devices will then connect.</p><p>wpa_supplicant on Linux and Android, and Windows 8/10 have been tested and are not vulnerable. As they will validate the message authenticator sent from the authenticator and refuse to connect.</p><h4>Impact</h4><p>CVSS3 5.5<br> <a href="https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:A/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L">https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:A/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L</a></p><p>Devices could end up connected to networks the user believes are trusted. This could allow additional MitM attacks against the device or applications running on it.</p><p>Devices connecting to PEAP networks should validate the certificate sent by the authenticator, but user’s aren’t good at validating certificates. However, iOS devices won’t automatically connect to the network if it has a different certificate, meaning users will need to manually select the network and choose to trust the new certificate. Although, cloning all aspects of the certificate with tools such as <a href="https://github.com/sensepost/apostille">https://github.com/sensepost/apostille</a> will make it hard for a user to differentiate a fake one from the original.</p><h4>How to Reproduce</h4><p>Install hostapd-wpe <a href="https://github.com/OpenSecurityResearch/hostapd-wpe/blob/master/hostapd-wpe.patch">https://github.com/OpenSecurityResearch/hostapd-wpe/blob/master/hostapd-wpe.patch</a><br> This is most simply done in Kali with “apt-get install hostapd-wpe” and the following assumes that approach.</p><p>Run it with the -e switch to enable “EAP Success”<br> <a href="https://github.com/OpenSecurityResearch/hostapd-wpe/blob/master/README#L135">https://github.com/OpenSecurityResearch/hostapd-wpe/blob/master/README#L135</a></p><p>On an iOS device, under Wifi, connect to the “hostapd-wpe” network. Choose to trust the certificate. Any credentials can be used.</p><p>The device will connect. Running dnsmasq to hand out DHCP will show the device gets an IP.</p><p>Attempting the same client connection with wpa_supplicant using the following sample configuration will not work:</p><pre>network={<br> ssid=”hostapd-wpe”<br> key_mgmt=WPA-EAP<br> eap=PEAP<br> phase2=”auth=MSCHAPV2″<br> identity=”test”<br> password=”password”<br> ca_cert=”/etc/hostapd-wpe/certs/ca.pem”<br>}</pre><p>You will see the supplicant will reject the final message authenticator and disconnect.</p><h4>Recommendation</h4><p>Validate the message authenticator sent in the final EAP-Success message, and do not allow iOS/macOS device to connect to rogue access points that cannot prove knowledge of the user’s password.</p><p>An example of wpa_supplicant performing this validation can be found at:<br> <a href="https://w1.fi/cgit/hostap/tree/src/eap_peer/mschapv2.c#n112">https://w1.fi/cgit/hostap/tree/src/eap_peer/mschapv2.c#n112</a></p><h4>Credit</h4><p>Credit for the functionality I used goes to Brad Antoniewicz (@brad_anton) the author of hostapd-wpe. Although, he was not aware of the iOS/macOS specifics.</p><p><em>Originally published at </em><a href="https://sensepost.com/blog/2019/understanding-peap-in-depth/"><em>https://sensepost.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8d679c72438" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Your Own LinuxKit With Docker For Mac]]></title>
            <link>https://medium.com/@notsinge/making-your-own-linuxkit-with-docker-for-mac-5c1234170fb1?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c1234170fb1</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[linuxkit]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[wifi]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Wed, 04 Jul 2018 12:17:31 GMT</pubDate>
            <atom:updated>2018-07-04T12:34:59.734Z</atom:updated>
            <content:encoded><![CDATA[<h4>Docker For Mac (and Windows) has done some interesting tricks to bring Docker to non-Linux platforms. It took me a while to figure it all out, and even longer to work out how to make change to the kernel and rebuild the VM. This is a write-up of what I did and why.</h4><p>If you just want the results, you can grab them from <a href="http://github.com/singe/linuxkit-for-mac">http://github.com/singe/linuxkit-for-mac</a></p><h4>Overview</h4><p>On a traditional Linux-based host, docker runs on the native OS and provisions and isolates containers with things like containerd and runc. Windows and MacOS don’t run Linux kernels and so you can’t run dockerd directly on the host OS. Instead, a Linux VM is used as an interstitial to run dockerd on. There’s some dark integration magic to allow things like bind volume mounts to the host OS from a container. In short, it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*b-jEt-V92bugJAAu3HsJsQ.png" /><figcaption>Highly Technical Overview of normal Docker vs Docker for Mac</figcaption></figure><p>You can get a proper explanation of it all from <a href="https://blog.docker.com/2016/05/docker-unikernels-open-source/">this docker blog post</a>.</p><p>If you don’t believe me and want to connect directly to your docker host VM on MacOS, you can run this:</p><pre>screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty</pre><p>You can also see the .iso it boots from at:</p><pre>/Applications/Docker.app/Contents/Resources/linuxkit/docker-for-mac.iso</pre><p>In line with Docker’s principle of “swappable batteries” the <a href="http://mobyproject.org/">Moby framework</a> includes <a href="https://github.com/linuxkit/linuxkit">LinuxKit</a> for building small/secure Linux host OS’ that can run on all sorts of things like MacOS, Windows, Mainframes and more. <a href="https://www.mirantis.com/blog/ok-i-give-up-is-docker-now-moby-and-what-is-linuxkit/">This article</a> has a good overview. Several months ago, <a href="https://www.docker.com/docker-mac">Docker-CE for Mac</a> moved away from using the boot2docker VirtualBox VM to a LinuxKit based HyperKit VM.</p><h4>Making Changes — Trying to just build a kernel module</h4><p>For our <a href="https://defcon.org/html/defcon-26/dc-26-speakers.html#Singe">upcoming Defcon talk</a>, I wanted to port the work we’d done on AWS to build WiFi CTF environments in the cloud, to Docker, so people can learn/practise WiFi hacking without needing hardware. This necessitates loading a kernel module <a href="https://wireless.wiki.kernel.org/en/users/Drivers/mac80211_hwsim">mac80211_hwsim</a> to create fake wifi devices. The LinuxKit VM doesn’t have these modules compiled, so my first failed attempt was to try and build these. You can build kernel modules for the existing LinuxKit VM by reading <a href="https://github.com/linuxkit/linuxkit/blob/master/docs/kernels.md#compiling-external-kernel-modules">the documentation</a>, and looking at <a href="https://github.com/linuxkit/linuxkit/tree/master/test/cases/020_kernel">these examples</a>. One critical piece of information not included, is that you can grab the config for the running kernel from /proc/config.gz like so:</p><pre>&gt; docker run -it --rm -v /:/host -v $(pwd):/macos alpine:latest<br>/ # uname -a<br>Linux 23b3e591c4eb 4.9.93-linuxkit-aufs #1 SMP Wed Jun 6 16:55:56 UTC 2018 x86_64 Linux<br>/ # cp /host/proc/config.gz /macos/<br>/ # exit</pre><p>You’ll also need the kernel source for that version, e.g.</p><pre>wget <a href="https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.93.tar.xz">https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.93.tar.xz</a></pre><p>But, while this will work for simple modules. This won’t work for wifi modules, as the existing LinuxKit kernel doesn’t have base support for wifi capabilities. So building the modules will get you errors like this:</p><pre>can&#39;t insert &#39;mac80211.ko&#39;: unknown symbol in module, or unknown parameter</pre><p>Ok, it looks like we’re going to need to build a whole new kernel.</p><h4>Rebuilding A New LinuxKit Kernel</h4><p>Building a new kernel is relatively easy, especially if you’re familiar with building Linux kernels in general. The <a href="https://github.com/linuxkit/linuxkit/blob/master/docs/kernels.md#modifying-the-kernel-config">documentation</a> is now clear and accurate. If you’re here for wifi, you don’t need to do this, as I’ve <a href="https://hub.docker.com/r/singelet/kernel/tags/">done it for you already</a>.</p><p>First you need a copy of LinuxKit, then you need to work out what new kernel options you need to add, then you need to build your custom kernel.</p><p>Build your custom config.</p><pre>git clone <a href="https://github.com/linuxkit/linuxkit">https://github.com/linuxkit/linuxkit</a><br>cd linuxkit/kernel</pre><pre>docker run --rm -ti -v $(pwd):/src linuxkit/kconfig<br># In container<br>cd linux-4.9.96/<br>make menuconfig<br>####Configure the kernel the way you want, I enabled base wifi<br>cp .config /src/config-4.9.x-x86_64-custom<br>exit #Exit Container</pre><p>For my purposes, I only <strong>added</strong> kernel options, so I stick those in a <a href="https://github.com/singe/linuxkit-for-mac/blob/master/linuxkit/config-wifi">config-wifi</a> file, so I can reuse them for other kernels, as these mostly haven’t changed across versions. You can now build your kernel, I’ve got the steps for that documented in the readme <a href="https://github.com/singe/linuxkit-for-mac/tree/master/linuxkit">here</a>. It should be a simple case of:</p><pre>make EXTRA=-custom build_4.9.x-custom</pre><p>This will build an image and store it in your docker image store with the tag linuxkit/kernel. You can now use this in your own LinuxKit builds. (Amusingly, this build is kernel panic’ing my vanilla docker-ce LinuxKit host right now, so there are still some bugs).</p><h4>Build a New LinuxKit Image</h4><p>Great, we’ve got a shiny new kernel image, time to build a new LinuxKit iso. There are a bunch of examples of these in the <a href="https://github.com/linuxkit/linuxkit/tree/master/examples">linuxkit/examples</a> directory. It makes sense to start with the docker-for-mac.yml. Open it up in your favourite editor, and replace the line</p><pre>image: linuxkit/kernel:4.14.52</pre><p>with your kernel e.g.</p><pre>image: linuxkit/kernel:4.14.52-wifi-ba03a8d668eb6be981e1ff71883b5e9e26274971-amd64</pre><p>Or just use my prebuilt kernel:</p><pre>image: singelet/kernel:4.14.52-wifi-ba03a8d668eb6be981e1ff71883b5e9e26274971-amd64</pre><p>If you want to have the kernel modules loaded automatically with modprobe, you’ll also need to add this to the .yml file:</p><pre>- name: modprobe<br>    image: linuxkit/modprobe:v0.4<br>    command: [&quot;modprobe&quot;, &quot;-a&quot;, &quot;mac80211_hwsim&quot;]</pre><p>Next up, build yourself an iso with:</p><pre>linuxkit build --format iso-efi docker-for-mac.yml</pre><p>If you haven’t build linuxkit, just run <em>make</em> in its top-level directory, and you’ll get the binary in linuxkit/bin/linuxkit.</p><p>This will create a file named docker-for-mac-wifi-efi.iso. You can use this, by stopping Docker, backing up your existing docker-ce iso and replacing it with this one, then restarting it.</p><pre>mv /Applications/Docker.app/Contents/Resources/linuxkit/docker-for-mac.iso /Applications/Docker.app/Contents/Resources/linuxkit/docker-for-mac.iso.orig<br>cp docker-for-mac-wifi-efi.iso /Applications/Docker.app/Contents/Resources/linuxkit/docker-for-mac.iso</pre><p>You can check that it boots alright by watching the console with the screen command a the top of this post.</p><p>If all went well, you should now have a docker running with your shiny new LinuxKit host, and immediately notice several problems. This is where it gets messy.</p><h4>Why Some Batteries Are Nicer Than Others</h4><p>Despite Docker’s principle of swappable batteries, the LinuxKit image they build for Docker-CE for MacOS, has a image docker-ce with proprietary and non-redistributable code. This means that the docker-for-mac.yml that comes with LinuxKit, creates a LinuxKit image that:</p><ul><li>Can’t do <strong>any</strong> bind mounts, whether to the LinuxKit host or MacOS host</li><li>Will never signal the taskbar icon that it’s started, so the GUI thinks it’s booting constantly.</li><li>Probably several other things I haven’t noticed yet.</li></ul><p>This is primarily because of a tool called transfused that communicates with the <a href="https://docs.docker.com/docker-for-mac/osxfs/">osxfs</a> process running on the mac. It used to be open source, but dissapeared and after some significant commit archeology, I eventually just asked:</p><h3>Dominic White on Twitter</h3><p>@justincormack Do you know were the code for transfused is kept post your commit removing it from linuxkit https://t.co/GwfRJpoCPn Because https://t.co/EMekVtOcGH can&#39;t mount volumes. I&#39;m getting very lost in commits &amp;amp; pointer would help.</p><p>To which the reply was:</p><h3>Justin Cormack on Twitter</h3><p>@singe Transfuse was never open source and that bit of code is probably very outdated.</p><p>And his suggestion was to just copy it out of the existing image, but:</p><h3>Justin Cormack on Twitter</h3><p>@singe Modified versions of d4mac are not redistributable. You need to either only modify it via containers at runtime or just ship LinuxKit</p><p>Shucks. Then there’s also sendtohost, which send simple state info to the Docker taskbar agent. It appears to come from a private docker repo called pinata (according to strings inside it). There’s an older version available <a href="https://hub.docker.com/r/dockerpinata/sendtohost-alpine/">here</a>. There also possibly a lot more I haven’t figured out yet.</p><p>This is why I built <a href="https://github.com/singe/linuxkit-for-mac/tree/master/get-dockerce">get-dockerce</a>, to extract the things you need from the existing LinuxKit image while it’s running. Because I can’t redistribute them. Plus, with the regular release cycle of docker-ce this stuff is likely to change over time. All it <a href="https://github.com/singe/linuxkit-for-mac/blob/master/get-dockerce/entrypoint.sh#L13">really does</a> is copy two files, transfused and sendtohost. Those two files are then used in the <a href="https://github.com/singe/linuxkit-for-mac/tree/master/docker-fakece">docker-fakece</a> image you’ll need to build yourself. After which, they can be used in the <a href="https://github.com/singe/linuxkit-for-mac/blob/master/linuxkit/docker-for-mac-mod.yml">modified LinuxKit docker-for-mac.yml file</a>. I had to painstakingly figure out how to make that work with limited documentation (I think LinuxKit .yml files are <a href="https://docs.docker.com/docker-cloud/apps/stack-yaml-reference/">Docker Cloud Stack</a> files) and by recreating the .iso and restarting Docker each time. There was all sorts of weirdness (like scripts with background’ing, &amp;, directives refusing to execute those), and figuring out how to pass the fuse device through. But it works.</p><p>Unfortunately, while transfused will now let you bind mount locations on the LinuxKit host, I haven’t got it working to allow bind mounts to those macOS host. If you have any ideas …</p><h4>Was It Worth It &amp; What Would Be Ideal</h4><p>While this was an interesting dive into the innards of LinuxKit and Docker for Mac, the latter part feels like a lot of work and ugly hacks, that are mostly not redistributable, and fragile to change. Ideally, Docker will release the docker-ce image they use, containing transfused and similar publicly on Docker hub (it’s already on everyone’s machines just in a hard to access way) as well as an updated docker-for-mac.yml. Then we could just change the kernel and build a first-tier LinuxKit image. A request I made <a href="https://github.com/docker/for-mac/issues/3050">here</a>.</p><p>Alternativley, they could add wireless options to the kernel they ship with LinuxKit, to allow wifi modules to be built. This isn’t great because it’s super specific to a wifi edge case, and doesn’t help people wanting to build custom kernels.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c1234170fb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cracking Efficiency Measurements & Common Substring Attack]]></title>
            <link>https://medium.com/@notsinge/cracking-efficiency-measurements-common-substring-attackthis-was-an-epic-week-for-password-fafd40523e0f?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fafd40523e0f</guid>
            <category><![CDATA[hashcat]]></category>
            <category><![CDATA[password-cracking]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Wed, 04 Jul 2018 08:20:41 GMT</pubDate>
            <atom:updated>2018-07-04T08:21:26.667Z</atom:updated>
            <content:encoded><![CDATA[<h4>I put together a cracking technique, and tested it against other techniques, generating some insight into the best performing cracking techniques. Rockyou with hob064 rules won, but my technique came a close second, and had a faster crack speed. Get the script <a href="https://github.com/sensepost/common-substr">here</a>.</h4><p>You can use the technique with a list of common substrings from your own lists (sorry we can’t share ours). Or use the technique targetted specifically at a dump you’ve been going at to mine more cracks out of it.</p><h3>Common Substrings</h3><p>As my eyes blurred over some boring work, I had the thought; “what if we used the most common substrings found in already cracked passwords, to crack more”. For example, if users regularly use “companyname” or “!!” in their passwords, this would pull them out.</p><p>To this end, I wrote some dirty python. It took 38 minutes to run across one list. Before optimising I thought I should try awk, which is famously good at this sort of processing.</p><p>That lead me to a kernel of an idea taken from <a href="https://www.unix.com/302889669-post4.html?s=2268e5a250e5a7eada6116db1127b031">these forums</a>. awk is magic, if hard to understand. I’ll leave doing that as an exercise to the reader. Needless to say, this is *much* faster than my pythonic attempts.</p><p>The way to use this, is to dump all the clears you’ve cracked so far to a file, then run this over that output. It’ll output some stats like percentage and number of times it was seen (and sort by percentage). Just cut on tabs to get the substrings only. <strong>Make sure you don’t unique anything, if a dump has lots of the same password repeated, you *want* that to show up as “more common”. If you unique either the hashes or the clears, you’ll lose that.</strong></p><p>I then used this to generate a list of common substrings specific to various password dumps, and managed to crack a whole lot more that I hadn’t cracked before. I used hashcat’s -a1 combinator attack mode with the substrings as the right most list and other password lists as the left. I’d run it twice, once with -jc (i.e. capitalise first letter) and then again without.</p><p>I then took the most common substrings (everything &gt;= 1%) by percentage from various dumps, and combined those to form a short super list of common substrings.</p><p>It looked like it was working well, but I wanted to see how it compared to other techniques.</p><h3>Efficiency Measurements</h3><p>It’s fine to some “something worked well” but what does that actually mean? Well, stand back, I’m going to try science!</p><p>I run 88 different tests on my laptop (kept constant) trying different techniques against different sets of hashes to see what worked best. I’d clear the potfile, run the text, then make a note of the time it took, the H/s, the number of hashes cracked and the percentage of the total that constituted.</p><p>The experiments combined several things:</p><ul><li>4 different sets of hashes from projects. Two were part of the substring creation list (a &amp; b) and two weren’t part of them (x &amp; y).</li><li>Two base password lists; rockyou and facebook-firstnames (and in one case our private lists as a comparison).</li><li>Three rule sets best64, hob064 and InsidePro-PasswordsPro. I chose them as they were fast, and this experiment needed speed to scale the tests.</li><li>Where appropriate, I tried with -j c and without (i.e. uppercase first char), mostly this was for the substrings tests.</li></ul><p>If you want raw results, my excel calcs are <a href="https://blog.sensepost.com/wp-content/uploads/2018/04/cracking-stats-1.xlsx">here</a></p><p>The overall results, were that a rules based approach with hob064 and rockyou featured in the top 4 for each password list as the most efficient, cracking on average 9,4% (ranging between 4,5%-18,2%) of the respective hash lists in 4–6s (your speed may vary). The second most effective, was using facebook firstnames with my substring list and uppercasing the first letter (i.e. -jc). This cracked on average 9,8% (ranging between 6,2–12,2%) of the passwords in the respective dumps between 7–8s. The next best technique (facebook-firstnames with best64) only averaged 3% and only did well against one password list, so it skewed its results. However, the substring attack had a significantly higher H/s on average than the rules based attack, which may give it an edge. Specifically:</p><ul><li>rockyou rules hob064 cracked <strong>9.4%</strong> in <strong>5s</strong> at <strong>190.25MH/s</strong></li><li>fb-firstnames substrings -jc cracked <strong>9.8%</strong> in <strong>7.3s</strong> at <strong>914.35MH/s</strong></li></ul><p>I did a brief test of our private wordlists against one set of hashes. Those lists outperformed both rockyou and facebook-firstnames in effectiveness. So it makes sense to develop your own for your specific use cases. The first list with hob064 rules did 15% of the hashes in 2s, and the second list with my substrings and -jc did 13% in 2s.</p><p>I also did a quick check of a mask attack out of interest, I used facebook-firstname and -jc and it took 37s to get 6% of the passwords.</p><p>Finally, I checked what the overlap between the rules-based approach and the substring approaches was (i.e. are they finding the same passwords or different ones). This was less good, on average there was a <strong>4.5%</strong> non-overlap between the rules and substring approaches. I suspect this has a lot to do with the wordlists.</p><p><em>Originally published at </em><a href="https://sensepost.com/blog/2018/cracking-efficiency-measurements-common-substring-attack/"><em>sensepost.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fafd40523e0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cheap Scriptable Web Interactions]]></title>
            <link>https://medium.com/@notsinge/cheap-scriptable-web-interactions-dbd7c19c664d?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbd7c19c664d</guid>
            <category><![CDATA[tools]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Tue, 02 Jan 2018 12:04:49 GMT</pubDate>
            <atom:updated>2018-01-02T12:04:49.743Z</atom:updated>
            <content:encoded><![CDATA[<h4>I came up with a nifty simple pattern for scriptable web interactions you may find useful.</h4><p>We need to interact with apps served over HTTP all the time. Generally, I use one of the following patterns:</p><ol><li>A quick curl — good for single shot interactions or scripting requests</li><li>Burp, ZAP or similar — ol’ faithful</li><li>Python’s <a href="http://docs.python-requests.org/en/master/">requests</a> library (with <a href="https://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> for extra parsing) — useful for scripting interactions, but no JS makes it limited</li><li><a href="http://docs.seleniumhq.org/">Selenium</a> — full blown browser automation</li></ol><p>These have served me well over the years. However, I recently had a situation where I wanted to do some scripted interaction, retain a browser and its UI interface and do it on a single, small, limited execution device (an iPhone). Any two of those requirements left me needing something between 3 and 4.</p><p>To solve this, I used the Python Requests library with the BaseHTTPRequestHandler to create a reverse proxy of sorts. I can then script the interactions with Requests, parse the DOM with BeautifulSoup and display the page in a normal browser window for the user to interact with (and run all the ajax-y JS). Put another way, Requests interacts with the server, and stores session state (like Cookies). The results are served over HTTP on <a href="http://localhost:1337/">http://localhost:1337/.</a> Any new requests from your browser are proxied by Requests and the results displayed back to the browser. So while Requests can’t grok JS, your browser can and the resulting request will just get proxied by Requests again.</p><p>Two examples; one that auto-login’s to Facebook mobile (including skipping the “do you want to set up one touch login for future) interstitial page; and one that doesn’t do any scripted interactions for testing at w3schools are available at: <a href="https://gist.github.com/singe/cba85800dd6e701c53d0614d8506b281"><strong>https://gist.github.com/singe/cba85800dd6e701c53d0614d8506b281</strong></a></p><p>It just handle’s GET and POST commands at the moment (which is enough for most uses), but the sample code and <a href="https://docs.python.org/3/library/http.server.html#http.server.BaseHTTPRequestHandler">Python docs</a> give you everything you need to extend it. This will run fine on a computer, but even better, this will run on iOS with the <a href="http://omz-software.com/pythonista/">Pythonista app</a> (in-fact, that’s where I wrote it).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbd7c19c664d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Propagation of 7MHz signals & ionospheric refraction]]></title>
            <link>https://medium.com/@notsinge/propagation-of-7mhz-signals-ionospheric-refraction-93f64578b0df?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/93f64578b0df</guid>
            <category><![CDATA[wspr]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ham-radio]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Sun, 17 Dec 2017 19:32:40 GMT</pubDate>
            <atom:updated>2017-12-17T20:46:27.190Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve long been interested in the physics of RF, but never had a chance to play with it until recently. This post covers my experiments with the propagation of 7MHz signals.</p><h3>The Setup</h3><p>My setup is at home, where I’ve got an ancient HF radio (<a href="https://www.universal-radio.com/catalog/hamhf/738.html">ICOM 738</a>), plugged in to a 20m dipole antenna on my roof and a laptop doing <a href="https://en.wikipedia.org/wiki/WSPR_(amateur_radio_software)">WSPR</a> with the <a href="http://physics.princeton.edu/pulsar/K1JT/wsjtx.html">wsjt-x</a> program for this experiment.</p><p>If you’re interested in more detail of the setup … otherwise skip this part. The antenna is borrowed from <a href="https://twitter.com/wicusross">Wicus</a> (thanks dude!) and consists of two 10m wires coming into a <a href="https://en.wikipedia.org/wiki/Balun">balun</a> which connects to the coax (RG58) feed line. The balun effectively filters out unwanted signals that are picked up by the coax sheath (I think, still trying to grok these fully). It’s jury-rigged to what I had in the house at the time, a piece of too-thin PVC cable tied to a telescopic painter’s pole. The radio is too old to do digital modes (which WSPR is), so I’ve got a homebrew <a href="http://www.tigertronics.com/slusbmain.htm">SignalLink</a>-like device which routes sound out of the radio to a USB soundcard for input (thanks ZS6SKY). For output, wsjt-x converts the digital signal to audio which is sent via the microphone input of the radio (a proprietary 8-pin ICOM plug). There’s also a <a href="https://www.soundcardpacket.org/7cableptt.aspx#isolation">serial cable that triggers the push-to-talk</a> (PTT) pin of the microphone input (by pulling RTS down to GND).</p><p>This is focused on 7Mhz signals, because I had to start somewhere, it’s where my antenna has the lowest <a href="https://en.wikipedia.org/wiki/Standing_wave_ratio">SWR ratio</a> (1:1) (aka signals are efficiently radiated via the antenna, and nothing is reflected back down again) and I need another USB to RS232 serial converter to <a href="http://www.qsl.net/g3vgr/civ.html">auto-control my rig</a> to switch frequencies while also triggering the microphone to transmit.</p><p>I’m also using the WSPR digital mode for three reasons. Firstly, I’m based in a suburban area, which means the noise floor is *terrible* (using the <a href="https://en.wikipedia.org/wiki/S_meter">S-measure</a> of signal strength my noise is sitting at a 9 with the preamp on and a 6 with it off, which is terribad!). This means I can barely hear traditional analog voice contacts through the noise. Secondly, digital modes are much less susceptible to RFI, and can encode the info more efficiently on narrower bandwidths which a DSP can pick out. Lastly, WSPR is designed to work even in really poor signal conditions.</p><p>My setup does two things. First, it monitors for signals from others and uploads these “spots” to <a href="http://wsprnet.org/drupal/wsprnet/spots">WSPRnet</a>. These are done in two minute windows (about 110s). WSPR is a very narrow digital mode (about 6Hz), so the radio’s output can include several at once and the software can pick out even very weak signals (that’s the point of WSPR).</p><p>Then my setup broadcasts a signal every six minutes or so. I vary the power of the transmitted signals between 2W and 10W (as I wanted to see how power affects things) but the default is 5W. Other stations monitoring for WSPR signals will report when they see me.</p><p>The WSPR signal includes some very basic information:</p><ul><li>Your callsign (I’m ZS6HAK)</li><li>Your location as a <a href="https://en.wikipedia.org/wiki/Maidenhead_Locator_System">maidenhead grid location</a></li><li>Your transmit power level</li></ul><p>These get encoded into 50bits; 28 bits for callsign, 15 for locator, 7 for power level (I’m using a 6 digit grid locator so it’s more complex). I’m still learning what the signal looks like exactly. You’ll notice that it’s completely spoofable, but at the moment they just rely on an honour system not to pollute the data.</p><h3>The Results</h3><p>Before running this, I had tried a couple of voice contacts and hadn’t gotten much farther than PMB (about 400km away). I could sometimes barely hear a friend of mine from Cape Town (about 2000km away) thanks to the noise issue I spoke about, so I didn’t think I’d get much further than a few hundred kilometers.</p><p>When I first started running this, one afternoon two weekends ago, I thought I had messed something up. I was spotting other local ZA transmission (even one in Cape Town!) but nobody was spotting me. Then, in the early evening I suddenly got spotted by Russia and large parts of Europe (furthest contact was over 9000km). When I woke up the next morning, I saw that I had made contacts as far away as Wisconsin America (over 14 000km away), and by the next evening I managed by furthest contact at 16 941km in California!</p><p>Looking at <a href="http://wsprnet.org/drupal/wsprnet/activity">lines of text</a> is pretty dry. However, WSPRnet gives you a <a href="http://wsprnet.org/drupal/wsprnet/map">pretty map</a> where you can see who’s seen your signal and whose signals you’ve seen. What you’ll notice is that most of the contacts (in the 40m band we’re looking at) were made between two night-side stations. Here are some example pictures:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4clOOhzU4ncilBJs10Avuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZZbBX5ejSdtUSzWRTN4lA.png" /></figure><p>However, I thought it would be really cool to visualise these changing over time in a video, so you could see how the day/night change affect things. I figured it would be a couple lines of code and a few minutes of work. Instead it took me about 6 hours, 231 lines of code and python and JavaScript to get it done over a few nights. The code is <a href="https://github.com/singe/wspr-pewpew">here</a> if you’d like. Here’s a video of the last two days of activity from my stations, neatly showing how day/night affects the propagation.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYJz_Zugs5nc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYJz_Zugs5nc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYJz_Zugs5nc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/259a23e3d2d0cd7d8b14368c528fcf88/href">https://medium.com/media/259a23e3d2d0cd7d8b14368c528fcf88/href</a></iframe><h3>But Why?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jOeVY5Pwlrur2C17z0WTuQ.png" /></figure><p><a href="http://www.arrl.org/files/file/Technology/pdf/119962.pdf">This three pager</a> from the American Amateur Radio League explains it better than most other references I’ve seen. Essentially, at night, the ionosphere thins, and starts reflecting 7MHz signals back to earth. This reflection can be anywhere between 2000–4000km (depending on the frequency of the signal and the state of the ionosphere at the time). The 17000km contacts are due to multiple bounces where it gets reflects back to earth, then bounces back to the ionosphere multiple times. This works particularly well over the Atlantic because the sea reflects better than say, the Sahara.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2cB1N8sllHwdCcIx-yTdA.png" /></figure><p>In a bit more detail, when radiation from space hits the ionosphere (a rough area covering 50–650km above sea level), it splits molecules into ions and electrons (ionisation). The biggest contributor of this is solar radiation (aka the sun). Higher up in the ionosphere has both thinner air and gets hit by more radiation, and so the molecules are split more aggressively and don’t recombine as easily as lower down. The lower down layer (<a href="https://en.wikipedia.org/wiki/Ionosphere#D_layer">D-layer</a>) attenuates our 7MHz signal as it’s more dense and so a lower frequency radio signal will cause the free electrons to vibrate and collide with lots of nearby molecules. These collisions reduce the power of the signal. However, at night, the D-layer disappears as the sun’s radiation is no longer ionising that low down. This means our signals make it to the <a href="https://en.wikipedia.org/wiki/Ionosphere#E_layer">E</a> and <a href="https://en.wikipedia.org/wiki/Ionosphere#F_layer">F layers</a> of the ionosphere. There, the air is less dense, and so there are fewer collisions meaning our signal is less attenuated. The magic however, is that the free electrons in these layers, tend to re-radiate signals coming into them (no idea why, I’d love an explanation). As the electron density is higher the higher you go (more space radiation) the signal is “repelled” the higher it goes. This means the signal is effectively “bent” back to earth (refracted/reflected) at night.</p><h3>The End</h3><p>If you made it this far, well done and thanks for listening to my physics experiment. Radio is magic! If this excited you, let me know and I’ll help you through your <a href="http://www.sarl.org.za/public/licences/rae.asp">Radio Amateur Exams</a> so you can get licensed and come play too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93f64578b0df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improvements in Rogue AP attacks — MANA]]></title>
            <link>https://medium.com/@notsinge/improvements-in-rogue-ap-attacks-mana-6f2b45a82f3a?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f2b45a82f3a</guid>
            <category><![CDATA[wifi]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Sun, 17 Dec 2017 19:15:38 GMT</pubDate>
            <atom:updated>2017-12-17T19:15:38.854Z</atom:updated>
            <content:encoded><![CDATA[<h4>At Defcon 22 we presented several improvements in wifi rogue access point attacks. We entitled the talk “Manna from heaven” and released the MANA toolkit. I’ll be doing two blog entries. The first will describe the improvements made at a wifi layer, and the second will cover the network credential interception stuff. If you just want the goodies, you can get them at the end of this entry for the price of scrolling down.</h4><p><strong>Introduction</strong></p><p>This work is about rogue access points, by which we mean a wireless access point that mimics real ones in an attempt to get users to connect to it. The initial work on this was done in <a href="http://www.wirelessdefence.org/Contents/KARMAMain.htm">2004 by Dino dai Zovi and Shaun Macaulay</a>. They realised that the way wifi devices probe for wireless networks that they’ve “remembered” happens without authentication, and that if a malicious access point merely responds to these directed probes, it can trick wireless clients into connecting to it. They called this a KARMA attack.</p><p>Additionally, <a href="http://www.willhackforsushi.com/?page_id=37">Josh Wright and Brad Antoniewicz in 2008</a> worked out that if you man in the middle the EAP authentication on secured networks, you could crack that hash and gain access to the network yourself. They implemented this in freeradius-wpe (wireless pwnage edition).</p><p>However, KARMA attacks no longer work well, and we wanted to know why. Also, the WPE stuff seemed ripe for use in rogue access points rather than just for gaining access to the original network. This is what we implemented.</p><p><strong>Changes in Probing</strong></p><p>After a significant amount of time poring over radio captures of the ways in which various devices probed, and informed by our previous work on <a href="https://github.com/sensepost/snoopy-ng">Snoopy</a>, we realised two things. The first is that modern devices, particularly mobile ones, won’t listen to directed probe responses for open, non-hidden networks if that AP didn’t also/first respond to a broadcast probe. What this means is that our rogue access point needs to implement the same. However, the challenge is, what do we respond to the broadcast probe *with*?</p><p>To overcome that, we took the existing <a href="http://digi.ninja/karma/">KARMA functionality built by Digininja</a>, ported it to the latest version of hostapd and extended it to store a view of the “remembered networks” (aka the Preferred Network List (PNL)) for each device it sees. Then when hostapd-mana sees a broadcast probe from that device, it will respond with a directed probe response for each network hostapd-mana knows to be in that device’s PNL. This is based on our finding, that wifi clients don’t have a problem with a single BSSID (i.e. AP MAC address) to have several ESSIDs (aka SSID aka network name).</p><p>Practically, suppose there are two devices, one probing for a network foo, and the other probing for two networks bar and baz. When device1 sends a broadcast probe, hostapd-mana will respond with a directed probe response for foo to device1. Likewise when device2 sends a broadcast probe, hostapd-mana will respond with two directed probe responses to device 2, one for bar and one for baz. In addition, the “normal” KARMA functionality of responding to directed probes will also occur. Practically, we found this significantly improved the effectiveness of our rogue AP.</p><p><strong>iOS and hidden networks</strong></p><p>iOS presented an interesting challenge to us when it came to hidden networks. A hidden network is one configured not to broadcast its ESSID in either its beacons or broadcast probe response. Practically, the only way a client device can know if the hidden network it has remembered is nearby is by constantly sending out directed probes for the network. This is why hidden networks aren’t a very good design, as their clients need to spew their names out all over the place. However, when observing iOS devices, while they could join a hidden network just fine, they seemed to not probe for it most of the time. This had us constructing faraday cages, checking other factors like BSSID and geolocation to no avail. Until we realised that iOS will not probe for any hidden networks in its PNL, unless there is at least one hidden network nearby. So, if you’d like to maximise your rogue’ing, make sure you have a hidden network nearby. It doesn’t even need to be a real network; use a mifi, use airbase-ng or just create another hostapd network.</p><p><strong>Limits in probing</strong></p><p>Modern mobile devices probe for networks on their PNL *significantly* less than laptops or older devices do. In an ideal world, manufacturers would change the implementation to never probe for open network, and only wait for a response to a broadcast, effectively limiting these attacks to requiring pre-knowledge, common networks or being performed in the vicinity of the actual network. Actually, <a href="http://w1.fi/cgit/hostap/commit/?id=4ed3492206097c24aa37b4429938fec049ba1827">a patch was pushed to wpa_supplicant</a> to limit the stupid probing behaviour Android does in low power mode a few months ago, this will make it into Android proper sometime soon. Also, iOS has significantly reduced how often it probes.</p><p>There are two ways to work around this. The first is manual; go for a common network. The rise of city-wide wifi projects makes this somewhat easy. Or if you’re going for a corporate network, just do some recon and name one of your access points after that. But, we wanted to make things work better than that. The default behaviour of hostapd-mana is to build up a view of each devices PNL and only respond to broadcasts with networks specific to that device. However, we can remove that limitation and build a global PNL, and respond to each broadcast with every network every device has probed for. We call this loud mode, and it’s configurable in the hostapd-mana config. This relies on the fact that many devices, particularly laptops and older mobile devices still probe for networks a lot. It also relies on the fact that many devices have networks in common (have they been in the same city, same airport, same conference, same company, same pocket etc.). This works *very* well in less crowded areas, and you’ll get a much higher number of devices connecting.</p><p>However, in busy areas, or if your antenna is large enough, you’ll quickly exceed the capacity for your average wifi device to respond fast enough to all of the devices, and as the number of response probes grows exponentially with each new device, even in quiet areas over time, this problem crops up (but didn’t on stage at Defcon miraculously). So, it’s *good enough* for now, but needs an in-kernel or in-firmware implementation with some network ageing to scale a bit better (one of the many opportunities for extending this work if you’re up for some open source contribution).</p><p><strong>Auto Crack ‘n Add</strong></p><p>freeradius-wpe is great, it provides a nice way to grab EAP hashes for clients that don’t validate certificates presented via EAP’s that implement SSL (PEAP, EAP-GTC, PEAL-TTLS). However, the patches are for freeradius v1 and, much like the KARMA patches for hostapd, have aged. But, hostapd contains a radius server, and so we could port the freeradius-wpe work to that, something we based off some initial but incomplete patches by Brad Antoniewicz. So hostapd-mana will also let you grab EAP hashes without needing another tool.</p><p>However, the KARMA attacks only work against open wifi networks. EAP networks are increasingly common (especially corporate ones) and we wanted to be able to have a go at getting devices probing for those to connect to our rogue AP. To do this, we modified hostapd-mana to always accept any EAP hash, but send it off for cracking. It simply writes these to a file, from which the simple python tool crackapd (included) will grab it and send it off to another process for cracking. Currently, we use asleap (also by Josh) and the rockyou password list, but these can all be easily modified. For example, to use <a href="https://www.cloudcracker.com/">CloudCracker</a> and its incredibly optimised MS-CHAPv2 cracking setup.</p><p>The net result is pretty great for simple EAP hashes. The device will try and connect, and fail as we don’t know enough to do the challenge response right. But after the hash is cracked, when it retries to connect (something a device will keep doing) it will succeed (and you’ll have your first creds). For simple hashes, this is transparent to the user. Of course, very complex hashes will only work if you crack them in time. Worst case scenario, you leave with hashes.</p><p><strong>Conclusion</strong></p><p>So that’s what we built into hostapd-mana. You get improved KARMA attacks, a modern hostapd version, an integrated hash stealer, and the possibility of rogue’ing some EAP networks. You can get the full toolkit at <a href="https://github.com/sensepost/mana">MANA toolkit on GitHub</a> or our hostapd-mana at <a href="https://github.com/sensepost/hostapd-mana">hostapd-mana on GitHub</a>.</p><p>The next blog entry will cover what we did once we got a device to connect.</p><p><strong>The Goodies</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fi2-jReLBSVk%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Di2-jReLBSVk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fi2-jReLBSVk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ad69a72357ed861d84c6c275c762065/href">https://medium.com/media/3ad69a72357ed861d84c6c275c762065/href</a></iframe><p>The supporting slide deck with more information:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2FbslgPyXynFyr5t&amp;url=https%3A%2F%2Fwww.slideshare.net%2Fsensepost%2Fimprovement-in-rogue-access-points-sensepost-defcon-22&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fdc22-mana-supporting-150223014609-conversion-gate02-thumbnail-4.jpg%3Fcb%3D1424677678&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/52b22b22a58208a9b89ebbcd2a532e96/href">https://medium.com/media/52b22b22a58208a9b89ebbcd2a532e96/href</a></iframe><p>The final toolkit: <a href="https://github.com/sensepost/mana">MANA toolkit on GitHub</a> You can also get this on Kali with “apt-get install mana-toolkit”</p><p>The modified hostapd (for hackers or people who want to build their own setup): <a href="https://github.com/sensepost/hostapd-mana">hostapd-mana on GitHub</a></p><p><em>Originally published at </em><a href="https://sensepost.com/blog/2015/improvements-in-rogue-ap-attacks-mana-1%2F2/"><em>sensepost.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f2b45a82f3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A quick view on IBM’s approach to mainframe security disclosures]]></title>
            <link>https://medium.com/@notsinge/a-quick-view-on-ibms-approach-to-mainframe-security-disclosures-8776ea464ef3?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8776ea464ef3</guid>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Sun, 17 Dec 2017 19:14:59 GMT</pubDate>
            <atom:updated>2017-12-17T19:14:59.007Z</atom:updated>
            <content:encoded><![CDATA[<p>At DerbyCon I made a point about IBM’s security response procedures. It’s a complex and subtle issue that won’t carry well over Twitter. Here’s my quick attempt at clarifying my personal view, hurriedly typed on a phone before I catch a flight.</p><p>IBM responded quickly and proactively to seeing the original HITB abstract (they contacted me). They asked smart questions and got a patch out for NVAS quickly. It was a somewhat uncomfortable conversation, over email only, as I believe their legal team “contributed” to each mail. However, the patch and knowledge of the issue is only available to active NVAS customers (not wider System Z customers) and no fixes exist for the wider issue. IBM take a stance of not publicizing new vulnerabilities beyond a need to know group. There’s some merit to this and it clearly limits the sorts of public scrutiny and tool development other applications see (there are nearly no Metasploit modules for System Z despite its long life and critical use within its install base for eg). However, within 45 mins of hypothesizing it, I was able to find and implement tools to exploit a family of vulnerabilities within the 30yr old TN3270 protocol, that likely affects nearly every app exposed via that protocol. This includes apps run in CICS, IMS, REXX etc. That’s pretty significant, and there’s no patch for it (that I can see or IBM can point customers to at the time of publication) beyond fixing each vulnerable app individually. I’m pretty confident that nearly no one, as a tourist to Windows or Facebook systems (for eg), would achieve anything so damaging in the same timeframe against those systems. Especially not critical protocols that had been in use for over 30 years. So what’s the difference? My belief is that it’s the approach; by discouraging a wider understanding of security issues and inhibiting offensive innovation within mainframes, IBM has landed themselves in the situation where enterprise mainframe apps are more vulnerable than their web app counterparts. Other apps have been exposed to full disclosure and used those issues to direct security teams. Note, the subtly here is not that IBM doesn’t have smart security people, but rather that they may not have had their focus sharpened by external research in the way someone like Microsoft did. This approach seems to be the best we have at the moment, characterized by the movement towards bug bounties. As a final point, IBM may have listened to their customers on security up till now. But it’s been at the expense of ignoring security researchers. It may come to a point soon where they need to take a smart stance, even if it’s in opposition to customers, to enhance the security of their platform.</p><p><em>Originally published at </em><a href="https://singe.za.net/blog/archives/1062-A-quick-view-on-IBMs-approach-to-mainframe-security-disclosures.html"><em>singe.za.net</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8776ea464ef3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Admission of illegally obtained evidence in ZA courts; hacked FB messages]]></title>
            <link>https://medium.com/@notsinge/admission-of-illegally-obtained-evidence-in-za-courts-hacked-fb-messages-fca6974199ac?source=rss-8c24fecf2d1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fca6974199ac</guid>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Dominic White]]></dc:creator>
            <pubDate>Sun, 17 Dec 2017 19:09:32 GMT</pubDate>
            <atom:updated>2017-12-17T19:09:32.914Z</atom:updated>
            <content:encoded><![CDATA[<h4>Since it was a pretty attention grabbing headline, I sought out the <a href="http://www.saflii.org/za/cases/ZAECGHC/2015/149.html">full text of the judgement</a> to understand the, usually carefully considered and well reasoned results.</h4><p>The heart of the case is about whether Niland had acted in opposition to his fiduciary duties to the CC he remained attached to, and the Facebook messages were used to show he had violated this. I’m going to ignore this and focus on the part relevant to infosec, privsec and citizens; can someone hack you and use that as evidence in a case?</p><p>Sections [13]-[16] of the judgement provide the details of what happened; an employee at Harvey’s organisation claimed to know Niland’s Facebook password. Harvey asked this employee to log in as Niland and check the private messages for evidence, which they did. The messages show Niland is guilty. Niland disputes that he had given his password, and claims he was hacked. No more technical details of how the messages were obtained was provided. If I had to guess, I suspect Niland left himself logged in to Facebook on one of the company machines, or had an easy to guess password (written on a post-it left under his keyboard?) or had in fact told the other employee a password to something else, and just re-used it.</p><p>Sections [38–53] of the judgement deal with the admissibility of the Facebook messages. Niland’s attorney argued that hacking the Facebook messages is a crime according to the Electronic Communications and Transactions Act 25 of 2002 (ECT Act) and should render the evidence inadmissible. Additionally, it was a violation of the constitutionally enshrined right to privacy [Section 14(d) of the Constitution of South Africa], which includes the right not to have the privacy of your communications infringed.</p><p>The judge cited much case law and established the following four high-level counters to the above:</p><p><strong>One</strong> The ECT act is silent on whether acts marked as criminal negate their output being used as evidence. A prior case relating to phone tapping was cited where the Interception and Monitoring Prohibition Act 127 of 1992 too was silent on whether evidence obtained by phone tap was inadmissible, despite declaring such tapping a criminal offence.</p><p>Interestingly, Niland’s attorney sought to separate the two cases by arguing that the ECT act is a “game changer”, the specifics of the argument are not disclosed, but the judge rejected the idea by citing the similarity in the two cases and acts as discussed above.</p><p><strong>Two</strong> Next, the judge cited a case describing the difference between a criminal and civil case. In a criminal case, the defendant has a right against self-incrimination, and doesn’t need to help the state’s case, however, in a civil case, the defendant is subject to discovery that includes information that may be harmful to their case. While the messages were not found in discovery (more on that later) their disclosure does fit the requirements of the civil case.</p><p><strong>Three</strong> The judge then tries to consider what rules he should operate under in further considering whether the evidence should be admissible. Here he cites a case where it was determined that the right to privacy “attenuates” the further away from “the home” (aka private life) one moves. In this case, the Facebook messages submitted were directly relevant to the business of Harvey and Niland, and messages related to Niland’s private life were excluded. Thus, the right to privacy may be lessened in this case.</p><p><strong>Four</strong> Lastly, the judge tries to determine whether there were other, legal, means of obtaining this data, and concludes that there weren’t. Harvey could have sued Niland for damages resulting from the suspected breach, and in doing so, would be entitled to discovery of the messages. I mentioned this above, in a civil case relevant information must be provided by the defendant, even if it hurts their case. This is why you often see internal e-mails from companies being cited in public court proceedings. If Harvey was worried that Niland would delete the messaged, he could ask for an “Anton Piller order. An “Anton Piller order” is a sort of surprise search warrant where the defendant is not informed. However, the judge believed that such a request would be dismissed as a fishing expedition since the messages are the basis of the case, without them the justification could not be made for such an order.</p><p>And so, the evidence was admitted, and Niland was found guilty of breaching his fiduciary duties.</p><p><strong>Analysis</strong></p><p>I think at this point, it should be clear, that information obtained about you via illegal hacks cannot arbitrarily be used against you and admissible in court. It should also be clear, that in a civil case, you may be subject to discovery that would require such information to be disclosed anyway. And even in criminal cases, where you aren’t required to disclose such information, it can still be obtained and used against you. <a href="https://twitter.com/singe/status/453089833205129216">For example</a>, in the Oscar Pistorius case, detailed information about his WhatsApp messages between him and others, including deeply personal messages to his deceased girlfriend Reeva Steenkamp, as well as call records and even movement based on cell towers his phone was communicating with were provided.</p><p>If you want to defend yourself, the easiest take-away is for you to regularly delete your private communications (WhatsApp, Facebook Messages, SMS, SnapChats, Twitter DMs, etc.) <strong>before</strong> they become relevant to a potential case.</p><p><strong>Meta-Analysis</strong></p><p>There are two things that I’d like to discuss in addition to this case. The first is the observation that we have a fantastic judiciary, with smart judges that apply their minds, and public records of such judgements are available. If you ever hear bombastic claims off the back of a case, it usually pays to read the actual judgement.</p><p>The second, relates to the proposed Cybercrime bill. The bill attempts to pick up from the ECT act, as well as implement parts of the National Cybersecurity Policy Framework. It’s first public draft received much negative attention about the privacy procedural implications of the bill. There’s a call to get more technical experts involved. The case law considerations from this case are exactly why tech experts should be very wary about doing so. While any act would, of course, require accurate technical descriptions and assumptions, the bulk of the act will be interpreted outside of such technicalities, in much the way the judge did in this. As such, the implications of wording in the act can have significant unforeseen consequences. In my mind, it is significantly more important for legal minds, familiar with how acts are read during proceedings, to provide input, supported by technical experts.</p><p><em>Originally published at </em><a href="https://singe.za.net/blog/archives/1063-Admission-of-illegally-obtained-evidence-in-ZA-courts;-hacked-FB-messages.html"><em>singe.za.net</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fca6974199ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>