General 的个人博客

你一定会喜欢那个因为喜欢她而发光的自己!

人间忽晚,山河已秋。

  menu
48 文章
0 浏览
ღゝ◡╹)ノ❤️

XPath注入

XPath 简介

XPath 即为 XML 路径语言 (XML Path Language) ,是一种用于导航 XML 文档并从中获取数据的解释性语言。

如果 Web 应哟偶那个程序将数据保存在 XML 文档中,那么就是以使用 XPath 访问数据,以响应用户提交的输入。如果这个输入未经任何过滤或精华就插入到 XPath 查询中,攻击者就可以通过控制查询来破坏应用程序的逻辑,或者获取未经授权访问的数据。

XML 文档不是保存企业数据的首选工具,但是它常常用于保存可根据用户输入获取的应用程序配置数据或者保存一些简单信息。

<users>
    <user>
        <username>First</username>
        <password>aaaaaa</password>
        <email>first@qq.com</email>
        <card>111111</card>
    </user>
    
    <user>
        <username>Second</username>
        <password>bbbbbb</password>
        <email>second@qq.com</email>
        <card>222222</card>
    </user>
    
    <user>
        <username>Third</username>
        <password>cccccc</password>
        <email>third@qq.com</email>
        <card>333333</card>
    </user>
    
    <user>
        <username>Fouth</username>
        <password>dddddd</password>
        <email>fouth@qq.com</email>
        <card>444444</card>
    </user>
</users>

获取所有电子邮件的 XPath 查询

//users/user/email

在一些应用程序中,用户提交的数据会被直接嵌入到 XPath 查询中,查询的结果可能在应用程序的响应中返回,或者用于决定应用程序某些方面的行为。

更多 XPath 语法,可以查看 https://www.runoob.com/xpath/xpath-tutorial.html

逻辑注入

以一个根据用户名和密码获得用户的信用卡号码的 XPath 查询为例:

//users/user[username='First' and password='aaaaaa']/card

与 SQL 注入一样,可以破坏它的查询获取所有用户的信用卡号:

//users/user[username='First' and password='aaaaaa' or 'a'='a']/card

判断注入

XPath 中包含一个字符串函数,可用它一次一个字符地测试字符串的值。

如果用户密码第一个字符为 'a',将返回结果。

//users/user[username='First' and substring(password,1,1)='a']

轮流针对每个字符进行测试,就可获得 First 的完整密码。

父节点注入

你处在第四个节点,可以通过获取祖先节点的方式获取所有用户信息。

//username[text()='Fouth']/ancestor::users/user

标题:XPath注入
作者:General
地址:https://ZZUGEneral.github.io/articles/2020/10/27/1603789794959.html
一个没有得到Java开发工作的测试员!