Gremwell - Marvinhttps://www.gremwell.com/taxonomy/term/37
enTapping 802.1x Links with Marvinhttps://www.gremwell.com/marvin-mitm-tapping-dot1x-links
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>While testing fat clients and appliances for resistance against <a href="http://en.wikipedia.org/wiki/Man-in-the-middle_attack">man-in-the-middle attack</a> I always had to mess with iptables/ebtables/socat to divert network connections. It is enough in most cases, but sometimes the setup gets too elaborate. To make my life easier, I have decided to write a tool, capable to divert and re-inject a network connections while preserving the original network addresses, including layer 2 ones. The tool is not complete yet, but it already can be used to tap into a wired network protected with 802.1x, so I've decided to publish it anyway.</p>
<!--break--><p><u>Update 15/01/2011</u>: Initially the tool has been published under the name of Mallory, but it turned out there is a TCP/UDP mitm tool with this name, so I had to change the name to Marvin.</p>
<p><u>Update 27/01/2011</u>: New version of the tool, <b>Marvin 0.91, can be downloaded from <a href="/sites/default/files/marvin/marvin-0.91.tgz">here</a></b>. It supports connection interception and includes numerous GUI improvements. Unfortunately as of now it is not extensively tested nor documented. It should be reasonably straightforward though -- just click on 'Intercept' button in 'Conversations' table. If you have any questions or problems feel free to comment here.</p>
<h3>Intended Use</h3>
<p>I have to say upfront that Marvin has nothing to do with ARP poisoning or similar techniques. It will not impact any remote traffic flow. The assumption is that the pen-tester cuts the link and connect two cables to the host running Marvin. The diagram below illustrates the tapping:<br /><span class="inline inline-center"><a href="http://www.gremwell.com/sites/default/files/images/links-before-after-tapping.png" onclick="launch_popup(84, 1058, 794); return false;" target="_blank"><img src="http://www.gremwell.com/sites/default/files/images/links-before-after-tapping.png" alt="Links Before and After Tapping" title="Links Before and After Tapping" class="image image-_original " width="640" height="480" /></a></span></p>
<p>The tool will bridge the traffic between the first and the second interface and inject traffic it receives from the third interface into the first two. The pen-tester is expected to connect another host to the third network interface to enjoy ICMP/TCP/UDP connectivity to the bridged network. The source addresses of the injected frames/packets will be masqueraded (on IP and Ethernet levels), as configured by the user.</p>
<h3>Step 1. Install and Run</h3>
<p>The simplest way to run Marvin is on a box with three physical network interfaces. It must be Linux with Java JRE, and you must have root privileges there. The tool is self-contained, all libraries it needs are bundled with it.</p>
<p>The latest build can be downloaded from <a href="/sites/default/files/marvin/marvin-0.9.tgz">here</a>. The tarball contains a sample config file <a href="/sites/default/files/marvin/marvin.properties">marvin.properties</a>, and a script called marvin.sh which should be used to launch the tool.</p>
<p>Marvin uses JPcap (wrapper around libpcap) to receive and send Ethernet frames, so you have to run it as root. Run it with '-t' option to disable GUI, add '-d' option to increase the logging level, set '-l marvin.log' to redirect all logging output into a file. Use '-f configfile' to specify path to a config file explicitly (marvin.properties from the same directory as marvin.sh is the default choice).</p>
<p>I will assume you wire the first interface (eth1) to the legitimate client, the second (eth2) -- to the switch, and the third (eth3) -- to the tap client. (Alternatively you can also run Marvin in VM and use host OS as tap client. This way you will need only one computer with two physical network interfaces. I can write the instructions for this use case if someone is interested).</p>
<p>The configuration file bundled with the tool is relevant to my testbed only. Unless you have very similar setup, you will have to reconfigure to fit your environment before it does anything useful. You can do it by manually editing the config file or via GUI.</p>
<p>Just as an example, the IP addressing scheme of my testbed (which corresponds to the default config bundled with Marvin) looks like following:<br /><span class="inline inline-center"><a href="http://www.gremwell.com/sites/default/files/images/ip-before-after-tapping.png" onclick="launch_popup(85, 1058, 794); return false;" target="_blank"><img src="http://www.gremwell.com/sites/default/files/images/ip-before-after-tapping.png" alt="Marvin ip-before-after-tapping.png" title="Marvin ip-before-after-tapping.png" class="image image-_original " width="640" height="480" /></a></span></p>
<h3>Step 2: Make Bridging Work</h3>
<p>On startup Marvin reads the config and, if the config was correct, starts working right away. Unless you run Marvin with '-t' flag, the following GUI will appear:<br /><span class="inline inline-center"><a href="http://www.gremwell.com/sites/default/files/images/main-screen.png" onclick="launch_popup(86, 701, 521); return false;" target="_blank"><img src="http://www.gremwell.com/sites/default/files/images/main-screen.png" alt="Marvin main-screen.png" title="Marvin main-screen.png" class="image image-_original " width="701" height="521" /></a></span><br />
There you can change any parameter in runtime and click 'Apply' button.</p>
<p>At the very minimum you have to select the interfaces Marvin will send and receive network traffic. For example:</p>
<ul><li>Set br1if.interface parameter to the interface name facing the client (eth1)
</li><li>Set br2if.interface parameter to the interface name facing the switch (eth2)
</li><li>Set tapif.interface parameter to the interface name facing the tap client (eth3)
</li></ul><p>Now the bridge between eth1 and eth2 is active, all traffic being forwarded transparently. The legitimate 802.1x client should be able to authenticate towards the network and have network access as usual. </p>
<h3>Step 3. Configure Tap Interface and Masquerading</h3>
<p>Now let's finish off the config file and set parameters necessary for tap clients to access the bridged network. If you use GUI, you can click on 'Select ...' button to access the list of suitable candidates to use for masquerading addresses. For the first interface Marvin will suggest to use stations connected to the second interface, and visa versa. The list of candidates may appear empty if Marvin has not seen any ARP messages yet.</p>
<p>The following parameters have to be set, via GUI or in the config filie:</p>
<ul><li> MAC and IP address of the legitimate client. Marvin will use it to masquerade the tap client when it accesses the network. Set br2if.smac and br2if.saddr accordingly.
</li><li> MAC and IP address of some host on the network (i.e. default gateway). Marvin will use it to masquerade the tap client when it accesses the legitimate client. Default gateway seems to be an adequate choice here, but it can be absolutely anything as long as the legitimate client swallows it. Set br1if.smac and br1if.saddr accordingly.
</li><li> IP address of the default gateway and the netmask. Have a look at the content of DHCP Offer message, if any. Marvin needs this information to route traffic to non-directly connected hosts. Set br.netmask and br.gateway accordingly.
</li></ul><p>Now, connect you tap client host to the third interface and restart Marvin (or apply the config). If you haven't modified the default values, set tap client to use 10.0.1.2 as IP address, 255.255.255.252 as netmask, and 10.0.1.1 as default gateway. Try to ping the hosts on the bridged link, it should work.</p>
<h3>Information About the Relayed Connections</h3>
<p>Marvin GUI has several tabs which contain information about ARP/ICMP/TCP/UDP flows and conversations it relays/translates (a conversation is a pair of unidirectional flows). You can peek there for troubleshooting purposes, but under high load you can experience inconsistency in the displayed information. I don't have documentation for these screens yet, only a screenshot of Marvin masquerading TAP client traffic. Here tap client (10.0.1.2) is pinging the legitimate client (172.16.208.148). Marvin translates the source IP address of a tap client (10.0.1.2) into IP address of the default gateway (172.16.208.2). MAC addresses get translated too, but you can't see it on this screen.<br /><span class="inline inline-center"><a href="http://www.gremwell.com/sites/default/files/images/tap-source-ip-masq.png" onclick="launch_popup(87, 786, 242); return false;" target="_blank"><img src="http://www.gremwell.com/sites/default/files/images/tap-source-ip-masq.png" alt="" title="" class="image image-_original " width="640" height="213" /></a></span></p>
<h3>Performance</h3>
<p>The performance is not bad at all. Marvin is multi-thraded and will benefit from multi-core CPUs. It can certainly handle nmap SYN scan in normal mode, but will die soon if you try to run nmap at wire speed (-T insane). Obviously, it has to keep connection states for every TCP SYN and expire them. If you have hundreds thousands of active connections these tasks will start to take quite a bit of memory and CPU. Running in VM with two CPUs and relaying a SYN scan, it will let nmap go up to 3kpps.</p>
<h3>Additional Information</h3>
<p>I know the explanations could be more clear, I will certainly write better docs in the future. If you have any problems or questions, just post a comment here and I will reply. Again, the download is <a href="/sites/default/files/marvin/marvin-0.9.tgz">here</a>.</p>
<p>For now the project is closed source. More likely than not 1.0 release will be open source under GNU or Apache License.</p>
<p>There is a couple of PDF documents which may shed some light on how the tool is working. These <a href="/sites/default/files/marvin/intro.pdf">slides</a> contain more less the same info as this post. This <a href="/sites/default/files/marvin/piggybacking.pdf">table</a> explains the packet manipulation process in some more details.</p>
<p>The following features will be added in the future (higher priority first):</p>
<ul><li>Make a better package
</li><li><s>Fix stats display inconsistencies</s> (done in 0.91)
</li><li>NAPT (now ports are not translated)
</li><li>Enqueue IP packets pending ARP resolution (now they are dropped)
</li><li><s>Connection interception rules</s> (done in 0.91)
</li><li>Automatically prepare connection re-injection rules
</li><li>Save the config, retain the interception rules between restarts
</li><li>802.1q
</li><li>Full ICMP support (now only ICMP echo is supported)
</li><li>Move to JNetPcap
</li><li>IP packet reassembly (now fragmented packets are dropped)
</li><li>ARP entry expiration (now learned IP-MAC resolution remains forever)
</li></ul></div></div></div><div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/taxonomy/term/37">Marvin</a></div><div class="field-item odd"><a href="/taxonomy/term/38">tool</a></div><div class="field-item even"><a href="/taxonomy/term/40">mitm</a></div><div class="field-item odd"><a href="/taxonomy/term/41">802.1x</a></div><div class="field-item even"><a href="/taxonomy/term/107">pentest</a></div></div></div>Sat, 15 Jan 2011 03:35:27 +0000abb83 at https://www.gremwell.comhttps://www.gremwell.com/marvin-mitm-tapping-dot1x-links#comments