<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-9163961975500012189</atom:id><lastBuildDate>Mon, 27 May 2019 08:25:15 +0000</lastBuildDate><category>Delorean</category><category>MitM</category><category>Tools</category><category>NTP</category><category>DEFCON</category><category>WebSecurity</category><category>Windows</category><category>BlackHat</category><category>BrowserSecurity</category><category>Hibernation</category><category>Linux</category><category>MacOSX</category><category>Mimikatz</category><category>PentesterEs</category><category>SANS</category><category>SQLi</category><category>Volatility</category><category>bsides</category><category>crypto</category><category>ctf</category><category>php</category><title>Pentester.es (EN)</title><description>Information Systems Security</description><link>http://www.en.pentester.es/</link><managingEditor>noreply@blogger.com (Jose Selvi)</managingEditor><generator>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-7110821079957881596</guid><pubDate>Tue, 14 Nov 2017 08:00:00 +0000</pubDate><atom:updated>2017-11-14T09:27:01.010+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bsides</category><category domain="http://www.blogger.com/atom/ns#">crypto</category><category domain="http://www.blogger.com/atom/ns#">ctf</category><category domain="http://www.blogger.com/atom/ns#">php</category><title>Undo Five/Nine (Crypto 300, Lisbon CTF)</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Last week I had the opportunity to participate in the on-site Bsides Lisbon CTF. I teamed up with some workmates and we tried to solve some of the challenges.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;One of the challenges I was working on was &quot;Crypto 300: Undo Five/Nine&quot;. I didn&#39;t take notes on the description, but basically they gave a piece of PHP code &quot;&lt;i&gt;snip.php&lt;/i&gt;&quot; and two other files: &quot;&lt;i&gt;readme.txt&lt;/i&gt;&quot; and &quot;&lt;i&gt;readme.txt.fsociety&lt;/i&gt;&quot;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A quick look at &quot;&lt;i&gt;snip.php&lt;/i&gt;&quot; helps us to understand how the other two files were used or generated:&lt;/div&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$crypted = fopen($file . &quot;.fsociety&quot;, &quot;w&quot;);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$fp = fopen($file, &quot;r+&quot;);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$clear = fread($fp, 2048);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;// destroy original file&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;destroy_file($fp,strlen($clear));&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;// generate unique key&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$key = gen_aes_key();&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$aes = new Crypt_AES(CRYPT_AES_MODE_ECB);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$aes-&amp;gt;setKeyLength(128);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$aes-&amp;gt;setKey($key);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;// create encrypted file&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$clear = $aes-&amp;gt;encrypt($clear);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;fwrite($crypted,$clear,strlen($clear));&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;As we can see, it seems this PHP script read a plaintext secret from &quot;&lt;i&gt;readme.txt&lt;/i&gt;&quot; and destroys it somehow. Then an encryption key is generated and the plaintext is encrypted using AES-128 in ECB mode. The encrypted secret is then stored in &quot;&lt;i&gt;readme.txt.fsociety&lt;/i&gt;&quot;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;So it seems we should be able to recover that encrypted message somehow. Since key is not stored, it was obvious that we were facing some kind of weakness in that key generation. Let&#39;s have a look:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;function gen_aes_key() {&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp;$key = &quot;&quot;;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp;for ($i = 0;$i &amp;lt; 16;$i++)&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; &lt;b&gt;&amp;nbsp;$key.= chr(mt_rand(0, 255));&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp;return $key;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Well, that makes sense. &quot;&lt;a href=&quot;http://php.net/manual/en/function.mt-rand.php&quot; target=&quot;_blank&quot;&gt;mt_rand&lt;/a&gt;&quot; function generates a random value via the Mersenne Twister Random Number Generator. This function, as its documentation warns, is not secure for cryptographic purposes. I googled for a while, and I found &lt;a href=&quot;http://www.openwall.com/php_mt_seed/&quot; target=&quot;_blank&quot;&gt;more information about this issue&lt;/a&gt;, where we can find the following information:&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&quot;Common misuses of mt_rand() include generation of anti-CSRF tokens, custom session tokens (not relying on PHP&#39;s builtin sessions support, which uses a different PRNG yet was also vulnerable until recently), password reset tokens, passwords, database backup filenames, etc. If one of these items is exposed and another is generated later without the web application or server reseeding the PRNG, then an attack is possible where the seed is cracked from the item generated earlier and is then used to infer the unknown item generated later.&quot;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;It seems we should have at least another call to &quot;&lt;i&gt;mt_rand&lt;/i&gt;&quot; and to have access to its results in order to be able to exploit this issue, but we only have an encrypted message, and a destroyed file. Let&#39;s have a look to the piece of code that destroys that file:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;function destroy_file($fp,$len) {&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; $random = &quot;&quot;;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; for ($i = 0;$i &amp;lt; $len;$i++)&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; $random.= chr(mt_rand(0, 255));&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; fseek($fp, 0);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; fwrite($fp, substr($random, 0, $len));&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; fclose($fp);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Bingo! It was overwritten using &quot;random&quot; values generates with the same function, which means that if we can obtain the seed, we could regenerate all the stream and grab the encryption key.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Let&#39;s do it! I was reading the &lt;a href=&quot;http://www.openwall.com/php_mt_seed/&quot; target=&quot;_blank&quot;&gt;seed cracker&lt;/a&gt; documentation for a while. It wasn&#39;t as easy as I initially thought, since this tool has several modes of operation, but I finally understood that the proper syntax was as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$&amp;nbsp;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;./php_mt_seed [first_num] [first_num] 0 255 [second_num] [second_num] 0 255 ...&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But I had a bunch of bytes, so I decided to generate it using a few lines of PHP code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$fp = fopen(&quot;readme.txt&quot;, &quot;r+&quot;);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$clear = str_split( fread($fp, 2048) );&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;foreach ($clear as $v) {&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; &amp;nbsp; echo ord($v) . &#39; &#39; . ord($v) . &quot; 0 255 &quot;;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This code generated of the parameter that I needed. In a minute or two, I got an answer: &quot;&lt;b&gt;844114388&lt;/b&gt;&quot;. Now we need to regenerate all the stream based on this seed. Let&#39;s go back to a piece of PHP code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;mt_srand(844114388);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;for ($i = 0;$i &amp;lt; 64;$i++)&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; &amp;nbsp; echo chr(mt_rand(0, 255));&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;When we generate this stream, we will see a number of bytes that should be the same to the information we can found in &quot;readme.txt&quot;. After those bytes, we should have the encryption key (16 bytes).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$ php gen.php &amp;nbsp;| xxd&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;00000000: 7b36 0ee9 f9b9 1cfe d0bb d0e6 1311 5828 &amp;nbsp;{6............X(&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;00000010: fcfe 84a6 7453 03f6 85b6 e270 76c3 41f8 &amp;nbsp;....tS.....pv.A.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;00000020: aec4 9ca5 &lt;b&gt;f658 dda4 20f2 1c9f 5d14 b5b1&lt;/b&gt; &amp;nbsp;.....X.. ...]...&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;00000030: &lt;b&gt;beb5 1669&lt;/b&gt; 3135 31f9 30bc 9438 d0ac d0d6 &amp;nbsp;...i151.0..8....&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So let&#39;s see if we can decrypt the file:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;$ openssl enc -aes-128-ecb -d -K &quot;f658dda420f21c9f5d14b5b1beb51669&quot; -in readme.txt.fsociety&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style=&quot;margin-left: 2em;&quot;&gt;flag{the_darkarmy_is_now_on_to_you}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Bang! We got it! Unfortunately, I wasn&#39;t able to submit this flag. Why? First because, for some reason, I had in mind that &quot;snip.php&quot; was generating integers and then they were being truncated, so I spend around an hour reading the tool and trying to modify it. Second, because I got a syntax error on my code 10 seconds before CTF&#39;s deadline, so I wasn&#39;t able to fix it and to submit the flag. Anyway, I enjoyed the CTF :)&lt;/div&gt;&lt;/div&gt;</description><link>http://www.en.pentester.es/2017/11/undo-fivenine.html</link><author>noreply@blogger.com (Jose Selvi)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-6758497855438189260</guid><pubDate>Mon, 19 Dec 2016 08:30:00 +0000</pubDate><atom:updated>2016-12-19T09:30:03.830+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Hibernation</category><category domain="http://www.blogger.com/atom/ns#">Mimikatz</category><category domain="http://www.blogger.com/atom/ns#">Volatility</category><category domain="http://www.blogger.com/atom/ns#">Windows</category><title>Evil-Maid attacks with Hibernation</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;I have shared the speech I gave in the last RootedCon Valencia, about an &lt;a href=&quot;http://www.slideshare.net/rpinuaga/bad-hibernationrooted&quot;&gt;Evil-Maid attack technique exploiting Windows hibernation files&lt;/a&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;This technique is not new (and I didn&#39;t discover it for the first time), but it isn&#39;t very well documented.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;I have also written about this kind of attacks in &lt;a href=&quot;http://www.areopago21.org/2016/09/ataques-evil-maid_21.html&quot;&gt;Areopago21 blog&lt;/a&gt; (in Spanish).&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In this post I am going to focus on the hands-on part.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Summarizing: If we get physical access to a computer powered on (but locked) or in suspension. We can try to recover the critical volatile information (session identifiers, clear-text passwords, cryptographic keys, etc.) from the hibernation file.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In order to obtain the hibernation file, we need to extract it from the hard drive. We could boot the computer from an external device (forensic Linux distro, Hirens bootcd, etc.) or we could take out the hard drive from the computer. If the hard drive is encrypted, it gets more complicated.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;This file is in the root of the drive: c:\hiberfyl.sys. Even for Windows, this file is hidden by default and it is locked, so we can’t read it.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The hibernation file is never deleted, only its headers are modified when it is used for rebooting. This way, if the computer has been hibernated at any time in the past, we will have this file. If not, we need to force an hibernation.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;This is possible even if the computer is locked, if the user has activated the hibernation option:&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-jO_yXte8QC4/WFazMMNKFjI/AAAAAAAAANc/jHn1dELvpAwBbxV_PH3ZAsUPaopZy0JhwCLcB/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;321&quot; src=&quot;https://3.bp.blogspot.com/-jO_yXte8QC4/WFazMMNKFjI/AAAAAAAAANc/jHn1dELvpAwBbxV_PH3ZAsUPaopZy0JhwCLcB/s400/1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Unfortunately, starting from Windows 7, the hibernation feature is disabled by default. Although some laptop manufactures enable it.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;However, there is a way to force hibernation. If the battery reaches critical level, the computer is hibernated automatically. This is configured by default in all Windows version up to Windows 10.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-sujw-Utrsm4/WFazMVJBa8I/AAAAAAAAANg/edVcMPf1jbgLKMM-FOMV9fz-0s1FvKeewCEw/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://3.bp.blogspot.com/-sujw-Utrsm4/WFazMVJBa8I/AAAAAAAAANg/edVcMPf1jbgLKMM-FOMV9fz-0s1FvKeewCEw/s400/2.png&quot; width=&quot;361&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Once we have the hibernation file, we can work with it:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The basic tool for the task is Volatility; with it we can do the following things:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Obtaining information about the hibernation file: vol.exe hibinfo -f hiberfil.sys &lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Convert it to raw format: vol.exe imagecopy -f hiberfil.sys -O hiberfil.bin&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Convert it to DMP format (Windbg compatible): vol.exe raw2dmp -f hiberfil.sys -O hiberfil.dmp&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Obtaining the browsing history: vol.exe iehistory -f hiberfil.sys&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Obtaining local password hashes: vol.exe hashdump -f hiberfil.sys&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Obtaining Truecrypt cryptographic keys: vol.exe truecryptpassphrase -f hiberfil.sys&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Example of usage:&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-F5N4IhB8Lq4/WFazMRgGWOI/AAAAAAAAANk/k1nNUiAN2fQ6bodc58Tpyc50IHOM4MGtACEw/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;110&quot; src=&quot;https://2.bp.blogspot.com/-F5N4IhB8Lq4/WFazMRgGWOI/AAAAAAAAANk/k1nNUiAN2fQ6bodc58Tpyc50IHOM4MGtACEw/s400/3.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;We also have multiple &lt;a href=&quot;https://github.com/volatilityfoundation/community&quot;&gt;community plugins&lt;/a&gt; for other tasks: mimikatz, bitlocker, bitcoin, etc.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;For the conversion we can also use the &lt;a href=&quot;https://blog.comae.io/your-favorite-memory-toolkit-is-back-f97072d33d5c#.6ioe7f777&quot;&gt;tools from Matt Suiche&lt;/a&gt; (just released), previously known as MoonSols Windows Memory Toolkit. They work better than Volatility and they support Windows up to version 10.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Despite we have a Mimikatz plugin for Volatility, it is very limited so it’s better to work directly with Mimikatz. For that we have to:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Convert the hiberfil.sys file to a format compatible with Windbg (DMP):&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;vol.exe raw2dmp -f hiberfil.sys -O hiberfil.dmp –profile=Win7SP0x64&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Load the DMP into Windbg:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;.symfix =&amp;gt; Configures the Microsoft symbol repositories.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;.reload =&amp;gt; Reloads the needed symbols. &lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;.load wow64exts =&amp;gt; Loads the module for debugging WOW64 processes.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;!wow64exts.sw =&amp;gt; Activates WOW64 extensions.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;•&amp;nbsp;Load Mimikatz module in Windbg:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;.load c:\Users\rpinuaga\Desktop\bad-hibernation\demo\mimilib64.dll =&amp;gt; Loads the Mimikatz module.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;!process 0 0 lsass.exe =&amp;gt; Looks for the lsass process (Local Security Authority Subsystem Service).&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;.process /r /p fffffa800424e910 =&amp;gt; Configures the context to the lsass process.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; o&amp;nbsp;!mimikatz&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;And it’s done, here we have the results:&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-rM2k309S9tc/WFazMUJ3j1I/AAAAAAAAANo/kWfDuHGnLDsJfQMHgCoDtK_baivxpP11ACEw/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;367&quot; src=&quot;https://1.bp.blogspot.com/-rM2k309S9tc/WFazMUJ3j1I/AAAAAAAAANo/kWfDuHGnLDsJfQMHgCoDtK_baivxpP11ACEw/s400/4.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Note: Volatility only supports hibernation files from Windows up to version 7 (starting in Windows 8 the format changes a bit). The new tool from Matt Suiche in theory allows it, but last time I checked the file resulting from the conversion was not recognized by Volatility.&lt;/div&gt;</description><link>http://www.en.pentester.es/2016/12/evil-maid-attacks-with-hibernation.html</link><author>noreply@blogger.com (Ramon Pinuaga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://3.bp.blogspot.com/-jO_yXte8QC4/WFazMMNKFjI/AAAAAAAAANc/jHn1dELvpAwBbxV_PH3ZAsUPaopZy0JhwCLcB/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-1019153737703966059</guid><pubDate>Wed, 17 Feb 2016 07:00:00 +0000</pubDate><atom:updated>2016-02-17T08:04:42.576+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQLi</category><category domain="http://www.blogger.com/atom/ns#">WebSecurity</category><title>SQL LIKE clauses wildcard injection</title><description>I’m going to talk about a little known vulnerability and traditionally considered of low risk, although as we are going to see in some situations it can have a big impact.&lt;br /&gt;&lt;br /&gt;This vulnerability involves the possibility of injecting a wildcard in the search field of a LIKE clause in a SQL statement.&lt;br /&gt;&lt;br /&gt;OWASP covers briefly this kind of &lt;a href=&quot;https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet#Escaping_Wildcard_characters_in_Like_Clauses&quot;&gt;injections&lt;/a&gt; in its guides.&lt;br /&gt;&lt;br /&gt;In SQL we have 2 types of wildcards:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;% equivalent to any string of cero or more characters.&lt;/li&gt;&lt;li&gt;_ equivalent to any character.&lt;/li&gt;&lt;/ul&gt;An application is vulnerable to this attack when it uses the LIKE operator with a user received parameter not filtering any of these 2 wildcards.&lt;br /&gt;&lt;br /&gt;For example if we have the following URL:&lt;br /&gt;&lt;a href=&quot;http://www.example.com/fruit.php?name=apple&quot;&gt;http://www.example.com/fruit.php?name=apple&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;That shows a text extracted from the database with a SQL query like the following:&lt;br /&gt;&lt;a href=&quot;http://SELECT%20text%20FROM%20table%20WHERE%20fruit%20LIKE%20%E2%80%98$name%E2%80%99/&quot;&gt;SELECT text FROM table WHERE fruit LIKE ‘$name’&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Instead of using the simple form:&lt;br /&gt;&lt;a href=&quot;http://SELECT%20text%20FROM%20table%20WHERE%20fruit=%E2%80%98$name%E2%80%99/&quot;&gt;SELECT text FROM table WHERE fruit=‘$name’&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Even if the $name parameter is sanitized for avoiding SQL injection (for example filtering the single quote) it’s still possible to inject wildcards in the search field, as following:&lt;br /&gt;&lt;a href=&quot;http://www.example.com/fruit.php?name=ap%&quot;&gt;http://www.example.com/fruit.php?name=ap%&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In an application like this, altering the search logic it’s not critical, but what happens if we have another application like the following? (Where we don’t know the name of the users).&lt;br /&gt;&lt;a href=&quot;http://www.example.com/userphoto.php?name=john&quot;&gt;http://www.example.com/userphoto.php?name=john&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We can easily do the following and obtain a listing of all available users:&lt;br /&gt;&lt;a href=&quot;http://www.example.com/userphoto.php?name=a%&quot;&gt;http://www.example.com/userphoto.php?name=a%&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.example.com/userphoto.php?name=b%&quot;&gt;http://www.example.com/userphoto.php?name=b%&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.example.com/userphoto.php?name=c%&quot;&gt;http://www.example.com/userphoto.php?name=c%&lt;/a&gt;&lt;br /&gt;…&lt;br /&gt;&lt;br /&gt;We can automate the process with a simple script that will go pulling the names of each user character by character (like in the war games movie).&lt;br /&gt;&lt;br /&gt;In what situations this kind of vulnerabilities can be dangerous?&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;In login forms. I have found sometimes this vulnerability in the “username” field of some forms and less commonly even in the “password” field.&lt;/li&gt;&lt;li&gt;In password recovery forms. This vulnerability can allow us to reset the password of other users.&lt;/li&gt;&lt;li&gt;In fields containing session identifiers or tokens. This vulnerability can allow us to “steal” or “predict” the tokens or the sessions ids of other users.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;It’s incredible but this works sometimes:&lt;br /&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-9JpWIgk1pz8/VreFaqqDBAI/AAAAAAAAALE/Dsd9431sLR8/s1600/login.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://3.bp.blogspot.com/-9JpWIgk1pz8/VreFaqqDBAI/AAAAAAAAALE/Dsd9431sLR8/s1600/login.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;The injection of the % wildcard sometimes can be hard, because this character is usually filtered to avoid encoding attacks o precisely because it is wrongly decoded (in this case we can replace it by %25 or %2525).&lt;br /&gt;&lt;br /&gt;Some time ago I found a curious situation where an application authenticated users with a session identifier stored in a database. The extraction of the values stored was made with a vulnerable query, this way:&lt;br /&gt;&lt;a href=&quot;http://www.example.com/admin/private.php?sessionid=0123456789&quot;&gt;http://www.example.com/admin/private.php?sessionid=0123456789&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The server filtered the % wildcard, but the _ character was permitted. With the following trick we could exploit the vulnerability:&lt;br /&gt;&lt;a href=&quot;http://www.example.com/admin/privado.php?sessionid=__________&quot;&gt;http://www.example.com/admin/privado.php?sessionid=__________&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If we wanted to access a specific session, we only needed to do a sweep:&lt;br /&gt;&lt;a href=&quot;http://www.example.com/admin/privado.php?sessionid=0_________&quot;&gt;http://www.example.com/admin/privado.php?sessionid=0_________&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.example.com/admin/privado.php?sessionid=1_________&quot;&gt;http://www.example.com/admin/privado.php?sessionid=1_________&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.example.com/admin/privado.php?sessionid=2_________&quot;&gt;http://www.example.com/admin/privado.php?sessionid=2_________&lt;/a&gt;&lt;br /&gt;…&lt;br /&gt;&lt;br /&gt;Why some programmers fall with this evident bug?&lt;br /&gt;&lt;br /&gt;I suppose that sometimes it’s only an oversight, but I have detected that some programming frameworks encapsulate the SQL statements transparently for the programmer but internally they use the LIKE operator, without him even knowing.&lt;br /&gt;&lt;br /&gt;For example the following Django sentence:&lt;br /&gt;&lt;a href=&quot;http://result%3dentry.objects.get%28headline__contains%3d%27lennon%27%29/&quot;&gt;result=Entry.objects.get(headline__contains=&#39;Lennon&#39;)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Results in:&lt;br /&gt;&lt;a href=&quot;http://select%20...%20where%20headline%20like%20%27%25lennon%25%27/&quot;&gt;SELECT ... WHERE headline LIKE &#39;%Lennon%&#39;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This can easily lead to multiple vulnerabilities if the developer is not careful.&lt;br /&gt;&lt;br /&gt;Also this other &lt;a href=&quot;https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1688&quot;&gt;bug&lt;/a&gt; very similar in the Propel module of Symfony.</description><link>http://www.en.pentester.es/2016/02/like-sqli.html</link><author>noreply@blogger.com (Ramon Pinuaga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://3.bp.blogspot.com/-9JpWIgk1pz8/VreFaqqDBAI/AAAAAAAAALE/Dsd9431sLR8/s72-c/login.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-8288348608376780359</guid><pubDate>Tue, 26 Jan 2016 08:00:00 +0000</pubDate><atom:updated>2016-01-26T09:00:06.521+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DEFCON</category><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">NTP</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>Helper tools for Delorean</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Have a look to other posts of this serie:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-microsoft.html&quot; target=&quot;_blank&quot;&gt;[4] Microsoft Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/11/ntp-hsts.html&quot; target=&quot;_blank&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/11/ntp-pki.html&quot; target=&quot;_blank&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/a&gt;&lt;/div&gt;&lt;a href=&quot;http://www.en.pentester.es/2016/01/ntp-other-attacks.html&quot; target=&quot;_blank&quot;&gt;[7] Other Attacks&lt;/a&gt;&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;Disclaimer: All this information has been obtained from  empirical tests and in a specific period of time, so they could have  changed.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;We are finally in the last post of this serie about Deloran. At this point, I have talked about the attacks that were tested, about the tool and many other things. However, if you pay attention to the &lt;a href=&quot;https://github.com/pentesteres/delorean&quot; target=&quot;_blank&quot;&gt;Delorean repository&lt;/a&gt;, you will see that there are &amp;nbsp;couple of additional python scripts there. They are small tools that I created as a helper tools, because I needed a feature but I didn&#39;t make sense to integrate it with Delorean, so I keep them as separate tools.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The first one is &lt;a href=&quot;https://github.com/PentesterES/Delorean/blob/master/hsts_catcher.py&quot; target=&quot;_blank&quot;&gt;hsts_catcher.py&lt;/a&gt; which is a simple tools that just connects to a website an returns its HSTS configuration. Nothing that you couldn&#39;t do with curl and grep:&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;$ &lt;b&gt;./hsts_catcher.py -U https://accounts.google.com -A &quot;Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)&quot;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;max-age=10893354; includeSubDomains&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The second tools is &lt;a href=&quot;https://github.com/PentesterES/Delorean/blob/master/crl_checker.py&quot; target=&quot;_blank&quot;&gt;crl_checker.py&lt;/a&gt; which is much cooler than hits_catcher.py. When I was looking for certificates that I could use, I faced a big problem: Some certificates that I found had issues in their certificate chain, for example it root CA was expired or similar problems. Unfortunately, checking all possible issues is &lt;strike&gt;a pain in the ass&lt;/strike&gt; a manual process that can take valuable time, so the most convenient option was to use a browser to check if the certificate chain was valid or no. However, I had another problem here: A web server needs both the certificate and the private key, and to find the private key is the hardest part here, so I prefer to do it only for those certificates where I know I will be successful in advance. It seemed the egg and the chicken problem.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;That&#39;s why crl_checker.py was born. It implements the first stages of the SSL handshake, where the private key is not really needed before the certificate validation, so we can check it just using our browser and running the following command:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br style=&quot;text-align: start;&quot; /&gt;&lt;span style=&quot;text-align: start;&quot;&gt;&lt;i&gt;$ &lt;b&gt;./crl_checker.py -p 10443 -c /etc/apache2/ssl/ietf.crt&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-dPB5N3qGo4w/VqTKPn5gg_I/AAAAAAAACIw/2VbBq4NnNd4/s1600/certOK.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;273&quot; src=&quot;http://4.bp.blogspot.com/-dPB5N3qGo4w/VqTKPn5gg_I/AAAAAAAACIw/2VbBq4NnNd4/s400/certOK.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;Sometimes you need to refresh several times to have this warning message. Probably my SSL handshake implementation is too much hardcoded, but I haven&#39;t go in depth of this since the tool is still useful.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;You will always see a warning message even if the certificate chain is perfect, because you are not connecting to the correct hostname, but this doesn&#39;t really matters. There are other warning messages that doesn&#39;t matter as well, such us the expiration one, since we will use Delorean to bypass this. If you only have these warning messages... that&#39;s great! your certificate can be used for a successful attack. Now you need to get the private key as we did in previous posts.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-fAvGuv3WX_A/VqTL3I_Y8yI/AAAAAAAACI4/oe3tyeK0UtY/s1600/certFAIL.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;293&quot; src=&quot;http://3.bp.blogspot.com/-fAvGuv3WX_A/VqTL3I_Y8yI/AAAAAAAACI4/oe3tyeK0UtY/s400/certFAIL.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;If you aren&#39;t lucky, you will see other warning messages such as &quot;the issuer certificate is unknown&quot; which means that the issuer CA was removed from trusted CAs list or other similar issues. You probably should try with another victim.&lt;/div&gt;</description><link>http://www.en.pentester.es/2016/01/ntp-helper-tools.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-dPB5N3qGo4w/VqTKPn5gg_I/AAAAAAAACIw/2VbBq4NnNd4/s72-c/certOK.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-1631515246125682257</guid><pubDate>Mon, 25 Jan 2016 06:36:00 +0000</pubDate><atom:updated>2016-01-25T07:36:19.153+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DEFCON</category><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">NTP</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>Other Attacks using Delorean</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Have a look to other posts of this serie:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-microsoft.html&quot; target=&quot;_blank&quot;&gt;[4] Microsoft Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/11/ntp-hsts.html&quot; target=&quot;_blank&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/11/ntp-pki.html&quot; target=&quot;_blank&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/a&gt;&lt;/div&gt;&lt;a href=&quot;http://www.en.pentester.es/2016/01/ntp-other-attacks.html&quot; target=&quot;_blank&quot;&gt;[7] Other Attacks&lt;/a&gt;&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;Disclaimer: All this information has been obtained from  empirical tests and in a specific period of time, so they could have  changed.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;The attacks shown in the previous posts are the ones that I considered more likely and with biggest impact. However, I was trying other exploitation opportunities using time synchronization attacks. Some of them worked even being unlikely, and some others didn&#39;t work at all.&lt;br /&gt;&lt;br /&gt;One of the attacks that worked was an attack against the Windows Task Scheduler. As you probably know, there is a service in Windows boxes that run certain maintenance tasks in the background, such as the same time synchronization.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-C7JNeqQK348/VqSSmd7YTVI/AAAAAAAACH4/cyzv066Zdh4/s1600/sched1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;http://2.bp.blogspot.com/-C7JNeqQK348/VqSSmd7YTVI/AAAAAAAACH4/cyzv066Zdh4/s400/sched1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The task scheduler keeps information about the last time when the task was ran and the next time it will do. These fields are important because, depending on the task configuration, &quot;Next Run Time&quot; is sometimes calculated based on the &quot;Last Run time&quot;, which gives us the opportunity to manipulate the next run time by manipulating the clock using Delorean.&lt;br /&gt;&lt;br /&gt;As I said, not all the tasks calculate &quot;Next Run Time&quot; in this way, but there are some interesting tasks that do, for example the Windows Automatic Updated Service.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-GpymquDWcpQ/VqSU-dT9yfI/AAAAAAAACIE/dtyUhAersNU/s1600/sched2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;263&quot; src=&quot;http://4.bp.blogspot.com/-GpymquDWcpQ/VqSU-dT9yfI/AAAAAAAACIE/dtyUhAersNU/s400/sched2.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;So, What happen if we manipulate the the clock using Delorean, as we did in previous posts, and the Windows Automatic Update task is executed? The &quot;Last Run Time&quot; field would be updated to the fake date (let&#39;s said 2020), so the &quot;Next Run Time&quot; would be calculated in base of that date, in other words, at some point in 2020. That should&#39;t be a problem if the system would maintain that fake date forever, but if the clock is restored to the real date... then the next Windows Automatic Update will take place in 4 years, so the users wouldn&#39;t be warned about new updates and fixes if they don&#39;t manually check it.&lt;br /&gt;&lt;br /&gt;This is an unlikely attack because Windows is the mosts unlikely platform to be a victim for a Delorean attack, and because I couldn&#39;t find a way to restore the clock without user intervention. However, other tasks and other platforms (cron in Linux, for example) could be abused in the same way.&lt;/div&gt;</description><link>http://www.en.pentester.es/2016/01/ntp-other-attacks.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-C7JNeqQK348/VqSSmd7YTVI/AAAAAAAACH4/cyzv066Zdh4/s72-c/sched1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-3392138443233511784</guid><pubDate>Wed, 04 Nov 2015 09:30:00 +0000</pubDate><atom:updated>2016-01-24T09:30:10.353+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DEFCON</category><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">NTP</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>Attacking the Public Key Infrastructure</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Have a look to other posts of this serie:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-microsoft.html&quot; target=&quot;_blank&quot;&gt;[4] Microsoft Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/11/ntp-hsts.html&quot; target=&quot;_blank&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/11/ntp-pki.html&quot; target=&quot;_blank&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/a&gt;&lt;/div&gt;&lt;a href=&quot;http://www.en.pentester.es/2016/01/ntp-other-attacks.html&quot; target=&quot;_blank&quot;&gt;[7] Other Attacks&lt;/a&gt;&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;Disclaimer: All this information has been obtained from  empirical tests and in a specific period of time, so they could have  changed.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;Disclaimer (2): In this post I talk about certificates, SSL keys, etc. Please note that I could talk about (for example) &quot;the certificates&#39;s private key&quot; because it&#39;s the way I usually speak, but probably it isn&#39;t the most correct term. I should talk about &quot;the private key of the certificate&#39;s public key&quot;, but I think it&#39;s easier to understand if we simplify this. Any way, if something sounds confusing, just drop me an email or comment and I&#39;ll try to clarify it.&lt;br /&gt;&lt;br /&gt;From the number of attacks that I tried using Deloran, this was my favorite one. While I was thinking about what could go wrong when the clock can be tampered, SSL certificates expiration dates came to my mind.&lt;br /&gt;&lt;br /&gt;As you probably know, a SSL certificate is valid if:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It was issued by a trusted certification authority (CA) or by an Intermediate CA that was issued by a trusted CA.&lt;/li&gt;&lt;li&gt;Common name matches the server&#39;s hostname (wildcards can be used).&lt;/li&gt;&lt;li&gt;&lt;b&gt;Current date is between the &quot;Not valid before&quot; and &quot;Not valid after&quot; dates.&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;When a SSL certificate expire, we need to get a new one, and the older ones are usually forgotten, because they&#39;re invalid (3rd case). However, with Delorean this isn&#39;t completely true, since we could tamper the internal clock and make a computer to believe that an old certificate is valid.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-BQVFp9n6myQ/VjmbzVfeRmI/AAAAAAAACEY/0ozEqBXQ2QU/s1600/certchain.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;http://2.bp.blogspot.com/-BQVFp9n6myQ/VjmbzVfeRmI/AAAAAAAACEY/0ozEqBXQ2QU/s400/certchain.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;But we can&#39;t attack all the old certificates in the world using Delorean. We need to find certificates with the following conditions:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;u&gt;We need to reconstruct the old certificate chain&lt;/u&gt;: This isn&#39;t a problem, since CA certificates have long validity periods, so perhaps the current certificate chain also works with the old certificate, and if not, looking for the &quot;Issuer name&quot; in the Internet usually works.&lt;/li&gt;&lt;li&gt;&lt;u&gt;Root CA&lt;/u&gt; (starts the certificate chain) &lt;u&gt;has to be a trusted OS/Browser CA&lt;/u&gt;: If the root CA has expired and remove from the browser&#39;s certificates database, victim&#39;s browser won&#39;t be able to validate the certificate chain. This is only a problem for root CAs. Any other Intermediate CA could be expired and that wouldn&#39;t avoid our attack.&lt;/li&gt;&lt;li&gt;&lt;u&gt;We need to find the old host certificate&lt;/u&gt;: This is harder than it seems. It&#39;s not such an easy task. Let&#39;s talk about this a few lines below.&lt;/li&gt;&lt;li&gt;&lt;u&gt;We need to be able to get the host certificate&#39;s private key&lt;/u&gt;: This is the only one private key that we need to know. That&#39;s why we&#39;re interested in old certificates, because we could find much easier ways to get the private key than in modern ones. Let&#39;s talk about this a few lines below as well.&lt;/li&gt;&lt;/ul&gt;So... we said that we need to get old SSL host certificates. Where could I find them? Unfortunately, I did&#39;t grab SSL certificates 10 years ago, so I need to find somebody else in the Internet that did it. I spent a lot of time looking for this kind of database (the oldest the better, of course) and the better and oldest resource that I found was &lt;a href=&quot;https://www.eff.org/observatory&quot; target=&quot;_blank&quot;&gt;The SSL Observatory&lt;/a&gt; from &lt;a href=&quot;https://www.eff.org/&quot; target=&quot;_blank&quot;&gt;EFF&lt;/a&gt;. They crawled the Internet in 2010 and stored a huge database with all the SSL certificates that they found.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-iXfApA2dVWU/VjmjX84j_LI/AAAAAAAACEo/9JJJQ0gkDXA/s1600/observatory.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;http://1.bp.blogspot.com/-iXfApA2dVWU/VjmjX84j_LI/AAAAAAAACEo/9JJJQ0gkDXA/s400/observatory.png&quot; width=&quot;342&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Now that we have an old SSL certificates database, we can start looking for certificates that we think we could break and get it&#39;s private key. For example, something that came to my mind was the &lt;a href=&quot;https://freakattack.com/&quot; target=&quot;_blank&quot;&gt;FREAK attack&lt;/a&gt;. As a part of this attack, they cracked RSA-512 keys in a few hours, using a big Amazon EC2 cluster, so we could do something similar if we find RSA-512 certificates in our database.&lt;br /&gt;&lt;br /&gt;Unfortunately, the most interesting targets (Google, Facebook, etc) didn&#39;t use RSA-512 in 2010. Maybe if we had an older database... Anyway, I was able to found some interesting certificates and some funny ones, such as a Disney site (not the main site).&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Disclaimer&lt;/u&gt; (3): When I do a Delorean demo using a website, I&#39;m &lt;u&gt;&lt;b&gt;NOT&lt;/b&gt;&lt;/u&gt; attacking the website. The website is &lt;u&gt;&lt;b&gt;NOT&lt;/b&gt;&lt;/u&gt; vulnerable. I&#39;m attacking a vulnerable client, that is my own testing machine, so I&#39;m attacking myself, not the website.&lt;br /&gt;&lt;br /&gt;I&#39;m not going to specify step by step how I crack the RSA-512 certificate, because I would be a post (or some of them) itself, and because It was the fist time that I did it, so you can find much more useful information in the Internet &lt;a href=&quot;https://github.com/tomrittervg/cloud-and-control/blob/master/gnfs-info/factoring-howto.txt&quot; target=&quot;_blank&quot;&gt;[1]&lt;/a&gt;&lt;a href=&quot;https://www.cis.upenn.edu/~nadiah/projects/faas/&quot; target=&quot;_blank&quot;&gt;[2]&lt;/a&gt;&lt;a href=&quot;http://cado-nfs.gforge.inria.fr/&quot; target=&quot;_blank&quot;&gt;[3]&lt;/a&gt;&lt;a href=&quot;http://gilchrist.ca/jeff/factoring/nfs_beginners_guide.html&quot; target=&quot;_blank&quot;&gt;[4]&lt;/a&gt;. At the end of the day, I had four EC2 machines running 3 days (as far as I remember) and It was around $150 in total.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-PsrxcEqpAGY/Vjm6jqhKTbI/AAAAAAAACFg/AY1GnxlujkY/s1600/cracked.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;208&quot; src=&quot;http://2.bp.blogspot.com/-PsrxcEqpAGY/Vjm6jqhKTbI/AAAAAAAACFg/AY1GnxlujkY/s400/cracked.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Once you have factored the old RSA key, you have the two prime numbers that were used to create the public and private keys, so you just need to do it again (&lt;a href=&quot;http://www.loyalty.org/~schoen/rsa/private-from-pq.c&quot; target=&quot;_blank&quot;&gt;private-from-pq.c&lt;/a&gt;) to get the private key. Let&#39;s see if it works or not.&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/GOYlAs2w7S4&quot; width=&quot;420&quot;&gt;&lt;/iframe&gt;&lt;/center&gt;&lt;br /&gt;It works! The certificate chain is valid again and we have the private key, so we can cheat the browser and impersonate the website. Cool!&lt;br /&gt;&lt;br /&gt;As far as I have read (I&#39;m not an expert in this field), Governments and other organizations with enough resources could crack RSA-1024 in a reasonable time. This is even more interesting than my demo, because RSA-512 is now banned from most modern browsers, so they would reject the certificate chain. I did this demo using an RSA-512 certificate because I don&#39;t have at this moment enough resources to crack RSA-1024 and because It&#39;s exactly the same process, so if we can do this for RSA-512 in a slightly old browser, we definitely could do it for RSA-1024 if we had enough cracking power.&lt;br /&gt;&lt;br /&gt;This is not the only one old weakness that we can use:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://pastebin.com/ff7Yg663&quot; target=&quot;_blank&quot;&gt;Hacked keys &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://heartbleed.com/&quot; target=&quot;_blank&quot;&gt;Heartbleeded&lt;/a&gt; keys&lt;/li&gt;&lt;li&gt;Weak certificate signatures (see &quot;&lt;a href=&quot;http://www.win.tue.nl/hashclash/rogue-ca/&quot; target=&quot;_blank&quot;&gt;MD5 considered harmful today&lt;/a&gt;&quot;)&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/g0tmi1k/debian-ssh&quot; target=&quot;_blank&quot;&gt;Debian PRNG generated keys&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Many more...&lt;/li&gt;&lt;/ul&gt;But there&#39;s something that probably came to your mind. What about certificate revocation? This isn&#39;t a problem with cracked certificates, because they never were revoked, but hacked certificates, heartbleeded, debian prng, etc ... all those certificates should have been revoked after generating a new one.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-1r_DH-mJsXc/VjmtYZP2xII/AAAAAAAACFE/c8oJnYwbejM/s1600/revokation.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;242&quot; src=&quot;http://1.bp.blogspot.com/-1r_DH-mJsXc/VjmtYZP2xII/AAAAAAAACFE/c8oJnYwbejM/s400/revokation.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;A Certificate Revocation List (CRL) is the database where all the revoked certificates are stored. Browsers download them (or request information via online services) and check if a given certificate is revoked or not, If it is, they reject the communication even if all the certificate chain is valid.&lt;br /&gt;&lt;br /&gt;When I was facing this problem, the question that came to my mind was: Do those CRLs store ALL the revoked certificates? From the beginning of time? This would make this files HUGE, which is something that could affect performance. Well, I can&#39;t be 100% sure about this, but I did some quick tests to check if CAs purge their CRLs when revoked certificates are not valid because of their validity period.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-J-EZ_zsO-8Y/VjmvSi7fZ3I/AAAAAAAACFQ/iyhIG3-dvkM/s1600/cas.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;218&quot; src=&quot;http://1.bp.blogspot.com/-J-EZ_zsO-8Y/VjmvSi7fZ3I/AAAAAAAACFQ/iyhIG3-dvkM/s400/cas.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I focused only in one simple test. I opened several well-known websites in my browser and I got their issuer certificate. Then I downloaded the referenced CRL and I looked for big difference between the date when the certificate was issued and the date of the oldest revoked certificate. If the certificate was issued in 2008,&amp;nbsp; and the first certificate in the CRL was revoked in 2012, and the second one in 2014... that&#39;s pretty weird. My humble opinion is that those CAs are purging expired certificates because they will be invalid anyway. That&#39;s 100% true, but it lets us to use our attack against those certificates, even if they should be revoked.&lt;br /&gt;&lt;br /&gt;Online Certificate Status Protocol (OCSP) doesn&#39;t really help (it&#39;s even easier), because most browsers are configured in order to accept certificates if they can&#39;t validate them, so an attacker just needs to drop OCSP connections. More information &lt;a href=&quot;https://www.grc.com/revocation/implementations.htm&quot; target=&quot;_blank&quot;&gt;HERE&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;From the list above, I looked for certificates that were generated using the old Debian PRNG bug. The problem was that this happened in 2008 and the SSL database that we have is from 2010, so most interesting websites changed their certificates before 2010. &lt;br /&gt;&lt;br /&gt;Looking around the Internet I found &lt;a href=&quot;http://codefromthe70s.org/sslblacklist.aspx&quot; target=&quot;_blank&quot;&gt;CodeFromThe70s&lt;/a&gt;. They developed a Firefox extension that detected certificated generated by the Debian PRNG bug. Detections were sent to them so they have a nice blacklist in their website. I used that list to find a certificate that I could use to test if it&#39;s still revoked or not.&lt;br /&gt;&lt;br /&gt;Next step was to get the private key. This wasn&#39;t as fast as I thought, because the pre-generated list published by HD Moore was for SSH keys only, so I needed to generate my own for HTTPS. What I did was to use the original patched &quot;getpid.so&quot; library and &quot;ubunturoot&quot; chrooted environment (original link was broken, so &lt;a href=&quot;https://github.com/g0tmi1k/debian-ssh&quot; target=&quot;_blank&quot;&gt;I downloaded it from here&lt;/a&gt;), and I developed a couple of shell scripts that just generate all possible SSL key pairs and check if it&#39;s the one I&#39;m looking for:&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;i&gt;$ &lt;b&gt;cat keyfind.sh &lt;/b&gt;&lt;br /&gt;#!/bin/bash&lt;/i&gt;&lt;br /&gt;&lt;i&gt;TARGET=0123456789abcdef0123456789abcdef&lt;br /&gt;&lt;br /&gt;for PID in `seq 1 32768`&lt;br /&gt;do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; chroot . /generate.sh $PID &amp;amp;&amp;gt;/dev/null&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; openssl rsa -in private.pem -noout -modulus | openssl md5 | awk &#39;{print $2}&#39; | grep &quot;$TARGET&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ $? -eq 0 ]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cp private.pem found.pem&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;FOUND!&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rm -f private.pem&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $PID&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;done&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;i&gt;$ &lt;b&gt;generate.sh&lt;/b&gt; &lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;export MAGICPID=$1&lt;br /&gt;export LD_PRELOAD=/getpid.so&lt;br /&gt;/usr/bin/openssl genrsa -out private.pem 1024 &amp;amp;&amp;gt;/dev/null&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;It took a few hours but I was able to get this private key as well. Maybe it wasn&#39;t the most efficient way, but it worked for me. The resulting demo is following:&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/QgLy6J_yNAQ&quot; width=&quot;420&quot;&gt;&lt;/iframe&gt;&lt;/center&gt;&lt;br /&gt;My DEF CON talk (August 7th, 2015) is online, so you can have a look as well. I presented this as well in Spanish in RootedCON (March 2015) and NavajaNegra/ConectaCON (October 2015), but their haven&#39;t published the videos yet:&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;/center&gt;&lt;center&gt;&lt;/center&gt;&lt;center&gt;&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/hkw9tFnJk8k&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/center&gt;&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/11/ntp-pki.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-BQVFp9n6myQ/VjmbzVfeRmI/AAAAAAAACEY/0ozEqBXQ2QU/s72-c/certchain.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-2340178942592266505</guid><pubDate>Mon, 02 Nov 2015 15:00:00 +0000</pubDate><atom:updated>2015-11-02T16:00:00.742+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">BlackHat</category><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">NTP</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>Attacking HTTP Strict Transport Security</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Have a look to other posts of this serie:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-microsoft.html&quot; target=&quot;_blank&quot;&gt;[4] Microsoft Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/11/ntp-hsts.html&quot; target=&quot;_blank&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/div&gt;[7] Other Attacks&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;Disclaimer: All this information has been obtained from  empirical tests and in a specific period of time, so they could have  changed.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;In the last few posts we have reviewed how time synchronization works in different operating systems and how we could change the clock using Delorean in each of them. However, we haven&#39;t seen any practical attack. What can we do by tampering a computer&#39;s clock?&lt;br /&gt;&lt;br /&gt;I started this research because I was doing a MitM demo, using &lt;a href=&quot;http://www.thoughtcrime.org/software/sslstrip/&quot; target=&quot;_blank&quot;&gt;SSLStrip&lt;/a&gt;, and it didn&#39;t work when I tried to visit GMail and other well-known websites. That was weird, because I had done the same demo many times in the past. Debugging the problem I discovered an HTTP header called &quot;&lt;a href=&quot;https://www.owasp.org/index.php/HTTP_Strict_Transport_Security&quot; target=&quot;_blank&quot;&gt;Strict-Transport-Security&lt;/a&gt;&quot;, something that had never seen before.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-ItFtbNn2ER8/VjWoevidU6I/AAAAAAAACDA/kEDIgpxoCmc/s1600/hsts.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;236&quot; src=&quot;http://1.bp.blogspot.com/-ItFtbNn2ER8/VjWoevidU6I/AAAAAAAACDA/kEDIgpxoCmc/s400/hsts.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;HTTP Strict Transport Security (aka HSTS) is a security protection that was released in 2012 and, despite is not widely used in the Internet yet, most well-known providers use it at this moment. The server part is really simple, a webserver just needs to set up the &quot;Strict-Transport-Security&quot; header setting the desired policy using the &quot;max-age&quot; and &quot;includeSubdomains&quot; parameters. In the example above, the web server sets a policy in the browser saying &quot;ey! it doesn&#39;t matter what happen, please connect to me always using HTTPS for the following 3153600 seconds&quot;.&lt;br /&gt;&lt;br /&gt;The hardest part in the HSTS feature is in the browser part. A browser needs to read this header and do all the necessary actions to ensure that it follows the policy. &lt;a href=&quot;http://caniuse.com/#feat=stricttransportsecurity&quot; target=&quot;_blank&quot;&gt;Most browsers support HSTS&lt;/a&gt; despite IE didn&#39;t support it until June 9th 2015. While I was delivering my talk in DEF CON (August 2015), an attendant from the first row correct me when I said &quot;IE doesn&#39;t support HSTS&quot;. He was right about that, because I&#39;m not an IE user and I tested it for the last time a few months before the talk. I asked him if this was something recent but he told me that &quot;six months ago&quot; (around February) which isn&#39;t exactly what I have found documentd. Anyway, It supports HSTS now.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-xBLMQhkh0bI/VjWste0piuI/AAAAAAAACDc/LjVQkDO5RkQ/s1600/caniuse.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;168&quot; src=&quot;http://1.bp.blogspot.com/-xBLMQhkh0bI/VjWste0piuI/AAAAAAAACDc/LjVQkDO5RkQ/s400/caniuse.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;In addition, Google and Mozilla created a Preloaded HSTS list for their browsers (later the idea was used in other browsers). A preloaded list is a list of well-known providers (google, twitter, facebook, paypal, etc) where HSTS is &quot;enforced by default&quot;. The goal of this preloaded list is to avoid the security gap when a user have just installed his browser or cleaned his cache, or when he visits a website for the first time, before any HSTS policy has ben set.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-hfBG2x6_2kY/VjWooSxp6YI/AAAAAAAACDI/S1eVVrFWnhk/s1600/preloaded.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;170&quot; src=&quot;http://2.bp.blogspot.com/-hfBG2x6_2kY/VjWooSxp6YI/AAAAAAAACDI/S1eVVrFWnhk/s400/preloaded.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Despite information from &lt;a href=&quot;https://www.chromium.org/hsts&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt; or &lt;a href=&quot;https://blog.mozilla.org/security/2012/11/01/preloading-hsts/&quot; target=&quot;_blank&quot;&gt;Mozilla&lt;/a&gt; seem to talk about the HSTS preloaded list as a static list, the real truth is that preloaded entries are treated exactly the same than dynamic entries. When a browser is installed or its cache is cleaned, all entries in this list are added as dynamic entries using a default value (10 weeks) and they&#39;re updated in the same way than dynamic entries are so, in real life, it doesn&#39;t make a difference for a Delorean.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-4qSovn-N1wI/VjWoxrpPcLI/AAAAAAAACDQ/ejN9gLUAMHA/s1600/chrome.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;245&quot; src=&quot;http://1.bp.blogspot.com/-4qSovn-N1wI/VjWoxrpPcLI/AAAAAAAACDQ/ejN9gLUAMHA/s400/chrome.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The only browser that I have found in my research which works in a different way is Apple Safari. It stores a .plist a preloaded list and it forces always HSTS in those hosts. It doesn&#39;t matter the local clock.&lt;br /&gt;&lt;br /&gt;Since we know that HSTS policy will avoid us from intercepting the first HTTP connection and, as a consequence, from using SSLStrip (or intercepting the communication in any other way), in the amount of seconds specified in the &quot;max-age&quot; parameter, our attack against HSTS is based on updating the local clock in order to make HSTS cache to expire. When there isn&#39;t any entry in the HSTS cache, a browser will work as usual, so when typing hostnames such as &quot;mail.google.com&quot; it will connect using HTTP before being redirected to HTTPS. &lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/_uWxZvJeJhY&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/center&gt;&lt;br /&gt;My talk in BlackHat Europe last year was based in this attack, and it was published several months ago, so you can have a look if my accent doesn&#39;t hurt you (as a comment in youtube said) ;)&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/eLhb4jZuv6M&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/center&gt;&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/11/ntp-hsts.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-ItFtbNn2ER8/VjWoevidU6I/AAAAAAAACDA/kEDIgpxoCmc/s72-c/hsts.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-5812359763395912565</guid><pubDate>Fri, 30 Oct 2015 07:30:00 +0000</pubDate><atom:updated>2015-11-01T00:44:56.138+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><category domain="http://www.blogger.com/atom/ns#">Windows</category><title>Microsoft Time Synchronization</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Have a look to other posts of this serie:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-microsoft.html&quot; target=&quot;_blank&quot;&gt;[4] Microsoft Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/div&gt;[7] Other Attacks&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;Of course, I couldn&#39;t finish my examples without talking about Microsoft. From the desktop OS vendor that I have tested, Microsoft has the most robust one in terms of security. It works in a different way for standalone computers than in domain members, so let&#39;s cover both circumstances:&lt;br /&gt;&lt;br /&gt;In a &lt;b&gt;standalone Windows&lt;/b&gt; box, time synchronization takes place each 7 days (Sundays at 1-2am or so) so the only one option to intercept an NTP request is to be there on Sunday or Monday, whenever the victim boots the computer for the first time after the synchronization time. In addition, Windows has a clock drift limitation of 15 hours, so we can&#39;t change the clock more than 15 hours on each synchronization, which is a real problem for most attacks that we will see in the following posts.&lt;br /&gt;&lt;br /&gt;The 15 hours value is not a harcoded value, it is stored in the registry, in a couple of keys called &quot;MaxPosPhaseCorrection&quot; and &quot;MaxNegPhaseCorrection&quot;, and they change in different systems, for example, in a Windows 7/8 is 15 hours but in a Windows Server 2012 is 48 hours, and in older servers is different as well. It could also change when some changes happen in the box, for example when a box become a domain member.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-6T8pQSQnPeE/VjMWUzVPuiI/AAAAAAAACBg/IPiY0-3Iqsw/s1600/15hours.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;http://2.bp.blogspot.com/-6T8pQSQnPeE/VjMWUzVPuiI/AAAAAAAACBg/IPiY0-3Iqsw/s400/15hours.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;In combination, both controls make Windows boxes pretty secure in terms of time synchronization. However, if any of both are changed by the user, there are some attack vectors that could be used. For example, there are many tutorials in the internet explaining how to change the time synchronization scheduled task, because they think (and probably they&#39;re right) that once a week is not enough for a good clock accuracy.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-2etaM3NqBCI/VjMYE2hH9MI/AAAAAAAACBs/zcBa4xxOJcg/s1600/more_often.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;215&quot; src=&quot;http://1.bp.blogspot.com/-2etaM3NqBCI/VjMYE2hH9MI/AAAAAAAACBs/zcBa4xxOJcg/s400/more_often.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;So, under this circumstance, a new attack vector came to my mind. What happen if the user configure his system to synchronize the time more often than the maximum clock drift allowed? The answer is than an attacker could intercept that NTP request and change the clock just a few seconds before the next scheduled time synchronization, then intercept the following NTP requst and do the same, and again, and again, and again until he reach the desired time. I called this attack &quot;Time Skimming&quot;, because it&#39;s a similar idea than a stone skimming in a lake, and it&#39;s implemented in Delorean:&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/HFCOoV_ipEM&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;There&#39;s another way to force time synchronization, but it requires some kind of social engineering. When the user manually request a time synchronization using the &quot;Internet Time Settings&quot;, but it&#39;s not as easy as in Mac OS X, since it takes several clicks.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Domain members&lt;/b&gt; work in a different way. The Max[Pos|Neg]PhaseCorrction value is set to 0xFFFFFFFF which means &quot;accept any clock drift&quot;. That is a risk, but they include a packet signature in order to authenticate the source of the response:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-ilW9JSVlxak/VjMa42UJcmI/AAAAAAAACB4/P0HHSdNwkLA/s1600/authwin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;http://2.bp.blogspot.com/-ilW9JSVlxak/VjMa42UJcmI/AAAAAAAACB4/P0HHSdNwkLA/s400/authwin.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;They use the NTP standard in a creative way. Key ID should be a value that identify which key should be used to sign the response. In a regular NTP request it should be 1 or 2, depending on the number of keys available. However, what Microsoft did was use this to identify the computers username in the active directory that is requesting the time synchronization. For example, if we have a KeyID 0x5e040000 we need to change its endianess and then we have 0x0000045e. The first bit of this is a key selector (0 or 1), and the rest is the Relative ID (RID) for the computer.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-29fmBKXmotg/VjMc41xbajI/AAAAAAAACCE/RCvWwAQM2Fg/s1600/rid.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;281&quot; src=&quot;http://3.bp.blogspot.com/-29fmBKXmotg/VjMc41xbajI/AAAAAAAACCE/RCvWwAQM2Fg/s400/rid.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;As you probably know, both computers and users are objects in active directory. Computers are a special kind of users. They set a password for this user when they join the domain, and those passwords are changed in a regular basis. A Domain Controller store the last two known hashed passwords, so the key selector that we mentioned before identify this.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;/* Sign the NTP response with the unicodePwd */&lt;br /&gt;MD5Init(&amp;amp;ctx);&lt;br /&gt;MD5Update(&amp;amp;ctx, nt_hash-&amp;gt;hash, sizeof(nt_hash-&amp;gt;hash));&lt;br /&gt;MD5Update(&amp;amp;ctx, sign_request.packet_to_sign.data, sign_request.packet_to_sign.length);&lt;br /&gt;MD5Final(signed_reply.signed_packet.data + sign_request.packet_to_sign.length + 4, &amp;amp;ctx);&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Response packets are signed using MD5 ( &lt;b&gt;md5(hashed_password+response_body)&lt;/b&gt; ), which is not the most robust hashing algorithm in the world, but I couldn&#39;t find a working attack for such a small message, so at this point I think a Microsoft domain time synchronization is the most robust that I have seen in my research.&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/10/ntp-microsoft.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-6T8pQSQnPeE/VjMWUzVPuiI/AAAAAAAACBg/IPiY0-3Iqsw/s72-c/15hours.png" height="72" width="72"/><thr:total>10</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-1519994594470529945</guid><pubDate>Wed, 28 Oct 2015 07:00:00 +0000</pubDate><atom:updated>2015-10-28T08:00:07.252+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">NTP</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>Fedora / Ubuntu Time Synchronization</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Have a look to other posts of this serie:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[4] Microsoft Time Synchronization&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/div&gt;[7] Other Attacks&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;Yesterday we were talking about how time synchronization works in Mac OS X, and how it is different for pre-Mavericks versions and the most modern ones. Today, we are having a look to GNU/Linux. Of course, we have a big amount of Linux flavors available, and we couldn&#39;t review all of them, but I chose the two favors that I think are most extended in desktop users (Ubuntu and Fedora), since they would be the target for this attacks.&lt;br /&gt;&lt;br /&gt;Disclaimer: All this information has been obtained from empirical tests and in a specific period of time, so they could have changed.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Ubuntu Linux&lt;/b&gt; is the only one reviewed system that doesn&#39;t synchronize the time in a regular basis, so it isn&#39;t just a matter of waiting the necessary amount of time and intercept the NTP request. In Ubuntu, time synchronization is done each time than a network interface comes up (and, of course, when the system boots up). This is easy to see if we have a look at the script files that Ubuntu runs when that happens:&lt;br /&gt;&lt;br /&gt;$ ls /etc/network/if-up.d/&lt;br /&gt;000resolvconf&amp;nbsp; avahi-daemon&amp;nbsp; &lt;b&gt;ntpdate&lt;/b&gt;&amp;nbsp; wpasupplicant&lt;br /&gt;avahi-autoipd&amp;nbsp;&amp;nbsp; ethtool&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; upstart&lt;br /&gt;&lt;br /&gt;There isn&#39;t any restriction in terms of a big date change, so we could easily intercept this request and set the computer&#39;s clock using Delorean. There are two possible scenarios: Intercept at boot time or when the computer connects to a network, or just detach the computer from the network (deauth on a Wifi, for example) and wait for the next connection.&lt;br /&gt;&lt;br /&gt;On the other hand, &lt;b&gt;Fedora Linux&lt;/b&gt; use a similar approach than Mac OS X. In previous versions, it just synchronized the time each minute, without any security restrictions, so it was easy and fast to use Delorean in order to tamper the system clock:&lt;br /&gt;&lt;br /&gt;$ tcpdump -i eth0 -nn src port 123&lt;br /&gt;12:&lt;b&gt;43&lt;/b&gt;:50.614191 IP 192.168.1.101.123 &amp;gt; 89.248.106.98.123: NTPv3, Client, length 48&lt;br /&gt;12:&lt;b&gt;44&lt;/b&gt;:55.696390 IP 192.168.1.101.123 &amp;gt; 213.194.159.3.123: NTPv3, Client, length 48&lt;br /&gt;12:&lt;b&gt;45&lt;/b&gt;:59.034059 IP 192.168.1.101.123 &amp;gt; 89.248.106.98.123: NTPv3, Client, length 48&lt;br /&gt;&lt;br /&gt;At some point they changed the synchronization approach. At this moment, there is a daemon called &quot;chrony&quot; which works in a similar way than &quot;pacemaker&quot; in Mac OS X. However, Chrony are configured in a more secure way than Pacemaker. By default, it doesn&#39;t accept big date changes. It only accepts them in the first three tries from the last reboot, so we can still use a Delorean attack at boot time or if we can crash the chrony service.&lt;br /&gt;&lt;br /&gt;We&#39;re probably going too fast, because we haven&#39;t talked about HSTS and how it could be bypassed using time synchronization attacks, but let me show you an example of this attack against an Ubuntu Linux box:&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/MxAJDc7g9SQ&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/10/ntp-linux.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/MxAJDc7g9SQ/default.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-8708610049388463402</guid><pubDate>Tue, 27 Oct 2015 07:00:00 +0000</pubDate><atom:updated>2015-10-28T07:58:23.349+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">MacOSX</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">NTP</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>Mac OS X Time Synchronization</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Have a look to other posts of this serie:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[4] Microsoft Time Synchronization&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/div&gt;[7] Other Attacks&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;Last week we showed how Delorean works, and how we could use it in order to tamper NTP responses. However, time synchronization work slightly different between OS vendors.&lt;br /&gt;&lt;br /&gt;Disclaimer: All this information has been obtained from empirical tests and in a specific period of time, so they could have changed.&lt;br /&gt;&lt;br /&gt;Pre-Mavericks Mac OS X use a simple time synchronization approach. An ntpd daemon is running and time is synchronized each 9 minutes. Any restriction or security configuration are applied in this daemon, so an attacker could use Delorean and change the internal clock easily.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;$ tcpdump -i eth0 -nn src port 123&lt;br /&gt;09:&lt;b&gt;02&lt;/b&gt;:18.166708 IP 192.168.1.100.123 &amp;gt; 17.72.148.53.123: NTPv4, Client, length 48&lt;br /&gt;09:&lt;b&gt;11&lt;/b&gt;:20.059792 IP 192.168.1.100.123 &amp;gt; 17.72.148.53.123: NTPv4, Client, length 48&lt;br /&gt;09:&lt;b&gt;20&lt;/b&gt;:17.951361 IP 192.168.1.100.123 &amp;gt; 17.72.148.53.123: NTPv4, Client, length 48 &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;However, Apple changed the time synchronization in Mavericks. NTPd is still running but it doesn&#39;t change the clock directly. The time drift is stored in /var/db/ntp.drift , and there is another service, called &quot;pacemaker&quot; that should check this file and change the clock if needed.&lt;br /&gt;This new service has several benefits. For example, It adapts the amount of NTP requests to the powers state (plugged or battery). Another important difference is that clock changes are not applied in a single step. The clock speeds up or slows down in order to correct the date but avoiding big time steps. It doesn&#39;t implement any other security feature so it can be intercepted using Delorean as well.&lt;br /&gt;&lt;br /&gt;Despite it shouldn&#39;t be a problem, we have found that NTPd wasn&#39;t working properly in modern versions of Mac OS X, so time synchronization was not working at all. &lt;a href=&quot;http://www.atmythoughts.com/living-in-a-tech-family-blog/2014/2/28/what-time-is-it&quot; target=&quot;_blank&quot;&gt;There are some people arguing in the Internet about this&lt;/a&gt;. Does it mean that modern Mac OS X are not vulnerable to a Delorean attack? The answer is NO. Let&#39;s have a look to the &lt;i&gt;/usr/libexec/ntpd-wrapper&lt;/i&gt; script:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-ZzYptvH-Ubs/Vi6UCWoqwqI/AAAAAAAACAk/TaRX2LUc_-E/s1600/boot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;http://1.bp.blogspot.com/-ZzYptvH-Ubs/Vi6UCWoqwqI/AAAAAAAACAk/TaRX2LUc_-E/s400/boot.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;As you can see above, Mac OS X runs a sntp (simple NTP) command at boot, before running the NTPd daemon. This sntp binary is not affected by the same bug, so &lt;b&gt;we could intercept this synchronization and run a Delorean attack when a Mac OS X boots up&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;There is still an additional way to exploit this weak time synchronization in Mac OS X. When a user opens the &quot;&lt;i&gt;Date &amp;amp; Time Preferences&lt;/i&gt;&quot; menu, the operating system automatically synchronize the time without user&#39;s knowledge, so we could use Delorean in this scenario as well.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-3s3LhvVLSjs/Vi6VtPNySFI/AAAAAAAACAw/mx7BiQ2sOI4/s1600/menuwin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;233&quot; src=&quot;http://1.bp.blogspot.com/-3s3LhvVLSjs/Vi6VtPNySFI/AAAAAAAACAw/mx7BiQ2sOI4/s400/menuwin.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;In the following posts, we will see how we could exploit this in order to intercept SSL communications, as we presented in DEF CON recently.&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/10/ntp-macosx.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-ZzYptvH-Ubs/Vi6UCWoqwqI/AAAAAAAACAk/TaRX2LUc_-E/s72-c/boot.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-6013359260314493791</guid><pubDate>Wed, 21 Oct 2015 06:00:00 +0000</pubDate><atom:updated>2015-10-28T07:58:07.137+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Delorean</category><category domain="http://www.blogger.com/atom/ns#">MitM</category><category domain="http://www.blogger.com/atom/ns#">NTP</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>NTP MitM Attack using a Delorean</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;Around one and a half year ago, I started a research about how computers synchronize their internal clocks, and how this could be used in order to attack well-known protocols and services running in Operating Systems. As a result, I have presented my findings in several security conferences such as &lt;a href=&quot;https://www.blackhat.com/eu-14/briefings.html#bypassing-http-strict-transport-security&quot; target=&quot;_blank&quot;&gt;BlackHat Europe 2014&lt;/a&gt;, &lt;a href=&quot;http://www.rootedcon.es/&quot; target=&quot;_blank&quot;&gt;RootedCON 2015&lt;/a&gt; (Spanish), &lt;a href=&quot;https://www.defcon.org/html/defcon-23/dc-23-speakers.html#Selvi&quot; target=&quot;_blank&quot;&gt;DEF CON 23&lt;/a&gt; and &lt;a href=&quot;http://navajanegra.com/&quot; target=&quot;_blank&quot;&gt;Navaja Negra / ConectaCON 2015&lt;/a&gt; (Spanish).&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-I_M_01BRJY0/ViW1HcNUHvI/AAAAAAAAB_0/6ALFEFArSl4/s1600/back-to-the-future-2015.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;http://4.bp.blogspot.com/-I_M_01BRJY0/ViW1HcNUHvI/AAAAAAAAB_0/6ALFEFArSl4/s320/back-to-the-future-2015.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Today, October 21th 2015, it&#39;s the date when Marty McFly went to the future in the second part of the amazing Back to the Future saga, so I can&#39;t think in a better date to start releasing all the details about this research.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/delorean.html&quot; target=&quot;_blank&quot;&gt;[1] NTP MitM Attack using a Delorean&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-macosx.html&quot; target=&quot;_blank&quot;&gt;[2] Mac OS X Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.en.pentester.es/2015/10/ntp-linux.html&quot; target=&quot;_blank&quot;&gt;[3] Fedora / Ubuntu Time Synchronization&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[4] Microsoft Time Synchronization&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[5] Attacking HTTP Strict Transport Security&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;[6] Attacking the Public Key Infrastructure&lt;/div&gt;[7] Other Attacks&lt;br /&gt;[8] Helper tools&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;As we will see in the upcoming posts, all the OS vendors that I have tested use the Network Time Protocol (NTP) in order to keep their internal clock accurate, which is very important for some authentication protocols and other stuff. Most of them don&#39;t deploy this service in a secure way, making it vulnerable to Man-in-the-Middle attacks.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In order to exploit this issue, I developed a tool called &lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://github.com/PentesterES/Delorean&quot; target=&quot;_blank&quot;&gt;DELOREAN&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;. Delorean is an NTP server written in python, open source and&amp;nbsp;&lt;a href=&quot;https://github.com/PentesterES/Delorean&quot; target=&quot;_blank&quot;&gt;available from GitHub&lt;/a&gt; (contributions are welcomed). I borrowed a few lines of code from &lt;a href=&quot;http://github.com/limifly/ntpserver&quot; target=&quot;_blank&quot;&gt;kimifly&#39;s ntpserver&lt;/a&gt; and, of course, all the credits to him have been included.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;What makes Delorean different and useful for us is that we can configure its flags in order to make it work in a different way than a regular NTP server. Basically, we can configure it in order to send fake&amp;nbsp;responses, similar to the Metasploit&#39;s fakedns module.&lt;/div&gt;&lt;br /&gt;&lt;i&gt;$ ./delorean.py -h&lt;br /&gt;Usage: delorean.py [options]&lt;br /&gt;&lt;br /&gt;Options:&lt;br /&gt;  -h, --help            show this help message and exit&lt;br /&gt;  -i INTERFACE, --interface=INTERFACE&amp;nbsp;Listening interface&lt;br /&gt;  -p PORT, --port=PORT  Listening port&lt;br /&gt;  -n, --nobanner        Not show Delorean banner&lt;br /&gt;  -s STEP, --force-step=STEP&amp;nbsp;Force the time step: 3m (minutes), 4d (days), 1M&amp;nbsp;(month)&lt;br /&gt;  -d DATE, --force-date=DATE&amp;nbsp;Force the date: YYYY-MM-DD hh:mm[:ss]&lt;br /&gt;-x, --random-date     Use random date each time&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;We have the typical interface (-i) and port (-p) flags, that help us to bind the service exactly where we want. The -n flag only hides the super-cool Delorean banner :)&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;_._ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _.-=&quot;_- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _.-=&quot; &amp;nbsp; _-&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | ||&quot;&quot;&quot;&quot;&quot;&quot;&quot;---._______ &amp;nbsp; &amp;nbsp; __.. &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ___.===&quot;&quot;&quot;&quot;-.______-,,,,,,,,,,,,`-&#39;&#39;----&quot; &quot;&quot;&quot;&quot;&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&quot;&quot;&amp;nbsp; __&#39;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; __.--&quot;&quot; &amp;nbsp; &amp;nbsp; __&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,&#39; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; o \ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; __&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [__|&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp; __-&quot;&quot;=======.--&quot;&quot;&amp;nbsp; &quot;&quot;--.=================================.--&quot;&quot;&amp;nbsp; &quot;&quot;--.=======: &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp;] &amp;nbsp; &amp;nbsp; &amp;nbsp; [w] : /&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \ : |========================|&amp;nbsp; &amp;nbsp; : /&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \ :&amp;nbsp; [w] : &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp;V___________:|&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |: |========================|&amp;nbsp; &amp;nbsp; :|&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |: &amp;nbsp; _-&quot;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp; V__________: \&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; / :_|=======================/_____: \&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; / :__-&quot; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Menlo; font-size: 12px; line-height: normal;&quot;&gt;&amp;nbsp; -----------&#39;&amp;nbsp; &quot;&quot;____&quot;&quot;&amp;nbsp; `-------------------------------&#39;&amp;nbsp; &quot;&quot;____&quot;&quot; &amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;We can use Delorean in several modes, but we are going to focus in the most useful ones. There are some other attacks that weren&#39;t really interesting after developing them, but they are still in the code. Perhaps I will remove them in the future, sine they require scapy and some dependencies.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Since it&#39;s too soon yet to talk about how OS synchronize, we will test how Delorean works using the command line tool &quot;ntpdate&quot;:&lt;/div&gt;&lt;br /&gt;&lt;i&gt;$ ntpdate -q 192.168.1.2&lt;br /&gt;server 192.168.1.2, stratum 2, &lt;b&gt;offset 97372804.086845&lt;/b&gt;, delay 0.02699&lt;br /&gt;20 Oct 06:05:45 ntpdate[881]: step time server 192.168.1.2 offset &lt;b&gt;97372804.086845 sec&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;By default (no flags), Delorean responses a date that matches the same week and month day than the current date, but at least 1000 days in the future. This was useful for the HSTS bypass as we will see in upcoming posts.&lt;/div&gt;&lt;br /&gt;&lt;i&gt;# ./delorean.py -n &lt;br /&gt;[19:44:42] Sent to 192.168.10.113:123 - Going to the future! 2018-08-31 19:44 &lt;br /&gt;[19:45:18] Sent to 192.168.10.113:123 - Going to the future! 2018-08-31 19:45&lt;/i&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can set a relative jump from the current date using the step flag (-s). Relative jumps can be defined as 10d (ten days in the future), -2y (two years in the past), etc:&lt;/div&gt;&lt;br /&gt;&lt;i&gt;# ./delorean.py -s 10d -n &lt;br /&gt;[19:46:09] Sent to 192.168.10.113:123 - Going to the future! 2015-08-10 19:46 &lt;br /&gt;[19:47:19] Sent to 192.168.10.113:123 - Going to the future! 2015-08-10 19:47&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;We can also set a specific date, and Delorean would answer always the same date:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;# ./delorean.py -d ‘2020-08-01 21:15’ -n &lt;br /&gt;[19:49:50] Sent to 127.0.0.1:48473 - Going to the future! 2020-08-01 21:15 &lt;br /&gt;[19:50:10] Sent to 127.0.0.1:52406 - Going to the future! 2020-08-01 21:15&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;There are an additional attack called &quot;Skimming Attack&quot; that is useful only on certain configurations, but we will go in depth with it when we will talk about Microsoft synchronization, despite it could be useful in other platforms.&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/10/delorean.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-I_M_01BRJY0/ViW1HcNUHvI/AAAAAAAAB_0/6ALFEFArSl4/s72-c/back-to-the-future-2015.jpg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-9103460209689885412</guid><pubDate>Tue, 08 Sep 2015 17:46:00 +0000</pubDate><atom:updated>2015-09-08T19:46:40.263+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SANS</category><title>SANS SEC-660: &quot;Advanced Penetration Testing, Exploit Writing and Ethical Hacking&quot; in Madrid</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;As you probably know, I have been quite involved with the SANS Institute since 2010, when I was a SANS Mentor for the first time. Currently I&#39;m a SANS Community Instructor and I have been teaching the SEC-560: &quot;Network Penetration Testing, Exploits and E&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;thical Hacking&quot; several times in Spain.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-RW_Twa5DdVk/Ve8cn5m_OtI/AAAAAAAAB-g/-y5y01qdSas/s1600/ddc548f37f7d20dcf1e034f08a1c01b6_400x400.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: justify;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;http://2.bp.blogspot.com/-RW_Twa5DdVk/Ve8cn5m_OtI/AAAAAAAAB-g/-y5y01qdSas/s200/ddc548f37f7d20dcf1e034f08a1c01b6_400x400.jpeg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Next November in Madrid (Spain), you will have the opportunity to step up your Penetration Testing skills to other fields and techniques not covered at SEC-560 course. As you can read in the SANS Institute web site: &lt;b&gt;SEC-660 &quot;Advanced Penetration Testing, Exploit Writing and Ethical Hacking&quot;&lt;/b&gt; is designed as a logical progression point for those who have completed SANS SEC-560, or for those with existing penetration testing experience. The topics covered in this course include attacks against network access control (NAC), virtual local area network (VLAN) manipulation, breaking Windows and Linux restricted environments (kiosk-like), cryptographic attacks, fuzzing, exploit writing and bypassing the most common OS protection such as ASLR, DEP, Canaries, etc , and much more.&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Despite not being a course focused in exploit-writing such as SEC-760, the exploiting part of SEC-660 (two days) is the perfect approach for those Pentesters that want a in-depth view of how processes and memory are managed in Windows and Linux, and how to exploit certain common flaws that could be really useful when there isn&#39;t a public exploit available or when it doesn&#39;t work properly in our specific environment.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In addition, even being used to the &quot;SANS-style&quot;, SEC-660 is one of the most hands-on course that I have ever seen. There are dozens of real-works attacks that we will covered in detail that you could probably found in your upcoming penetration tests.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Interested? Book the following dates: &lt;b&gt;November 2nd-7th in Madrid&lt;/b&gt;. You just need to drop me an email at jselvi{-at-}pentester.es and CC&amp;nbsp;sans{-at-}one-esecurity.com and we will explain you how to procede. Remember that &lt;b&gt;the course materials are in English, but the clases will be delivered in Spanish.&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Shall we &lt;strike&gt;dance&lt;/strike&gt; Pentest?&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;More information about SEC-660 &lt;a href=&quot;http://www.sans.org/course/advanced-penetration-testing-exploits-ethical-hacking&quot; target=&quot;_blank&quot;&gt;HERE&lt;/a&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;More information about other course and prices &lt;a href=&quot;http://one-esecurity.com/es/SANS/Calendario_2015.php&quot; target=&quot;_blank&quot;&gt;HERE&lt;/a&gt;.&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/09/sec660-madrid2015.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-RW_Twa5DdVk/Ve8cn5m_OtI/AAAAAAAAB-g/-y5y01qdSas/s72-c/ddc548f37f7d20dcf1e034f08a1c01b6_400x400.jpeg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-1151898778032183065</guid><pubDate>Fri, 20 Feb 2015 09:30:00 +0000</pubDate><atom:updated>2015-02-20T10:30:00.366+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">WebSecurity</category><title>From Case-Insensitive to RCE</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;This post was written by &lt;b&gt;The DarkRaver&lt;/b&gt;. He&#39;s a close friend and one of the best skilled security professionals that I have ever met. He&#39;s also known by publishing tools such as dirb or sqlibf that I strongly recommend.&lt;br /&gt;&lt;br /&gt;Go ahead with his post:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;------------------------------------------------------&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Some time ago, I was doing a webapp penetration testing when I found something really interesting. The application was coded in PHP and it relied on some commercial components. Soon I found lots of XSS and SQLi vulnerable forms, but we won&#39;t focus on that in this post.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Suddenly, I realised that requesting the same page in uppercase or lowercase changed its behavior. The webserver was based on Apache and Linux (case sensitive) but the files seem to be hosted in a cases insensitive filesystem (maybe a NAS share?), so when I requested page.php it responded as expected, but when I requested page.PHP its source code was shown.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-Zxh1YsIX6X8/VObkt_5TY1I/AAAAAAAAB38/eJ5Au7TF184/s1600/sourcecode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-Zxh1YsIX6X8/VObkt_5TY1I/AAAAAAAAB38/eJ5Au7TF184/s1600/sourcecode.png&quot; height=&quot;259&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;That vulnerability allowed to review the commercial application&#39;s source code, where I found several potentially dangerous functions such as &quot;include()&quot; and &quot;include_once()&quot; that could be vulnerable. No other dangerous functions such as &quot;system()&quot;, &quot;open()&quot; or &quot;file_get_contents()&quot; were found.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A few minutes later I could confirm that at least one of those &quot;include_once()&quot; functions was vulnerable to LFI and exploitable. However, only files with .js extension could be loaded.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-A9_j9SuQ_tQ/VObmDYge2CI/AAAAAAAAB4I/fjV1AxkRKMw/s1600/vuln.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-A9_j9SuQ_tQ/VObmDYge2CI/AAAAAAAAB4I/fjV1AxkRKMw/s1600/vuln.png&quot; height=&quot;164&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;I tried several ways to bypass this protection, such as null byte, long paths, etc, but nothing seemed to work. So... we&#39;re tied to that. How we could upload or create a .js file in the local filesystem?&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The upload forms didn&#39;t allow that kind of extensions and we weren&#39;t able to create files inside the server. Or... maybe we were? What about the following piece of code?&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-7ACVdyBid98/VObn2C-AfbI/AAAAAAAAB4U/0f8Y_5rmRuA/s1600/pieceofcode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-7ACVdyBid98/VObn2C-AfbI/AAAAAAAAB4U/0f8Y_5rmRuA/s1600/pieceofcode.png&quot; height=&quot;158&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;It was a feature that allowed to cache JavaScript files on disk! But... How could we inject custom content in those cached files?&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;An in-depth look showed that some JavaScripts were generated from a template and one of them included some user controled parameters. That sounds great!&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-znUwWd0Dvc0/VObpHDHvFGI/AAAAAAAAB4g/Gox9PnenyHo/s1600/patterns.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-znUwWd0Dvc0/VObpHDHvFGI/AAAAAAAAB4g/Gox9PnenyHo/s1600/patterns.png&quot; height=&quot;148&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Even better, the injectable parameter was the same that was vulnerable to LFI, so we could find a way to exploit both vulnerabilities at the same time.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;JavaScript files were stored in a path like that: &quot;/cache/&quot;.&lt;b&gt;$offv&lt;/b&gt;.$theme.$lang.$type.$name.&quot;.js&quot; , where $offv was the user provided input and the other parts could be easy guessed looking at the source code. So... the exploit string should be as follows:&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;http://www.app.com/plugin/minjs.php?&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;offending_var=../../cache/&amp;lt;?phpinfo();?&amp;gt;defaultes-lacoredefault&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;However, I got a &quot;500 - Internal Server Error&quot;. What the hell??? Something was terribly crashing. How we could fix it? I tried some other PHP functions such as &quot;system()&quot;, &quot;file_get_contents()&quot; and &quot;phpversion()&quot; but most of them crashed in the same way.&lt;br /&gt;&lt;br /&gt;Wait, what if the exploit works but it crashes at some point after that? what if we try to &quot;exit()&quot; the execution?&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;http://www.app.com/plugin/minjs.php?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;offending_var=../../cache/&amp;lt;?system(“id”);exit();?&amp;gt;defaultes-lacoredefault&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-UMTDrLoxevo/VObtw2lLb4I/AAAAAAAAB4s/q1v8LK3xhBg/s1600/pwned.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-UMTDrLoxevo/VObtw2lLb4I/AAAAAAAAB4s/q1v8LK3xhBg/s1600/pwned.png&quot; height=&quot;296&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;It works! Finally I had Remote Code Execution in the server, and everything began with a small source code leak caused by a case-insensitive filesystem. Small things sometimes cause big troubles.&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/02/from-case-insensitive-to-rce.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Zxh1YsIX6X8/VObkt_5TY1I/AAAAAAAAB38/eJ5Au7TF184/s72-c/sourcecode.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-5066343484193660313</guid><pubDate>Thu, 05 Feb 2015 15:55:00 +0000</pubDate><atom:updated>2015-02-05T16:55:45.112+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">BrowserSecurity</category><category domain="http://www.blogger.com/atom/ns#">WebSecurity</category><title>An IE Same Origin Policy Bypass story</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;A couple of days ago I was reading my feeds when suddenly a headline caught my attention: &quot;&lt;b&gt;Serious bug in fully patched Internet Explorer put user credentials at risk&lt;/b&gt;&quot;. A same-origin-policy bypass in Internet Explorer had been released. This is a really critical vulnerability, because SOP provides isolation between different websites inside our browser, and avoid evil sites to get access to other sites and modify its content and so on.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;I have been taking a look for the last few hours and it definitely works. The &lt;a href=&quot;http://www.deusen.co.uk/items/insider3show.3362009741042107/&quot; target=&quot;_blank&quot;&gt;provided PoC&lt;/a&gt; works but perhaps isn&#39;t the most practical approach. As far as I know, details of this vulnerability haven&#39;t been published apart from the PoC itself, so let&#39;s have a look to the PoC. I have prepared my own PoC, just to see if I could use this vulnerability for more evil purposes.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-xHxcxw5KF30/VNOCf48h4sI/AAAAAAAAB2k/S3-a9a4d4NI/s1600/Exploit.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-xHxcxw5KF30/VNOCf48h4sI/AAAAAAAAB2k/S3-a9a4d4NI/s1600/Exploit.png&quot; height=&quot;243&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;At first sight, the vulnerability seems to be a race condition or similar. There are two iframes, the first one loads a dynamic webpage, for example 1.php. Its source code wasn&#39;t published with the PoC but it simply waits for a few seconds and then it redirects to the same url than the second iframe.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Both iframes load a webpage in the target website. It&#39;s important to find a webpage that could be loaded inside an iframe because if not the vulnerability isn&#39;t exploitable. Providers such as Google, Facebook, etc usually configure their sites with the &quot;&lt;b&gt;X-Frame-Options&lt;/b&gt;&quot; header in order to avoid &lt;a href=&quot;https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet&quot; target=&quot;_blank&quot;&gt;ClickJacking attacks&lt;/a&gt;.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-vGz5vEzcIpE/VNOD5y2XfvI/AAAAAAAAB2w/KQhrPUAM5aU/s1600/XFrameOptions.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-vGz5vEzcIpE/VNOD5y2XfvI/AAAAAAAAB2w/KQhrPUAM5aU/s1600/XFrameOptions.png&quot; height=&quot;366&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;However, a single page with no &quot;X-Frame-Options&quot; in the domain is enough for us, and this is not as difficult to find as it seems. There are two well known resources that aren&#39;t protected in most websites: robots.txt (the one used by the original author) and &lt;b&gt;favicon.ico&lt;/b&gt; (I used that one because it looks better for a practical attack).&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;There is a function called &quot;&lt;b&gt;go()&lt;/b&gt;&quot; that makes the real exploitation. It&#39;s difficult to read so let me decode it for you.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-4TUv_LeJLts/VNOG3Cceb-I/AAAAAAAAB28/fzGyZc0JpCg/s1600/Payload.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-4TUv_LeJLts/VNOG3Cceb-I/AAAAAAAAB28/fzGyZc0JpCg/s1600/Payload.png&quot; height=&quot;124&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Here is where interesting things happen. There are some &quot;&lt;b&gt;alert&lt;/b&gt;&quot; and &quot;&lt;b&gt;eval&lt;/b&gt;&quot; calls that seem to be important. I couldn&#39;t figure out why, but if you change them it won&#39;t work. This is the tricky part in this vulnerability.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;It gets the second iframe that we were talking before and store it in a variable &quot;&lt;b&gt;x&lt;/b&gt;&quot;. Then it waits a few seconds (1 second in the code) and shows an alert message. As I previously said, that alert seem to be important so we can remove it, but we can use a message that won&#39;t warn the user that something bad is just about to happen. After that, when the first iframe has already changed from my evil domain to the target domain (because of 1.php) a piece of javascript and HTML code is injected in that second iframe. We shouldn&#39;t be able to to that, because it&#39;s a different domain, but we are. &lt;b&gt;The same origin policy has been bypassed&lt;/b&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Let&#39;s see what a victim would see:&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-_a2j3skcLNY/VNOJ2Y6vkdI/AAAAAAAAB3I/Mvb8V29vwYE/s1600/1popup.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-_a2j3skcLNY/VNOJ2Y6vkdI/AAAAAAAAB3I/Mvb8V29vwYE/s1600/1popup.png&quot; height=&quot;424&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Some countries have specific laws about cookies and a warning message is needed at most websites, so users are used to click &quot;OK&quot;.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-604tIZWHQZk/VNOKTbfduBI/AAAAAAAAB3Q/Mobu6OwuiMg/s1600/2post.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-604tIZWHQZk/VNOKTbfduBI/AAAAAAAAB3Q/Mobu6OwuiMg/s1600/2post.png&quot; height=&quot;424&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;When I injected the javascript and HTML code in the iframe, I used a Google button. It isn&#39;t the most beautiful blog but well... It looks like a real blog :)&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-ogfKJ422SLE/VNOKwGIJpTI/AAAAAAAAB3Y/fBXecMBWi5E/s1600/3google.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-ogfKJ422SLE/VNOKwGIJpTI/AAAAAAAAB3Y/fBXecMBWi5E/s1600/3google.png&quot; height=&quot;560&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The Google authentication page is opened. Everything looks fine but I have changed the form action using the injected javascript code.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-dty6ObyNNNM/VNOLD-Zi4FI/AAAAAAAAB3g/LmC4x8VjAHw/s1600/4grab.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-dty6ObyNNNM/VNOLD-Zi4FI/AAAAAAAAB3g/LmC4x8VjAHw/s1600/4grab.png&quot; height=&quot;558&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Done! A really cool vulnerability. I can&#39;t wait for more details about the vulnerability. Let&#39;s see if in a few days we can know why &quot;alert&quot;, &quot;eval&quot; and &quot;setTimeout&quot; are sometimes as important as they are.&lt;/div&gt;</description><link>http://www.en.pentester.es/2015/02/an-ie-same-origin-policy-bypass.html</link><author>noreply@blogger.com (Jose Selvi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-xHxcxw5KF30/VNOCf48h4sI/AAAAAAAAB2k/S3-a9a4d4NI/s72-c/Exploit.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9163961975500012189.post-2901522308541562820</guid><pubDate>Mon, 20 Oct 2014 16:20:00 +0000</pubDate><atom:updated>2014-10-20T18:20:11.011+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PentesterEs</category><title>Pentester.Es now in English</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;For the past 7 years I have been writing in Spanish in my personal security blog: &lt;b&gt;&lt;a href=&quot;http://www.pentester.es/&quot; target=&quot;_blank&quot;&gt;Pentester.Es&lt;/a&gt;&lt;/b&gt;. I decided to write it in Spanish because it&#39;s my mother tongue and because I work mostly for spanish companies and with spanish people.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Around a year ago I decided that I should start an &quot;internationalisation&quot; process. A few days ago I talked for the first time in English at Black Hat Europe and now It&#39;s time to start writing my personal blog in English.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;So... you can now find a language selector in the upper right. I&#39;m not going to translate older posts but all newer ones are going to be available in both English and Spanish.&lt;/div&gt;</description><link>http://www.en.pentester.es/2014/10/pentesteres-now-in-english.html</link><author>noreply@blogger.com (Jose Selvi)</author><thr:total>2</thr:total></item></channel></rss>