Hack Forums
[TuT] - SQLi to XSS - [TuT] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45)
+--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449)
+---- Forum: Website Hacking (https://hackforums.net/forumdisplay.php?fid=43)
+---- Thread: [TuT] - SQLi to XSS - [TuT] (/showthread.php?tid=2083756)



[TuT] - SQLi to XSS - [TuT] - zer0pwn - Jan 5, 2012

[TuT] - SQLi to XSS - [TuT]


Hello all of Hack Forums, I decided to post another tutorial on XSS. This tutorial will be involving SQLi aswell though. I will teach you how to get XSS, out of ANY SQLi vulnerable site. This method is very useful for sites that don't have any useful information stored. You can use this method to get the administrator's cookie quite easily

Starting Off

So first of all, we need an SQLi vulnerable site. Just use a google dork like "inurl:event.php?id=". Once you've found a vulnerable site, SQL inject it like you would with ANY site. Now at the part where it displays the vulnerable columns, we will inject our XSS. Now, this is almost impossible for the admin to tell whether you're trying to steal his cookie or not. Usually you will do something like this:

Code
http://www.site.com/news.php?id=1337 UNION SELECT 1,2,3,4,5--+-

Then it will display our vulnerable column. So, on the vulnerable column, we will add our own little comment. Now, of course the site won't allow any plain-text. We have to use Hex, which is a huge help in this case. So we will encrypt our XSS Vector into Hex. I suggest you do this at:

Code
http://www.swingnote.com/tools/texttohex.php

Once you've encrypted it, put it in the place of your vulnerable column. But we can't just put the hex there, we have the let the server know that we want our Hex to be decoded on it's way to the page. So we will use "0x" So basically, put "0xHEXHERE". Now hit enter.

Now you should have an alert.

NOTE: It will block the quotes, so you have to do <script>alert(/XSS/)</script>

Although, it shouldn't be a problem for our cookie logger.

That's pretty much it, I hope you guys liked it and will find it useful. If you have any questions or need any help just PM me and I'll get back to you ::)

One more thing, I'd like to thank Zer0Freak for helping me use this method (Because I didn't know how to use comments in SQL -facepalm-). Thanks Zer0Freak!



* - Zhen. - Jan 5, 2012

Nice tutorial bro
Keep it up
Very useful for XSS


* - IHateMyOldUsername - Jan 5, 2012

You have to many Tutorials they are filling up my bookmarks.
But nice work very HQ tut.


* - BeggFoMercy - Jan 5, 2012

Nice tut mates keep up the good work
helped me alot Xd


* - Ichi - Jan 5, 2012

Once again, another good tutorial. Keep it up man


* - zer0pwn - Jan 5, 2012

Here's an example:
http://ogra.org.pk/cats_disp.php?cat=-172%20/*!UNION*/%20/*!SELECT*/%201,2,3,4,5,0x3c7363726970743e616c6572742831293c2f7363726970743e%20,7,8--+-

Come on guys, this is a useful method for cookie stealing! Haha, ?


* - Hooded Robin - Jan 5, 2012

Here is another example of XFS, compliments of Rutgers EDU:
Code
https://www.camden.rutgers.edu/security-bb/page.php?id=-2 UNION SELECT 1,0x3c7363726970743e616c657274282758535327293c2f7363726970743e,3,4,5--

Enjoy!