php破解防盗链技术
php破解防盗链技术
发送http请求
构造referer信息
在Http协议中,头信息里,有一个重要的选项: Referer
Referer: 代表网页的来源,即上一页的地址

具体方法http.class.php
// http请求类的接口
interface Proto {
// 连接url
function conn($url); //发送get查询
function get(); // 发送post查询
function post(); // 关闭连接
function close();
} class Http implements Proto { const CRLF = "\r\n"; protected $errno = -1;
protected $errstr = '';
protected $response = ''; protected $url = null;
protected $version = 'HTTP/1.1';
protected $fh = null; protected $line = array();
protected $header = array();
protected $body = array(); public function __construct($url) {
$this->conn($url);
$this->setHeader('Host: ' . $this->url['host']);
} // 此方法负责写请求行
protected function setLine($method) {
$this->line[0] = $method . ' ' . $this->url['path'] . '?' .$this->url['query'] . ' '. $this->version;
} // 此方法负责写头信息
public function setHeader($headerline) {
$this->header[] = $headerline;
} // 此方法负责写主体信息
protected function setBody($body) {
$this->body[] = http_build_query($body);
} // 连接url
public function conn($url) {
$this->url = parse_url($url);
// 判断端口
if(!isset($this->url['port'])) {
$this->url['port'] = 80;
} // 判断query
if(!isset($this->url['query'])) {
$this->url['query'] = '';
} $this->fh = fsockopen($this->url['host'],$this->url['port'],$this->errno,$this->errstr,3);
} //构造get请求的数据
public function get() {
$this->setLine('GET');
$this->request();
return $this->response;
} // 构造post查询的数据
public function post($body = array()) {
$this->setLine('POST'); // 设计content-type
$this->setHeader('Content-type: application/x-www-form-urlencoded'); // 设计主体信息,比GET不一样的地方
$this->setBody($body); // 计算content-length
$this->setHeader('Content-length: ' . strlen($this->body[0])); $this->request(); return $this->response;
} // 真正请求
public function request() {
// 把请求行,头信息,实体信息 放在一个数组里,便于拼接
$req = array_merge($this->line,$this->header,array(''),$this->body,array(''));
//print_r($req); $req = implode(self::CRLF,$req);
//echo $req; exit; fwrite($this->fh,$req); while(!feof($this->fh)) {
$this->response .= fread($this->fh,1024);
} $this->close(); // 关闭连接
} // 关闭连接
public function close() {
fclose($this->fh);
} } $http = new Http('http://localhost/apple.jpg'); //本机服务器www目录下的apple.jpg图片 $http->setHeader('Referer: http://localhost'); //构造Referer信息
$res = $http->get();
//print_r($res);
file_put_contents('./aa.png',substr(strstr($res,"\r\n\r\n"),4));
php破解防盗链技术的更多相关文章
- php笔记05:http协议中防盗链技术
倘若我们自己在电脑上写了一个网站文件(可以是html,php文件等等),但是只希望本机可以访问这个文件,不希望别的电脑访问就需要这里的防盗链技术 1.我们在本地写了一个import.php文件: 而且 ...
- 防盗链技术终极解决方案(squid+cookie)
防盗链技术现状:1.通过识别Referer确认请求来源页面2.Apache,squid等都能对Referer进行识别3.通过ActiveX显示的内容不向服务器提供Referer Header(例如,F ...
- php防盗链技术
在Http协议中,头信息里,有一个重要的选项: Referer Referer: 代表网页的来源,即上一页的地址 如果是直接在浏览器上输入地址,回来进来,则没有Referer头. 这也是: 为什么服务 ...
- http协议以及防盗链技术
http协议,又称为超文本传输协议,顾名思义,http协议不仅能传输文本,还能传输图片,视频,压缩包等文件,http协议是建立在tcp/ip协议的基础之上的,http协议对php程序员来讲可以说是重中 ...
- [php]referer应用--http防盗链技术
1.防盗链的理解 所谓防盗链是防止其他的网站引用自己网站的资源连接,比如图片.视频等等,但是并不会阻碍从自己网站上享受资源的用户,这就要求能够将其他网站的连接请求阻止 2.防盗链的原理 其实从自己网站 ...
- JavaWeb学习记录(二)——防盗链技术
public class TestServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpSer ...
- php curl破解防盗链
function get_content($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $header = array( ...
- Java破解图片防盗链
前言 今天想下载几张好看的壁纸,然后发现了一张是自己比较喜欢的额.然后点进去看看,WOW!好多好看的壁纸呀,于是我就起了贪念.哈哈!想把他们这一组图片打包下载,小白的方法就是一张一张下载,那样对于我们 ...
- 网站资源被盗链的:预防方法 VS 网站资源防盗链的:破解技巧
1 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问! 1 资源被盗链:(简明定义) 下载者不是从你的网站直接下载资源,而是通过其他盗链网站提供的你的下载资源链接进行下载你的服务 ...
随机推荐
- 使用Auto Layout处理比例间距问题
使用Auto Layout处理比例间距问题 Auto Layout 是一个掌握起来很具有挑战性的东西.iOS 9引入的 Stack Views和 layout 锚点有一些帮助,但是明白如何创建特定的 ...
- 项目中遇到Uncaught TypeError: Converting circular structure to JSON报错问题
最近公司项目中出现一个报错Uncaught TypeError: Converting circular structure to JSON,,根据上述报错可以知道代码是运行到JSON.stringi ...
- 【BZOJ2400】Spoj 839 Optimal Marks 最小割
[BZOJ2400]Spoj 839 Optimal Marks Description 定义无向图中的一条边的值为:这条边连接的两个点的值的异或值. 定义一个无向图的值为:这个无向图所有边的值的和. ...
- SpringInAction4笔记——复习
由于目前只做后端的业务代码的开发,所以根据自己掌握的熟悉程度,只需要复习几个模块即可 重点看的是核心容器(IOC),redis,缓存,消息(主要是rabbitmq),事务,springboot,单元测 ...
- html5 file 上传图片
说明:开发环境 vs2012 mvc4项目,后台语言csharp 1.前端代码 <html xmlns="http://www.w3.org/1999/xhtml"> ...
- Maximum likelihood from incomplete data via the EM algorithm (1977)
Maximum likelihood from incomplete data via the EM algorithm (1977)
- python错误提示“TabError: inconsistent use of tabs and spaces in indentation”
在遍历打印10以内的奇数是出现“TabError: inconsistent use of tabs and spaces in indentation”的错误提示: 代码如下: 第一感觉没什么错误, ...
- 挂断电话demo
<!-- 结束通话和打电话的权限 --> <uses-permission android:name="android.permission.CALL_PHONE" ...
- php mcrypt加密实例
<?php //当前mcrypt支持的加密模型 $modes_list = mcrypt_list_modes(); // Array // ( // [0] => cbc // [1] ...
- Understand .sync in Vue
Preface The first time I met .sync modifier, I didn't know it very well. So, I seldom use that. Toda ...