web352笔记(parse_url)

<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if($x['scheme']==='http'||$x['scheme']==='https'){
if(!preg_match('/localhost|127.0.0/')){
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
echo ($result);
}
else{
    die('hacker');
}
}
else{
    die('hacker');
}
?> hacker
parse_url的用法,主要是将一个URL拆分为协议、主机、路径、查询字符串等部分。
然后源码中想用preg_match过滤了127.0.0.1localhost关键字,但是没有指定对哪个变量过滤,所以条件恒为真。
url=http://127.0.0.1/flag.php

 

 

posted @ 2025-05-21 16:16  justdoIT*  阅读(8)  评论(0)    收藏  举报