Slide 1

Slide 1 text

How do I see the source code? • Include files (header.inc) • Backup files • Temp files (nano, vim, etc) • .git or another version-control system • Arbitrary file reading

Slide 2

Slide 2 text

Interpret it! Anton “Bo0oM” Lopanitsyn

Slide 3

Slide 3 text

Server configuration errors Multiple routing and microservices location / { try_files $uri $uri/ /index.html; ... } location /blog { … }

Slide 4

Slide 4 text

Server configuration errors Multiple routing and microservices

Slide 5

Slide 5 text

How to find it? https://example.com/config.php - 200, 0B https://example.com/config.php - 200, 3KB Content-type: application/octet-stream text/plain

Slide 6

Slide 6 text

Find a vulnerability in the config! location ~ ^(.+\.php)(.*)$ { fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT /var/www/html; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_index index.php; }

Slide 7

Slide 7 text

Nope https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info

Slide 8

Slide 8 text

Windows + Nginx = <3 https://example.com/config.php - 200, 0B https://example.com/config.pHP location ~ ^(.+\.php)(.*)$ location ~ ^(.+\.php)(.*)$ Linux (case sensitive): https://example.com/config.pHP - 404 Windows: https://example.com/config.pHP - 200

Slide 9

Slide 9 text

Nginx /etc/nginx/site-enabled/default
 
 
 server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.html index.htm index.nginx-debian.html; server_name _; location / { try_files $uri $uri/ =404; } }

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Apache /etc/apache2/sites-enabled/000-default.conf ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

Slide 14

Slide 14 text

Apache /etc/apache2/sites-enabled/example.conf DocumentRoot /var/www/html/example.com SetHandler application/x-httpd-php 
 …

Slide 15

Slide 15 text

How to find it? example.com, IP: 123.123.123.123 Check http://123.123.123.123/config.php http://123.123.123.123/example/config.php http://123.123.123.123/example.com/config.php

Slide 16

Slide 16 text

CDN’s https://forum.example.com https://cdn.example.com/forum/static/123/123.jpg https://cdn.example.com/forum/config.php Unbelievable, but the fact is, some move the whole project to cdn!

Slide 17

Slide 17 text

0day

Slide 18

Slide 18 text

Blog: https://bo0om.ru Twitter: @i_bo0om Telegram channel: @webpwn