[nginx/openresty]代理请求修改referer,破解防盗链

/ 184,214评论 / 468228阅读 / 15点赞

有时我们想引用其他网站的资源(图片,视频等),明明在其网站上可用,而我们发送请求时却得到了403错误,访问被拒绝,很可能就是该网站对这些资源文件设置了防盗链,下面我们聊聊其防盗的原理以及破解方法。

名词

防盗链

Referer

Origin

破解防盗链

直接伪造请求

这个方法适用于客户端,而不适用于浏览器中的网页。

const axios = require(`axios`);
const getServer = (in_url, in_data, successFun, errFun) => {
    axios({
        method: "get",
        url:    in_url,
        params: in_data,
        headers: {
            "referer":"https://www.bilibili.com/"

            //"referer":"https://127.0.0.1/"  //你可以尝试使用这一句替换上面那句,请求将被拒绝
        }
    }).then(function (res) {
        console.log(res.data);
        if (typeof (successFun) != 'undefined') {
            successFun(res);
        }
        console.log("--- 请求成功 ---");
    }).catch(function (err) {
        console.log(err);
        if (typeof (errFun) != 'undefined') {
            errFun(err);
        }
        console.log("--- 请求失败 ---");
    })
}

//获取对应id的视频的下载链接
getServer(
    "https://api.bilibili.com/x/player/playurl",
    {
        "fnval": 80,
        "bvid":"BV1pT41157it",
        "cid":"746904707"
    });

代理转发

客户端,网页都适用,但一般客户端不需要由服务器代理,客户端自己可以搞定,就不需要占用服务器的带宽性能

server {
        listen       80;
        server_name  localhost, 127.0.0.1;
	resolver 8.8.8.8;
        location / {
		header_filter_by_lua_file /usr/local/openresty/lua/toBili.lua;
                proxy_set_header referer 'https://www.bilibili.com/';
		proxy_set_header Host $proxy_host;
		proxy_set_header Origin 'https://www.bilibili.com';
		if ($query_string ~* ^(.*)url=(.*)$) {
			proxy_pass $2;
		}
	}
}
ngx.header['Access-Control-Allow-Origin']  =  '*';
ngx.header['Access-Control-Allow-Methods'] = 'get, post, options';
ngx.header['Access-Control-Allow-Headers'] = 'dnt,x-mx-reqtoken,keep-alive,user-agent,x-requested-with,if-modified-since,cache-control,content-type,authorization';

关于空referer

<!DOCTYPE html>
<html lang="zh">
<head>

    <meta name="referrer" content="never">
</head>
<body>
</body>

摸索过程记录

add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'POST,OPTIONS,GET';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

思考

上面的示例中,我们在使用时,只能也必须传入一个参数 url,那有没有办法传递更多参数呢?

  1. Davidfrify说道:

    cytotec online buy cytotec pills online cheap buy cytotec

  2. RonaldSwobe说道:

    http://ciprofloxacin.tech/# buy cipro cheap

  3. but also to prepare himself for penetrating the ass)オナドール and that feeling from going from dirty ass eating and wetness to the tip slowly penetrating is just so fucking wild.”

  4. Davidfrify说道:

    cipro for sale ciprofloxacin ciprofloxacin 500 mg tablet price

  5. Davidfrify说道:

    cost generic propecia prices cost of propecia online get generic propecia pill

  6. WilliamRen说道:

    https://lisinopril.network/# lisinopril 40 mg tablet

  7. RonaldSwobe说道:

    https://cytotec.club/# buy cytotec online

  8. WilliamRen说道:

    http://cytotec.club/# buy cytotec over the counter

  9. RandallGuesE说道:

    generic propecia: cost propecia for sale – cost of propecia without a prescription

  10. Davidfrify说道:

    п»їcipro generic ciprofloxacin mail online buy cipro online

  11. RandallGuesE说道:

    buying propecia pill: propecia brand name – cost propecia for sale

  12. RandallGuesE说道:

    generic for zestril: lisinopril canada – zestril cost

  13. WilliamRen说道:

    https://ciprofloxacin.tech/# cipro 500mg best prices

  14. RandallGuesE说道:

    lisinopril 15 mg: buy lisinopril online usa – lisinopril 10 mg online no prescription

  15. Davidfrify说道:

    ciprofloxacin order online ciprofloxacin generic price purchase cipro

  16. WilliamRen说道:

    http://ciprofloxacin.tech/# ciprofloxacin over the counter

  17. RandallGuesE说道:

    buy tamoxifen: alternatives to tamoxifen – does tamoxifen cause menopause

  18. Davidfrify说道:

    purchase cytotec cytotec pills buy online buy cytotec pills

  19. RandallGuesE说道:

    buy misoprostol over the counter: buy cytotec pills – cytotec pills online

  20. Scottvaw说道:

    로드스탁과의 레버리지 스탁: 투자법의 참신한 지평

    로드스탁에서 제공하는 레버리지 방식의 스탁은 주식 시장의 투자의 한 방법으로, 높은 수익률을 목적으로 하는 투자자들을 위해 유혹적인 선택입니다. 레버리지를 이용하는 이 전략은 투자자가 자신의 자금을 넘어서는 금액을 투자할 수 있도록 하여, 주식 시장에서 더욱 큰 작용을 행사할 수 있는 기회를 제공합니다.

    레버리지 스탁의 기본 원칙
    레버리지 스탁은 일반적으로 자본을 빌려 사용하는 방법입니다. 사례를 들어, 100만 원의 투자금으로 1,000만 원 상당의 증권을 취득할 수 있는데, 이는 투자자들이 기본적인 자본보다 훨씬 더 많은 증권을 사들여, 주식 가격이 올라갈 경우 상응하는 더욱 큰 수익을 얻을 수 있게 합니다. 그렇지만, 증권 값이 떨어질 경우에는 그 손실 또한 증가할 수 있으므로, 레버리지를 사용할 때는 신중하게 생각해야 합니다.

    투자 계획과 레버리지 사용
    레버리지는 특히 성장 가능성이 높은 회사에 적용할 때 도움이 됩니다. 이러한 사업체에 큰 비율을 통해 투자하면, 잘 될 경우 큰 수익을 가져올 수 있지만, 반대 경우의 경우 큰 위험성도 짊어져야 합니다. 따라서, 투자하는 사람은 자신의 리스크 관리 능력과 시장 분석을 통해 통해, 어느 기업에 얼마만큼의 자본을 투입할지 결정해야 합니다.

    레버리지의 장점과 위험 요소
    레버리지 스탁은 높은 이익을 약속하지만, 그만큼 상당한 위험성 수반합니다. 주식 장의 변화는 추정이 어렵기 때문에, 레버리지를 사용할 때는 언제나 상장 추세를 세심하게 관찰하고, 손해를 최소화할 수 있는 전략을 마련해야 합니다.

    맺음말: 조심스러운 결정이 필수입니다
    로드스탁에서 제공된 레버리지 방식의 스탁은 효과적인 투자 수단이며, 잘 사용하면 큰 이익을 벌어들일 수 있습니다. 그러나 큰 위험성도 생각해 봐야 하며, 투자 선택은 충분히 많은 정보와 조심스러운 고려 후에 진행되어야 합니다. 투자하는 사람의 재정적 상태, 위험을 감수하는 능력, 그리고 시장의 상황을 반영한 균형 잡힌 투자 전략이 핵심입니다.

  21. Davidfrify说道:

    buy cipro online without prescription buy ciprofloxacin over the counter antibiotics cipro

  22. リアルラブドール 日本の「あこがれ人形」での日常生活に似ているもの

  23. WilliamRen说道:

    https://finasteride.store/# cost of cheap propecia pill

  24. Davidfrify说道:

    buy cytotec over the counter п»їcytotec pills online buy cytotec over the counter

  25. WilliamRen说道:

    http://lisinopril.network/# lisinopril 30mg coupon

  26. WilliamRen说道:

    http://cytotec.club/# purchase cytotec

  27. RandallGuesE说道:

    ciprofloxacin mail online: cipro online no prescription in the usa – ciprofloxacin

  28. Davidfrify说道:

    tamoxifen mechanism of action nolvadex half life tamoxifen vs clomid

  29. RandallGuesE说道:

    tamoxifen lawsuit: benefits of tamoxifen – tamoxifen and ovarian cancer

  30. RandallGuesE说道:

    lisinopril brand: lisinopril 12.5 mg price – lisinopril price comparison

  31. RonaldSwobe说道:

    http://finasteride.store/# cost of generic propecia without insurance

  32. WilliamRen说道:

    http://ciprofloxacin.tech/# cipro 500mg best prices

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注