Blind XPath Injection - Çeviri Kulübü - VirtualGuardian ENGLISH

VirtualGuardian

Katılımcı Üye
29 Tem 2016
359
0
System
Description

XPath is a type of query language that describes how to locate specific elements (including attributes, processing instructions, etc.) in an XML docu ment. Since it is a query language, XPath is somewhat similar to Structured Query Language (SQL), however, XPath is different in that it can be used to reference almost any part of an XML docu ment without access control restrictions. In SQL, a "user" (which is a term undefined in the XPath/XML context) may be restricted to certain databases, tables, columns, or queries. Using an XPATH Injection attack, an attacker is able to modify the XPATH query to perform an action of his choosing.

Blind XPath Injection attacks can be used to extract data from an application that embeds user supplied data in an unsafe way. When input is not properly sanitized, an attacker can supply valid XPath code that is executed. This type of attack is used in situations where the attacker has no knowledge about the structure of the XML docu ment, or perhaps error message are suppressed, and is only able to pull once piece of information at a time by asking true/false questions(booleanized queries), much like Blind SQL Injection.


Examples

The attacker may mount a successful attack using two methods: Boolenization and XML Crawling. By adding to the XPath syntax, the attacker uses additional expressions (replacing what the attacker entered in the place of the injection).

Boolenization

Using the "Boolenization" method the attacker may find out if the given XPath expression is True or False. Let's assume that the aim of the attacker is to log in to an account in a web application. A Successful log in would return "True" and failed log in attempt would return "False". Only a small portion of the information is targeted via the analyzed character or number. When the attacker focuses on a string he may reveal it in its entirety by checking every single character within the class/range of characters this string belongs to.


Using a string-length(S) function, where S is a string, the attacker may find out the length of this string. With the appropriate number of substring(S,N,1) function iterations, where S is a previously mentioned string, N is a start character, and "1" is a next character counting from N character, the attacker is able to enumerate the whole string.



Kod:
<?xml version="1.0" encoding="UTF-8"?>
<data>
   <user>
   <login>admin</login>
   <password>test</password>
   <realname>SuperUser</realname>
   </user>
   <user>
   <login>rezos</login>
   <password>rezos123</password>
   <realname>Simple User</realname>
   </user>
</data>
Function:
  • string.stringlength(//user[position()=1]/child::node()[position()=2]) returns the length of the second string of the first user (8),
  • substring((//user[position()=1]/child::node()[position()=2),1,1) returns the first character of this user ('r').
XML Crawling

To get to know the XML docu ment structure the attacker may use:

  • count(expression)

    Kod:
    count(//user/child::node()
    This will return the number of nodes (in this case 2).
  • stringlength(string)

    Kod:
    string-length(//user[position()=1]/child::node()[position()=2])=6
    Using this query the attacker will find out if the second string (password) of the first node (user 'admin') consists of 6 characters.
  • substring(string, number, number)

    Kod:
    substring((//user[position()=1]/child::node()[position()=2]),1,1)="a"
    This query will confirm (True) or deny (False) that the first character of the user ('admin') password is an "a" character.
If the log in form would look like this:

C#:


Kod:
String FindUser;
FindUser = "//user[login/text()='" + Request("Username") + "' And
      password/text()='" + Request("Password") + "']";
then the attacker should inject the following code:

Kod:
Username: ' or substring((//user[position()=1]/child::node()[position()=2]),1,1)="a" or ''='
The XPath syntax may remind you of common SQL Injection attacks but the attacker must consider that this language disallows commenting out the rest of expresssion. To omit this limitation the attacker should use OR expressions to vo id all expressions, which may disrupt the attack.
Because of Boolenization the number of queries, even within a small XML docu ment, may be very high (thousands, houndred of thousands and more). That is why this attack is not conducted manually. Knowing a few basic XPath functions, the attacker is able to write an application in a short time which will rebuild the structure of the
docu ment and will fill it with data by itself.

Source: OWASP
 

qwer954

Kıdemli Üye
3 Ocak 2016
3,850
1
Bilinmez
Açıklama

XPath bir XML belgesel sinde (nitelikleri, işleme talimatları, vb dahil) belirli öğeleri bulmak açıklamaktadır sorgu dili bir türüdür. kontrollü bir kısıtlama olmadan, bir XML belgesel sinde neredeyse herhangi bir bölümünü referans için kullanılabilir olması ile bir sorgulama dili olduğu XPath Structured Query Language (SQL) benzeyen, ancak, XPath farklıdır. SQL, bir "kullanıcı" (XPath / XML bağlamda tanımlanmamış bir terim olan) bazı veritabanları, tablolar, sütunlar, veya sorguları kısıtlanmış olabilir. Bir XPATH Enjeksiyon saldırısı kullanarak, bir saldırganın kendi seçtiği bir eylemi gerçekleştirmek için XPATH sorgu değiştirmek mümkün değildir.

Kör XPath Enjeksiyon saldırıları güvenli olmayan bir şekilde kullanıcı tarafından sağlanan verileri gömer bir uygulama veri ayıklamak için kullanılabilir. giriş düzgün temizlenmiş değilken, bir saldırganın yürütülür geçerli XPath kodu sağlayabilmektedir. Bu tip saldırılara saldırganın bastırılmış XML belgesel Ment, ya da belki de hata iletisi yapısı hakkında hiçbir bilgiye sahip durumlarda kullanılan ve (doğru / yanlış sorular sorarak bir defada bilgi parçasına bir kez çekmek için sadece yapabiliyor çok Kör SQL Enjeksiyon gibi booleanized sorgular).

Örnekler

Boolenization ve XML Crawling: Saldırgan iki yöntem kullanarak başarılı bir saldırı monte edilebilir. XPath sözdizimi ekleyerek, saldırgan ek ifadeleri (saldırgan enjeksiyon yerinde girdiğiniz yerine) kullanır.

Boolenization

Belirtilen XPath ifadesi Doğru veya Yanlış ise saldırganın öğrenmek olabilir "Boolenization" yöntemi kullanarak. en saldırgan amacı bir web uygulamasında bir hesaba giriş yapmak olduğunu varsayalım. Başarılı Bir günlük olarak "True" dönmek ve "Yanlış" dönecekti girişimi günlüğü başarısız olur. Sadece bilgi küçük bir kısmı analiz karakter veya sayı üzerinden hedeflenmektedir. Saldırgan bir dize üzerinde duruluyor zaman o bu dize ait karakter sınıfı / aralığındaki her karakter kontrol ederek bütünüyle bunu ortaya çıkarabilir.


S dize dize uzunluğu (S) işlevini kullanarak, saldırgan, bu dizenin uzunluğu öğrenmek olabilir. S önce sözü edilen dize alt dize uygun sayıda (S, N, 1) işlevi tekrarlamalar ile, N başlangıç karakter ve "1" N karakter sayma bir sonraki karakter, saldırgan numaralandırmak yapabiliyor bütün dize.


Kod:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Veri>
***<Kullanıcı>
***<Giriş> Admin </ login>
***<Password> testi </ parola>
***<Realname> SuperUser </ realname>
***</ User>
***<Kullanıcı>
***<Giriş> Rezos </ login>
***<Password> rezos123 </ parola>
***<Realname> Basit kullanıcı </ realname>
***</ User>
</ Veri>
İşlev:
string.stringlength (// kullanıcı [position () = 1] / child :: node () [position () = 2]) ilk kullanıcı ikinci dizenin uzunluğunu döndürür (8),
Alt dize ((// kullanıcı [position () = 1] / child :: node () [position () = 2), 1,1) Bu kullanıcının ( 'r') ilk karakterini döndürür.
XML Tarama

Saldırgan kullanabilir, XML belgesel ment yapısını tanımak için:
saymak (ifade)

Kod:
() (// Kullanıcı / çocuk :: düğüm saymak
Bu (bu durumda 2) düğümlerin sayısını döndürür.
stringlength (dize)

Kod:
dize uzunluğu (// kullanıcı [position () = 1] / child :: node () [position () = 2]) = 6
İlk düğüm (kullanıcı 'admin') ikinci dize (şifre) 6 karakterden oluşuyorsa saldırganın bulacaksınız bu sorguyu kullanarak.
alt dize (string, sayı, sayı)

Kod:
Alt dize ((// kullanıcı [position () = 1] / child :: node () [position () = 2]), 1,1) = "a"
Bu sorgu (true) onaylamak veya kullanıcının ilk karakteri ( 'admin') parolası bir "a" karakteri olduğunu (Yanlış) inkar edecek.
şeklinde günlük şuna benzer edin:

C #:

Kod:
Dize FINDUSER;
FINDUSER = "// kullanıcı [giriş / text () = '" + Talebi ( "Kullanıcı adı") + "' Ve
******parola / text () = ' "+ Request (" Parola ") +"'] ";
Daha sonra saldırganın aşağıdaki kodu enjekte edilmelidir:

Kod:
Kullanıcı adı: 'veya alt dize ((// kullanıcı [position () = 1] / child :: node () [position () = 2]), 1,1) = "a" ya da' '='
XPath sözdizimi ortak SQL Injection saldırıları hatırlatmak ancak saldırganın bu dil ekspresyonu, geri kalanını yorumlama izin vermediğini göz önünde bulundurmalıdır. Saldırgan saldırı bozabilir ki, ID, tüm ifadeleri vo kullanmak VEYA ifadeler gereken bu sınırlama atlamak için.
Boolenization bile küçük bir XML belgesel Ment içinde sorgu sayısı, ve, (binlerce binlerce ve daha houndred) çok yüksek olabilir çünkü. Bu saldırı elle yürütülen değildir nedeni budur. Birkaç temel XPath işlevleri bilerek, saldırgan belgesel Ment yapısını yeniden inşa edecek ve kendisi tarafından verilerle doldurur kısa sürede bir uygulama yazmak mümkün olur.

Kaynak: OWASP


Çevirisi bu ama kodlar türkçede çok komik durmuş yazıda ( benim yazımda ) :D
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.