执行XPATH Injection Attacks需要了解的XPATH知识及练习思路

来源:互联网 发布:方维借贷源码 编辑:程序博客网 时间:2024/06/05 15:25


XPATH是现在普遍使用的一种轻量级查询语言,有自己的语法结构,

基于XML的树状结构,用来确定XML(标准通用标记语言的子集)

文档中某部分位置的语言,提供在数据结构树中找寻节点的能力。


此处不做系统学习与论证,只是了解下简单语法结构,

可以组织查询条件语句查询定位到节点就OK了。

下面重点描述练习思路及结果推论。


关于XPATH Injection课程,提供用户名、密码输入框,

认证通过后获取该User的薪资信息,

猜测数据存储可能为两种格式salaries节点salaries节点),如下:


<?xml version="1.0" encoding="utf-8" ?><tcftest><salaries><employee id="1" name="a" pass="1"><age>1</age><gender>male</gender><salary>1</salary></employee><employee id="2" name="b" pass="1"><age>1</age><gender>female</gender><salary>2</salary></employee><employee id="3" name="c" pass="1"><age>1</age><gender>female</gender><salary>3</salary></employee></salaries><salaries2><employee id="1"><name>a</name><pass>1</pass><age>1</age><gender>male</gender><salary>1</salary></employee><employee id="2"><name>b</name><pass>1</pass><age>1</age><gender>female</gender><salary>2</salary></employee><employee id="3"><name>c</name><pass>1</pass><age>1</age><gender>female</gender><salary>3</salary></employee></salaries2></tcftest>



由于不确定后台数据存储格式以及查询时组织条件的方式,下面分别尝试多种方法去提交,查询时条件组织格式如下(黄色背景部分,红色为输入):

//employee[@name="a"][@pass=1]或//employee[@name="a" and @pass=1]


1)调整 //employee[@name="a" and @pass=1]为or模式尝试规避验证,条件组织格式如下:

//employee[@name="a"or 1 or "1"="1" and @pass=1]×

//employee[@name='a' or 1 or '1'='1' and @pass=1]

2)调整//employee[@name="a"][@pass=1]为or模式尝试规避验证,由于第一种方式中双引号(")引参数通不过验证,所以推断后台处理参数采用单引号(')方式,条件组织格式如下:

//employee[@name='a' or '1'='1'][@pass=1]×



通过3次尝试及结果可以推断】:

1)后台数据中username及password均为属性值(非属性名);

或许:<employee id="1" username="a" password="1">

2)Lesson界面提交的参数(用户名、密码)组织条件时采用单引号(')

3)Lesson界面提交的参数(用户名、密码)组织条件时采用OR运算符连接多个条件而非联合条件方式

(1) 采用OR运算符连接Username参数与password参数,示例格式如下:

//employee[@name='a' or 1 or '1'='1' and @pass=1]

(2) 联合条件方式组织查询条件,示例格式如下:

//employee[@name='a' or '1'='1'][@pass=1]




参考资料:

http://baike.baidu.com/link?url=ZGMwnEAsI5qYFO2W2hBnWyutf80eFWhaiExnVvhzo8EXRRQNLzaY2iWoEXkjXVftpS4KZNC5-ycrjqxBD8CmrK

http://blog.csdn.net/shen332401890/article/details/22866843


推荐一个XPATH测试小工具:

http://download.csdn.net/detail/xyxieqing/830767



0 0