From 686085e9350deda4949bc6b2df40393254676773 Mon Sep 17 00:00:00 2001 From: Luke Ogburn <21106956+OakBaron@users.noreply.github.com> Date: Mon, 8 Apr 2019 23:21:58 -0400 Subject: [PATCH] Made things functional, decrypt still doesn't work --- decrypt.php | 17 ++++++++++++++ decryptFunc.php | 30 +++++++++++++++++++++++++ error_log | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 25 ++++++--------------- submit.php | 18 +++++---------- 5 files changed, 119 insertions(+), 30 deletions(-) create mode 100644 decrypt.php create mode 100644 decryptFunc.php create mode 100644 error_log diff --git a/decrypt.php b/decrypt.php new file mode 100644 index 0000000..386056c --- /dev/null +++ b/decrypt.php @@ -0,0 +1,17 @@ + + + + + Decrypt file + + + + +
+ + + + +
+ + \ No newline at end of file diff --git a/decryptFunc.php b/decryptFunc.php new file mode 100644 index 0000000..725da5b --- /dev/null +++ b/decryptFunc.php @@ -0,0 +1,30 @@ +"; + + + //Get the IV + preg_match('#(?<=())(.*?)(<\/iv>)#', $data, $ivArr); + $iv = $ivArr[0]; + $iv = substr($iv, 0, strlen("")); + echo "iv is $iv
"; + + //Get the tag + preg_match('#(?<=())(.*?)(<\/tag>)#', $data, $tagArr); + $tag = bin2hex($tagArr[0]); + $tag = substr($tag, 0, strlen("")); + echo "tag is $tag
"; + + //Get the ciphertext + preg_match('#(?<=())(.*?)(<\/content>)#', $data, $ctArr); + $ciphertext = $ctArr[0]; + $ciphertext = substr($ciphertext, 0, strlen("")); + echo "text is $ciphertext
"; + + $content = decrypt($ciphertext, $key, $iv, $tag); + echo "content is:
"; var_dump($content); +?> \ No newline at end of file diff --git a/error_log b/error_log new file mode 100644 index 0000000..2168f5d --- /dev/null +++ b/error_log @@ -0,0 +1,59 @@ +[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 diff --git a/index.php b/index.php index bf44f1a..916a98b 100644 --- a/index.php +++ b/index.php @@ -3,34 +3,23 @@ Encrytion and stuff - - + +
-

500

+

-
- - -
+ +
\ No newline at end of file diff --git a/submit.php b/submit.php index 604f345..973fe77 100644 --- a/submit.php +++ b/submit.php @@ -1,15 +1,9 @@ '.$enc[1].'
'.''.$enc[2].''.''.$enc[0].""; - $stmt = $conn->prepare("INSERT INTO posts (id, user_id, text, iv, tag) VALUES (:id, :uid, :txt, :iv, :tag)"); - $stmt->bindParam(":id", $postID); - $stmt->bindParam(":uid", $current_userID); - $stmt->bindParam(":txt", $enc[0]); - $stmt->bindParam(":iv", $enc[1]); - $stmt->bindParam(":tag", $enc[2]); - $stmt->execute(); - - header("Location: /500/read/?post=".$postID); + header('Content-type: text/plain'); + header('Content-Disposition: attachment; filename="encrypted.txt"'); + echo $content; ?> \ No newline at end of file