【Xpath注入】xpath注入的原理

admin 2022年1月10日03:31:12评论10 views字数 1187阅读3分57秒阅读模式

前言

  • Xpath注入形式

Xpath注入

当前目录创建xpath.php、xpath_user.xml

image-20210820160428212

然后php中写入

1
2
3
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
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form method="POST">
用户名:<input type="text" name="username"><br/>
密码:<input type="password" name="password"><br/>
<input type="submit" value="Login" name="submit">
</form>
</body>
</html>
<?php
/*
# -*- coding: utf-8 -*-
# @Author: GuYing
# @Date: 2021/8/15
*/
if(file_exists('xpath_user.xml')){
$xml=simplexml_load_file('xpath_user.xml');

if($_POST['submit']){
$username = $_POST['username'];
$password = $_POST['password'];
$sql="user[@username='{$username}' and @password='{$password}']";
$result = $xml->xpath($sql);
if(count($result)!=0){
echo 'Success';
}else{
echo 'failed';
}

// foreach($xml as $v)
// {
// if($v['username']==$username)
// if($v['password']==$password)
// echo '登陆成功';
// else{
// echo '密码错误';
// }
// }

}
}

?>

下面一个xml文件中写入

1
2
3
4
5
6
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user id="1" username="admin" password="admin"></user>
<user id="2" username="root" password="admin"></user>
<user id="3" username="system" password="admin"></user>
</users>

这样就搭建一个xpath形式的登陆框,一样可以使用万能密码登陆

image-20210820160619564

我的个博客

孤桜懶契:http://gylq.gitee.io

FROM:gylq.gitee Author:孤桜懶契

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月10日03:31:12
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【Xpath注入】xpath注入的原理https://cn-sec.com/archives/729952.html

发表评论

匿名网友 填写信息