Skip to content

Commit

Permalink
Add Cloudflare BFM detection (#9407)
Browse files Browse the repository at this point in the history
  • Loading branch information
medariox authored Apr 6, 2021
1 parent 5444f4a commit cd61ab7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions medusa/session/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def cloudflare(session, resp, **kwargs):
A request handler that retries a request after bypassing Cloudflare anti-bot
protection.
"""
if CloudScraper.is_Challenge_Request(resp):
if CloudScraper.is_IUAM_Challenge(resp) or CloudScraper.is_Captcha_Challenge(resp):
log.debug('Cloudflare protection detected, trying to bypass it.')

# Get the original request
Expand Down Expand Up @@ -68,5 +68,7 @@ def cloudflare(session, resp, **kwargs):
log.debug('Cloudflare successfully bypassed.')
return cf_resp
else:
log.warning("Cloudflare captcha challenge v2 or firewall detected, it can't be bypassed.")
if (CloudScraper.is_New_IUAM_Challenge(resp) or CloudScraper.is_Firewall_Blocked(resp)
or CloudScraper.is_New_Captcha_Challenge(resp) or CloudScraper.is_BFM_Challenge(resp)):
log.warning("Cloudflare captcha challenge v2 or firewall detected, it can't be bypassed.")
return resp

0 comments on commit cd61ab7

Please sign in to comment.