Secure web file retriever based in PHP
A public file retriever via HTTP to provide links to files in secure environments. This system allows you to recover a file hosted on a web server in a safe way by hiding the real path, real file name and restricting access to authorized users who haven’t the encryption key.
As an encryption mechanism it is proposed to use AES-256-CBC through the cryptographic extension of PHP OpenSSL (PHP 5 >= 5.3.0, PHP 7).
All files that you want to be accessible via the secure links can be located anywhere on your computer, PHP will take care of reading them and providing them if you have access to them.
From the name of a file to be accessed, it is encrypted using a symmetrical key algorithm. This encrypted string is part of the secure link to access the remote server file.
The encrypted string is converted in index.html
with Javascript to Base64 in client side so that the transmission does not present coding problems. This is done in an intermediate phase.
In this phase, this coded string is automatically sent to the delta.php
script using GET
with x parameter.
The server record the access with timestamp and IP address.
In order to configure the retriever, a number of parameters must be set:
$rute = '<ABSOULTE_PATH>';
$domain = "<DOMAIN>";
$password = hex2bin('<PASSWORD>');
$iv = hex2bin('<IV>');
To obtain in secure link it is necessary to generate by means of symmetric encryption the encrypted name of the file to which you want to retrieve.
echo -n "<FILENAME_TO_ENCRYPT>" | openssl AES-256-CBC -K "<KEY>" -iv "<IV>" -a -salt
$output = openssl_encrypt("<FILENAME_TO_ENCRYPT>", 'AES-256-CBC', $password, 0, $iv);
Note that the key must be provided in hexadecimal and 32 digits.
Now, with the encrypted string is possible create the secure link. The generated secure link must have the following structure: http://example.com/opendelta/?=<encrypted_string>
This project is licensed under GNU Lesser General Public License v3.0