当前位置:网站首页>SQL injection database operation foundation
SQL injection database operation foundation
2022-07-03 17:23:00 【Cook 666】
- Connect to database
Enter the command :mysql -u root -p
- Display all database names in the system
Enter the command :show databases;

- New database student
command :create database student;
View results :show databases;

- Using a database student
command :use student;

- In the database student Create a table result
command :create table result(id int(8),name varchar(20),city varchar(20),score int(5));

- In the table result Add data to
stay result Insert five rows of data :
command :insert into result(id,name,city,score) values(1,"wang", "beijing",75);
insert into result(id,name,city,score) values(1,"li", "shanghai",80);
insert into result(id,name,city,score) values(5,"chen", "fuzhou",70);
insert into result(id,name,city,score) values(2,"zhou", "xian",90);
insert into result(id,name,city,score) values(7,"han", "guangzhou",65);

After successful insertion , use select * from result; Command query result Everything in the table :

- In the table result Delete in 1 Data
Delete id=7 The data of
Commands available :delete from result where id=7;
View the results after deletion :select * from result;

- Modify table result Medium 1 Data
modify id=5 The data of , Put it score Set to 60
command :update result set score=60 where id=5;
View the results after successful modification :select * from result;

- Query table result Data in
command :select * from result;// All fields in the query table

select name,score from result;
// Look up name and score Field

select score from result where name="li";
// see name by li Credits of students

The second part :Mysql(MariaDB) Advanced operation
- order by Usage of
- take result The data in the table is calculated according to the score (score) Sort from high to low :
command :select * from result order by score desc;
among ,desc Representation of descending order ( Decline ); If from low to high ( Arrange in ascending order ), Then you can put desc
Switch to asc; If you don't add this parameter , By default, they are arranged in ascending order

- Try the following commands :
select id,name,score from result order by 1;

Normal display with id The result of ascending order .
select id,name,score from result order by 2;

Normal display with name The result of ascending order .
- limit Usage of
The basic format is :
limit M,N
// Says from the first M+1 Data starts Query down in sequence N Data
limitM
// Indicates before query M Data
Try to perform the following two tasks
select * from result limit 0,2;
// The first... In the query table 2 Data
select id,name ,score from result limit 1,3;
// From 2 This data starts from , Look down 3 Of data id、name and score Field

3. union select Usage of
(1) select * from result union select 1,2,3,4;
The query result of this statement , That is select * from result and select 1,2,3,4 Splicing of query results .

(2) Try the following 3 statement :
select id,name ,score from result union select 1,2,3;

Normal display !
select id,name ,score from result union select 1,2;

Report errors !
select id,name ,score from result union select 1,2,3,4;

Report errors !
From the above results, we can sum up , For the following commands :
select c1,c2,. . . ,cn from result union select d1,d2, . . .dm;
The second half of the sentence union select Number of fields queried (m) Must be the same as the first half of the sentence select Number of fields queried (n
equal , The database can display the results normally . And order by be similar , This feature can be used to judge the number of fields queried in the database .
(3) Try the following statement
select id,city from result where id=1 and 1=2 union select name ,score from result;

From the above results, we can sum up , When the field name is known , An attacker simply places the field anywhere it can be displayed , You can expose the value of this field .
4. union select combination information_schema database
MySQL (MariaDB)5.5 The above version comes with information_schema database , It's about MySQL Information about all other databases maintained by the server , Such as database name 、 Table of database 、
Data type and access right of table column . You can put information_schema Database as MySQL
(MariaDB) Of “ Catalog "!
(1) Try to execute the following two statements :
show databases ;
select schema_name from information_schema.schemata;

The execution results of the two statements are the same !
边栏推荐
- New library online | cnopendata complete data of Chinese insurance institution outlets
- Luogu: p2685 [tjoi2012] Bridge
- Hongmeng fourth training
- UE4 official charging resources, with a total price of several thousand
- 【RT-Thread】nxp rt10xx 设备驱动框架之--hwtimer搭建和使用
- Online assignment 3 of mobile Internet technology in the 20th autumn of electronic technology [standard answer]
- i++与++i的区别:通俗易懂的讲述他们的区别
- An example of HP array card troubleshooting
- The largest matrix (H) in a brush 143 monotone stack 84 histogram
- IntelliJ 2021.3 short command line when running applications
猜你喜欢

Wechat applet for the first time

Applet setting multi account debugging
![[error reporting] omp: error 15: initializing libiomp5md dll, but found libiomp5md. dll already initialized.](/img/a0/4fc0e0741aad2885873e60f2af3387.jpg)
[error reporting] omp: error 15: initializing libiomp5md dll, but found libiomp5md. dll already initialized.

Life is still confused? Maybe these subscription numbers have the answers you need!

Play with fancy special effects. This AE super kit is for you

Redis: operation commands for list type data

Pools de Threads: les composants les plus courants et les plus sujets aux erreurs du Code d'affaires

跨境电商:外贸企业做海外社媒营销的优势

Prepare for the golden three silver four, 100+ software test interview questions (function / interface / Automation) interview questions. win victory the moment one raises one 's standard

国内如何购买Google Colab会员
随机推荐
Select 3 fcpx plug-ins. Come and see if you like them
The largest matrix (H) in a brush 143 monotone stack 84 histogram
i++与++i的区别:通俗易懂的讲述他们的区别
【RT-Thread】nxp rt10xx 设备驱动框架之--Audio搭建和使用
One brush 142 monotone stack next larger element II (m)
New library online | cnopendata China bird watching record data
[error reporting] omp: error 15: initializing libiomp5md dll, but found libiomp5md. dll already initialized.
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)
VM11289 WAService. js:2 Do not have __ e handler in component:
C language string inversion
kubernetes资源对象介绍及常用命令(五)-(NFS&PV&PVC)
C language modifies files by line
Where is the database account used when running SQL tasks in data warehouse tasks configured
新库上线 | CnOpenData中国观鸟记录数据
Redis:关于列表List类型数据的操作命令
Leetcode13. Roman numeral to integer (three solutions)
新库上线 | CnOpenData中国保险机构网点全集数据
【RT-Thread】nxp rt10xx 设备驱动框架之--Pin搭建和使用
University of Electronic Science and technology, accounting computerization, spring 20 final exam [standard answer]
Kotlin learning quick start (7) -- wonderful use of expansion