fixed decrypting

This commit is contained in:
Luke Ogburn
2019-04-08 23:50:37 -04:00
parent 686085e935
commit 38ba5a20b1
3 changed files with 35 additions and 76 deletions

View File

@@ -1,30 +1,21 @@
<?php
require "enc.php";
$data = $_POST["words"];
$words = "<encrypted>".$_POST["words"]."</encrypted>";
$data = simplexml_load_string($words) or die("Couldn't make object");
//Get the key
$key = $_POST["key"];
echo "key is $key <br>";
//Get the IV
preg_match('#(?<=(<iv>))(.*?)(<\/iv>)#', $data, $ivArr);
$iv = $ivArr[0];
$iv = substr($iv, 0, strlen("</content>"));
echo "iv is $iv <br>";
$iv = hex2bin($data->iv);
//Get the tag
preg_match('#(?<=(<tag>))(.*?)(<\/tag>)#', $data, $tagArr);
$tag = bin2hex($tagArr[0]);
$tag = substr($tag, 0, strlen("</tag>"));
echo "tag is $tag <br>";
$tag = hex2bin($data->tag);
//Get the ciphertext
preg_match('#(?<=(<content>))(.*?)(<\/content>)#', $data, $ctArr);
$ciphertext = $ctArr[0];
$ciphertext = substr($ciphertext, 0, strlen("</content>"));
echo "text is $ciphertext <br>";
$ciphertext = $data->content;
$content = decrypt($ciphertext, $key, $iv, $tag);
echo "content is:<br>"; var_dump($content);
echo "<pre>Your decrypted content:<br>";
echo decrypt($ciphertext, $key, $iv, $tag);;
?>

View File

@@ -1,59 +1,27 @@
[08-Apr-2019 22:38:51 America/New_York] PHP Notice: Undefined variable: current_key in /home/lukeuxao/public_html/cs/submit.php on line 3
[08-Apr-2019 22:38:51 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
[08-Apr-2019 22:41:11 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
[08-Apr-2019 22:41:25 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:41:25 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:42:00 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:42:00 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:42:28 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:42:28 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:42:53 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:42:53 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:43:33 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:43:33 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:43:33 America/New_York] PHP Notice: Undefined index: file in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:44:04 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:44:04 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:44:04 America/New_York] PHP Notice: Undefined index: encrypted.txt in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:44:13 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:44:13 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:44:13 America/New_York] PHP Notice: Undefined index: encrypted in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:45:21 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:45:21 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:45:21 America/New_York] PHP Notice: Undefined index: upload_file in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
[08-Apr-2019 22:45:21 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
[08-Apr-2019 22:47:24 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:47:24 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:47:24 America/New_York] PHP Notice: Undefined index: upload_file in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
[08-Apr-2019 22:47:24 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
[08-Apr-2019 22:47:43 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:47:43 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:48:15 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:48:15 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 22:48:15 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:48:15 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:51:00 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:51:00 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:51:03 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:51:03 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:51:07 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:51:07 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:53:04 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:53:04 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 22:55:21 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
[08-Apr-2019 23:01:42 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
[08-Apr-2019 23:01:50 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
[08-Apr-2019 23:04:28 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:04:33 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:04:42 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:05:07 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:05:23 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:13:43 America/New_York] PHP Notice: Undefined variable: iv in /home/lukeuxao/public_html/cs/decryptFunc.php on line 13
[08-Apr-2019 23:13:43 America/New_York] PHP Notice: Undefined variable: iv in /home/lukeuxao/public_html/cs/decryptFunc.php on line 25
[08-Apr-2019 23:13:43 America/New_York] PHP Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined index: words in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined index: key in /home/lukeuxao/public_html/cs/decryptFunc.php on line 6
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined offset: 0 in /home/lukeuxao/public_html/cs/decryptFunc.php on line 11
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined offset: 0 in /home/lukeuxao/public_html/cs/decryptFunc.php on line 16
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined offset: 0 in /home/lukeuxao/public_html/cs/decryptFunc.php on line 21
[08-Apr-2019 23:14:25 America/New_York] PHP Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:39:18 America/New_York] PHP Notice: Undefined variable: tag in /home/lukeuxao/public_html/cs/decryptFunc.php on line 18
[08-Apr-2019 23:40:03 America/New_York] PHP Warning: substr() expects parameter 1 to be string, array given in /home/lukeuxao/public_html/cs/decryptFunc.php on line 18
[08-Apr-2019 23:43:45 America/New_York] PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Extra content at the end of the document in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:43:45 America/New_York] PHP Warning: simplexml_load_string(): &lt;iv&gt;7b2db79604ebdc87ecacc527&lt;/iv&gt;&lt;tag&gt;c5b396d20a22bb418ba238d6563b0df3&lt;/tag&gt;&lt;con in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:43:45 America/New_York] PHP Warning: simplexml_load_string(): ^ in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:43:45 America/New_York] PHP Notice: Trying to get property 'iv' of non-object in /home/lukeuxao/public_html/cs/decryptFunc.php on line 11
[08-Apr-2019 23:43:45 America/New_York] PHP Notice: Trying to get property 'tag' of non-object in /home/lukeuxao/public_html/cs/decryptFunc.php on line 15
[08-Apr-2019 23:43:45 America/New_York] PHP Notice: Undefined variable: tag in /home/lukeuxao/public_html/cs/decryptFunc.php on line 16
[08-Apr-2019 23:43:45 America/New_York] PHP Notice: Trying to get property 'content' of non-object in /home/lukeuxao/public_html/cs/decryptFunc.php on line 19
[08-Apr-2019 23:43:45 America/New_York] PHP Notice: Undefined variable: ciphertext in /home/lukeuxao/public_html/cs/decryptFunc.php on line 20
[08-Apr-2019 23:43:45 America/New_York] PHP Notice: Undefined variable: ciphertext in /home/lukeuxao/public_html/cs/decryptFunc.php on line 22
[08-Apr-2019 23:43:45 America/New_York] PHP Notice: Undefined variable: tag in /home/lukeuxao/public_html/cs/decryptFunc.php on line 22
[08-Apr-2019 23:43:45 America/New_York] PHP Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in /home/lukeuxao/public_html/cs/enc.php on line 14
[08-Apr-2019 23:44:04 America/New_York] PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Extra content at the end of the document in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:04 America/New_York] PHP Warning: simplexml_load_string(): &lt;iv&gt;7b2db79604ebdc87ecacc527&lt;/iv&gt;&lt;tag&gt;c5b396d20a22bb418ba238d6563b0df3&lt;/tag&gt;&lt;con in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:04 America/New_York] PHP Warning: simplexml_load_string(): ^ in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:15 America/New_York] PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Extra content at the end of the document in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:15 America/New_York] PHP Warning: simplexml_load_string(): &lt;iv&gt;7b2db79604ebdc87ecacc527&lt;/iv&gt;&lt;tag&gt;c5b396d20a22bb418ba238d6563b0df3&lt;/tag&gt;&lt;con in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:15 America/New_York] PHP Warning: simplexml_load_string(): ^ in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:40 America/New_York] PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Extra content at the end of the document in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:40 America/New_York] PHP Warning: simplexml_load_string(): &lt;iv&gt;7b2db79604ebdc87ecacc527&lt;/iv&gt;&lt;tag&gt;c5b396d20a22bb418ba238d6563b0df3&lt;/tag&gt;&lt;con in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:44:40 America/New_York] PHP Warning: simplexml_load_string(): ^ in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
[08-Apr-2019 23:47:44 America/New_York] PHP Notice: Undefined variable: tag in /home/lukeuxao/public_html/cs/decryptFunc.php on line 17
[08-Apr-2019 23:47:44 America/New_York] PHP Notice: Undefined variable: ciphertext in /home/lukeuxao/public_html/cs/decryptFunc.php on line 21
[08-Apr-2019 23:47:44 America/New_York] PHP Notice: Undefined variable: ciphertext in /home/lukeuxao/public_html/cs/decryptFunc.php on line 23
[08-Apr-2019 23:47:44 America/New_York] PHP Notice: Undefined variable: tag in /home/lukeuxao/public_html/cs/decryptFunc.php on line 23
[08-Apr-2019 23:48:21 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14

View File

@@ -1,7 +1,7 @@
<?php
require "enc.php";
$enc = encrypt($_POST["words"], $_POST["key"]);
$content = '<iv>'.$enc[1].'</iv>'.'<tag>'.$enc[2].'</tag>'.'<content>'.$enc[0]."</content>";
$content = '<iv>'.bin2hex($enc[1]).'</iv>'.'<tag>'.bin2hex($enc[2]).'</tag>'.'<content>'.$enc[0]."</content>";
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="encrypted.txt"');