Advertisement
Guest User

Untitled

a guest
Nov 29th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. Plaintext cookie : name=guest;admin=0;password=guest;userid=1337
  2.  
  3. <?php
  4.  
  5. require('key.php');
  6.  
  7. function source()
  8. {
  9.     echo "<pre>";
  10.     highlight_string(file_get_contents(__FILE__));
  11.     echo "</pre>";
  12. }
  13.  
  14. function quit()
  15. {
  16.     source();
  17.     die();
  18. }
  19.    
  20. function encrypt($input) {
  21.     $res = openssl_encrypt($input, "AES-128-ECB", KEY, OPENSSL_RAW_DATA);
  22.     return $res;
  23. }
  24.  
  25. function decrypt($input) {
  26.     $res = openssl_decrypt($input, "AES-128-ECB", KEY, OPENSSL_RAW_DATA);
  27.     return $res;
  28. }
  29.  
  30. if(!isset($_COOKIE['key'])) {
  31.     $username=(isset($_GET['username'])) ? $_GET['username'] : "guest";
  32.     $password=(isset($_GET['password'])) ? $_GET['password'] : "guest";
  33.     if(preg_match("/admin=1/i", $username) || preg_match("/admin=1/i", $password) ) quit();
  34.     $cookieenc = encrypt("name=$username;admin=0;password=$password;userid=1337");
  35.     setcookie('key', base64_encode($cookieenc));
  36.     $_COOKIE['key'] = base64_encode($cookieenc);
  37. }
  38.  
  39. if(strpos(decrypt(base64_decode($_COOKIE['key'])), 'admin=1') !== false)
  40. {
  41.     echo "<img src='https://media.giphy.com/media/H6CDICYUiPAwE/giphy.gif' /><br>";
  42.     echo "Bravo, tu peux valider avec le flag suivant : ".FLAG ;
  43.     die();
  44. }
  45. else
  46. {
  47.     echo "Plaintext cookie : ".decrypt(base64_decode($_COOKIE['key']))."<br>";
  48.     quit();
  49. }
  50. source();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement