吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2884|回复: 23
收起左侧

[其他原创] 突破限制复活新浪图床

  [复制链接]
evlon 发表于 2022-10-22 15:56
本帖最后由 evlon 于 2022-10-22 17:51 编辑

背景

新浪图床曾经是做好用的图床,大概在19年吧,新浪添加了防盗链,所有的图片都不能使用了。

防盗链原理

防盗链的原理,是判断访问图片的 referer ,如果是未授权的,图片请求就返回403错误,结果就是图片不能展示。

突破复活原理

先使用 noref 的方式加载图片,加载成功后,在设置为此图片。此时,因为已经有缓存,所以图片可以正常显示。

地址

github开源地址

演示地址

核心代码

HTML


<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>demo</title>
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta name="applicable-device" content="pc">
<meta name="mobile-agent" content="format=html5;url=http://m.yy4480.io/api.php/timming/make"/>
<meta http-equiv="Cache-Control" content="no-transform" /> 
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/favicon.ico" type="image/x-icon" rel="icon">
<link href="/favicon.ico" type="image/x-icon" rel="shortcut icon">

</head>
<body>
<script src="//libs.baidu.com/jquery/1.9.1/jquery.js"></script>
<script src="js/evlonimageloader.js?20190225"></script>
<script>
function norefreload(img){
    EvlonImageLoader.reloadImage(img, 'images/empty.gif');
}

function preGetImage(imgsrc){
    return imgsrc;
}

</script>

    <img  class="norelreload" data-src="https://ww1.sinaimg.cn/large/006yeRCugy1g3vsks4061j31b80eg10a.jpg" alt="x战警:黑凤凰 蓝光" style="background-color: #EEEEEE;"/>
    <img  class="norelreload" data-src="https://ww1.sinaimg.cn/large/006yeRCugy1g0tzakoqf0j31b80eg78f.jpg" alt="北漂爱情故事 更新至12集/共12集" style="background-color: #EEEEEE;"/>
    <img  class="norelreload" data-src="https://ww1.sinaimg.cn/large/006yeRCugy1g0pz3t9dh6j31b80egwm3.jpg" alt="正义联盟 蓝光" style="background-color: #EEEEEE;"/>

<script>
        $('img.norelreload').each(function(idx,img){
                img.onerror = function(){
            norefreload(img)};
                    $(img).attr('src',preGetImage($(img).attr('data-src')));
        });
</script>

脚本

/**
 * @Project: EvlonImageLoader.
 * @Licence: The MIT License.
 * @Author: Evlon evlion@qq.com.
 * @Description: Crossbrowser kill Ref load Image.
 */

/**
 * home.php?mod=space&uid=395055 ReferrerKiller
 */
var EvlonImageLoader = (function () {
        var showInfo = false;
        var _imageQueue = [];
        var _iframeReady = false;
        var PUB = {};
        PUB.iframeLoaderId = 'evlonimageloader';

        var  reloadImage = PUB.reloadImage = function(img, emptyPic){
                if(img.src == '')
                        return;
                var imgsrc = img.src;        
                if(_iframeReady){        
                        //处理,方便缓存                
                        var match = imgsrc.match(/(^.+?)\?/);
                        if(match){
                                imgsrc = match[1];
                        }

                        var iframe = document.getElementById(PUB.iframeLoaderId);
                        if(!iframe){
                                console.warn('<body><script src="evlonimageloader.js"></script> ...')
                                return;
                        }
                        else{
                                var tryTimes = 0;
                                var imgsrc_first = imgsrc;
                                function doGetImage(){
                                        if(showInfo) console.info('load image:' + imgsrc);
                                        iframe.contentWindow.getImage(imgsrc,function(success, imgLoaded){
                                                if(success){
                                                        img.src = emptyPic;
                                                        img.src = imgsrc;
                                                        img.onerror = null;
                                                        if(showInfo) console.info('OK load image :' + imgsrc)
                                                }
                                                else{
                                                        if(tryTimes < 3){
                                                                tryTimes ++;
                                                                imgsrc = imgsrc_first + '?t=' + tryTimes;
                                                                doGetImage();
                                                        }
                                                        else{
                                                                if(showInfo) {
                                                                        console.warn('error load image :' + imgsrc);
                                                                        alert('error load image :' + imgsrc);
                                                                }
                                                        }
                                                }
                                        })
                                }
                                doGetImage();

                        }

                }
                else{
                        _imageQueue.unshift(img);
                        if(showInfo) console.info('into image queue:' + imgsrc);
                }

        }

        window.__EvlonImageLoader_onIframeReady = PUB.onIframeReady = function(){
                _iframeReady = true;

                if(_imageQueue.length > 0){
                        while(_imageQueue.length > 0){
                                var img = _imageQueue.pop();
                                reloadImage(img);

                        }
                }
        };

        function buildIframe(id){
                var iframeHtml = '<iframe \
                style="display:none;width:1px;height: 1px" \
                scrolling="no" \
                frameborder="no" \
                allowtransparency="true" \
                id="' + id + '" ' +
        '        src="javascript:\'\
        <!doctype html>\
        <html>\
        <head>\
        <meta charset=\\\'utf-8\\\'>\
        <meta name=\\\'referrer\\\' content=\\\'never\\\'>\
        <style>*{margin:0;padding:0;border:0;}\x3C/style>\
        \x3C/head>' +
        /*-- Function to adapt iframe's size to content's size --*/
        '<script>\
                function getImage(imgsrc,cb){\
                        var image = new Image() ;\
                        image.onload = function(){\
                                cb(true,image)\
                        };\
                        image.onerror = function(err) {\
                                cb(false,image);\
                        };\
                        image.src = imgsrc; \
                } \
                console.info(\\\'evlonimageload inner ok.\\\'); \
        \x3C/script><body> \x3C/body>\x3C/html>\'">\x3C/iframe>';

                document.write(iframeHtml);
        }

        buildIframe(PUB.iframeLoaderId);
        if(showInfo) console.info('evlonimageload outer ok.');

        return PUB;
})();

免费评分

参与人数 5吾爱币 +12 热心值 +5 收起 理由
wushaominkk + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
ysbks + 1 + 1 谢谢@Thanks!
晚辈小生 + 2 + 1 谢谢@Thanks!
坐久落花多 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
诗和远方代言人 + 1 + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

bingtuzibb 发表于 2022-10-22 16:21
不错  能出成品么
 楼主| evlon 发表于 2022-10-22 17:53
woshixiaomajia 发表于 2022-10-22 17:34
不用这么麻烦呀,直接用新域名就行
https://51.ruyo.net/12432.html

对,用的就是你链接中这个方法。
----------------------------------------
内嵌iframe
原理有点像no-referrer~ 使用iframe加载图片不会跟踪到原请求域名,可以加载图片!

图片加载成功后会缓存在浏览器中。网站中再加载图片的时候直接从缓存加载了~~

缺点:改动较大~
MHao008 发表于 2022-10-22 16:22
anwen 发表于 2022-10-22 16:27
大佬 两个链接的超链接错了~多加了东西
woshixiaomajia 发表于 2022-10-22 17:34
不用这么麻烦呀,直接用新域名就行
https://51.ruyo.net/12432.html
 楼主| evlon 发表于 2022-10-22 17:51
anwen 发表于 2022-10-22 16:27
大佬 两个链接的超链接错了~多加了东西

谢谢提醒,已经修正
2623666 发表于 2022-10-22 17:57
它的门户几乎没去过  更别说用它的图床了
夜泉 发表于 2022-10-22 18:01


这就是你说的突破吗?
woshixiaomajia 发表于 2022-10-22 18:40
evlon 发表于 2022-10-22 17:53
对,用的就是你链接中这个方法。
----------------------------------------
内嵌iframe

直接换域名就行哇,其他太折腾了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-14 09:25

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表