知识点

  • 反序列化
  • pop链的构造

启动靶机

1. 访问题目,直接给出了源码

  1. Welcome to index.php
  2. <?php
  3. //flag is in flag.php
  4. //WTF IS THIS?
  5. //Learn From https://ctf.ieki.xyz/library/php.html#%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95
  6. //And Crack It!
  7. class Modifier {
  8. protected $var;
  9. public function append($value){
  10. include($value);
  11. }
  12. public function __invoke(){
  13. $this->append($this->var);
  14. }
  15. }
  16. class Show{
  17. public $source;
  18. public $str;
  19. public function __construct($file='index.php'){
  20. $this->source = $file;
  21. echo 'Welcome to '.$this->source."<br>";
  22. }
  23. public function __toString(){
  24. return $this->str->source;
  25. }
  26. public function __wakeup(){
  27. if(preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) {
  28. echo "hacker";
  29. $this->source = "index.php";
  30. }
  31. }
  32. }
  33. class Test{
  34. public $p;
  35. public function __construct(){
  36. $this->p = array();
  37. }
  38. public function __get($key){
  39. $function = $this->p;
  40. return $function();
  41. }
  42. }
  43. if(isset($_GET['pop'])){
  44. @unserialize($_GET['pop']);
  45. }
  46. else{
  47. $a=new Show;
  48. highlight_file(__FILE__);
  49. }