# XSLT Sunucu Tarafı Enjeksiyonu (Genişletilebilir Stil Sayfası Dönüşümleri)
{{#include ../banners/hacktricks-training.md}}
## Temel Bilgiler
XSLT, XML belgelerini farklı formatlara dönüştürmek için kullanılan bir teknolojidir. Üç versiyonu vardır: 1, 2 ve 3, bunlar arasında en yaygın olarak kullanılan versiyon 1'dir. Dönüşüm süreci, ya sunucuda ya da tarayıcı içinde gerçekleştirilebilir.
En sık kullanılan çerçeveler şunlardır:
- **Libxslt** Gnome'dan,
- **Xalan** Apache'den,
- **Saxon** Saxonica'dan.
XSLT ile ilişkili güvenlik açıklarının istismar edilmesi için xsl etiketlerinin sunucu tarafında saklanması ve ardından bu içeriğe erişilmesi gerekmektedir. Böyle bir güvenlik açığının bir örneği aşağıdaki kaynakta belgelenmiştir: [https://www.gosecure.net/blog/2019/05/02/esi-injection-part-2-abusing-specific-implementations/](https://www.gosecure.net/blog/2019/05/02/esi-injection-part-2-abusing-specific-implementations/).
## Örnek - Eğitim
```bash
sudo apt-get install default-jdk
sudo apt-get install libsaxonb-java libsaxon-java
```
```xml:xml.xml
CD Title
The artist
Da Company
10000
1760
```
```xml:xsl.xsl
The Super title
```
Yürüt:
```xml
saxonb-xslt -xsl:xsl.xsl xml.xml
Warning: at xsl:stylesheet on line 2 column 80 of xsl.xsl:
Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
The Super title
Title |
artist |
CD Title |
The artist |
```
### Parmak İzi
```xml:detection.xsl
Version:
Vendor:
Vendor URL:
Product Name:
Product Version:
Is Schema Aware ?:
Supports Serialization:
Supports Backwards Compatibility:
```
Ve çalıştırın
```xml
$saxonb-xslt -xsl:detection.xsl xml.xml
Warning: at xsl:stylesheet on line 2 column 80 of detection.xsl:
Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
XSLT identification
Version:2.0
Vendor:SAXON 9.1.0.8 from Saxonica
Vendor URL:http://www.saxonica.com/
```
### Yerel Dosyayı Oku
```xml:read.xsl
```
```xml
$ saxonb-xslt -xsl:read.xsl xml.xml
Warning: at xsl:stylesheet on line 1 column 111 of read.xsl:
Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
```
### SSRF
```xml
```
### Sürümler
Kullanılan XSLT sürümüne bağlı olarak daha fazla veya daha az işlev olabilir:
- [https://www.w3.org/TR/xslt-10/](https://www.w3.org/TR/xslt-10/)
- [https://www.w3.org/TR/xslt20/](https://www.w3.org/TR/xslt20/)
- [https://www.w3.org/TR/xslt-30/](https://www.w3.org/TR/xslt-30/)
## Parmak İzi
Bunu yükleyin ve bilgi alın
```xml
Version:
Vendor:
Vendor URL:
Product Name:
Product Version:
Is Schema Aware ?:
Supports Serialization:
Supports Backwards Compatibility:
```
## SSRF
```xml
```
## Javascript Enjeksiyonu
```xml
```
## Dizin listeleme (PHP)
### **Opendir + readdir**
```xml
-
-
-
-
-
-
-
-
-
```
### **Assert (var_dump + scandir + false)**
```xml
```
## Dosyaları Oku
### **İç - PHP**
```xml
```
### **İç - XXE**
```xml
]>
&ext_file;
```
### **HTTP Üzerinden**
```xml
```
```xml
]>
&passwd;
```
### **Dahili (PHP-fonksiyonu)**
```xml
```
```xml
```
### Port taraması
```xml
```
## Bir dosyaya yaz
### XSLT 2.0
```xml
Write Local File
```
### **Xalan-J uzantısı**
```xml
Write Local File
```
PDF'de dosya yazmanın diğer yolları
## Harici XSL dahil et
```xml
```
```xml
```
## Kod Çalıştır
### **php:function**
```xml
```
```xml
```
Kodları PDF'de diğer çerçeveler kullanarak çalıştırın
### **Daha Fazla Dil**
**Bu sayfada diğer dillerde RCE örneklerini bulabilirsiniz:** [**https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt_injection#C%23%2FVB.NET%2FASP.NET**](https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt_injection#C%23%2FVB.NET%2FASP.NET) **(C#, Java, PHP)**
## **Sınıflardan PHP statik fonksiyonlarına erişim**
Aşağıdaki fonksiyon, XSL sınıfının `stringToUrl` statik metodunu çağıracaktır:
```xml
```
(Örnek [http://laurent.bientz.com/Blog/Entry/Item/using_php_functions_in_xsl-7.sls](http://laurent.bientz.com/Blog/Entry/Item/using_php_functions_in_xsl-7.sls))
## Daha Fazla Payload
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSLT%20Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSLT%20Injection) kontrol edin
- [https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt_injection](https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt_injection) kontrol edin
## **Brute-Force Tespit Listesi**
{{#ref}}
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/xslt.txt
{{#endref}}
## **Referanslar**
- [XSLT_SSRF](https://feelsec.info/wp-content/uploads/2018/11/XSLT_SSRF.pdf)
- [http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20IO%20Active.pdf](http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20IO%20Active.pdf)
- [http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20Blackhat%202015.pdf](http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20Blackhat%202015.pdf)
{{#include ../banners/hacktricks-training.md}}