Owncloud – Descifrar ficheros manualmente
Con el siguiente script se puede descrifrar el contenido de un fichero cifrado de owncloud.
El script php quedaría así:
<?php
require_once 'crypt.php';
// first get users private key and decrypt it
$encryptedUserKey = file_get_contents("/var/www/clients/client1/web1/web/data/user1/files_encryption/test.txt.private.key");
$decryptedUserKey = OCA\Encryption\Crypt::decryptPrivateKey($encryptedUserKey, "admin");
// now we need to decrypt the file-key, therefore we use our private key and the share key
$shareKey = file_get_contents("/var/www/clients/client1/web1/web/data/user1/files_encryption/share-keys/documents/test.txt.user1.shareKey");
$encryptedKeyfile = file_get_contents("/var/www/clients/client1/web1/web/data/user1/files_encryption/keyfiles/documents/test.txt.key");
$decryptedKeyfile = OCA\Encryption\Crypt::multiKeyDecrypt($encryptedKeyfile, $shareKey, $decryptedUserKey);
// finally we can use the decrypted file-key to decrypt the file
$encryptedContent = file_get_contents("/var/www/clients/client1/web1/web/data/user1/files/documents/test.txt");
$decryptedContent = OCA\Encryption\Crypt::symmetricDecryptFileContent($encryptedContent, $decryptedKeyfile);
//echo "result: " . $decryptedContent . "\n";
echo $decryptedContent;
?>
Observaciones:
- Hay un require de crypt.php, se tiene que tener en cuenta ehhh 😉
- Se tiene que disponer de la private.key, del shareKey y del keyfile para poder realizar el descifrado.
RT @okITupSL: Owncloud – Descifrar ficheros manualmente: Con el siguiente script se puede descrifrar el contenido de un… https://t.co/S5A…