V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
purezhang
V2EX  ›  问与答

wget/curl 下载某些网站的图片,直接给 jpg 链接都只有 403,为啥?

  •  
  •   purezhang · 2018-09-13 21:19:53 +08:00 · 2853 次点击
    这是一个创建于 2270 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <title>403 Forbidden</title> <center>

    403 Forbidden

    </center>
    <center>nginx</center> <script src="/aes.js" type="text/javascript"></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("171bd056f97a595e95a9ef2231b52dad");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg?i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>[
    第 1 条附言  ·  2018-09-13 21:51:42 +08:00
    提醒:图片 NSFW,仅供测试,技术探讨,别直接打开,谢谢!
    9 条回复    2018-09-14 01:34:54 +08:00
    purezhang
        1
    purezhang  
    OP
       2018-09-13 21:20:06 +08:00
    有啥办法解决吗?用什么参数?。
    NickCarter
        2
    NickCarter  
       2018-09-13 21:29:24 +08:00 via iPhone
    加个 header 试试? referer
    purezhang
        3
    purezhang  
    OP
       2018-09-13 21:33:18 +08:00
    wget -U 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg
    --2018-09-13 20:57:31-- http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg
    Resolving fujisaki.000a.biz... 185.27.134.147
    Connecting to fujisaki.000a.biz|185.27.134.147|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 871 [text/html]
    Saving to: `okm129h_hikaru_003.jpg'

    100%[==========================================================================================================================>] 871 --.-K/s in 0s

    2018-09-13 20:57:32 (139 MB/s) - `okm129h_hikaru_003.jpg' saved [871/871]


    871 字节,一样的提示,都是下载一个 403
    westoy
        4
    westoy  
       2018-09-13 21:42:12 +08:00
    这个 403 页面里的 js 很清楚了啊, 服务端有做 cookie 验证, 验证失败就输出这个 403 页面写入 cookie, 再做一次跳转
    Wincer
        5
    Wincer  
       2018-09-13 21:44:11 +08:00
    需要加 Cookie 和其它一些参数。
    curl 'http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg?i=1' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Referer: http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: __test=d1bef3f56c1a7418dd54e5dc8b1f8240' --compressed

    (提醒,图片 NSFW
    purezhang
        6
    purezhang  
    OP
       2018-09-13 21:50:55 +08:00
    @Wincer
    curl 'http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg?i=1' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Referer: http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: __test=d1bef3f56c1a7418dd54e5dc8b1f8240' --compressed

    <html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("171bd056f97a595e95a9ef2231b52dad");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://fujisaki.000a.biz/okkam/nude129/images/okm129h_hikaru_003.jpg?i=2";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>
    Wincer
        7
    Wincer  
       2018-09-13 21:57:45 +08:00
    @purezhang 你用 Chrome 打开图片后,在开发者工具 network 选项卡选择右键 copy as curl
    purezhang
        8
    purezhang  
    OP
       2018-09-13 23:58:28 +08:00
    @Wincer 上面的地址就是用 chrome 打开后 copy 的图片链接,我都打开源码看来。
    crab
        9
    crab  
       2018-09-14 01:34:54 +08:00
    cookies __test
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2699 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 09:07 · PVG 17:07 · LAX 01:07 · JFK 04:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.