//phpinfo();exit;
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
error_reporting(E_ALL);
ini_set('display_errors', 1);
} else {
error_reporting(0);
}
//some kind of edit.
$dateformat = 'Y-m-d h:i:s a';
$availableHashes = array("md4", "md5", "sha1", "sha224", "sha256", "sha384", "sha512");
$availableEncodings = array("base64-encode", "base64-decode", "hex-to-binary", "binary-to-hex");
$now = new DateTime();
function filterChars(& $str) {
$len1 =strlen(bin2hex($str))/2;
$str = preg_replace('/[\x00-\x1F\x7F]/u', '', $str);
$len2 =strlen(bin2hex($str))/2;
if($len1 != $len2) {
$str = "(filtered) $str";
}
if(empty($str)) {
$str = "Error converting";
}
}
if(!empty($_POST["toepoch"])) {
$date = new DateTime($_POST["toepoch"]);
echo $date->getTimestamp();
exit;
}
if(!empty($_POST["todate"])) {
if(is_numeric($_POST["todate"])) {
$date = new DateTime("@".$_POST["todate"]);
echo $date->format($dateformat);
}
exit;
}
if(!empty($_POST["cryptome"])) {
//echo "Do it: ".$_POST["hashme"];
while (true) {
$filename = "/tmp/".uniqid('cryptoknife', true) . '.txt';
if (!file_exists($filename)) break;
}
//echo json_encode(array($filename)); exit;
if(file_put_contents($filename, $_POST["cryptome"]) < 1) {
echo json_encode(array("Error: Empty.")); exit;
}
//exit;
$resultArray = array();
foreach($availableHashes as $hash) {
if(!empty($_POST[$hash])){
$resultArray[$hash] = exec('openssl dgst -'.$hash.' '.$filename.' | sed \'s/^.* //\'');
}
}
if(!empty($_POST["base64-encode"])){
$resultArray["base64-encode"] = base64_encode(file_get_contents($filename));
}
if(!empty($_POST["base64-decode"])){
try {
$resultArray["base64-decode"] = base64_decode(file_get_contents($filename));
filterChars($resultArray["base64-decode"]);
} catch(Exception $e) {
$resultArray["base64-decode"] = "Could not decode";
}
//filter non ascii...
}
if(!empty($_POST["hex-to-binary"])){
$resultArray["hex-to-binary"] = hex2bin(file_get_contents($filename));
filterChars($resultArray["hex-to-binary"]);
}
if(!empty($_POST["binary-to-hex"])){
$resultArray["binary-to-hex"] = bin2hex(file_get_contents($filename));
filterChars($resultArray["binary-to-hex"]);
}
//echo -n 'input' | openssl base64
unlink($filename);
echo json_encode($resultArray);
exit;
}
$windowsdownload = "https://github.com/dannagle/Cryptoknife/releases/download/v2.0.1/CryptoknifePortable_v2.0.1.zip";
$windowsversion = "v2.0.1";
$macdownload = "https://github.com/dannagle/Cryptoknife/releases/download/v2.0.1/Cryptoknife_v2.0.2.dmg";
$macversion = "v2.0.2";
require_once "Parsedown.php";
$mailattempt = false;
$mailret = false;
//echo $_GET["page"];exit;
$locationinclude = "pages/about.php";
$location = $locationinclude;
if (empty($_GET["page"])) {
$locationinclude = "pages/about.php";
} else {
$location = "pages/".$_GET["page"].".php";
$locationinclude = $location;
}
if (file_exists($locationinclude)) {
$locationinclude = $location;
} else {
header("Location: /");
}
include_once $locationinclude;
$markdown = "";
if ($locationinclude == "pages/documentation.php") {
$Parsedown = new Parsedown();
$markdown = $Parsedown->text(file_get_contents("DOCUMENTATION.md"));
$markdown = str_ireplace("" . $markdown . "";
}
if ($mailattempt || ($locationinclude == "pages/contact.php")) {
//$Parsedown = new Parsedown();
//$markdown = $Parsedown->text(file_get_contents("PSREADME.md"));
// $markdown = str_ireplace("
Cryptoknife is an open source all-in-one, portable,
collection of general-purpose cryptography tools from the same author of Packet Sender.