Advertisement
Guest User

Untitled

a guest
Sep 10th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. PHP Posion Logs Writeup
  2. by DeathsPirate
  3. $who
  4.  
  5. Points: 50
  6.  
  7. Patch the PHP to remve the vulnerability. The format for the flag is "linenumber, patched code" Example: "9, fclose($File);"
  8.  
  9. Challenge created by DigitalOutcast.
  10.  
  11. <?php
  12.  
  13.  
  14. if ( !function_exists('writeLogs') ) :
  15. function writeLogs()
  16. {
  17. $IP = $_SERVER['REMOTE_ADDR'];
  18. $USERAGENT = strip_tags($_SERVER['HTTP_USER_AGENT']);
  19. $REF = strip_tags($_SERVER['HTTP_REFERER']);
  20. $URI = urldecode($_SERVER['REQUEST_URI']);
  21. $DOCROOT = $_SERVER['DOCUMENT_ROOT'];
  22.  
  23. $file = fopen($DOCROOT . "/logs/" . date("mm-Y") . ".html","a");
  24. $Output = "$IP -> $USERAGENT : $REF : $URI";
  25. fwrite($file,$Output);
  26. fclose($file);
  27. }
  28. endif;
  29.  
  30. ?>
  31.  
  32.  
  33. Solution:
  34. Look at line 9, $URI = urldecode($_SERVER['REQUEST_URI']);
  35.  
  36. This variable is passed into the file here:
  37. $Output = "$IP -> $USERAGENT : $REF : $URI";
  38.  
  39. We need it sanitised, so just don't urldecode it.
  40.  
  41. This gives us the answer:
  42.  
  43. 9, $URI = $_SERVER['REQUEST_URI'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement