php下通过伪造http头破解防盗链的代码
伪造referer实例代码,主要用于一些突破防盗链,比如图片,软件等等
这里就直接给出完整的程序吧,具体的应用可以自己修改。
我这里给出的例子是很简单的,其实可以从这个例子中发展出很多的应用。比如隐藏真实的URL地址……嘿嘿,具体的就自己分析去吧
这里新建一个文件file.php。后面的参数就是需要伪造referfer的目标地址吧。如:file.php/http://www.xxx.xxx/xxx.mp3
复制代码 代码如下:
$url=str_replace('/file.php/','',$_SERVER["REQUEST_URI"]);//得出需要转换的网址。这里我就偷懒,不做安全检测了,需要的自己加上去
$downfile=str_replace(" ","%20",$url);//替换空格之类,可以根据实际情况进行替换
$downfile=str_replace("http://","",$downfile);//去掉http://
$urlarr=explode("/",$downfile);//以"/"分解出域名
$domain=$urlarr[0];//域名
$getfile=str_replace($urlarr[0],'',$downfile);//得出header中的GET部分
$content = @fsockopen("$domain", 80, $errno, $errstr, 12);//连接目标主机
if (!$content){//链接不上就提示错误
die("对不起,无法连接上 $domain 。");
}
fputs($content, "GET $getfile HTTP/1.0rn");
fputs($content, "Host: $domainrn");
fputs($content, "Referer: $domainrn");//伪造部分
fputs($content, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)rnrn");
while (!feof($content)) {
$tp.=fgets($content, 128);
if (strstr($tp,"200 OK")){ //这里要说明一下。header的第一行一般是请求文件的状态。具体请参照HTTP 1.1状态代码及其含义 hi.baidu.com/110911/blog/item/21f20d2475af812ed50742c5.html这里是正常的文件请求状态,只需直接转向就可以。其他状态的继续执行程序
header("Location:$url");
die();
}
}
//302 转向,大部分的防盗链系统都是先判断referfer,对了的话再转向真实的地址。下面就是获取真实的地址。
$arr=explode("n",$tp);
$arr1=explode("Location: ",$tp);//分解出Location后面的真时地址
$arr2=explode("n",$arr1[1]);
header('Content-Type:application/force-download');//强制下载
header("location:".$arr2[0]);//转向目标地址
die();
?>
这段程序只能针对使用referer来判断是否盗链的防盗链系统,使用其他特殊方法防盗链的,这个估计就不适用了
复制代码 代码如下:
$txt=$_GET['url'];
echo referfile($txt,'http://www.jb51.net/');
function referfile($url,$refer='') {
$opt=array('http'=>array('header'=>"Referer:$refer"));
$context=stream_context_create($opt);
Header("Location:".$url);
return file_get_contents($url,false,$context);
}
复制代码 代码如下:
$host = "pakey.net"; //你要访问的域名
$target = "/test.asp"; //你要访问的页面地址
$referer = "http//uuwar.com/"; //伪造来路页面
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if(!$fp){
echo "$errstr($errno)
\n";
}else{
$out = "
GET $target HTTP/1.1
Host: $host
Referer: $referer
Connection: Close\r\n\r\n";
fwrite($fp, $out);
while(!feof($fp)){
echo fgets($fp, 1024);
}
fclose($fp);
}
?>
个是我用在我的小说小偷中的代码,破解 了云轩阁的txt电子书防盗链。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.