purezhang
V2EX  ›  问与答

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

  •  
  •   purezhang · Sep 13, 2018 · 4009 views
    This topic created in 2977 days ago, the information mentioned may be changed or developed.
    <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>[
    Supplement 1  ·  Sep 13, 2018
    提醒:图片 NSFW,仅供测试,技术探讨,别直接打开,谢谢!
    9 replies  •  2018-09-14 01:34:54 +08:00
    purezhang
    purezhang
    OP
    Sep 13, 2018
    1
    有啥办法解决吗?用什么参数?。
    NickCarter
    NickCarter
    Sep 13, 2018 via iPhone
    2
    加个 header 试试? referer
    purezhang
    purezhang
    OP
    Sep 13, 2018
    3
    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
    westoy
    Sep 13, 2018
    4
    这个 403 页面里的 js 很清楚了啊, 服务端有做 cookie 验证, 验证失败就输出这个 403 页面写入 cookie, 再做一次跳转
    Wincer
    Wincer
    Sep 13, 2018
    5
    需要加 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
    purezhang
    OP
    Sep 13, 2018
    6
    @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
    Wincer
    Sep 13, 2018
    7
    @purezhang 你用 Chrome 打开图片后,在开发者工具 network 选项卡选择右键 copy as curl
    purezhang
    purezhang
    OP
    Sep 13, 2018
    8
    @Wincer 上面的地址就是用 chrome 打开后 copy 的图片链接,我都打开源码看来。
    crab
    crab
    Sep 14, 2018
    9
    cookies __test
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   747 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 22:58 · PVG 06:58 · LAX 14:58 · JFK 17:58
    ♥ Do have faith in what you're doing.