<?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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>NetSPI Blog » NetsPWN: Assessment Services</title>
	
	<link>http://www.netspi.com/blog</link>
	<description>Information security consulting</description>
	<lastBuildDate>Wed, 22 May 2013 13:00:11 +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/NetspiBlog/application-security" /><feedburner:info uri="netspiblog/application-security" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Breaking Out! of Applications Deployed via Terminal Services, Citrix, and Kiosks</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/4FbjGaxQ5fY/</link>
		<comments>http://www.netspi.com/blog/2013/05/22/breaking-out-of-applications-deployed-via-terminal-services-citrix-and-kiosks/#comments</comments>
		<pubDate>Wed, 22 May 2013 13:00:11 +0000</pubDate>
		<dc:creator>Scott Sutherland</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[bypass controls]]></category>
		<category><![CDATA[Escalation]]></category>
		<category><![CDATA[group policy bypass]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacking citrix]]></category>
		<category><![CDATA[hacking terminal services]]></category>
		<category><![CDATA[ikat]]></category>
		<category><![CDATA[kiosk breakout]]></category>
		<category><![CDATA[Penetration Test]]></category>
		<category><![CDATA[windows breakout]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3423</guid>
		<description><![CDATA[The goal of this blog is to provide a simple process for testing common breakout scenarios related to applications published via Kiosks, Terminal Services, and Citirx using manual techniques and free tool kits.  This should be useful to penetration testers and system administrators alike. <br /><a class="readmore" href="http://www.netspi.com/blog/2013/05/22/breaking-out-of-applications-deployed-via-terminal-services-citrix-and-kiosks/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>In order to meet business requirements and client demand for remote access, many companies choose to deploy applications using  Terminal Services, Citrix, and kiosk platforms.  These platforms are commonly deployed in both internal networks as well as internet facing environments.  In my experience, such application deployments are rarely locked down enough to prevent an attacker from breaking out to the underlying operating system. As a result, these systems can often be used as an entry point into the network and have the potential to provide attackers with unauthorized access to systems, applications, and sensitive data.  The goal of this blog is to provide a simple process for testing common breakout scenarios using manual techniques and free tool kits.  This should be useful to penetration testers and system administrators alike.</p>
<p>Below is an overview of the high level process and topics that will be covered:<strong></strong></p>
<ul>
<li><a href="#obtainingwindows">Obtain a common dialog box</a></li>
<li><a href="#folderpathrestrictions">Bypass folder path restrictions</a></li>
<li><a href="#filerestrictions">Bypass file type restrictions</a></li>
<li><a href="#fileexecutionrestrictions">Bypass file execution restrictions</a></li>
<li><a href="#filelists">Bypass file black/white lists</a></li>
<li><a href="#interactiveshells">Obtain access to native interactive shells</a></li>
<li><a href="#managementconsoles">Obtain access to native management consoles</a></li>
<li><a href="#downloadingthirdpartyapps">Downloading third party applications</a></li>
<li><a href="#usefullthirdpartyapps">Useful third party applications</a></li>
</ul>
<h2><a id="obtainwindows"></a>Obtain a Common Dialog Box</h2>
<p>The first step towards breaking out of applications deployed via Terminal Services, Citrix, or a kiosk platform is often obtaining a Windows common dialog box.  This is usually possible via keyboard shortcuts and application functionality that interacts with the file system.  Windows XP dialog boxes look something like the screenshot below.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_1.png"><img class="alignleft size-full wp-image-3424" alt="Scott_BreakingOut_Img_1" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_1.png" width="566" height="456" /></a></p>
<p>Windows Vista and above have additional built-in functionality for these dialogs such as Windows Search.  However, a lot of those functions can be limited or removed via group policy settings.  Regardless, there are a few ways that attackers and users are able to obtain a Windows dialog box.</p>
<h4>Intended Application Functionality</h4>
<p>Many desktop applications deployed via Citrix and Terminal Services support functionality that allows them to interact with files on the operating system. Functions that allow users <em>to save, save as, open, load, browse, import, export, help, search, scan, and print </em>will usually be able to provide an attacker with a Windows dialog box.  Below is a basic example using notepad.exe.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_2.png"><img class="alignleft size-full wp-image-3425" alt="Scott_BreakingOut_Img_2" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_2.png" width="564" height="359" /></a></p>
<h4>Shortcut Keys: Windows</h4>
<p>A lot of applications are deployed to environments that do not suppress default Windows shortcut keys via group policy or other means.  As a result, attackers can often gain unauthorized access to other applications, menus, and dialog boxes.  I have had a lot of luck with the accessibility option shortcut keys, but a larger list of default Windows shortcut keys can be found at <a href="http://support.microsoft.com/kb/126449">http://support.microsoft.com/kb/126449</a>.  Also, the terminal services hardening guide (from Microsoft) can be found at <a href="http://technet.microsoft.com/en-us/library/cc264467.aspx">http://technet.microsoft.com/en-us/library/cc264467.aspx</a>.  It provides some guidance for disabling most of the shortcut keys.  Below is a basic example showing how to obtain an explorer dialog box using the “Sticky Keys” accessibility option shortcut keys.</p>
<ol>
<li>Hit shift 5 times to obtain the Sticky Keys popup.
<p>&nbsp;<a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_3.png"><img class="alignleft size-full wp-image-3426" alt="Scott_BreakingOut_Img_3" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_3.png" width="514" height="213" /></a></li>
<li>Click the link to access to open the explorer dialog box. In this instance, the explorer functionality can be accessed via the address bar.
<p><img class="alignleft size-full wp-image-3427" alt="Scott_BreakingOut_Img_4" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_4.png" width="655" height="567" /></li>
</ol>
<h4>Shortcut Keys: Citrix ICA Hotkeys</h4>
<p>Citrix implementations have their own set of shortcuts or “hotkeys” that can lead to unauthorized system access.  In some cases, custom hotkeys can be set in the ICA configuration file.  Below are a few links that cover the default hotkeys, how to configure custom hotkeys, and how both can be disabled.</p>
<ul>
<li><a href="http://support.citrix.com/article/CTX140219">http://support.citrix.com/article/CTX140219</a></li>
<li><a href="http://support.citrix.com/proddocs/topic/receivers-java-101/java-client-hotkeys.html">http://support.citrix.com/proddocs/topic/receivers-java-101/java-client-hotkeys.html</a></li>
</ul>
<h4>Internal Explorer Breakouts: Download and Run/Open</h4>
<p>Most browsers support the execution of downloaded files from the browser.  They also support running open files with their default program.  So for example, a .txt file downloaded from a malicious web server would most likely open in notepad by default.   Interactive Kiosk Attack Tool (iKAT) Desktop is a free Kiosk hacking framework that has some nice support for quite a few break out scenarios.  However, in this instance the “File Handlers” and “iKat Tools” menus are particularly useful.  It can be downloaded from <a href="http://ikat.ha.cked.net/Windows/index.html">http://ikat.ha.cked.net/Windows/index.html</a>.</p>
<h4>Internal Explorer Breakouts: Menus</h4>
<p>A lot of web applications are deployed via Terminal Services, Citrix, and Kiosk platforms.  Most of them are made accessible via Internet explorer.  As it turns out Internet Explorer is very integrated with the Windows operating system.  As a result, it can be used to navigate to folders, execute programs, and download content via native functionality.   Common areas that can be used to break out of Internet Explorer include, but are not limited to:</p>
<ul>
<li>The address bar</li>
<li>Search menus</li>
<li>Help menus</li>
<li>Print menus</li>
<li>All other menus that provide dialog boxes</li>
<li>Right-click menus that support things like:
<ul>
<li>Goto/search copied address functionality</li>
<li>View source functionality</li>
<li>Third party plug-ins</li>
</ul>
</ul>
<p>Below is a basic screen shot of Internet Explorer.  I’ve outlined a few of the common functions/menus that can be used to break out to other applications or obtain a dialog box.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_5.png"><img class="alignleft size-full wp-image-3428" alt="Scott_BreakingOut_Img_5" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_5.png" width="707" height="569" /></a></p>
<h4>Internal Explorer Breakouts: Menu Links</h4>
<p>In Internet Explorer you can also access common dialog boxes via HTML hyperlinks.  iKat Desktop has included a module to launch dialog boxes through such links.  In order to leverage the module simply start iKat, navigate the iKat web server via the target application, and click on the links in the “Common Dialogs” menu.  Below is a sample screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_6.png"><img class="alignleft size-full wp-image-3429" alt="Scott_BreakingOut_Img_6" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_6.png" width="868" height="488" /></a></p>
<p>To be fair I’ve also provided a few links related to locking down Internet Explorer and placing it into “kiosk mode” to help prevent attackers from using it to breakout to the local operating system.</p>
<ul>
<li><a href="http://technet.microsoft.com/en-us/library/cc775996%28v=ws.10%29.aspx">http://technet.microsoft.com/en-us/library/cc775996%28v=ws.10%29.aspx</a></li>
<li><a href="http://social.technet.microsoft.com/Forums/en-US/winserverGP/thread/207ef293-2a5c-461a-aafb-630caacd3d56/">http://social.technet.microsoft.com/Forums/en-US/winserverGP/thread/207ef293-2a5c-461a-aafb-630caacd3d56/</a></li>
</ul>
<h2><a id="folderpathrestrictions"></a>Bypass Folder Path Restrictions</h2>
<p>After obtaining a Windows dialog box, the next step is often to navigate to a folder path that houses native executables that can provide an interactive console, registry access, etc.  Usually you can simply type the folder path into the file name field, but sometimes you will have to use alternative options.  Below are some options that typically work in both explorer and Internet Explorer.  Most of them can be prevented via group policy or registry modifications.</p>
<h4>Standard Folder Paths</h4>
<p>A standard file path looks like “C:\Windows\System32\” and can be entered into the file name field in order to navigate to the desired folder.  Below is a basic screen shot example from Windows XP.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_7.png"><img class="alignleft size-full wp-image-3430" alt="Scott_BreakingOut_Img_7" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_7.png" width="566" height="455" /></a></p>
<h4>Folder Paths in Shortcut Links</h4>
<p>In a handful of instances I’ve found it useful to modify existing Windows shortcuts to gain unauthorized access to folder paths.  Below are the basic steps.</p>
<ul>
<li>Right-click the shortcut</li>
<li>Choose properties</li>
<li>In the “Target” field change the path to the folder you wish to access.</li>
</ul>
<p>Below is a sample screen shot of what the shortcut properties window should look like for an application named “MyApplication”.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_8.png"><img class="alignleft size-full wp-image-3431" alt="Scott_BreakingOut_Img_8" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_8.png" width="370" height="510" /></a></p>
<h4>Folder Path Alternatives: Environmental variables</h4>
<p>By default, Windows sets a number of environmental variables that can be used almost anywhere in Windows (including file dialog boxes).  To view the standard environmental variables you can type “set” in a command console.  In most cases you should be able to type the variable into the Filename and gain some access to the relative directory.  Below are some default variables to get you started.</p>
<ul>
<li>%USERPROFILE%</li>
<li>%PROGRAMDATA%</li>
<li>%PUBLIC%</li>
<li>%TMP%</li>
<li>%WINDIR%</li>
<li>%SYSTEMDRIVE%</li>
<li>%SYSTEMROOT%</li>
</ul>
<p>Below is a basic screen shot example.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_9.png"><img class="alignleft size-full wp-image-3432" alt="Scott_BreakingOut_Img_9" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_9.png" width="564" height="457" /></a></p>
<h4>Folder Path Alternatives: Shell URI Handlers</h4>
<p>There are a lot of folder locations that can be accessed via shell command shortcuts.  Many of which will allow you to execute programs, and provide some level of write access, that will come in handy later on.  I have not been able to find any solid Microsoft documentation on this, but there are quite a few sites online with good command lists. One of which is <a href="http://docs.rainmeter.net/tips/launching-windows-special-folders">http://docs.rainmeter.net/tips/launching-windows-special-folders</a>.  Below are a few shell command examples.  They can be executed from the run menu, taskmgr, command console,  or the file name/path fields in a Windows dialog box.</p>
<ul>
<li>shell:DocumentsLibrary</li>
<li>shell:Librariesshell:UserProfiles</li>
<li>shell:Personal</li>
<li>shell:SearchHomeFolder</li>
<li>shell:System shell:NetworkPlacesFolder</li>
<li>shell:SendTo</li>
<li>shell:Common Administrative Tools</li>
<li>shell:MyComputerFolder</li>
<li>shell:InternetFolder</li>
</ul>
<p>Below is a basic screen shot example showing how the “shell:Common Administrative Tools” command can be issued in the file name field to access a folder containing shortcuts to administrative tools.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_10.png"><img class="alignleft size-full wp-image-3433" alt="Scott_BreakingOut_Img_10" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_10.png" width="585" height="473" /></a></p>
<p>It’s worth noting the common Shell handler commands can be found in the iKat Desktop “File System Links” menu.</p>
<h4>Folder Path Alternatives: File Protocol Handler</h4>
<p>Below is an example of how to use the file handler to access a folder path.  Enter the path into the filename and press enter to change the directory.  A file handler folder path looks like “../../../Windows/System32/”.  </p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_11.png"><img class="alignleft size-full wp-image-3434" alt="Scott_BreakingOut_Img_11" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_11.png" width="565" height="455" /></a></p>
<p>
There are a number of other native protocol handlers that can be targeted as well. iKat  has a menu that contains a list of the common ones, but I’ve provided a short list of them below to give you an idea of the potential.</p>
<ul>
<li>data:</li>
<li>res:</li>
<li>about:</li>
<li>mailto:</li>
<li>ftp:</li>
<li>news:</li>
<li>telnet:</li>
<li>view-source:</li>
</ul>
<h4>Folder Path Alternatives: UNC Path</h4>
<p>In many cases UNC paths can be used to bypass group policy restrictions preventing you from accessing all of your favorite file paths.  Below is a basic screen shot showing how a UNC path can be used to navigate to the “c:\windows\system32\” directory of a Windows 7 system via the address field.  It should be noted that you can use the file protocol handler and UNC paths together.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_12.png"><img class="alignleft size-full wp-image-3435" alt="Scott_BreakingOut_Img_12" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_12.png" width="656" height="404" /></a></p>
<h4>Windows Search</h4>
<p>The native search functionality in Windows can often be used to navigate the operating system even with restrictive policies in place.  For example, performing a search and then clicking the “custom” menu will at a minimum provide a full list of the folders on of the operating system even if the file restrictions have been put into place by GPO.  In some cases you may even be able to break out to your personal directories.  This can be accomplished using the steps below:</p>
<ol>
<li>Obtain a dialog box
<p>	<a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_13.png"><img class="alignleft  wp-image-3436" style="margin-bottom: 10px;" alt="Scott_BreakingOut_Img_13" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_13.png" width="627" height="433" /></a></li>
<li>Search for any string
<p>	<a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_14.png"><img class="alignleft  wp-image-3437" style="margin-bottom: 10px;" alt="Scott_BreakingOut_Img_14" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_14.png" width="628" height="435" /></a></li>
<li>Click &#8220;Custom&#8230;&#8221;
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_15.png"><img class="alignleft  wp-image-3438" style="margin-bottom: 10px;" alt="Scott_BreakingOut_Img_15" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_15.png" width="622" height="434" /></a></li>
<li>Add a custom search path for &#8220;c:\&#8221;
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_16.png"><img class="alignleft size-full wp-image-3439" style="margin-bottom: 10px;" alt="Scott_BreakingOut_Img_16" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_16.png" width="415" height="492" /></a></li>
<li>Expand the “c:\” and right-click the sub directory that you would like to access.  Then choose “Include in library-&gt;Create new library”.
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_17.png"><img class="alignleft  wp-image-3440" style="margin-bottom: 10px;" alt="Scott_BreakingOut_Img_17" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_17.png" width="567" height="500" /></a></li>
<li>A soft link to the location will be created in your personal libraries folder, and the folder will be automatically opened. In some case allow you to access folders and files that you shouldn’t have access to.
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_18.png"><img class="alignleft  wp-image-3441" style="margin-bottom: 10px;" alt="Scott_BreakingOut_Img_18" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_18.png" width="675" height="550" /></a> </li>
</ol>
<p>There are also some more advanced search commands that can help you refine searches for key files during your breakouts at the sites listed below.</p>
<ul>
<li><a href="https://windowssecrets.com/top-story/getting-the-most-from-windows-search-part-2/">https://windowssecrets.com/top-story/getting-the-most-from-windows-search-part-2/</a></li>
<li><em></em><a href="http://windows.microsoft.com/en-us/windows7/advanced-tips-for-searching-in-windows">http://windows.microsoft.com/en-us/windows7/advanced-tips-for-searching-in-windows</a></li>
</ul>
<h2><a id="filerestrictions"></a>Bypass File Type Restrictions</h2>
<p>Sometimes dialog boxes will be deployed so that only certain file types or folders can be viewed.  Most of the time this can be bypassed by entering wild card characters into the filename field and pressing enter.  I provided some basic examples below, but didn’t feel this one really warranted a screen shot.</p>
<ul>
<li>*.exe</li>
<li>*</li>
<li>*.*</li>
</ul>
<h4>Bypass File Read Restrictions</h4>
<p>In some cases you may not have the ability to launch applications to read files on the operating system.  However, in many cases you can upload files to an evil web server via an upload form via your web browser.  iKat Desktop actually has a module called “File Reflection” in the “Reconnaissance” menu to a serve that purpose.  Below is a screen shot example showing  the upload and viewing of a file called “helloworld.txt” that contains the string “Hello World!”.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_19.png"><img class="alignleft size-full wp-image-3442" alt="Scott_BreakingOut_Img_19" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_19.png" width="871" height="490" /></a></p>
<h2><a id="fileexecutionrestrictions"></a>Bypass File Execution Restrictions</h2>
<p>The fantastic thing about Windows is that there is always more than one way to do everything. Naturally this makes Windows easier for users, but it also makes it harder to lock down.  Below are a few different options for executing files when standard execution isn’t possible.</p>
<h4>Right-Click and Open</h4>
<p>The classics never die.  If accessing right-click menus is possible then simply right-click the file you wish to execute and choose open from the Windows file dialog box.  Below is a basic example showing how to run cmd.exe</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_20.png"><img class="alignleft size-full wp-image-3443" alt="Scott_BreakingOut_Img_20" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_20.png" width="623" height="501" /></a></p>
<h4>File Protocol Handler</h4>
<p>In most scenarios this works well in the address bar for both Internet Explorer and Windows Explorer.  To execute a file with this method type &#8220;../../../Windows/System32/cmd.exe” into the address bar.  Below are a few screen shots to illustrate the process.  Once again, this can also be done using iKat by clicking on a preconfigured hyperlink.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_21.png"><img class="alignleft size-full wp-image-3444" alt="Scott_BreakingOut_Img_21" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_21.png" width="626" height="432" /></a></p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_22.png"><img class="alignleft size-full wp-image-3445" alt="Scott_BreakingOut_Img_22" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_22.png" width="706" height="436" /></a></p>
<h4>File Shortcuts</h4>
<p>Some “restricted” desktops and dialog boxes may allow you to modify or create shortcuts to the files for execution.   After the shortcut is modified/created a simply double-click should do the trick.</p>
<ul>
<li>Right-click the shortcut</li>
<li>Choose properties</li>
<li>In the “Target” field change the path to the executable you wish to run.</li>
</ul>
<p>Below is a basic example screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_23.png"><img class="alignleft size-full wp-image-3446" alt="Scott_BreakingOut_Img_23" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_23.png" width="385" height="531" /></a></p>
<h4>Drag and Drop Execution</h4>
<p>Windows also allows for drag and drop execution.  For example, if right-click or file handler options are unavailable, you can simply drag any file onto cmd.exe in order to open a console Window.  This can be done with a single dialog or between multiple as shown in the basic example below.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_24.png"><img class="alignleft size-full wp-image-3447" alt="Scott_BreakingOut_Img_24" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_24.png" width="625" height="433" /></a></p>
<h4>Browser Add-ons</h4>
<p>If you’re testing a web application in most cases you’ll have the ability to navigate to a web server via the address bar in Internet Explorer or Windows Explorer.  By starting up your own web server on a remote server you should be able to access add-on applications that have the ability to pass commands to the operating system.  For example, you can use a Java  applet that passes commands through cmd.exe and displays the results on the page.  Below are some common technologies that can be used.  If you don’t feel like writing your own wrappers, iKat supports a number of different “Browser Addons” including java applets, click once, and ActiveX.</p>
<h4>Browser Based Exploits</h4>
<p>Many browsers and browser add-ons suffer from exploits that allow the execution of arbitrary code on the system.  One way to leverage those kind of issues while trying to break out an application deployed via Terminal Service, Citrix, or Kiosk platform is to simply visit a web page hosting the exploit.  You can configure and deploy your own malicious web pages with Metasploit manually or through iKat.  However, Metasploit provides the flexibility to test one module at a time or test many at once with the “<a href="http://www.metasploit.com/modules/auxiliary/server/browser_autopwn">browser_autopwn</a>” module.  I would provide instructions, but the usage has been documented a million times.  Feel free to Google it.</p>
<h4>Office File Macros</h4>
<p>Office and Adobe PDF documents can contain macros that will execute arbitrary code on the system.  Simply create an Office file that with run the operating system command of your choice via a macro, host it on your malicious web server, and open it from the application’s browser or Internet Explorer.  Surprise! iKat supports this as well.</p>
<h4>Native Application Functionality</h4>
<p>A surprising number of applications have command execution functionality built in on purpose.  So make sure that you walk through the entire application looking for command execution, scheduled tasks, and database query options.  Many thick applications also provide users with the ability to execute arbitrary queries on backend databases.  In many cases that functionality can be used to execute operating system commands through existing database functions on the database server such as xp_cmdshell.</p>
<h2><a id="filelists"></a>Bypass File Execution Black/White Lists</h2>
<p>Administrators can configure group policy to prevent or allow applications to be run by name.  However, attackers have a few workarounds available to them which can be hard to prevent with group policy on its own.  Below are a few examples.</p>
<h4>Rename files</h4>
<p>Simply renaming files will typically allow you to bypass  group policy enforced black and white lists.  In most cases you can rename your files to anything that isn’t on the blacklist,  but I have had the most success when naming files after required or running processes like svchost.exe, conhost, explorer.exe, iexplore.exe, etc.</p>
<h4>Change Directories</h4>
<p>Although the default folders used by the application may not allow files to execute, your user’s personal directories usually do.  Navigating to %userprofile% or shell:Personal will often give you the write/execute access you’ll need to break out of the application and execute commands on the operating system.</p>
<h2><a id="interactiveshells"></a>Obtain Access to Native Interactive Shells</h2>
<p>There are lots of native applications that will provide an interactive shell.  I’ve listed a few of the common ones are below:</p>
<h4>CMD.exe</h4>
<p>Cmd.exe is the native  console for Windows.  I think most people are more comfortable with it than the alternatives just because it’s familiar.  However, use what you like.  Below is a basic screen shot example.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_25.png"><img class="alignleft size-full wp-image-3448" alt="Scott_BreakingOut_Img_25" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_25.png" width="659" height="246" /></a></p>
<p>It’s worth noting that there are two version of cmd.exe in 64bit Windows systems.  The are located in c:\windows\system32 and C:/Windows/SYSWOW64\cmd.exe.</p>
<h4>COMMAND.com</h4>
<p>Everyone goes straight for cmd.exe, but don’t forget about command.com.  It’s still on older Windows systems and when everything else is locked down it can come in handy.  Below is a basic example screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_26.png"><img class="alignleft size-full wp-image-3449" alt="Scott_BreakingOut_Img_26" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_26.png" width="670" height="336" /></a></p>
<h4>FTP.exe</h4>
<p>A lot of people forget that the native ftp.exe client in Windows has a command  that allows users to execute local operating system commands without direct access to cmd.exe.  This usually comes in handy when there are a lot of restrictions around cmd.exe, and you don’t have change or write access to the file system.  Below is a basic overview of how to use the FTP client to obtain a directory listing.</p>
<ol>
<li>Double-click ftp.exe, the console will launch</li>
<li>Type “!dir” to get a directory listing</li>
</ol>
<p>Below is a basic screen shot example.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_27.png"><img class="alignleft size-full wp-image-3450" alt="Scott_BreakingOut_Img_27" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_27.png" width="674" height="339" /></a></p>
<h4>POWERSHELL.exe</h4>
<p>PowerShell provides its own console with a bunch of cmd.exe aliases so that (for the most part) you can interact with it as though you were using cmd.exe.  It also supports all the .net magic, which means you can basically run any command  or call any API method that you have the privileges to.  This is my preferred shell for that reason, but of course PowerShell must already be installed on the system.  Below is a basic screen shot example.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_28.png"><img class="alignleft size-full wp-image-3451" alt="Scott_BreakingOut_Img_28" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_28.png" width="672" height="341" /></a></p>
<h4>Scripts of All Kinds</h4>
<p>If script extensions such as .bat, .vbs, or .ps are configured to automatically execute their code via their intended interpreter, then in some cases it may be possible to drop a script that acts as an interactive console or downloads/launches your favorite Third-party applications.</p>
<h2><a id="managementconsoles"></a>Obtain Access to Native Management Consoles</h2>
<p>It’s pretty well known that most kiosk systems are configured to run with local administrative privileges.  So the native applications below should give you the means to access a full remote desktop or disable group policies that are making your life difficult.  They can also come in handy when attacking Terminal Service and Citrix applications.</p>
<h4>MMC.exe</h4>
<p>MMC.exe allows users to build custom management control panels.  It can be very handy for disabling restrictions on files, and other local configurations.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_29.png"><img class="alignleft size-full wp-image-3452" alt="Scott_BreakingOut_Img_29" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_29.png" width="614" height="332" /></a></p>
<h4>CONTROL.exe</h4>
<p>Control.exe actually launches the control panel.  Depending on the group policy this may or may not give you access to what you’re looking for.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_30.png"><img class="alignleft size-full wp-image-3453" alt="Scott_BreakingOut_Img_30" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_30.png" width="613" height="329" /></a></p>
<h4>RUNDLL32.exe</h4>
<p>Run dll can be used to execute dll functions from the command line.  This includes the native API calls to launch management consoles.  Below are a few examples that can be useful.</p>
<ul>
<li>Add/Remove Programs: RunDll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,0Content Advisor</li>
<li>Control Panel: RunDll32.exe shell32.dll,Control_RunDLL</li>
<li>Device Manager: RunDll32.exe devmgr.dll DeviceManager_Execute</li>
<li>Folder Options – General: RunDll32.exe shell32.dll,Options_RunDLL 0</li>
<li>Folder Options – Search: RunDll32.exe shell32.dll,Options_RunDLL 2</li>
<li>Forgotten Password Wizard:  RunDll32.exe keymgr.dll,PRShowSaveWizardExW</li>
<li>System Properties: Advanced: RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,4</li>
<li>Taskbar Properties: RunDll32.exe shell32.dll,Options_RunDLL 1</li>
<li>User Accounts: RunDll32.exe shell32.dll,Control_RunDLL nusrmgr.cpl</li>
<li>Windows Firewall: RunDll32.exe shell32.dll,Control_RunDLL firewall.cpl</li>
</ul>
<p>Below is an example screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_31.png"><img class="alignleft size-full wp-image-3454" alt="Scott_BreakingOut_Img_31" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_31.png" width="616" height="331" /></a></p>
<h4>TASKMGR.exe</h4>
<p>If you’re looking for something a little more intuitive than rundll32.exe, then taskmrg.exe may be for you.  It will let you view all of the running process, logged in users, and provides functionality to run commands easily.  Below is a basic screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_32.png"><img class="alignleft size-full wp-image-3455" alt="Scott_BreakingOut_Img_32" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_32.png" width="614" height="329" /></a></p>
<h4>MSTSC.exe</h4>
<p>Mstsc.exe is the remote desktop client application.  By remote desktop-ing to the Terminal or Citrix server that your already on, you may be able to obtain a full desktop without the original restrictions.  It can make life easier if you’re trying to escalate privileges.  Below is a basic screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_33.png"><img class="alignleft size-full wp-image-3456" alt="Scott_BreakingOut_Img_33" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_33.png" width="611" height="330" /></a></p>
<h2><a id="downloadingthirdpartyapps"></a>Download Third Party Applications</h2>
<p>In many cases leveraging native executables will be enough, but sometimes you may want to download your own tools to the target system.  There are a ton of ways to accomplish this goal.  However, I’m lazy so I’ve only included three common methods.</p>
<h4>Terminal Services and Citrix clipboards</h4>
<p>Based on my experience, Terminal Services and Citrix clipboards are left enabled to meet business requirement most of the time.  That means that as an attacker you can simply copy and paste your tools to the remote server.</p>
<h4>Web Server</h4>
<p>Don’t forget that you can simply startup your own web server and download tools via the web browser.  A lot of people like <a href="http://www.lamphowto.com/">LAMP</a> and <a href="http://www.wampserver.com/en/">WAMP</a> for the sake of simplicity, but use what you like.  Also, (as mentioned) iKat Desktop has some useful tools.</p>
<h4>FTP Server</h4>
<p>Similar to web servers, it’s easy to start up a malicious FTP server.  As we have already seen, Windows has a FTP client installed by default that can be used to pull down tools to the target system.  Also,  don’t  forget that Internet Explorer can be used as a FTP client with the “ftp://” protocol handler.</p>
<h2><a id="usefullthirdpartyapps"></a>Useful Third Party Applications</h2>
<p>There are a number of third party tools that can come in handy when breaking out of applications.  If policies and privileges are very restrictive it may be easier to simply upload your own application to do simple things like manage the registry, navigate the file system, and obtain an interactive console.  So below I’ve provide a few tools that I’ve had success with.  Also, iKat has a lot of fun options.</p>
<h4>Alterative Registry Editors</h4>
<p>Oh registry how I love thee.  If you’re looking for a few registry editors that won’t be blocked by the standard group policy then look no further.  Simpleregedit and Uberregedit are GUI tools that can be used to edit Windows registry.  Below is a basic screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_34.png"><img class="alignleft size-full wp-image-3457" alt="Scott_BreakingOut_Img_34" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_34.png" width="628" height="390" /></a></p>
<p>They can be downloaded from the links below.</p>
<ul>
<li><a href="http://sourceforge.net/projects/simpregedit/?source=recommended">http://sourceforge.net/projects/simpregedit/?source=recommended</a></li>
<li><a href="http://sourceforge.net/projects/uberregedit/">http://sourceforge.net/projects/uberregedit/</a></li>
</ul>
<h4>Alternative File System Editor</h4>
<p>I like this little single executable file explorer.  It’s fast and easy to use.  Best of all it will bypass all of the folder restrictions applied by group policy.  Below is a basic screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_35.png"><img class="alignleft size-full wp-image-3458" alt="Scott_BreakingOut_Img_35" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_35.png" width="632" height="383" /></a></p>
<p>Explorer++.exe can be downloaded from the link below.  However, be aware that there are separate executables for x64 and x86 architectures.</p>
<ul>
<li><a href="http://sourceforge.net/projects/explorerplus/files/Explorer%2B%2B/">http://sourceforge.net/projects/explorerplus/files/Explorer%2B%2B/</a></li>
</ul>
<h4>Alternative Interactive Console</h4>
<p>Console.exe may sound generic, but it gets the job done when harsh group policy restrictions are in place.  It does consist of four files, but does not need to be “installed” so it’s still very portable.   Below is a basic screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_36.png"><img class="alignleft size-full wp-image-3459" alt="Scott_BreakingOut_Img_36" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/Scott_BreakingOut_Img_36.png" width="605" height="369" /></a></p>
<p>Console.exe can be downloaded from the link below.</p>
<ul>
<li><a href="http://sourceforge.net/projects/console/">http://sourceforge.net/projects/console/</a></li>
</ul>
<h2>Wrap Up</h2>
<p>This blog has provided some insight into common break out methods that can be used for Terminal Services, Citrix, and kiosk applications.   As with any game &#8211; your offense is usually better when you have a solid understanding of the your opponent’s defensive strategy.  So I highly recommend looking at the hardening guides provided below by Microsoft and Citrix to get an understanding of what administrators are/should be doing. Hopefully using the blog and guides together will help you identify common security weakness before the bad guys do. Good luck and hack responsibly.</p>
<h2>References and Links</h2>
<ul>
<li><a href="http://www.virtualizationadmin.com/articles-tutorials/terminal-services/security/locking-down-windows-terminal-services.html">http://www.virtualizationadmin.com/articles-tutorials/terminal-services/security/locking-down-windows-terminal-services.html</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/cc264467.aspx">http://technet.microsoft.com/en-us/library/cc264467.aspx</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/cc758409(v=ws.10).aspx">http://technet.microsoft.com/en-us/library/cc758409(v=ws.10).aspx</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa767740(v=VS.85).aspx">http://msdn.microsoft.com/en-us/library/aa767740(v=VS.85).aspx</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa767731(v=VS.85).aspx">http://msdn.microsoft.com/en-us/library/aa767731(v=VS.85).aspx</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/cc848897(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/cc848897(v=vs.85).aspx</a></li>
<li><a href="http://ha.cked.net/Windows/index.html">http://ha.cked.net/Windows/index.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/05/22/breaking-out-of-applications-deployed-via-terminal-services-citrix-and-kiosks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/05/22/breaking-out-of-applications-deployed-via-terminal-services-citrix-and-kiosks/</feedburner:origLink></item>
		<item>
		<title>Patching Java Executables – The Easy Way</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/VQuQCf3lu78/</link>
		<comments>http://www.netspi.com/blog/2013/05/16/patching-java-executable-the-easy-way/#comments</comments>
		<pubDate>Thu, 16 May 2013 13:00:42 +0000</pubDate>
		<dc:creator>Khai Tran</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3409</guid>
		<description><![CDATA[&#160; &#160; &#160; The process of patching a Java executable (.jar files) without the original source code has been known for a while. As I know of, currently there are two ways of doing it: Decompile the executable &#62; Import &#8230; <br /><a class="readmore" href="http://www.netspi.com/blog/2013/05/16/patching-java-executable-the-easy-way/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The process of patching a Java executable (.jar files) without the original source code has been known for a while. As I know of, currently there are two ways of doing it:</p>
<ol>
<li>Decompile the executable &gt; Import decompiled classes to an IDE (Eclipse, NetBeans, etc.) &gt; Modify source code &gt; Recompile &gt; Repack</li>
<li>Extract Java classes from executable &gt; Modify Java Bytecode &gt; Verify &gt; Repack</li>
</ol>
<p>Method (1) has big advantage if you are already familiar Java or similar OO-styled languages. However, in practice it has two main drawbacks:</p>
<ul>
<li>Typically, the targeted jar file has dependencies to other libraries. You should be familiar with linking those dependencies to your project</li>
<li>The decompilation process is not an exact science, so expect to fix syntactical errors before getting it to recompile</li>
</ul>
<p>On one project after importing a decompiled jar file into Eclipse there are nearly 1000 syntactical errors. Going through and fixing all of it would be a pain, especially what you want to do is just edit a few lines of code.</p>
<p>In this blog post, I want to introduce to you a method (2) of patching Java. It is faster, less error-prone and quite simple to execute. I hope it will be useful for developers that are in need of patching Java. Some potential use cases are:</p>
<ul>
<li>Bypass software restrictions (license, signature, hash, etc.)</li>
<li>Patch security issues without original source code</li>
<li>Inject custom code to application</li>
</ul>
<p>In the example below, I will show you how to patch the JBoss encrypting library to use custom private key to encrypt data source strings.</p>
<h2>Background</h2>
<p>JBoss has a <strong>SecureIdentityLoginModule</strong> utility to encrypt data source password in XML configuration files. More info can be found at the <a href="https://community.JBoss.org/wiki/EncryptingDataSourcePasswords" target="_blank">JBoss Community Site</a>. In JBoss 7, the module is located in <strong>picketbox-4.0.7.Final.jar</strong></p>
<p>The actual command to encrypt the password is:</p>
<p><i>java -cp modules\org\JBoss\logging\main\JBoss-logging-3.1.0.GA.jar;modules\org\picketbox\main\picketbox-4.0.7.Final.jar  org.picketbox.datasource.security.SecureIdentityLoginModule password<br />
</i><i>Encoded password: 5dfc52b51bd35553df8592078de921bc</i></p>
<h2>Problem</h2>
<p>If you peek into the source code, the utility is using Blowfish encryption algorithm with a fixed key set to: “jaas is the way”.  There is already a tool to decrypt it located at <a href="http://usefulfor.com/security/2009/09/24/beware-of-JBoss-secureidentityloginmodule/" target="_blank">http://usefulfor.com/security/2009/09/24/beware-of-JBoss-secureidentityloginmodule/</a>.</p>
<h2>Objective</h2>
<p>The objective is to modify default private key. The key is still in the jar file and you can call the corresponding decode() function of the jar file to decrypt it anyway. Hence for a production system I would recommend switching to use  the keystore-based JaasSecurityDomainIdentityLoginModule<b> </b> instead. More information could be found at <a href="https://community.JBoss.org/wiki/EncryptingDataSourcePasswords" target="_blank">https://community.JBoss.org/wiki/EncryptingDataSourcePasswords</a>.</p>
<h2>High-level steps:</h2>
<ol>
<li>Setup the environment</li>
<li>Use JD-GUI to peek into the jar file</li>
<li>Unpack the jar file</li>
<li>Modify the .class file with a Java Bytecode Editor</li>
<li>Repack the modified classes into new archive file</li>
<li>Verify it with JD-GUI</li>
</ol>
<h2>Step 1: Setup the Java environment</h2>
<p>Most computers should have the JRE installed by default. For this tutorial, you will need to download and install the latest version of JDK. For this example, I am using JDK 6 update 35.</p>
<p>You may also need to add the JDK bin folder to your PATH environment variable. Upon completion, open up a command line console and type:</p>
<p><i>java -version</i></p>
<p>The result should look something like this:</p>
<p><i>java version &#8220;1.6.0_35&#8243;<br />
</i><i>Java(TM) SE Runtime Environment (build 1.6.0_35-b10)<br />
</i><i>Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)</i></p>
<h2>Step 2: Use JD-GUI to peek into the jar file</h2>
<p>Bytecode editors typically do not support decompiling Java executables. For that reason, I prefer to use a standalone decompiler to quickly browse decompiled classes and identify potential classes/methods. My favorite tool for this task is <a href="http://java.decompiler.free.fr/?q=jdgui" target="_blank">JD-GUI</a> (we also need it later on to verify the modified bytecode):</p>
<p><img class="alignleft  wp-image-3410" alt="KTran_Patching_Java_Img_1" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/KTran_Patching_Java_Img_1-1024x382.png" width="1024" height="382" /></p>
<p>As shown in the picture above, browsing to <strong>SecurityIdentityLoginModule</strong> reveals the default secret key used to encrypt string.</p>
<h2>Step 3: Unpack the jar file</h2>
<p>The below commands will create new directory &gt; Copy jar file &gt; Extract all the classes (note that in Windows you can use 7zip to extract them as well)</p>
<p style="padding-left: 30px;"><i>cd &lt;JBOSS_HOME&gt;\modules\org\picketbox\main<br />
</i><i>mkdir picketbox<br />
</i><i>cp picketbox-4.0.7.Final.jar picketbox<br />
</i><i>cd picketbox<br />
</i><i>jar -xf picketbox-4.0.7.Final.jar</i></p>
<h2>Step 4: Modify the .class file with a Java Bytecode Editor</h2>
<p>Download and run <a href="http://set.ee/jbe/">Java Bytecode Editor (JBE)</a></p>
<p>In this example we need to modify two methods of <strong>SecureIdentityLoginModule</strong> class<b>: </b><strong>encode()</strong> and <strong>decode()</strong>. Note that the original encryption/decryption methods only work with 16-character key. To keep it simple, I will modify default key <b>“jaas is the way”</b> to <b>“java is the way”</b> to keep the length intact.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/KTran_Patching_Java_Img_2.png"><img class="alignleft size-large wp-image-3411" alt="KTran_Patching_Java_Img_2" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/KTran_Patching_Java_Img_2-1024x430.png" width="584" height="245" /></a></p>
<h2>Step 5: Repack the jar file</h2>
<p>Take the changed class file and repack the jar file</p>
<p style="padding-left: 30px;"><i>cd picketbox<br />
</i><i>jar -cvf picketbox.jar *.*</i></p>
<h2>Step 6: Verify the changes with JD-GUI</h2>
<p>JBE tool has Code Verification feature, but in practice, I found it complains too much . Hence, I use JD-GUI again to verify correctness of the modified jar file.</p>
<p>If there’s any error in the modified class file, JD-GUI will not able to render the new jar file. If things go well, you should see your changes reflected in the patched jar file:</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/05/KTran_Patching_Java_Img_3.png"><img class="alignleft size-full wp-image-3412" alt="KTran_Patching_Java_Img_3" src="http://www.netspi.com/blog/wp-content/uploads/2013/05/KTran_Patching_Java_Img_3.png" width="1008" height="459" /></a></p>
<h2>Final test:</h2>
<p><i>java -cp modules\org\JBoss\logging\main\JBoss-logging-3.1.0.GA.jar;modules\org\picketbox\main\picketbox.jar  org.picketbox.datasource.security.SecureIdentityLoginModule password<br />
</i><i>Encoded password: 3f8c894b05a5462a4a06c734ae626874</i></p>
<p>The last step would be overwriting the patched file to the original one.</p>
<p>I hope you had fun. Thanks Steve for helping me proofread this and happy hacking!</p>
<h3>References:</h3>
<p><a href="http://set.ee/jbe/">http://set.ee/jbe/</a></p>
<p><a href="http://java.decompiler.free.fr/?q=jdgui">http://java.decompiler.free.fr/?q=jdgui</a></p>
<p><a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk6u35-downloads-1836443.html">http://www.oracle.com/technetwork/java/javase/downloads/jdk6u35-downloads-1836443.html</a></p>
<p><a href="https://community.jboss.org/wiki/EncryptingDataSourcePasswords">https://community.JBoss.org/wiki/EncryptingDataSourcePasswords</a></p>
<p><a href="http://usefulfor.com/security/2009/09/24/beware-of-jboss-secureidentityloginmodule/">http://usefulfor.com/security/2009/09/24/beware-of-JBoss-secureidentityloginmodule/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/05/16/patching-java-executable-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/05/16/patching-java-executable-the-easy-way/</feedburner:origLink></item>
		<item>
		<title>Adding PowerShell to Web Shells to get Database Access</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/rZb1WCPEHBk/</link>
		<comments>http://www.netspi.com/blog/2013/04/22/adding-powershell-to-web-shells-to-get-database-access/#comments</comments>
		<pubDate>Mon, 22 Apr 2013 13:00:09 +0000</pubDate>
		<dc:creator>Antti Rantasaari</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[Database Security]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3381</guid>
		<description><![CDATA[File upload vulnerabilities and web shells are not a novelty when talking about web application security. It’s not rare to see a web shell result in a full compromise of the web server. For example, Metasploit can generate uploadable web &#8230; <br /><a class="readmore" href="http://www.netspi.com/blog/2013/04/22/adding-powershell-to-web-shells-to-get-database-access/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>File upload vulnerabilities and web shells are not a novelty when talking about web application security. It’s not rare to see a web shell result in a full compromise of the web server. For example, Metasploit can generate uploadable web payloads that can initiate Metasploit shells. It’s also not that rare that the same web server hosts multiple web applications, all with their own back-end database connectivity.</p>
<p>I thought it would be nice to know how much data we can gain access to by simply uploading a web shell to a web server if we decided to take a step back and chose not to completely compromise it. This really becomes more practical when you’re testing an application in a QA environment and you want to show the client that access to a random QA application may grant you direct access to databases used by other applications, even critical production databases.</p>
<p>To simplify the process I rewrote an existing .aspx web shell and included PowerShell functionality to allow for database connectivity to create a new CmdSql.aspx web shell. Keep in mind that the shell only works on IIS servers that allow .aspx execution, PowerShell has to be available on the web server, and the current PowerShell code only allows connectivity to MSSQL servers. Not perfect, but nice enough for me.</p>
<p>It’s worth noting that the CmdSql shell can help in escalating an attack in tightly configured environments. If ingress and egress filtering are properly configured, normal Metasploit bind or reverse shells may not work. And if ingress filtering from the web server limits traffic to database communication, attacking databases may provide the means to escalate the attack into the internal network.</p>
<h3>CmdSQL.aspx Script Overiew</h3>
<p>The CmdSql.aspx web shell supports three different functions: OS command execution, web.config parsing, and SQL query execution. Below is an overview of the functionality and a basic screen shot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/Antti_Powershell_OS_Command_Execution.png"><img class="alignleft size-medium wp-image-3382" alt="Antti_Powershell_OS_Command_Execution" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/Antti_Powershell_OS_Command_Execution-300x195.png" width="300" height="195" /></a></p>
<h3>OS Command Execution</h3>
<p>This is really the core definition of a web shell I guess. Apart from the obvious, the command execution can be used to locate the web directories (such as C:\inetpub) and thus make locating web.configs faster for the next step. Below is a basic example screen shot.</p>
<p><img class="alignleft size-full wp-image-3385" alt="Antti_Powershell_Web_Config_Parsing" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/Antti_Powershell_Web_Config_Parsing.png" width="559" height="488" /></p>
<h3>Web.config Parsing</h3>
<p>For the sake of CmdSql.aspx, the main function of web.config is to store the database connection strings. There can be multiple connection strings for an application, and there can be multiple web.configs per server. The connection strings can be either clear text or they can be encrypted. Nevertheless, they are needed for arbitrary SQL query execution.</p>
<p>CmdSql.aspx looks for all web.config files in the provided directory and extracts all the connection strings. If the connection string is encrypted, aspnet_regiis is first used to decrypt the configuration file (in a temp folder). Aspnet_regiis is a .NET tool that is typically used to encrypt web.configs; CmdSql attempts to find to newest version of the tools to decrypt the web.config. No key or any other decryption information has to be provided to aspnet_regiis, just the file location. I haven’t done comprehensive testing / research to determine what permissions are needed to run the program, but it seems to always work on my test systems. I decided to use aspnet_regiis even though WebAdminstration snapin could probably be used and it would be “cleaner”; I just wasn&#8217;t sure if it’s installed with IIS by default or if it’s otherwise common. Below is a basic example screenshot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/Antti_Powershell_SQL_Query_Execution.png"><img class="alignleft size-full wp-image-3383" alt="Antti_Powershell_SQL_Query_Execution" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/Antti_Powershell_SQL_Query_Execution.png" width="627" height="509" /></a></p>
<h3><b>SQL Query Execution</b></h3>
<p>Now that web.configs are successfully parsed (hopefully), and the connection strings are extracted, they can be popped into a text box in the web shell and arbitrary SQL queries can be executed on targeted database server. Below is a basic screen shot example.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/Antti_Powershell_The_Code.png"><img class="alignleft size-full wp-image-3384" alt="Antti_Powershell_The_Code" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/Antti_Powershell_The_Code.png" width="639" height="517" /></a></p>
<h3><b> </b></h3>
<h3>The Code</h3>
<p>Feel free to <a href="https://github.com/NetSPI/cmdsql" target="_blank">download the CmdSql.aspx web shell and give it a shot</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/04/22/adding-powershell-to-web-shells-to-get-database-access/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/04/22/adding-powershell-to-web-shells-to-get-database-access/</feedburner:origLink></item>
		<item>
		<title>GPU Cracking: Setting up a Server</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/WICoxNb4DsA/</link>
		<comments>http://www.netspi.com/blog/2013/04/15/gpu-cracking-setting-up-a-server/#comments</comments>
		<pubDate>Mon, 15 Apr 2013 15:18:48 +0000</pubDate>
		<dc:creator>Eric Gruber</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[GPU Cracking]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3266</guid>
		<description><![CDATA[Last week Karl Fosaaen described the various trials and tribulations we went through at a hardware level in building a dedicated GPU cracking server. This week I will be doing a complete walkthrough for installing all the software that we use on our box. This includes installing the operating system , AMD drivers, oclHashcat-plus, and John the Ripper with OpenCL support. <br /><a class="readmore" href="http://www.netspi.com/blog/2013/04/15/gpu-cracking-setting-up-a-server/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>Last week <a href="http://www.netspi.com/blog/author/kfosaaen/" target="_blank">Karl Fosaaen</a> described in his <a title="blog" href="http://www.netspi.com/blog/2013/04/07/gpu-cracking-building-the-box/">blog</a> the various trials and tribulations we went through at a hardware level in building a dedicated GPU cracking server. This week I will be doing a complete walkthrough for installing all the software that we use on our box. This includes the operating system, video drivers, oclHashcat-plus, and John the Ripper. Because we have AMD video cards, the driver installation and compiling John the Ripper sections will be tailored for AMD, sorry Nvidia users.</p>
<h2>Installing the OS:</h2>
<p>For an operating system, Linux and Windows are going to be the way to go. For a headless server however, Linux is the best way to go. The only downside with Linux is that driver support among video cards, especially AMD, is somewhat lacking to its Windows counterpart. However, the good news is that both AMD and Nvidia have been increasing their support for Linux drivers in recent years.</p>
<p>Any Linux distribution will do, but for our server, we opted for Ubuntu 12.10 64-Bit server edition to do the most minimal setup. Much of the information for the next few sections is from the <a href="http://hashcat.net/wiki/doku.php?id=linux_server_howto" target="_blank">hashcat wiki</a>.</p>
<p>To start off, download the Ubuntu 12.10 server edition ISO from <a href="http://www.ubuntu.com/download/server" target="_blank">Ubuntu</a>. We don’t have a cd drive on our server, so we had to copy the ISO to a flash drive. <a href="http://www.pendrivelinux.com/yumi-multiboot-usb-creator/" target="_blank">YUMI</a> and <a href="http://unetbootin.sourceforge.net/" target="_blank">UNetbootin</a> make this process painless on Windows and Linux, respectfully. Otherwise, the ISO can be burned to a disc.</p>
<p>Boot up the Ubuntu image, choose your language, and select Install Ubuntu Server.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_1.png"><img class="alignnone size-full wp-image-3267" alt="EricG_GPU_Server_Set_Up_Ubuntu_1" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_1.png" width="644" height="484" /></a></p>
<p>Navigate through the installation options and select your preferences. For most people, the defaults should be sufficient. Then create your user when the dialog comes up. When the installation reaches the “Partition Disks” section, either manually set them up (if you know what you’re doing) or just use the “Guided – use entire disk” option. We choose not to use LVM on our box, but the option is up to you.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_2.png"><img class="alignnone size-full wp-image-3268" alt="EricG_GPU_Server_Set_Up_Ubuntu_2" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_2.png" width="803" height="595" /></a></p>
<p>After you are done partitioning your hard drive, write the changes to the disc. If you have an HTTP proxy, enter the information when the dialog appears. If not, then just continue. Next, select if you would like to have automatic updates enabled. We opted not to, but it&#8217;s entirely up to you. When the software selection appears, select OpenSSH server by navigating to it with the arrow keys and pressing spacebar to select the option.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_7.png"><img class="alignnone size-full wp-image-3355" alt="EricG_GPU_Server_Set_Up_Ubuntu_7" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_7.png" width="791" height="592" /></a></p>
<p>None of the other packages are required unless you need them. Press enter to install the software. When the installation is finished, install GRUB to the master boot record and reboot. You should now be booted into your new Ubuntu server!</p>
<h2>Setting Up Ubuntu:</h2>
<p>Before we install the video drivers, we have to setup our Ubuntu server with X11. This is because the AMD drivers require X11 to interact with video cards to obtain fan speeds and GPU temps, which are very important to know when cracking away.</p>
<p>To begin, ssh into your server and update Ubuntu with the following command:</p>
<p><code><strong>sudo apt-get update &amp;&amp; sudo apt-get upgrade</strong></code></p>
<p>After Ubuntu has updated, we will need to install a minimal X11 environment that our user can automatically login to when the server is rebooted. This is to ensure that the xserver will always be running and in turn allow continuous cracking without any hiccups.</p>
<p>To keep it simple, a light weight window manager is recommend. Openbox, fluxbox, and blackbox are three simple light weight window managers that we can use. You are by no means restricted to a window manager. If you want gnome, xfce, or kde, those can be installed too. For this installation, we will install fluxbox with lightdm as the display manager. To install these, run the following command:</p>
<p><code><strong>sudo apt-get install fluxbox lightdm-gtk-greeter x11-utils</strong></code></p>
<p>This should install all the necessary packages for an X11 environment to run. Now that we have an X11 environment installed, we need to let applications from the console know which display we are using. To do this, we set the DISPLAY variable to our current display. The format for the DISPLAY variable is hostname:display. For a local instance, the hostname can be omitted. The default display is usually going to be 0. Run the command below to set your current display to 0.</p>
<p><code><strong>export DISPLAY=:0</strong></code></p>
<p>Add the above command to your bashrc to make it persistent whenever your user logs in. I have run into many issues because I did not have this set. So make sure your bashrc is setup with your correct display location.</p>
<p>Now that our X11 environment is setup, we can install the AMD drivers.</p>
<h2>Installing AMD Drivers:</h2>
<p>To begin installing the AMD drivers, we need to install some prerequisites. First install unzip with the following command</p>
<p><code><strong>sudo apt-get install unzip</strong><br />
</code><br />
Next, we need to install the dependencies for fglrx, which is the proprietary Linux driver for AMD on Ubuntu&#8217;s repositories. The only difference between fglrx and AMD&#8217;s Catalyst drivers is that the latter is newer, but they both require the same dependencies. Run the following command to install the fglrx dependencies:</p>
<p><code><strong>sudo apt-get build-dep fglrx</strong></code></p>
<p>If the fglrx dependencies are not installed, the AMD driver installation will fail with this fglrx error:</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_3.png"><img class="alignnone size-full wp-image-3347" alt="EricG_GPU_Server_Set_Up_Ubuntu_3" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_3.png" width="1012" height="628" /></a></p>
<p>Now we can grab the latest version of the AMD Catalyst drivers from the <a href="http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx" target="_blank">AMD Catalyst™ Proprietary Display Driver page</a>.</p>
<p>The latest version at this time is 13.1. It should also be noted that oclHashCat-plus requires a specific version of Catalyst installed, which at this point is 13.1. So we’re good there.</p>
<p>Fetch the AMD driver with wget and then unzip it:</p>
<p><code><strong>wget http://www2.ati.com/drivers/linux/amd-driver-installer-catalyst-13.1-linux-x86.x86_64.zip</strong></code></p>
<p><code><strong>unzip amd-driver-installer-catalyst-13.1-linux-x86.x86_64.zip</strong></code></p>
<p>There should now be a .run file in the directory. Execute the file while running as root.</p>
<p><code><strong>sudo sh amd-driver-installer-catalyst-13.1-linux-x86.x86_64.run</strong></code></p>
<p>Select the default options on all the dialog boxes and let the driver install.</p>
<p>After it is done, create a new xorg.conf by running:</p>
<p><code><strong>sudo amdconfig --adapter=all --initial -f</strong></code></p>
<p>Then we are going to setup our user to automatically login to fluxbox when the server boots up.</p>
<p>Open the lightdm.conf file in /etc/lightdm/ as root and add the following lines:</p>
<p><code>[SeatDefaults]<br />
greeter-session=lightdm-gtk-greeter<br />
user-session=fluxbox<br />
autologin-user=USER<br />
autologin-user-timeout=0</code></p>
<p>Reboot the server and your user should be automatically logged into fluxbox.</p>
<p>When the server boots up run <code><strong>amdconfig --list-adapters</strong></code> and <code><strong>amdconfig --adapter=all --odgt</strong></code> to verify that all your cards and their temperatures can be seen.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_9.png"><img class="alignnone size-full wp-image-3363" alt="EricG_GPU_Server_Set_Up_Ubuntu_9" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_9.png" width="433" height="355" /></a></p>
<p>Now that the AMD drivers are installed, we can install our cracking software.</p>
<h2>Installing oclHashcat-plus</h2>
<p><a href="http://hashcat.net/oclhashcat-plus/" target="_blank">Download the latest oclHashcat-plus</a>. We will just wget the latest version to our box.</p>
<p><code><strong>wget http://hashcat.net/files/oclHashcat-plus-0.14.7z</strong></code></p>
<p>oclHashcat-plus comes in a 7z format. So we need to install p7zip to extract it.</p>
<p><code><strong>sudo apt-get install p7zip</strong></code></p>
<p>Run p7zip with the –d flag to extract a 7z file.</p>
<p><code><strong>p7zip -d oclHashcat-plus-0.14.7z</strong><br />
</code><br />
Navigate to the newly extracted ocl directory and run one of the Example.sh scripts to test run the cracking process.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_5.png"><img class="alignnone size-full wp-image-3349" alt="EricG_GPU_Server_Set_Up_Ubuntu_5" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_5.png" width="737" height="716" /></a></p>
<p>If all goes well you should see your cards loading up and the hash getting cracked! If you do not see all your cards being recognized, make sure that your xorg.conf was created properly. Try running the amdconfig command above again to regenerate an xorg.conf.</p>
<p>Next we will install John the Ripper with OpenCL support</p>
<h2>Installing John the Ripper</h2>
<p>Like oclHashcat-plus, John also supports cracking hashes on GPUs, but it must be compiled with the options to do so. Much of the information here is taken from the john GPU wiki (http://openwall.info/wiki/john/GPU).</p>
<p>First <a href="http://developer.amd.com/tools/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/downloads/" target="_blank">download the Accelerated Parallel Processing SDK from AMD</a>. 32 bit and 64 bit are supported, so make sure you download the correct one for your architecture.</p>
<p>Copy the file to your server with scp or if you&#8217;re on Windows, WinSCP.</p>
<p>Next, extract the APP SDK file.</p>
<p><code><strong>tar xvf AMD-APP-SDK-v2.8-lnx64.tgz</strong></code></p>
<p>Then run the <strong>Install-AMD-APP.sh</strong> as root.</p>
<p><code><strong>sudo ./Install-AMD-APP.sh</strong></code></p>
<p>Reboot the server.</p>
<p>After the APP SDK has been installed, <a href="http://www.openwall.com/john/" target="_blank">download the latest version of John</a>. We will be using the jumbo version.</p>
<p><code><strong>wget http://www.openwall.com/john/g/john-1.7.9-jumbo-7.tar.gz</strong></code></p>
<p>Extract john with the following command:</p>
<p><code><strong>tar xvf john-1.7.9-jumbo-7.tar.gz</strong></code></p>
<p>Next, install the libssl-dev package from apt-get so that John compiles correctly.</p>
<p><code><strong>sudo apt-get install libssl-dev</strong></code></p>
<p>Navigate to the john src directory. Compile john with OpenCL for either 32 bit or 64 bit with <code><strong>make linux-x86-opencl</strong></code> and <code><strong>make linux-x86-64-opencl</strong></code> respectfully. John can also be compiled with CUDA support if you have Nvidia cards. The information on how to do that is located on their wiki.</p>
<p>If you get openssl headers not found during compilation, install the libssl-dev package.</p>
<p>Navigate back to the run directory and your newly compiled john binary should be there. You can test that John can use your GPUs by running a test command.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_6.png"><img class="alignnone size-full wp-image-3350" alt="EricG_GPU_Server_Set_Up_Ubuntu_6" src="http://www.netspi.com/blog/wp-content/uploads/2013/04/EricG_GPU_Server_Set_Up_Ubuntu_6.png" width="659" height="176" /></a></p>
<h2>Conclusion</h2>
<p>This is guide details one of many possible setups for a GPU cracking server. When all is done, our cracking server built with these specifications works very well. Next week we will be benchmarking, extracting, and providing strategies for cracking several different types of hashes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/04/15/gpu-cracking-setting-up-a-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/04/15/gpu-cracking-setting-up-a-server/</feedburner:origLink></item>
		<item>
		<title>GPU Cracking: Building the Box</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/qvhZpKR6jvk/</link>
		<comments>http://www.netspi.com/blog/2013/04/07/gpu-cracking-building-the-box/#comments</comments>
		<pubDate>Sun, 07 Apr 2013 12:00:20 +0000</pubDate>
		<dc:creator>Karl Fosaaen</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[GPU Cracker]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3246</guid>
		<description><![CDATA[This winter, we decided to create our own dedicated GPU cracking solution to use for our assessments. It was quite the process, but we now have a fully functional hash cracking machine that tears through NTLMs at roughly 25 billion hashes per second (See below). While attempting to build this, we learned a lot about pushing the limits of consumer-grade hardware. <br /><a class="readmore" href="http://www.netspi.com/blog/2013/04/07/gpu-cracking-building-the-box/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<h2>Intro</h2>
<p>This winter, we decided to create our own dedicated GPU cracking solution to use for our assessments. It was quite the process, but we now have a fully functional hash cracking machine that tears through NTLMs at roughly 25 billion hashes per second (See below). While attempting to build this, we learned a lot about pushing the limits of consumer-grade hardware.</p>
<h2>Goals</h2>
<p>We set out to build a cracking rig with four high end video cards (AMD Radeon HD 7950) to run <a href="http://hashcat.net/oclhashcat-plus/" target="_blank">oclHashcat</a>. We also wanted this solution to be rack mountable, so that it would be easy to store in our data center. As it turns out, there are not a ton of video card friendly server cases. We were only able to find a few GPU cracking friendly cases, but most of them cost more than the rest of our cracking hardware combined. If you have the money to spend, we would recommend going with the special case to save yourself from other issues, but this isn&#8217;t really an option for everyone. The reason why we recommend this is that the cards themselves do not take well to being lined up all together on a standard ATX motherboard. The fans tend to stick out further than they should and end up hitting the next card in the row. On top of that, the cramped conditions lead to overheating cards and cracking jobs stopping. The specialized cases have enough space to avoid these issues, making it easier to set up a box.</p>
<p>We opted for an “open air” configuration for our cracking box. This was primarily driven by trying to mimic the setups of bitcoin mining rigs that we had seen online. I will say that this is not the prettiest option for housing all of these cards. However, it is one of the most efficient ways to space the cards out for cooling. With the “open air” setup, we’re able to connect riser cables to two of the cards and keep the other two cards down on the board. These riser cables can have their own problems. We ended up opting for one (16x to 1x) riser cable and a different (16x to 16x) riser cable that has some modifications for voltage. The 16x to 16x cable has a 12 volt molex adapter soldered to the 12 volt pins on the riser slot.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/GPU_Cracker_Blog_1_A.png"><img class="alignleft size-full wp-image-3247" alt="GPU_Cracker_Blog_1_A" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/GPU_Cracker_Blog_1_A.png" width="416" height="521" /></a></p>
<p>While this looks a little hackish, it actually works quite well. We had to do this to supplement the voltage from the motherboard, as it was unable to pull proper voltage for all four cards (with two riser cables). I should also mention that there is some crafty engineering taking place to suspend the two cards above the board. This was accomplished with several zip ties and a modified piece of wire-mesh shelving.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/GPU_Cracker_Blog_1_B-e1364585100361.png"><img class="alignleft size-full wp-image-3248" alt="GPU_Cracker_Blog_1_B" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/GPU_Cracker_Blog_1_B-e1364585100361.png" width="506" height="379" /></a></p>
<p>I should also note that this whole rig is tied down (with stand-offs) to an old rack mount shelf. All in all, this setup works quite well. We can have all four cards running at full speed and the the hottest card will top out at 85° Celsius. We’re very aware of the fact that this looks insane. It’s hopefully a temporary solution. Eventually, we’re looking at securing a single rail to the rack to screw the cards into.</p>
<p>As for performance, here’s our current averages for hash cracking (OCL in Brute-Force mode):</p>
<p style="padding-left: 30px;">MD5 &#8211; ~16000.0M/s<br />
NTLM &#8211; ~25500.0 M/s<br />
SHA1 &#8211; ~7900.0M/s</p>
<p> <a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/GPU_Cracker_Blog_1_C.png"><img class="alignleft size-full wp-image-3249" alt="GPU_Cracker_Blog_1_C" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/GPU_Cracker_Blog_1_C.png" width="738" height="483" /></a></p>
<h2>5 Tips for Building Your Own</h2>
<p>So if you’re planning on putting together your own GPU cracking rig, here’s some steps that you may want to take to make it easier.</p>
<ol>
<li>Look into a nice GPU server case and motherboard combo like this one <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16816152125" target="_blank">http://www.newegg.com/Product/Product.aspx?Item=N82E16816152125</a>
<ol>
<li>These will be spendy (~$3,500+ for the combo, cards not included) but they are meant for this kind of setup.</li>
</ol>
</li>
<li>Look at what the bitcoin miners are doing.
<ol>
<li>Our “open-air” setup is actually pretty similar to most mining rigs that I can find.</li>
<li>Replicate their parts list for your setup, if it works for them, it “should” work for you.</li>
</ol>
</li>
<li>Plan everything out as best you can.
<ol>
<li>From components and case layout to power and cooling requirements.</li>
<li>Measure twice and cut once to avoid returns, repairs, and rebuying parts.</li>
</ol>
</li>
<li>Devote a resource to the project
<ol>
<li>Intern not busy enough? Have them build the cracking machine.</li>
<li>Find the person that plays more PC games than you.
<ol>
<li>They may know more about the cards and multi-GPU setups.</li>
</ol>
</li>
</ol>
</li>
<li>Don’t get discouraged if your set up isn’t working.
<ol>
<li>We didn’t get it right on the first try, but we eventually got there.</li>
</ol>
</li>
</ol>
<p>Check out <a title="GPU Cracking: Setting up a Server" href="http://www.netspi.com/blog/2013/04/15/gpu-cracking-setting-up-a-server/">GPU Cracking: Setting up the Server</a> by Eric Gruber on how to configure your cracking box to see all of the cards and run the cracking software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/04/07/gpu-cracking-building-the-box/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/04/07/gpu-cracking-building-the-box/</feedburner:origLink></item>
		<item>
		<title>Certificate Pinning in a Mobile Application</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/IpaWOzK3dgw/</link>
		<comments>http://www.netspi.com/blog/2013/04/01/certificate-pinning-in-a-mobile-application/#comments</comments>
		<pubDate>Mon, 01 Apr 2013 12:00:14 +0000</pubDate>
		<dc:creator>Steve Kerns</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[Certificate Pinning]]></category>
		<category><![CDATA[Man in the Middle]]></category>
		<category><![CDATA[Mobile Applications]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3226</guid>
		<description><![CDATA[Many times during our mobile application penetration testing, we are finding the applications are vulnerable to man-in-the-middle attacks (MITM). Certificate pinning is one part of the answer to MITM attacks in a mobile application. For those who do not know &#8230; <br /><a class="readmore" href="http://www.netspi.com/blog/2013/04/01/certificate-pinning-in-a-mobile-application/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>Many times during our mobile application penetration testing, we are finding the applications are vulnerable to <a href="http://en.wikipedia.org/wiki/Man-in-the-middle_attack" target="_blank">man-in-the-middle attacks</a> (MITM). Certificate pinning is one part of the answer to MITM attacks in a mobile application. For those who do not know about certificate pinning, this is not pinning your CISSP certificate to the wall.</p>
<p><strong>What is it?</strong></p>
<p>Certificate pinning is hardcoding or storing the information for digital certificates/public keys in a mobile application. Since the predefined certificates are used for secure communication, all others will fail, even if the user trusted other certificates.</p>
<p>In a mobile application, the application knows what servers they will connect to, so that the application can check for those specific certificates.  A browser cannot implement certificate pinning, since it is designed for general-purpose communication.</p>
<p><strong>What happens during an SSL Connection?</strong></p>
<p>When an application sees an SSL certificate from a server, it should verify two things:</p>
<ol>
<li>The certificate signed by a root certificate authority (CA)</li>
<li>The server&#8217;s name (via DNS) matches the Common Name (CN) presented in the SSL certificate</li>
</ol>
<p>In the case where these do not match, the application (or browser) throws up a warning and lets the user decide what to do. In many cases, the general user population will not understand the warning and just decide to accept the invalid certificate.</p>
<p><strong>What are we trying to do by certificate pinning?</strong></p>
<p>The idea is to prevent a man in the middle attack. This allows the attacker to get in the middle of the conversation between a client and server. They could be just eavesdropping on the conversation or could be changing the data as it moves to the client or server.</p>
<p>An attacker who gains control of a user’s operating system can install trusted root Certificate Authorities.  These root CAs will be able to sign new certificates, which will satisfy SSL validation procedures.  Certificate pinning prevents this by ensuring a specific server public key is used to initiate secured traffic.</p>
<p><strong>How do we implement certificate pinning?</strong></p>
<p>Distribute the server’s public key with the application.  Any time the application begins an SSL exchange with the server, validate that the traffic has been encrypted with the same key that matches the public key included with the app.  This takes the CA system out of the equation and assuming it is the correct certificate, the names do match.</p>
<p><strong>Is there a way to break certificate pinning?</strong></p>
<p>An attacker would have to decompile the application, change the code, rebuild it and redeploy the application. Another option would be to run the application in a debugger.</p>
<p>For Android, you can obfuscate your code. You can also check to see if the application is running in a debugger.  Code signing will also make it more difficult for an attacker to create an unauthorized patch for your application.</p>
<p>For iOS, see <a href="http://developer.apple.com/library/mac/#qa/qa1361/_index.html" target="_blank">Detecting the Debugger</a></p>
<p>For Android, see <a href="http://android-developers.blogspot.com/2010/09/securing-android-lvl-applications.html" target="_blank">Securing Android LVL Applications</a></p>
<p>Neither of the above options are perfect, but they do help. Both of these methods make the attacker&#8217;s job harder, but not impossible.</p>
<p><strong>Where else can I find information on this?</strong></p>
<p>OWASP provides some information and sample code:<br />
<a href="https://www.owasp.org/index.php/User_Privacy_Protection_Cheat_Sheet" target="_blank">User Privacy Protection Cheat Sheet</a>  and <a href="https://www.owasp.org/index.php/Pinning_Cheat_Sheet" target="_blank">Pinning Cheat Sheet</a></p>
<p>Moxie Marlinspike provides good information for an Android on his blog:<br />
<a href="http://www.thoughtcrime.org/blog/authenticity-is-broken-in-ssl-but-your-app-ha/" target="_blank">Your app shouldn&#8217;t suffer SSL&#8217;s problems </a></p>
<p>iSecPartners provides other information for iOS:<br />
<a href="https://www.isecpartners.com/news-events/news/2013/february/ssl-pinning.aspx" target="_blank">SSL Pinning on iOS</a></p>
<p>&#8212;&#8212;</p>
<p><span style="color: #b50937;"><strong>Be sure to check out author Steve Kern&#8217;s webinar on <a href="http://youtu.be/bH7D7hEuIQE" target="_blank"><span style="color: #b50937;">Securing Your Mobile Applications</span></a></strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/04/01/certificate-pinning-in-a-mobile-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/04/01/certificate-pinning-in-a-mobile-application/</feedburner:origLink></item>
		<item>
		<title>Attacking Restricted Linux Shells</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/53I5z923U2Q/</link>
		<comments>http://www.netspi.com/blog/2013/03/25/attacking-restricted-linux-shells/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 12:00:05 +0000</pubDate>
		<dc:creator>Michael Anderson</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[breakout]]></category>
		<category><![CDATA[chroot jail]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3213</guid>
		<description><![CDATA[Lately, I&#8217;ve been working with some older technologies, and I&#8217;ve gotten to play with some of the restricted access shells that used to be popular. Many older appliances used to include an sshd that allowed users into a chroot jail &#8230; <br /><a class="readmore" href="http://www.netspi.com/blog/2013/03/25/attacking-restricted-linux-shells/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>Lately, I&#8217;ve been working with some older technologies, and I&#8217;ve gotten to play with some of the restricted access shells that used to be popular. Many older appliances used to include an sshd that allowed users into a chroot jail with restricted access to binaries. This was done in an attempt to allow the user to access the appliance’s functionality without exposing the internal workings of the application. Fortunately, many chroot jails fail to properly set some essential security bits, assuming that restricting binaries is enough to keep users out of the real filesystem, while also giving users root access to their chroot jail. With just these three things, you can break out of any chroot jail:</p>
<ol>
<li>Root access – you’ll need root access *inside* your chroot jail to execute a breakout. This is the weakest link here, but many chroot jails have been improperly configured, as root privileges are used to access the application functionality that the shell is supposed to expose.</li>
<li>The echo utility – this is built in to several shells, so you can rely on this in many situations.</li>
<li>A file that you have both write and execute privileges on – if the chroot jail has been properly secured you won’t have access to chmod, but check the filesystem for these privileges. This will allow you to get your breakout on the filesystem and to execute it.</li>
</ol>
<p>Now for the juicy bit. To break out of your jail, the basic steps are pretty simple. Determine if you have chmod available inside your chroot jail. If you don’t, search for a file with both write and execute privileges . You can use find –executable –writable or ls –lR / | grep wx to search entire partitions for these files. This might be difficult if you don’t have find or grep, but you can check common locations for executables like /bin/. Remember the path of this file, as you’ll have to overwrite it later.</p>
<p>Spin up a VM with the same kernel as the machine hosting the chroot jail you’re targeting. Grab code for a chroot jail (<a href="http://www.bpfh.net/simes/computing/chroot-break.html" target="_blank">there are examples all over the internet</a>). For the purposes of this demonstration, I’ve put my code into breakout.c. All this code does is create a file descriptor for the current directory and then makes a new chroot jail in a subdirectory. Since the program has saved a file descriptor to a directory outside this new sub-chroot jail, the program will use fchdir to hop back out of the new chroot jail and onto the main directory structure. Then it cd’s all the way back up to the real root where it execs a new shell. Use gcc to compile the code into a binary on your VM. Use hexdump with the command below to dump the binary into the format you’ll need. This command works just like a C printf statement:</p>
<p style="padding-left: 30px;">hexdump -ve &#8216;&#8221;\\\x&#8221; 1/1 &#8220;%02x&#8221;&#8216; bin.o &gt; echo_this</p>
<p>Copy the contents of the file echo_this, and paste them into an echo command inside the chroot jail:</p>
<p style="padding-left: 30px;">Echo –ne \x7f\x45\x4c\x46… &gt; name_of_file_from_first_step (ie: /bin/writeableBinary)</p>
<p>Finally, you can just execute the file you&#8217;ve just overwritten to escape the jail. This will provide you with a root shell on the complete file system of the machine you were jailed in earlier.</p>
<p>Preventing this is actually pretty simple, and just relies on some linux security basics that sometimes get neglected in these chroot jails. Don’t let the user run as root, if you can avoid it. If a user has to run as root, restrict access to binaries, and make sure there aren&#8217;t any files that they have both write and execute permissions on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/03/25/attacking-restricted-linux-shells/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/03/25/attacking-restricted-linux-shells/</feedburner:origLink></item>
		<item>
		<title>Hacking High Scores in iOS GameCenter</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/KNbJqVU97_k/</link>
		<comments>http://www.netspi.com/blog/2013/03/18/hacking-high-scores-in-ios-gamecenter/#comments</comments>
		<pubDate>Mon, 18 Mar 2013 12:00:27 +0000</pubDate>
		<dc:creator>Karl Fosaaen</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[Burp]]></category>
		<category><![CDATA[GameCenter]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacking gamecenter scores]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iOS traffic interception]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3173</guid>
		<description><![CDATA[I recently wrote a blog post about cracking email hashes from the iOS GameCenter application. During my research on the issue, I noticed that there were a number of games where users had insanely high scores. Lots of the users also had the exact same score (9,223,372,036,844,775,807) for each of the games that they played. Coincidentally this number is the largest possible signed integer value that you can have. It turns out that getting these high scores isn't that hard to do. <br /><a class="readmore" href="http://www.netspi.com/blog/2013/03/18/hacking-high-scores-in-ios-gamecenter/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>I recently wrote a blog post about <a href="http://www.netspi.com/blog/2013/02/11/know-your-opponent-an-inference-attack-against-ios-game-center/" target="_blank">cracking email hashes from the iOS GameCenter</a> application. During my research on the issue, I noticed that there were a number of games where users had insanely high scores. Lots of the users also had the exact same score (9,223,372,036,844,775,807) for each of the games that they played. Coincidentally this number is the largest possible signed integer value that you can have. It turns out that getting these high scores isn&#8217;t that hard to do.</p>
<h2><b>Setup</b></h2>
<p>In order to modify our scores, we will need to <a href="http://portswigger.net/burp/proxy.html" target="_blank">proxy our iOS traffic through Burp</a>. In order to properly intercept the encrypted iOS traffic, you will also need to <a href="http://portswigger.net/burp/help/proxy_options_installingCAcert.html#iphone" target="_blank">install the Portswigger certificate on your iOS device</a></p>
<p>At this point, you will want your Burp listener to be on the same wireless network as your iOS device. You also need to have your Burp listener set to listen on all interfaces to allow your iOS device to proxy through it.</p>
<p>The iOS proxy settings are fairly easy to set up. Just enter your Wi-Fi settings, tap on the blue and white arrow-in-a-circle (to the right of your SSID), and scroll down to your HTTP Proxy settings. Set the server IP to your Burp listener and set your port to the Burp listener port. Visit an https website on your iOS device to see if the Portswigger certificate is properly installed. If you don’t have any issues (or SSL warnings), you should be ready to go.</p>
<h2><b>Modifying Scores</b></h2>
<p>Once your iOS device is properly proxying traffic through your Burp listener, you will want to generate a score to post to GameCenter. For most games, this is not very hard to do. We will be using “<a href="https://itunes.apple.com/us/app/cut-the-rope/id380293530?mt=8" target="_blank">Cut the Rope</a>”as our example. Open up the first level, set Burp to intercept traffic, and complete the level (you cut one rope, it’s really easy). At this point you will see the “Level Complete” screen on your iOS device and the following request will come through Burp.</p>
<blockquote><p>POST /WebObjects/GKGameStatsService.woa/wa/submitScores HTTP/1.1<br />
Host: service.gc.apple.com<br />
User-Agent: gamed/4.10.17.1.6.13.5.2.1 (iPhone4,1; 6.1.2; 10B146; GameKit-781.18)<br />
Accept-Language: en-us<br />
Accept-Encoding: gzip, deflate<br />
Accept: */*<br />
Some-Cookies: have been removed to make this shorter<br />
Content-Type: application/x-apple-plist<br />
Connection: keep-alive<br />
Proxy-Connection: keep-alive<br />
x-gk-bundle-version: 2.1<br />
Content-Length: 473<br />
x-gk-bundle-id: com.chillingo.cuttherope</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;!DOCTYPE plist PUBLIC &#8220;-//Apple//DTD PLIST 1.0//EN&#8221; &#8220;http://www.apple.com/DTDs/PropertyList-1.0.dtd&#8221;&gt;<br />
&lt;plist version=&#8221;1.0&#8243;&gt;<br />
&lt;dict&gt;</p>
<p style="padding-left: 30px;">&lt;key&gt;scores&lt;/key&gt;<br />
&lt;array&gt;<br />
&lt;dict&gt;<br />
&lt;key&gt;category&lt;/key&gt;<br />
&lt;string&gt;1432673794&lt;/string&gt;<br />
&lt;key&gt;context&lt;/key&gt;<br />
&lt;integer&gt;0&lt;/integer&gt;<br />
&lt;key&gt;score-value&lt;/key&gt;<br />
<b>&lt;integer&gt;12345&lt;/integer&gt;</b><br />
&lt;key&gt;timestamp&lt;/key&gt;<br />
&lt;integer&gt;1361998342937&lt;/integer&gt;<br />
&lt;/dict&gt;<br />
&lt;/array&gt;</p>
<p>&lt;/dict&gt;<br />
&lt;/plist&gt;</p></blockquote>
<p>If you are seeing other requests come through, just forward them and keep your eye out for the request for the “submitScores” page.</p>
<p>Before forwarding the score on to Apple, you will want to modify the score. The highest possible value that you can submit is 9,223,372,036,844,775,807. Replace the “score-value” stored in the &lt;integer&gt; tags (bolded in the example) with 9223372036844775807 and forward the request. You should receive a “status 0” response from Apple and your score will be updated in GameCenter.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/GameCenter-Blog-Cut-The-Rope.png"><img class="alignleft size-full wp-image-3176" alt="GameCenter Blog Cut The Rope" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/GameCenter-Blog-Cut-The-Rope.png" width="617" height="461" /></a></p>
<h2 style="text-align: left;" align="center"><b>Conclusion</b></h2>
<p>I don’t intend on modifying my high scores for each of my GameCenter games. I really don’t care that much about the scores, but some people do. Given Apple’s current model for GameCenter leaderboards, this may not be an easy fix. At a minimum, Apple may want to do some checking on these high scores to weed out any of the users that are maxing out their top scores. For now, I’m going to put the iPhone down and get some work done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/03/18/hacking-high-scores-in-ios-gamecenter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/03/18/hacking-high-scores-in-ios-gamecenter/</feedburner:origLink></item>
		<item>
		<title>Resources for Aspiring Penetration Testers</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/1kX8O7wqSus/</link>
		<comments>http://www.netspi.com/blog/2013/03/11/resources-for-aspiring-penetration-testers/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 12:00:19 +0000</pubDate>
		<dc:creator>Scott Sutherland</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[penetration testing]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3183</guid>
		<description><![CDATA[At some point, all penetration testers get asked, “Where did you learn all this stuff?” In my experience, the question often comes from clients and students interested in pen testing. Usually, they’re asking because they aren’t sure where to start. There are a number of two- and four-year college programs that can provide a nice structured approach, but generally I think penetration testing is like any other skillset; if you find the right resources, a good direction, and study hard, you’ll acquire the skills you’re looking for. However, I will say that it does help to already have a strong IT background. <br /><a class="readmore" href="http://www.netspi.com/blog/2013/03/11/resources-for-aspiring-penetration-testers/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>At some point, all penetration testers get asked, “Where did you learn all this stuff?” In my experience, the question often comes from clients and students interested in pen testing. Usually, they’re asking because they aren’t sure where to start. There are a number of two- and four-year college programs that can provide a nice structured approach, but generally I think penetration testing is like any other skillset; if you find the right resources, a good direction, and study hard, you’ll acquire the skills you’re looking for. However, I will say that it does help to already have a strong IT background.</p>
<p>Regardless of the path taken, it’s nice to have some decent resources along the way. In this blog, I’ve put together a list of books and online training resources that cover topics and skills that I’ve found useful as a penetration tester. Hopefully the list is also useful to those of you interested in getting your feet wet. Have fun and Hack Responsibly!</p>
<h2><b>Recommended Books</b></h2>
<p>Read, read, and read some more. Recommending that people “<i>Read the F***ing Manual</i>” (RTMF) is just as important today as it was 20 years ago. The list below is really directed at specific tasks that most penetration testers have to perform. I’m aware that there are some obvious gaps in the list, but I haven’t found any books that I really love related to privilege escalation, network attacks, AV evasion, or penetration testing as a profession. Regardless, I hope you enjoy the books as much as I have.</p>
<ol>
<li><b><b><a href="http://www.amazon.com/The-Web-Application-Hackers-Handbook/dp/1118026470/ref=sr_1_1?ie=UTF8&amp;qid=1360960238&amp;sr=8-1" target="_blank">Web Application Hacker’s Handbook 2nd Edition</a></b></b>
<p>Every penetration tester should have a copy of this book. It has good coverage on a lot of web application attack methods with an emphasis on Burp Suite, which a very robust local HTTP proxy.</li>
<li><b style="color: #333333; font-style: normal;"><b style="color: #333333; font-style: normal;"><a href="http://www.amazon.com/Injection-Attacks-Defense-Second-Edition/dp/1597499633/ref=sr_1_sc_1?s=books&amp;ie=UTF8&amp;qid=1360960340&amp;sr=1-1-spell" target="_blank">SQL Injection Attack and Defense</a></b></b>
<p>This book is very complimentary to the Web Application Hacker’s Hand Book. It provides a pretty straightforward approach for identifying and exploiting SQL injection flaws on common database platforms. As a side note, I also recommend playing with Burp Suite and SQLMap while learning how to perform SQL injection attacks.</li>
<li><b><b><a href="http://www.amazon.com/Web-Application-Obfuscation-WAFs-Evasion-Filters-alert/dp/1597496049/ref=sr_1_sc_1?s=books&amp;ie=UTF8&amp;qid=1361561286&amp;sr=1-1-spell&amp;keywords=web+applicatoin+obfscation" target="_blank">Web Application Obfuscation</a></b></b>
<p>This book is also complimentary to the Web Application Hacker’s Hand Book and SQL Injection Attack and Defense. It provides a decent overview of techniques that can be used to essentially hide your attacks from web application firewalls, intrusion prevention systems, and web application input filters.</li>
<li><b><b><a href="http://www.amazon.com/Database-Hackers-Handbook-Defending-Servers/dp/0764578014/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1360960321&amp;sr=1-1&amp;keywords=Database+hackers+handbook" target="_blank">Database Hacker’s Handbook</a></b></b>
<p>This is an oldie but a goody. It provides some great coverage on how to attack the common database platforms. This can come in handy if you’re hoping to escalate your privileges on the database level after finding an SQL injection issue.</li>
<li><b><b><a href="http://www.amazon.com/Managed-Code-Rootkits-Hooking-Environments/dp/1597495743/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1360960293&amp;sr=1-1&amp;keywords=Managed+Code+Rootkits" target="_blank">Managed Code Rootkits</a></b></b>
<p>This book provides manual and automated methods for reverse engineering managed code applications and frameworks. It covers the .NET framework, Java RTE., and Dalvik applications. I thought it was interesting because it has a large focus on actually poisoning the frameworks instead of the application directly. However, it should be noted that this book does not focus on advanced debugging techniques like most reversing books.</li>
<li><b><b><a href="http://www.amazon.com/Guide-Kernel-Exploitation-Attacking-Core/dp/1597494860/ref=sr_1_1?ie=UTF8&amp;qid=1361561143&amp;sr=8-1&amp;keywords=guide+to+kernel+exploitation" target="_blank">A Guide to Kernel Exploitation: Attacking the Core</a></b></b>
<p>Not all penetration testers spend their days developing kernel exploits, but it’s still good to know the basics. This book has a focus on understanding kernel exploits and how they actually expose operating system vulnerabilities. So far, it’s been a good read, but I haven’t finished it yet. Someone also recently recommended The Shellcoder’s Handbook to me. So consider that as well.</li>
<li><b><b><a href="http://www.amazon.com/Practical-Malware-Analysis-Dissecting-Malicious/dp/1593272901/ref=sr_1_1?ie=UTF8&amp;qid=1361560983&amp;sr=8-1&amp;keywords=malware" target="_blank">Practical Malware Analysis: The Hands-On Guide to Dissecting Malicious Software</a></b></b>
<p>I liked this one a lot. It provides a good assembly primer which can come in handy in a lot of ways during a penetration test. It also provides decent coverage in areas that you would expect like static and dynamic malware analysis, file structures, test handlers, packers, and debugging. I’ve also heard that the IDA PRO Book is great if you want to become the reversing master of the universe. However, I don’t actually own it at the moment.</li>
<li><b><b><a href="http://www.amazon.com/Gray-Hat-Python-Programming-Engineers/dp/1593271921/ref=sr_1_2?s=books&amp;ie=UTF8&amp;qid=1361987503&amp;sr=1-2" target="_blank">Gray Hat Python</a></b></b>
<p>I really like this book as well. It’s a quick read and it does a good job of describing different debugging, injection, and fuzzing techniques. It also provides a lot of sample code that can be used to perform tasks like hooking and DLL/code injection. I’ve found both techniques to be quite handy for avoiding anti-virus solutions and stealing data protected with encryption.</li>
<li><b><b><a href="http://www.amazon.com/Windows%C2%AE-Internals-Part-Covering-Windows/dp/0735648735/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1361987683&amp;sr=1-1" target="_blank">Windows® Internals, Part 1</a> / <a href="http://www.amazon.com/Windows%C2%AE-Internals-Part-Covering-Windows/dp/0735665877/ref=pd_sim_b_1" target="_blank">Part 2: Covering Windows Server® 2008 R2 and Windows 7</a></b></b>
<p>I will most likely never finish either of these books in their entirety. However, they do make great references. If you ever need to know anything about how any part of Windows works, these are the go-to books.</li>
<li><a href="http://www.amazon.com/Nmap-exploration-security-auditing-Cookbook/dp/1849517487/ref=sr_1_3?s=books&amp;ie=UTF8&amp;qid=1361562568&amp;sr=1-3&amp;keywords=nmap#_" target="_blank">N</a><b><b><a href="http://www.amazon.com/Nmap-exploration-security-auditing-Cookbook/dp/1849517487/ref=sr_1_3?s=books&amp;ie=UTF8&amp;qid=1361562568&amp;sr=1-3&amp;keywords=nmap#_" target="_blank">etwork exploration and security auditing cookbook</a></b></b>
<p>Nmap has become one of the fundamental “tools of the trade” over the past decade or so. In my opinion, it’s as valuable to administrators as it is to attackers. I think that every IT professional should know what Nmap is and how to use it. This book is a great start for someone who has not been exposed to it in the past. It covers everything from basic system discovery to writing your own plugins to scan for vulnerabilities.</li>
<li><b><b><a href="http://www.amazon.com/Metasploit-Penetration-Testers-David-Kennedy/dp/159327288X/ref=sr_1_3?s=books&amp;ie=UTF8&amp;qid=1361561703&amp;sr=1-3&amp;keywords=penetration+testing" target="_blank">MetaSploit: A Penetration Tester’s Guide</a></b></b>
<p>MetaSploit has also become one of the fundamental “tools of the trade” in recent years. There is a lot of community involvement and I think this is a good book for beginners who want to learn more about MetaSploit and some practical use cases.</li>
</ol>
<h2><b>Free Online Training and Vulnerable VMs</b></h2>
<p>Obviously, there are ton of great blogs, training sites, and vulnerable VMs/application out there. I will not be coving all of them. However, I’ve tried to include online resources that are valuable for beginners and veterans alike.</p>
<p><a href="http://www.securitytube.net/" target="_blank"><b>SecurityTube</b></a></p>
<p>SecurityTube is like YouTube, but the videos are dedicated to teaching penetration test skills. Our intern actually recommended this site to me before I knew what it was. Since that time, I’ve been checking every time I start learning a new topic just to see if they have already covered it. I feel the quality of the tutorials is great and obviously recommend it.</p>
<p><a href="http://www.irongeek.com/" target="_blank"><b>Irongeek</b></a></p>
<p>It’s not a pretty site, but it provides a lot of good content. It is also known for releasing video presentations from security conferences is record time.</p>
<p><a href="http://www.offensive-security.com/metasploit-unleashed/Main_Page" target="_blank"><b>MetaSploit Unleashed</b></a></p>
<p>This web site provides a free online course all about MetaSploit. They do ask for donations to fund Hackers for Charity which raises funds for underprivileged children in East Africa. It’s a great site with a great cause – I recommend checking it out.</p>
<p><a href="http://vulnhub.com/" target="_blank"><b>VulnHub</b></a></p>
<p>Reading only gets you so far. Most people in IT are hands on learners so, in order to get your hands dirty, I recommend checking out VulnHub. This is a relatively new site that supplies virtual machines that are designed to be vulnerable. For those of you looking for a quick way to set up a testing lab at home, this may be the most cost/time affective solution.</p>
<p><a href="http://blog.bugcrowd.com/list-of-active-bug-bounty-programs/" target="_blank"><b>Bug bounties</b></a></p>
<p>If you feel you have the skills that can now pay the bills, there are lots of companies willing to pay real money if you find a big issue in their product. Below is a site dedicated to consolidating a list of the companies currently paying “bug bounties”.</p>
<h2><b>Good Google Searches</b></h2>
<p>As I mentioned earlier, I haven’t been able to find books that cover everything I’d like them to. Where books fail, Google usually succeeds. I suggest using it to find good archived presentations from security conferences such as Defcon, Blackhat, Derby con etc. Below I’ve also provided some topics that you might find interesting.</p>
<p><b>Windows Penetration and Escalation</b></p>
<p>In my experience, 90% of enterprise environments are Windows-based operating systems that centralized access control around Active Directory Services. Therefore, it’s good to have an understanding of the tools and techniques used to escalate privileges in those environments. Unfortunately, I have yet to find a single book that covers well; below are some basic keywords, vulnerability categories, and tools to get you started.</p>
<ul>
<li>Default passwords</li>
<li>Clear text passwords</li>
<li>Excessive privileges: Users, services, gui, files, registry, memory</li>
<li>Insecure local and remote services</li>
<li>Insecure schedule tasks</li>
<li>Local and remote exploits</li>
<li>Password guessing: medusa, hydra, bruter, and MetaSploit</li>
<li>Password and hash dumping: Cain, lsa secrets, credential manager, fgdump, mimikatz, MetaSploit post modules</li>
<li>Password hash cracking: john the ripper, hashcat, lophtcrack, masking, Cain</li>
<li>Impersonating users: incognito, mimikatz, pass the hash, MetaSploit psexec, shared accounts, smbexec</li>
</ul>
<p><b>Linux Penetration and Escalation</b></p>
<p>Even though Linux and UNIX systems aren’t in the majority on most networks, they still have a role to play and so, naturally, it’s good to understand their soft spots as well. For the most part, Linux has many of the same basic keywords and vulnerability categories as Windows:<b></b></p>
<ul>
<li>Default passwords</li>
<li>Clear text passwords</li>
<li>Excessive privileges: Users, services, gui, files, memory, setuid, orphan files, world writable files, sudoers configurations</li>
<li>Insecure local and remote services</li>
<li>Insecure schedule tasks</li>
<li>Local and remote exploits</li>
<li>Password guessing: medusa, hydra, bruter, and MetaSploit</li>
<li>Password and hash dumping</li>
<li>Password hash cracking: john the ripper, hashcat, masking</li>
</ul>
<p><b>Man in the Middle (MITM) Attacks</b></p>
<p>For some of you, MITM attacks may be a new concept so here is brief description. If a workstation is communicating with a server, and you are routing traffic between them, then you are the MITM. It’s a great position to be in for monitoring and manipulating traffic. There are lots of ways to acquire a MITM position using a range of protocol attacks. To get you started, I’ve provided a list of 10 protocols and tools for attacking systems on a LAN.</p>
<ul>
<li>Address Resolution Protocol (ARP): Cain, ettercap, interceptor-ng, Subterfuge, easycreds</li>
<li>NetBIOS Name Service  (NBNS): MetaSploit and responder</li>
<li>Link-local Multicast Name Resolution (LLMNR): MetaSploit and responder</li>
<li>Pre-Execution Environment (PXE): MetaSploit</li>
<li>Dynamic Trunking Protocol (DTP): Yersinia</li>
<li>Spanning-Tree Protocol (STP): Yersinia, ettercap (lamia plugin)</li>
<li>Hot Stand-by Router Protocol (HSRP): Yersinia</li>
<li>Dynamic Host Configuration Protocol (DHCP): Interceptor, MetaSploit, manual setup</li>
<li>Domain Name Services (DNS): MetaSploit, ettercap, dsniff, zodiac, ADMIdPack</li>
<li>VLAN Tunneling Protocol (VTP): Yersinia, voiphopper, or modprobe+ifconfig</li>
</ul>
<p><b>Anti-Virus Evasion</b></p>
<p>Anti-virus evasion is often a requirement during penetration testing. I personally break down AV evasion approaches into the four buckets below. I provided a list of keywords for each category to get your searches started. I’m also planning to release a few blogs down the line that will provide more options and actual examples.</p>
<ul>
<li>Bypass Weak AV Configurations
<ul>
<li>Uninstall anti-virus, disable services, terminate processes, disabled via the GUI, create an exception policy for all .exe files, or execute from external media.</li>
</ul>
</li>
<li>Source Code Manipulation
<ul>
<li>Remove comments, randomize function and variable names, encode or encrypt content, delay execution of malicious code, use alternative functions, or insert superfluous functions that change execution flow.</li>
</ul>
</li>
<li>Binary Manipulation
<ul>
<li>Bind with white listed applications, pack or compress, modify strings, modify resources, modify imports table, modify assembly to do things mentioned in source code manipulation. Common packers: upx, iexpress, and mpress.</li>
</ul>
</li>
<li>Process Manipulation
<ul>
<li>Inject malicious code or DLLs into local or remote process. Native languages can do it directly or through a managed code framework like .net. Powershell is a popular example that the MetaSploit team (amongst others) has been using a lot lately. Also, process manipulation is commonly done with python code that is converted to a portable executable.</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/03/11/resources-for-aspiring-penetration-testers/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/03/11/resources-for-aspiring-penetration-testers/</feedburner:origLink></item>
		<item>
		<title>Hacking Web Services with Burp</title>
		<link>http://feedproxy.google.com/~r/NetspiBlog/application-security/~3/rrojUn1ktPU/</link>
		<comments>http://www.netspi.com/blog/2013/03/05/hacking-web-services-with-burp/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 12:00:48 +0000</pubDate>
		<dc:creator>Eric Gruber</dc:creator>
				<category><![CDATA[NetsPWN: Assessment Services]]></category>
		<category><![CDATA[Burp]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[Wsdler]]></category>

		<guid isPermaLink="false">http://www.netspi.com/blog/?p=3131</guid>
		<description><![CDATA[I’ve written a plugin for Burp that takes a WSDL request and parses out the operations that are associated with the targeted web service and creates SOAP requests which can then be sent to a web service. This plugin builds upon the work done by Tom Bujok and his soap-ws project which is essentially the WSDL parsing portion of Soap-UI without the UI. <br /><a class="readmore" href="http://www.netspi.com/blog/2013/03/05/hacking-web-services-with-burp/">READ POST</a>]]></description>
				<content:encoded><![CDATA[<p>WSDL (Web Services Description Language) files are XML formatted descriptions about the operations of web services between clients and servers. They contain possible requests along with the parameters an application uses to communicate with a web service. This is great for penetration testers because we can test and manipulate web services all we want using the information from WSDL files.</p>
<p>One of the best tools to use for working with HTTP requests and responses for applications is Burp. The only downside with Burp is that it does not natively support parsing of WSDL files into requests that can be sent to a web service. A common work around has been to use a tool such as Soap-UI and proxy the requests to Burp for further manipulation. I’ve written a plugin for Burp that takes a WSDL request and parses out the operations that are associated with the targeted web service and creates SOAP requests which can then be sent to a web service. This plugin builds upon the work done by <a href="https://github.com/reficio/soap-ws" target="_blank">Tom Bujok and his soap-ws project</a> which is essentially the WSDL parsing portion of Soap-UI without the UI.</p>
<p>The Wsdler plugin along with all the source is located at the Github repository here: <a href="https://github.com/NetSPI/Wsdler" target="_blank">https://github.com/NetSPI/Wsdler</a>.</p>
<h3>Wsdler Requirements</h3>
<ol>
<li>Burp 1.5.01 or later</li>
<li>Must be run from the command line</li>
</ol>
<h3>Starting Wsdler</h3>
<p>The command to start Burp with the Wsdler plugin is as follows:</p>
<p><strong>java -classpath Wsdler.jar;burp.jar burp.StartBurp</strong></p>
<h3>Sample Usage</h3>
<p>Here we will intercept the request for a WSDL file belonging to an online store in Burp.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-1-EG0304131.png"><img class="alignleft size-full wp-image-3136" title="Burp Blog 1 EG030413" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-1-EG0304131.png" alt="Burp WSDL intercept request" width="640" height="289" /></a></p>
<p>After the request for the WSDL has been intercepted, right click on the request and select Parse WSDL.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-2-EG0304131.png"><img class="alignleft size-full wp-image-3137" title="Burp Blog 2 EG030413" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-2-EG0304131.png" alt="Burp WSDL Parse" width="640" height="467" /></a></p>
<p>A new Wsdler tab will open with the parsed operations for the WSDL, along with the bindings and ports for each of the operations. Operations are synonymous with the requests that the application supports. There are two operations in this WSDL file, OrderItem and CheckStatus. Each of these operations has two bindings, for simplicity’s sake, bindings describe the format and protocol for each of the operations. The bindings for both of the operations are InstantOrderSoap and InstantOrderSoap12. The reason there are two bindings for each of the operations is because the WSDL file supports the creation of SOAP 1.1 and 1.2 requests. Finally, the ”Port” for each of the operations is essentially just the URL the request will be sent to. The full specification for each of the Objects in WSDL files can be read here: <a href="http://www.w3.org/TR/wsdl" target="_blank">http://www.w3.org/TR/wsdl</a>.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-3-EG0304131.png"><img class="alignleft size-full wp-image-3138" title="Burp Blog 3 EG030413" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-3-EG0304131.png" alt="Burp SOAP Operations Request" width="640" height="467" /></a></p>
<p>The SOAP requests for the operations will be in the lower part of the Burp window. The parsing functionality will also automatically fill in the data type for each of the parameters in the WSDL operation. In this example, strings are filled in with parts of the Aeneid and integers are filled in with numbers.</p>
<p>The request that Wsdler creates is a standard Burp request, so it can be sent to any other Burp function that accepts requests (intruder, repeater, etc.).</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-4-EG0304131.png"><img class="alignleft size-full wp-image-3139" title="Burp Blog 4 EG030413" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-4-EG0304131.png" alt="Burp Intruder Request" width="640" height="467" /></a></p>
<p>Here the request is sent to intruder for further testing. Because the request is XML, Burp automatically identifies the parameters for intruder to use.</p>
<p><a href="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-5-EG0304131.png"><img class="alignleft size-full wp-image-3140" title="Burp Blog 5 EG030413" src="http://www.netspi.com/blog/wp-content/uploads/2013/03/Burp-Blog-5-EG0304131.png" alt="Burp Payload Positioning" width="631" height="480" /></a></p>
<h3>Conclusion</h3>
<p>Currently, the plugin only supports WSDL specification 1.1, but there is work on supporting 1.2 / 2.0. Also, I will be adding the option to specify your own strings and integers when the plugin automatically fills in the appropriate data type for each of the parameters in the parsed operations. If there are any bugs or features that you would like to see added, send me an email or create a ticket on Github.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netspi.com/blog/2013/03/05/hacking-web-services-with-burp/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		<feedburner:origLink>http://www.netspi.com/blog/2013/03/05/hacking-web-services-with-burp/</feedburner:origLink></item>
	</channel>
</rss>
