Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.www.php > #22095
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Alessandro Pellizzari <shuriken@amiran.it> |
| Newsgroups | it.comp.www.php |
| Subject | Re: Limitare filebrowser ad una directory radice |
| Date | Thu, 14 Jun 2018 09:38:02 +0100 |
| Lines | 22 |
| Message-ID | <foenraFsj3U1@mid.individual.net> (permalink) |
| References | <slrnpi43pi.3kb.gbertozzi@debian.asus.home> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net ec/HBhrbPAM9BUrEOPg0fwaRrf/1ycn+L4+q9I9s+oSf7eB9o= |
| Cancel-Lock | sha1:pv99cacAe7YA4wShYrIxL4wmw4A= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
| In-Reply-To | <slrnpi43pi.3kb.gbertozzi@debian.asus.home> |
| Content-Language | en-GB |
| Xref | csiph.com it.comp.www.php:22095 |
Show key headers only | View raw
On 14/06/18 07:46, Gianfranco wrote:
> Il problema e' come evitare che passando un parametro ad hoc si
> scavalchi la radice "./documenti", ad esempio con "Dir=./documenti/../"
> oppure "Dir=/dir-esterna/".
Use realpath() per calcolare il path effettivo a cui l'utente vuole
accedere, poi controlli che inizi con il path che hai definito, e se non
lo fa torni errore.
$pathCondiviso = "/var/www/shared/";
$pathRichiesto = realpath($pathCondiviso . $_GET['Dir']);
if (mb_substr($pathRichiesto, 0, mb_strlen($pathCondiviso)) !==
$pathCondiviso) {
exit 'Not allowed';
}
O qualcosa del genere. Tweak a piacere.
Bye.
Back to it.comp.www.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Limitare filebrowser ad una directory radice Gianfranco <gbertozzi@gmail.com> - 2018-06-14 06:46 +0000
Re: Limitare filebrowser ad una directory radice Alessandro Pellizzari <shuriken@amiran.it> - 2018-06-14 09:38 +0100
Re: Limitare filebrowser ad una directory radice Gianfranco <gbertozzi@gmail.com> - 2018-06-14 10:37 +0000
Re: Limitare filebrowser ad una directory radice Gianfranco <gbertozzi@gmail.com> - 2018-06-14 14:26 +0000
csiph-web