<?xml version="1.0"?>
<!-- name="generator" content="blosxom/2.0" -->
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">
  <channel>
    <title>SensePost Blog   </title>
    <link>http://www.sensepost.com/blog</link>
    <description>doing the web 2.0 thing...</description>
    <language>en</language>

  <item>
    <title>Your first mobile assessment</title>
    <pubDate>Mon, 20 May 2013 07:39:00 </pubDate>
    <link>http://www.sensepost.com/blog/9009.html</link>
    <description>
&lt;p&gt;Monday morning, raring for a week of pwnage and you see you've just been handed a new assessment, awesome. The problem? It's a mobile assessment and you've never done one before. What do you do, approach your team leader and ask for another assessment? He's going to tell you to learn how to do a mobile assessment and do it quickly, there are plenty more to come.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Now you set out on your journey into mobile assessments and you get lucky, the application that needs to be assessed is an Android app. A few Google searches later and you are feeling pretty confident about this, Android assessments are meant to be easy, there are even a few tools out there that &quot;do it all&quot;. You download the latest and greatest version, run it and the app gets a clean bill of health. After all, the tool says so, there is no attack surface; no exposed intents and the permissions all check out. You compile your report, hand it off to the client and a week later the client gets owned through the application... Apparently the backend servers were accepting application input without performing any authentication checks. Furthermore, all user input was trusted and no server side validation was being performed. What went wrong? How did you miss these basic mistakes? After-all, you followed all the steps, you ran the best tools and you ticked all the boxes. Unfortunately this approach is wrong, mobile assessments are not always simply about running a tool, a lot of the time they require the same steps used to test web applications, just applied in a different manner. This is where SensePost's &lt;a title=&quot;Hacking by numbers: Mobile&quot; href=&quot;https://www.blackhat.com/us-13/training/hacking-by-numbers-mobile.html&quot;&gt;Hacking by numbers: Mobile&lt;/a&gt; comes to the fore, the course aims to introduce you to mobile training from the ground up.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The course offers hands-on training, introducing techniques for assessing applications on Android, IOS, RIM and Windows 8. Some of the areas covered include:&lt;br /&gt;
&lt;div id=&quot;_mcePaste&quot;&gt;&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
	&lt;li&gt;Communication protocols&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Programming languages for mobile development&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Building your own mobile penetration testing lab&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Mobile application analysis&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Static Analysis&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Authentication and authorization&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Data validation&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Session management&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Transport layer security and information disclosure&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Unlike other mobile training or tutorials that focus on a specific platform or a specific tool on that platform, Hacking by Numbers aims to give you the knowledge to perform assessments on &lt;strong&gt;any platform&lt;/strong&gt; with a well established methodology. Building on everything taught in the Hacking by Numbers series, the mobile course aims to move assessments into mobile sphere, continuing the strong tradition of pwnage. The labs are a direct result of the assessments we've done for clients. Our trainers do this on a weekly basis, so you get the knowledge learned from assessing numerous apps over the last few years.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;On your next mobile assessment you'll be able to do both static and dynamic analysis of mobile applications. You will know where to find those credit card numbers stored on the phone and how to intercept traffic between the application and the backend servers.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The course:  &lt;a title=&quot;Hacking by numbers: Mobile&quot; href=&quot;https://www.blackhat.com/us-13/training/hacking-by-numbers-mobile.html&quot;&gt;Hacking by numbers: Mobile&lt;/a&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Wifi Hacking &amp; WPA/2 PSK traffic decryption</title>
    <pubDate>Thu, 9 May 2013 11:22:00 </pubDate>
    <link>http://www.sensepost.com/blog/8965.html</link>
    <description>
&lt;p&gt;When doing wireless assessments, I end up generating a ton of different scripts for various things that I thought it would be worth sharing. I'm going to try write some of them up. This is the first one on decrypting WPA/2 PSK traffic. The second will cover some tricks/scripts for rogue access-points. If you are keen on learn further techniques or advancing your wifi hacking knowledge/capability as a whole, please check out the course &lt;a href=&quot;https://www.blackhat.com/us-13/training/hacking-by-numbers-unplugged.html&quot;&gt;Hacking by Numbers: Unplugged&lt;/a&gt;, I'll be teaching at BlackHat Las Vegas soon.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;When hackers find a WPA/2 network using a pre-shared key, the first thing they try and do most times, is to capture enough of the 4-way handshake to attempt to brute force the pairwise master key (PMK, or just the pre-shared key PSK). But, this often takes a very long time. If you employ other routes to find the key (say a client-side compromise) that can still take some time. Once you have the key, you can of course associate to the network and perform your layer 2 hackery. However, if you had been capturing traffic from the beginning, you would now be in a position to decrypt that traffic for analysis, rather than having to waste time by only starting your capture now. You can use the airdecap-ng tool from the &lt;a href=&quot;http://www.aircrack-ng.org&quot;&gt;aircrack-ng&lt;/a&gt; suite to do this:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;code&gt;airdecap-ng   -b &amp;lt;BSSID of target network&amp;gt; -e &amp;lt;ESSID of target network&amp;gt; -p &amp;lt;WPA passphrase&amp;gt; &amp;lt;input pcap file&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;However, because the WPA 4-way handshake generates a unique temporary key (pairwise temporal key PTK) every time a station associates, you need to have captured the two bits of random data shared between the station and the AP (the authenticator nonce and supplicant nonce) for that handshake to be able to initialise your crypto with the same data. What this means, is that if you didn't capture a handshake for the start of a WPA/2 session, then you won't be able to decrypt the traffic, even if you have the key.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;So, the trick is to de-auth all users from the AP and start capturing right at the beginning. This can be done quite simply using aireplay-ng:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;code&gt;aireplay-ng --deauth=5 -e &amp;lt;ESSID&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
Although, broadcast de-auth's aren't always as successful as a targeted one, where you spoof a directed deauth packet claiming to come from the AP and targeting a specific station. I often use airodump-ng to dump a list of associated stations to a csv file (with --output-format csv), then use some grep/cut-fu to excise their MAC addresses. I then pass that to aireplay-ng with:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;code&gt;cat &amp;lt;list of associated station MACs&amp;gt;.txt | xargs -n1 -I% aireplay-ng --deauth=5 -e &amp;lt;ESSID&amp;gt; -c % mon0&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
This tends to work a bit better, as I've seen some devices which appear to ignore a broadcast de-auth. This will make sure you capture the handshake so airdecap can decrypt the traffic you capture. Any further legitimate disconnects and re-auths will be captured by you, so you shouldn't need to run the de-auth again.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;In summary:&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
	&lt;li&gt;Don't forget how useful examining traffic can be, and don't discount that as an option just because it's WPA/2&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;Start capturing as soon as you get near the network, to maximise how much traffic you'll have to examine&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;De-auth all connected clients to make sure you capture their handshakes for decryption&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
Once again, I'll be teaching &lt;a href=&quot;https://www.blackhat.com/us-13/training/hacking-by-numbers-unplugged.html&quot;&gt;a course&lt;/a&gt; covering this and other techniques at BlackHat Las Vegas, please check it out or recommend it to others if you think it's worthwhile. We're also running a curriculum of other courses at BH, including a &lt;a href=&quot;https://www.blackhat.com/us-13/training/hacking-by-numbers-mobile.html&quot;&gt;brand new mobile hacking course&lt;/a&gt;.&lt;br /&gt;
&lt;ul&gt;&lt;/ul&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Windows Domain Privilege Escalation : Implementing PSLoggedOn in Metasploit (+ a bonus history module)</title>
    <pubDate>Mon, 22 Apr 2013 09:51:00 </pubDate>
    <link>http://www.sensepost.com/blog/8764.html</link>
    <description>
&lt;p&gt;There are multiple paths one could take to getting Domain Admin on a Microsoft Windows Active Directory Domain. One common method for achieving this is to start by finding a system where a privileged domain account, such as a domain admin, is logged into or has recently been logged into. Once access to this system has been gained, either stealing their security tokens (ala Incognito or pass-the-hash attacks) or   querying Digest Authentication (with Mimikatz/WCE)  to get their clear-text password. The problem is finding out where these user's are logged in.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;I've often seen nmap and the smb-enum-sessions script (&lt;a href=&quot;http://nmap.org/nsedoc/scripts/smb-enum-sessions.html&quot;&gt;http://nmap.org/nsedoc/scripts/smb-enum-sessions.html&lt;/a&gt;) used to retrieve all the user sessions on the network. This (not so grep'pable) output is then grep'ed to find the hosts where our target user is logged in. The process of smb-enum-sessions and subsequent analysis can be quite time consuming and clumsy. On a recent assessment, multiple tunnels in, where uploading nmap wasn't a great idea, we realised that there has to be a better way of doing this.  While searching for an alternative solution we came across PsLoggedOn (&lt;a href=&quot;http://technet.microsoft.com/en-us/sysinternals/bb897545.aspx&quot;&gt;SysInternals Suite&lt;/a&gt;) which, with a single binary, allows you search the network for locations where a user is logged in. The downside with this is that it doesn't cleanly run via psexec or other remote shells and you need graphical logon to a system on the domain, and you need to upload another binary (the PsLoggedOn executable) to the target system. Examining how PsLoggedOn worked we figured out that it was simply using the Windows &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/desktop/bb525382(v=vs.85).aspx&quot;&gt;NetSessionEnum API&lt;/a&gt;.   Having a look at the API I figured that it should be possible to write a simple post exploit module for Metasploit using the railgun.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;After some trial and error, we now present enum_domain_user.rb a simple Metasploit post exploit module capable of finding network sessions for a specific user. Below is a screenshot of the module in action.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/04/enum_domain_user_in_action.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;size-full wp-image-8765&quot; title=&quot;Enumerating domain for logged in Domain Admin&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/04/enum_domain_user_in_action.png&quot; alt=&quot;&quot; width=&quot;712&quot; height=&quot;673&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;To use the module,&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;1.) Download and copy it to:&lt;br /&gt;
&lt;code&gt;&amp;lt;msfinstall&amp;gt;/modules/post/windows/gather/&lt;/code&gt;&lt;br /&gt;
(we'll send a pull request to metasploit-framework's github shortly).&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;2.) In MSF:&lt;br /&gt;
&lt;code&gt;use post/windows/gather/enum_domain_user&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;3.) Set the USER and SESSION variables.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;4.) Then simply run it with &quot;&lt;code&gt;exploit&lt;/code&gt;&quot;.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The module can also be used directly from meterpreter with:&lt;br /&gt;
&lt;code&gt;run post/windows/gather/enum_domain_user USER=username&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;, this doesn't seem to work with x64 meterpreter yet mostly likely due to some memory pointer stuff I haven't worked out. Hopefully this will get updated shortly, or even better, one of you smart people out there can fix my horrible Ruby.&lt;br /&gt;
&lt;h2&gt;Bonus&lt;/h2&gt;&lt;br /&gt;
As an added extra I've included a Metapsloit history plugin. This plugin will simply allow you to view all the commands executed since the module was loaded and then execute them &quot;bash style&quot;.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Typing &quot;&lt;code&gt;history&lt;/code&gt;&quot; will give display the last 10 commands executed. If you wish to see more commands, type &lt;code&gt;history &amp;lt;numberof entries&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;To run a command from the history list type:&lt;br /&gt;
&lt;code&gt;history !&amp;lt;command number&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Below is an action shot of the history module.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/04/msf_history.png&quot; title=&quot;History module for msfconsole&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;size-full wp-image-8767&quot; title=&quot;msf_history&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/04/msf_history.png&quot; alt=&quot;&quot; width=&quot;551&quot; height=&quot;414&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;To install:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;1.) Download and Copy history.rb to the plugins folder: &lt;code&gt;&amp;lt;msf install&amp;gt;/plugins/&lt;/code&gt;&lt;br /&gt;
2.) In msfconsole type: &lt;code&gt;load history&lt;/code&gt;&lt;br /&gt;
3.) For usage info type: &lt;code&gt;help history&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 13px; font-weight: normal;&quot;&gt;Both modules are available for download on Github, and I'll submit a pull request to metasploit-framework shortly. Please feel free to fork and be merry. Any updates/fixes/comments are welcome.&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: 13px; font-weight: normal;&quot;&gt;Github: &lt;/span&gt;&lt;a style=&quot;font-size: 13px; font-weight: normal;&quot; href=&quot;https://github.com/sensepost/metasploit&quot;&gt;https://github.com/sensepost/metasploit&lt;/a&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Analysis of Security in a P2P storage cloud</title>
    <pubDate>Fri, 12 Apr 2013 14:48:00 </pubDate>
    <link>http://www.sensepost.com/blog/8399.html</link>
    <description>
&lt;p&gt;A cloud storage service such as Microsoft SkyDrive requires building   data centers as well as operational and  maintenance  costs. An alternative approach   is based on distributed computing model which utilizes portion of the storage and processing resources of   consumer level computers and SME NAS devices to form a peer to peer storage system. The members contribute some of their local storage space to the system and in return  receive &quot;online backup and data sharing&quot; service. Providing data confidentiality, integrity and availability in such de-centerlized storage system is a big challenge  to be addressed. As the cost of   data storage devices declines, there is a debate that whether the P2P storage could really be cost saving or not. I leave this debate to the critics and instead I will look into a peer to peer storage system and study its security  measures  and possible issues.   An overview of this system's architecture is shown in the following picture:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Each node in the storage cloud  receives an amount of free online storage space which can be  increased by the control server if the node agrees to &quot;contribute&quot; some of its local hard drive space to the system.    File  synchronisation  and contribution agents that are running on every node interact with the cloud control server and other nodes as shown in the above picture. Folder/File synchronisation is performed in the following steps:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-8423&quot; title=&quot;cloud&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/02/cloud.png&quot; alt=&quot;&quot; width=&quot;463&quot; height=&quot;308&quot; /&gt;&lt;/div&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;1) The node authenticates itself to the control server and sends file upload request with file meta data including SHA1 hash value, size, number of fragments   and file name over HTTPS connection.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;2) The control server replies with the AES encryption key for the relevant file/folder, a [IP Address]:[Port number] list of contributing nodes called &quot;endpoints list&quot; and a file ID.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;3) The file is split into blocks each of which is encrypted with the above AES encryption key. The blocks are further split into 64 fragments and redundancy information also gets added to them.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;4) The node then connects to the contribution agent on each endpoint address that was received in step 2 and uploads one fragment to each of them&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Since the system nodes are not under full control of the control server, they fall offline any time or the stored file fragments may become damaged/modified  intentionally. As such, the control server needs to monitor node and fragment health  regularly so that it may move lost/damaged fragments to alternate nodes if need be. For this purpose, the contribution agent on each node  maintains  an HTTPS connection to the control server on which it  receives  the following &quot;tasks&quot;:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;a) Adjust settings : instructs the node to modify its upload/download limits , contribution size and etc&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;b) Block check :   asks the node to connect to another contribution node and verify a fragment  existence  and hash value&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;c) Block Recovery : Assist the control server to recover a number of fragments&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;By delegating the above task, the control system has placed some degree of &quot;trust&quot; or at least &quot;assumptions&quot; about the  availability  and integrity of the agent software running on the storage cloud nodes. However, those agents can be manipulated by malicious nodes in order to  disrupt cloud operations, attack other nodes or even gain unauthorised access to the distributed data. I limited the scope of my research to the synchronisation and contribution agent software of two storage nodes under my control - one of which was acting as a contribution node.   I didn't include the analysis of the encryption or redundancy of the system in my  preliminary  research because  it could affect the live system and should   only be  performed  on a test  environment  which was not possible to set up, as the target system's control server was not publicly available.   Within the contribution agent alone, I identified that not only did I have unauthorised access file storage (and download) on the cloud's nodes, but I had unauthorised access to the folder encryption keys as well.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;a) Unauthorised file storage and download&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The contribution agent created a TCP network listener that processed commands from the control server as well as   requests from other nodes. The agent communicated over HTTP(s) with the control server and other nodes in the cloud. An example file fragment upload request from a remote node is shown below:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/02/putrequest1.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-8478&quot; title=&quot;putrequest&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/02/putrequest1.png&quot; alt=&quot;&quot; width=&quot;670&quot; height=&quot;340&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Uploading fragments with similar format to the above path name resulted in the &quot;bad request&quot; error from the agent. This indicated that the fragment name should be related to its content and this condition is checked by the contribution agent before accepting the PUT request. By decompiling the agent software code, it was found that the fragment name must have the following format to pass this validation:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&amp;lt;SHA1(uploaded content)&amp;gt;.&amp;lt;Fragment number&amp;gt;.&amp;lt;Global Folder Id&amp;gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;I used the above file fragment format to upload notepad.exe to the remote node successfully as you can see in the following figure:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/02/1.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-8479&quot; title=&quot;1&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/02/1.png&quot; alt=&quot;&quot; width=&quot;721&quot; height=&quot;390&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The download request (GET request) was also successful regardless of the validity of &quot;Global Folder Id&quot; and &quot;Fragment Number&quot;. The uploaded file was accessible for about 24 hours, until it was purged automatically by the contribution agent, probably because it won't   receive any &quot;Block Check&quot; requests for the control server for this fragment. Twenty four hours still is  enough  time for malicious users to abuse   storage cloud nodes bandwidth and storage to serve their contents over the internet without victim's knowledge.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;b) Unauthorised access to folder encryption keys&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The network listener responded to GET requests from any remote node as mentioned above. This was intended to serve &quot;Block Check&quot; commands from the control server which instructs a node to fetch a number of fragments from other nodes (referred to as &quot;endpoints&quot;) and verify their integrity but re-calculating the SHA1 hash and reporting back to the control server. This could be part of the cloud &quot;health check&quot; process to ensure that the distributed file fragments are accessible and not tampered with.   The agent could also process &quot;File Recovery&quot; tasks from the control server but I didn't observe any such command from the control server during the dynamic analysis of the contribution agent, so I searched the decompiled code for clues on the file recovery process and found the following code snippet which could suggest that the agent is cable of  retrieving encryption keys from the control server. This was something odd, considering that each node should only have access to  &lt;em&gt;its own folders&lt;/em&gt; encryption keys and it stores encrypted file fragments of &lt;em&gt;other nodes&lt;/em&gt;.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/02/22.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-8488&quot; title=&quot;2&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/02/22.png&quot; alt=&quot;&quot; width=&quot;526&quot; height=&quot;245&quot; /&gt;&lt;/div&gt;&lt;/a&gt;One possible  explanation  for the above file recovery code, could be that the node first downloads its own file fragments from remote endpoints (using an endpoint list received from the control server) and then retrieves the required folder encryption key from the control server in order to decrypt and re-assemble  its own files. In order to test if it's possible to abuse the file recovery operation to gain access to encryption key of the folders belonging to other nodes. I extracted the folderInfo request format from the agent code and set up another storage node as a target to test this idea. The result of the test was  successful  as shown in the following figure and it was possible to  retrieve  the AES-256 encryption key for the Folder Id &quot;1099869693336&quot;.   This could enable an attacker who has set up an contributing storage node to decrypt the fragments that belong to other cloud users.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/02/3.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-8490&quot; title=&quot;3&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/02/3.png&quot; alt=&quot;&quot; width=&quot;699&quot; height=&quot;236&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;While peer to peer storage systems have lower setup/maintenance costs, they face security threats from the storage nodes that are not under direct physical/remote control of the cloud controller system. Examples of such threats relate to the cloud's client agent software and the cloud server's authorisation control, as demonstrated in this post. While analysis of the data encryption and redundancy in the peer to peer storage system would be an interesting future research topic, we hope that the findings from this research can be used to improve the security of various distributed storage systems.&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Google Docs XSS - no bounty today</title>
    <pubDate>Tue, 19 Mar 2013 16:45:00 </pubDate>
    <link>http://www.sensepost.com/blog/8579.html</link>
    <description>
&lt;p&gt;A few days ago, during one of those nights with the baby crying at 2:00 am and the only thing you can do is to read emails, I realised that Gmail shows the content of compressed files when reading them in Google Docs. As often is the case at SensePost, the &quot;think evil (tm)&quot; came to me and I started to ponder the possibilities of injecting HTML inside the file listing.  The idea is actually rather simple. Looking at the file format of a .zip file we see the following:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-01-at-5.40.46-PM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8581&quot; title=&quot;Zip file content&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-01-at-5.40.46-PM-300x197.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;197&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Every file in the compressed file must have two entries; ZipFileRecord and ZipDirEntry. Both of these entries contain the filename, but only the first one contains the length of filename (it must match the actual length). Our first test case is obvious; if we could modify this name once the file was compressed, would Google sanitise it?  Thankfully, the answer is, yes! (go Google!)&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-01-at-6.05.28-PM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8588&quot; title=&quot;File list&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-01-at-6.05.28-PM-300x47.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;47&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;As you can see, Google shows the file name inside the compressed file but the tag is displayed with HTML entities. If we then try to see the contents of the file, Google responds by telling us it's not possible to read the content of the file (it's empty) and shows you the file &quot;without formatting&quot; after a few seconds:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-02-28-at-3.05.07-AM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8597&quot; title=&quot;Redirect to HTML without format&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-02-28-at-3.05.07-AM-300x187.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;187&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Finally, the filename is shown but not sanitised:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-02-28-at-3.05.25-AM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8598&quot; title=&quot;Injected Payload&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-02-28-at-3.05.25-AM-300x209.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;209&quot; /&gt;&lt;/div&gt;&lt;/a&gt; &lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-02-28-at-3.05.43-AM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8599&quot; title=&quot;The payload injected&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-02-28-at-3.05.43-AM-300x38.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;38&quot; /&gt;&lt;/div&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Why this is possible?&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Remember that the zip format has the name of the compressed files twice. Google uses the first one (&lt;em&gt;ZipFileRecord&lt;/em&gt;)  for displaying the file names, but in the vulnerable page it uses the second one (&lt;em&gt;ZipDirEntry&lt;/em&gt;).&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Possible attack vectors&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Going back to the 'thinking evil (tm)' mindset, it is now possible to leave a &quot;comprehensive&quot; name in the first entry and inject the malicious payload in the second one. When I first discovered the possibility of doing this, I contacted &lt;a href=&quot;http://www.google.co.uk/about/appsecurity/reward-program/&quot;&gt;Google&lt;/a&gt;, however, the XSS is in the &lt;em&gt;googleusercontent.com&lt;/em&gt; domain, which Google's security team described as a &quot;sandbox&quot; domain (i.e. we aren't injecting into the DOM of google.com) and therefore not worthy of a bounty.  Which I accept, if I had to prove usefulness this could be used as part of a simple social  engineering  attack, for example:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.13-PM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8601&quot; title=&quot;File protected&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.13-PM-300x32.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;32&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Leading the victim to my phishing site:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.13-PM.png&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.25-PM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8602&quot; title=&quot;Fake GMAIL&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.25-PM-300x103.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;103&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Which then proceeds to steals their Google session, or allows the attacker to use &lt;a href=&quot;http://beefproject.com/&quot;&gt;BeEF&lt;/a&gt;:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.25-PM.png&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.43-PM.png&quot;&gt;&lt;div class=&quot;blog_image&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-8603&quot; title=&quot;Dumped variables&quot; src=&quot;http://www.sensepost.com//blogstatic/2013/03/Screen-Shot-2013-03-04-at-1.18.43-PM-300x127.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;127&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Granted, there are simpler ways of achieving the same result. I just wanted to demonstrate how you can use file meta-information for such an attack.&lt;/p&gt;
</description>
  </item>
  </channel>
</rss>