Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fanbox] Cloudflare challenges #5791

Open
biggestsonicfan opened this issue Jun 26, 2024 · 26 comments
Open

[Fanbox] Cloudflare challenges #5791

biggestsonicfan opened this issue Jun 26, 2024 · 26 comments

Comments

@biggestsonicfan
Copy link

biggestsonicfan commented Jun 26, 2024

Looks like Fanbox recently updated to add cloudflare challenges? I'm using my cookies from browser with the same browser type and user agent.

EDIT: Only way I've gotten anything to work is by a Japanese VPN

@drunk-moe
Copy link

drunk-moe commented Jun 26, 2024

Refresh your cookies and double check your user agent. Just happened to me, got my UA from the requested headers in the network panel and rexported my cookies and it works fine now. A bit annoying but what can you do?

Also - not using any sort of VPN or anything. It worked fine for me once I grabbed my cookies again and used the same User Agent my browser was using.

@biggestsonicfan
Copy link
Author

Strangely, it was the "browser": "firefox" key that was the culprit. Removing that resolved my issue.

@mikf
Copy link
Owner

mikf commented Jun 27, 2024

Removing that resolved my issue.

browser overrides user-agent when present.

@bugreporter2334
Copy link

bugreporter2334 commented Jun 27, 2024

drunk-moe's method is not quite working for me. spoofing my browser's user agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 and using the same FANBOXSESSID from the cookies still gives me the error
[fanbox][warning] Cloudflare challenge
[fanbox][error] HttpError: '403 Forbidden' for 'https://api.fanbox.cc/post.listCreator?creatorId=[creator]&limit=10'
refreshing the page on my browser does not give a cloudfare challenge.

edit:
gallery-dl version for posterity (windows):

$ gallery-dl --version
1.27.1

relevant portions of my config:

    "extractor":
    {
        "base-directory": "./gallery-dl/",
        "parent-directory": false,
        "postprocessors": null,
        "archive": null,
        "cookies": null,
        "cookies-update": true,
        "proxy": null,
        "skip": true,

        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
        "retries": 4,
        "timeout": 30.0,
        "verify": true,
        "fallback": true,

        "sleep": 0,
        "sleep-request": 0,
        "sleep-extractor": 0,

        "path-restrict": "auto",
        "path-replace": "_",
        "path-remove": "\\u0000-\\u001f\\u007f",
        "path-strip": "auto",
        "extension-map": {
            "jpeg": "jpg",
            "jpe" : "jpg",
            "jfif": "jpg",
            "jif" : "jpg",
            "jfi" : "jpg"
        },

        "fanbox":
        {
            "cookies": 
            {
              "FANBOXSESSID": "<sessionid>"
            },
            "postprocessors": 
            [{
              "name": "metadata",
              "event": "post",
              "mode": "json",
              "filename": "{id}.json",
              "directory": "posts"
            }]
        },

@ZenoArrows
Copy link

I've also suddenly started encountering these none of the methods described so far resolve it unfortunately.

@biggestsonicfan
Copy link
Author

"FANBOXSESSID": "<sessionid>"

You are missing both the cf_clearance and __cf_bm cloudflare cookies.

@ZenoArrows
Copy link

You are missing both the cf_clearance and __cf_bm cloudflare cookies.

I've tried that also with the user agent set to be the same as my browser, but it still seems to be able to distinguish between my browser and gallery-dl.

@biggestsonicfan
Copy link
Author

My reply was for @bugreporter2334, I can't see your config file if you don't post it.

@bugreporter2334
Copy link

"FANBOXSESSID": "<sessionid>"

You are missing both the cf_clearance and __cf_bm cloudflare cookies.

Yep, works now with these two cookies. Here's the syntax:

"fanbox":
        {
            "cookies": 
            {
              "FANBOXSESSID": "fanbox cookie",
              "cf_clearance": "cf cookie1",
              "__cf_bm": "cf cookie 2"
            },
            "postprocessors": 
            [{
              "name": "metadata",
              "event": "post",
              "mode": "json",
              "filename": "{id}.json",
              "directory": "posts"
            }]
        },

On Chrome you can extract them from the same Application tab that you normally get your Fanbox cookies from.

@bossanovaorca
Copy link

"fanbox": {
  "cookies": ["firefox", null, null, null, ".fanbox.cc"],
},

I currently retrieve my cookies from my browser. do I need to change this method for it to retrieve the cloudflare cookies properly or am I using it incorrectly?

@mikf
Copy link
Owner

mikf commented Jun 30, 2024

You are using it correctly, but you need to use the user-agent of your browser as well.

"fanbox": {
  "cookies": ["firefox", null, null, null, ".fanbox.cc"],
  "user-agent": "..."
},

Extracting cookies from a browser profile can only get cookies that have been written to disk. Sometimes it takes a while for your browser to update its cookies database file.

@tryoutuser
Copy link

tryoutuser commented Jul 2, 2024

i've got this error instead :

[2024-07-02 23:09:03][warning] cookies: not enough values to unpack (expected 7, got 6)
[2024-07-02 23:09:03][warning] no 'FANBOXSESSID' cookie set

i'm using gallery-dl latest v1.27.1.
my config for fanbox :

        "fanbox":
        {
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
            "cookies": "%APPDATA%\\gallery-dl\\fanbox.txt",
            "cookies-update": false,
            "base-directory": "I:\\Server\\Server 1\\home\\user\\gallery-dl\\kemonoparty\\",
            "verify": false,
            "archive": "%APPDATA%\\gallery-dl\\fanbox.sqlite3",
            "archive-format": "{user['userId']}_{id}_{num:02d}_{filename}",
            "embeds": false,
            "filename": "{id}_{title}_{num:02d}_{filename}.{extension}",
            "directory": ["fanbox", "{user['userId']}"]
        },

inside my cookies text file :

# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by EditThisCookie
.fanbox.cc	TRUE	/	TRUE	1719936563	__cf_bm <redacted>
.fanbox.cc        TRUE       /       TRUE        1751445568    cf_clearance <redacted>
.fanbox.cc	TRUE	/	TRUE	1722524401	agreement_master_terms_of_use_202408	1
.fanbox.cc	TRUE	/	TRUE	1722526763	FANBOXSESSID	<redacted>
.fanbox.cc	TRUE	/	TRUE	1725825006	p_ab_d_id	187055155
.fanbox.cc	TRUE	/	TRUE	1725825006	p_ab_id	5
.fanbox.cc	TRUE	/	TRUE	1725825006	p_ab_id_2	3
.fanbox.cc	TRUE	/	TRUE	1751481237	privacy_policy_agreement	7
.fanbox.cc	TRUE	/	TRUE	1754494763	privacy_policy_notification	0
www.fanbox.cc	FALSE	/	TRUE	0	d_prefs	<redacted>

and i'm connected to softether VPN volunteer servers that is not the public-vpn.*number*.ad.ne.jp ones.

@mikf
Copy link
Owner

mikf commented Jul 2, 2024

@tryoutuser
Values in a cookies.txt file must be separated by tab characters and not spaces like it is the case for your cf_clearance line. Replace it with the following and it should load:

.fanbox.cc	TRUE	/	TRUE	1751445568	cf_clearance	<redacted>

@tryoutuser
Copy link

@mikf i did edit with tab after realizing that and it still says same error those 2 lines above.

updated cookie :

# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by EditThisCookie
.fanbox.cc	TRUE	/	TRUE	1719941452	__cf_bm	<redacted>
.fanbox.cc	TRUE	/	TRUE	1751475670	cf_clearance	<redacted>
.fanbox.cc	TRUE	/	TRUE	1722524401	agreement_master_terms_of_use_202408	1
.fanbox.cc	TRUE	/	TRUE	1722531668	FANBOXSESSID	<redacted>
.fanbox.cc	TRUE	/	TRUE	1725825006	p_ab_d_id	187055155
.fanbox.cc	TRUE	/	TRUE	1725825006	p_ab_id	5
.fanbox.cc	TRUE	/	TRUE	1725825006	p_ab_id_2	3
.fanbox.cc	TRUE	/	TRUE	1751481237	privacy_policy_agreement	7
.fanbox.cc	TRUE	/	TRUE	1754499668	privacy_policy_notification	0
www.fanbox.cc	FALSE	/	TRUE	0	d_prefs	<redacted>

@Hrxn
Copy link
Contributor

Hrxn commented Jul 4, 2024

You sure those are real tabs, and not soft tabs, elastic tabs etc. or something else?

@Coolchilion
Copy link

Where do you get cf_clearance from? I keep clearing my cookies and solving the verification but it never appears in my Get Cookies.txt

@komoreshi
Copy link

komoreshi commented Jul 9, 2024

Where do you get cf_clearance from? I keep clearing my cookies and solving the verification but it never appears in my Get Cookies.txt

Same issue on my end, but I suspect it just takes a while for it to be updated. Worst case you just extract it manually using developer tools and add it to your config:

firefox_MQvXXyuNR3

@USBhost
Copy link

USBhost commented Jul 11, 2024

Okay lads I need some help understanding what to do.
./gallery-dl --cookies-from-browser firefox --user-agent browser URL does not work
./gallery-dl --cookies cookies-fanbox-cc.txt --user-agent browser URL does not work.
cookie file gotten from the export cookie addon.
I keep getting 403 Forbidden

edit: ./gallery-dl --cookies-from-browser firefox --user-agent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0' URL

for the dumb lads like me make sure firefox is your primary or manually get your useragent.

@Coolchilion
Copy link

bugreporter2334

I tried following your config but I get

Extra data: line 1 column 16 (char 15)
and
no 'FANBOXSESSID' cookie set

@TheCrypticOne
Copy link

Having this issue as well. Using a cookies.txt file and getting

[fanbox][warning] Cloudflare challenge
[fanbox][error] HttpError: '403 Forbidden' for 'https://api.fanbox.cc/post.info?postId=8400185'

as the output

@amackenzie
Copy link

Same here, using cookies.txt method that worked for a while:

[fanbox][warning] Cloudflare challenge
[fanbox][error] HttpError: '403 Forbidden' for 'https://api.fanbox.cc/post.paginateCreator?creatorId=<id removed>'

@JacobDreiling
Copy link

I started getting the same error. Here are my fanbox configs. I'm not sure if I need to specify a user agent or a cookie file, because this used to work before I added them.

"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15",
"cookies": {
    "agreement_master_terms_of_use_202408": "1",
    "p_ab_id": "...",
    "p_ab_id_2": "...",
    "p_ab_d_id": "...",
    "FANBOXSESSID": "...",
    "cf_clearance": "...",
    "__cf_bm": "...",
    "privacy_policy_agreement": "...",
    "privacy_policy_notification": "..."
    },
"cookies-update": "test-fanbox-cookies.txt"

@mikf
Copy link
Owner

mikf commented Sep 12, 2024

  • Visit the URL causing the 403 error in a browser
  • Let it solve the challenge
  • Export its cookies (cf_clearance is important)
  • Run gallery-dl with those cookies and the browser's User-Agent header
$ gallery-dl https://xub.fanbox.cc --cookies cookies-fanbox-cc.txt --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
./fanbox/xub/7288162_0.jpg
./fanbox/xub/6566008_0.jpg
./fanbox/xub/6561218_0.jpg
...

(I can personally access fanbox without any of this)

@JacobDreiling
Copy link

Please excuse all my comments, but I'm getting an error when trying to export cookies. Here's what I have to automatically get cookies from safari.

"fanbox": {
    "user-agent": "browser",
    "cookies": ["safari"]
}

This gives me an error 1.

[fanbox][warning] cookies: [Errno 1] Operation not permitted: '/Users/quasarbooster/Library/Cookies/Cookies.binarycookies'
[fanbox][warning] no 'FANBOXSESSID' cookie set
[fanbox][warning] Cloudflare challenge

@cloudywings2
Copy link

Hello! The process I have used is:

using the Get Cookies.txt LOCALLY, mentioned on the main GitHub page
config file contains the path to the cookies.txt file, and the user agent

When running Gallery-DL as an .exe file I get the "cloudflare challenge" error and "403 Forbidden." My cookies do not have the cf_clearance tag, even if I export all the cookies from the browser. I have exported the cookies from the Fanbox home page as well as an individual artist's page, being sure I am logged in, of course.

@Syilumi
Copy link

Syilumi commented Sep 27, 2024

can anyone simply explain how to fix it because i dont know how, i dont even know how iv been using gallery-dl since iv just been using .bat files with the gallery-dl hyperlinks and hoping for the best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests