Uploaded Encryptor

This commit is contained in:
MatMasIt 2021-02-15 12:35:44 +01:00 committed by GitHub
parent 6c02400ae7
commit 59ced988f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 279 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{
"require": {
"nelexa/zip": "^3.3"
}
}

223
SafeBoxEncryptor/composer.lock generated Normal file
View File

@ -0,0 +1,223 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "dc4537a601225d89f3349e44fc30dfdb",
"packages": [
{
"name": "nelexa/zip",
"version": "3.3.3",
"source": {
"type": "git",
"url": "https://github.com/Ne-Lexa/php-zip.git",
"reference": "501b52f6fc393a599b44ff348a42740e1eaac7c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ne-Lexa/php-zip/zipball/501b52f6fc393a599b44ff348a42740e1eaac7c6",
"reference": "501b52f6fc393a599b44ff348a42740e1eaac7c6",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"paragonie/random_compat": "*",
"php": "^5.5.9 || ^7.0",
"psr/http-message": "^1.0",
"symfony/finder": "^3.0|^4.0|^5.0"
},
"require-dev": {
"ext-bz2": "*",
"ext-fileinfo": "*",
"ext-openssl": "*",
"ext-xml": "*",
"guzzlehttp/psr7": "^1.6",
"phpunit/phpunit": "^4.8|^5.7",
"symfony/var-dumper": "^3.0|^4.0|^5.0"
},
"suggest": {
"ext-bz2": "Needed to support BZIP2 compression",
"ext-fileinfo": "Needed to get mime-type file",
"ext-mcrypt": "Needed to support encrypt zip entries or use ext-openssl",
"ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpZip\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ne-Lexa",
"email": "alexey@nelexa.ru",
"role": "Developer"
}
],
"description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, ZipAlign tool, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.",
"homepage": "https://github.com/Ne-Lexa/php-zip",
"keywords": [
"archive",
"extract",
"unzip",
"winzip",
"zip",
"zipalign",
"ziparchive"
],
"time": "2020-07-11T21:01:42+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.100",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a",
"shasum": ""
},
"require": {
"php": ">= 7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "symfony/finder",
"version": "v5.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "4adc8d172d602008c204c2e16956f99257248e03"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/4adc8d172d602008c204c2e16956f99257248e03",
"reference": "4adc8d172d602008c204c2e16956f99257248e03",
"shasum": ""
},
"require": {
"php": ">=7.2.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"time": "2021-01-28T22:06:19+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

View File

@ -0,0 +1,51 @@
<?php
require ("vendor/autoload.php");
echo "SafeBox v 1.0\n";
echo "Ecryptor\n";
echo ">New Archive\n";
$title = readline("\nTitle: ");
$author = readline("\nAuthor: ");
$line = readline("\nMessage [multiline, \"quit\" to quit]: \n");
$message = "";
do{
if ($line == "quit") break;
$message .= $line . "\n";
$line = readline("");
}
while (trim($message) != "quit");
$nkeys = (int)readline("\nHow many keys? : ");
$keysArr = [];
$keytot = [];
for ($i = 0;$i < $nkeys;$i++)
{
$keytot[] = trim(readline("Key No. " . ($i + 1) . ": "));
}
echo "\n--------\n";
echo "ATTENTION!\n";
echo "Ask to keep the key and key number to the holder!\n";
echo "The SafeBox can only be decrypted with the exact keys in the exact order, which is:\n";
for ($i = 0;$i < $nkeys;$i++)
{
echo ($i + 1) . " -> " . $keytot[$i] . "\n";
}
echo "\n--------\n";
do{
$path = readline("\nInsert box folder path: ");
}
while (!is_dir($path));
$fileName = readline("\nInsert Box Name: ");
$fileName = preg_replace("/[^a-zA-Z0-9]+/", "", $fileName);
$json = json_encode(["title" => $title, "author" => $author, "message" => $message, "nkeys" => $nkeys, "unixcreated" => time() ], JSON_PRETTY_PRINT);
$zipDirHandle = new \PhpZip\ZipFile();
$zipDirHandle->addDir($path);
$zipDirHandle->setPassword("|" . implode("|", $keytot) . "|");
$zipDirHandle->saveAsFile("data.zip");
$safeBoxHandle = new \PhpZip\ZipFile();
$safeBoxHandle->addFromString("meta.json", $json);
$safeBoxHandle->addFile("data.zip");
$safeBoxHandle->saveAsFile($fileName . ".sfbx");
echo "\nDONE\n";