├── Dockerfile ├── LICENSE ├── Readme.md ├── app.py ├── compose.yaml ├── requirements.txt └── wsgi.py /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3-slim 2 | 3 | WORKDIR /app 4 | 5 | COPY . . 6 | 7 | RUN pip install -r requirements.txt 8 | RUN pip install gunicorn 9 | 10 | EXPOSE 8080 11 | 12 | CMD [ "gunicorn", "-w", "4", "-b", "0.0.0.0:8080", "wsgi:app" ] 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Iqbal Rifai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Cf-Bypasser 2 | Bypass Cloudflare IUAM and Captcha Protected Site 3 | 4 | Simple Python Script for Bypass Cloudflare IUAM and Captcha Protected Site. 5 | 6 | 7 | ## Usage 8 | 9 | 1. `pip install -r requirements.txt` 10 | 11 | 2. `pip install gunicorn` 12 | 13 | 3. Edit file `app.py` on the line `9` you can change to the Web Target. 14 | 15 | 4. Run the code `gunicorn -w 4 -b 0.0.0.0:8080 wsgi:app` 16 | 17 | 5. Open the `localhost:8080/getcookie` for initialize get the Cloudflare cookie. 18 | 19 | 6. Enjoy 20 | 21 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, jsonify, request, Response 2 | from CFSession import cfSession, cfDirectory 3 | import threading 4 | import os 5 | import logging 6 | import json 7 | 8 | CACHE_DIR = os.path.join(os.getcwd(), "cache") 9 | WEB_TARGET = "https://multimovies.art/" 10 | app = Flask(__name__) 11 | 12 | logging.basicConfig(level=logging.INFO) 13 | logger = logging.getLogger(__name__) 14 | 15 | class Renewer(): 16 | def __init__(self, target: str): 17 | self.renewing = False 18 | self.target = target 19 | self._thread = None 20 | 21 | def _renew_backend(self, session: cfSession): 22 | self.renewing = True 23 | try: 24 | resp = session.get(self.target) 25 | logger.info(f"Renewal request for {self.target} completed with status code {resp.status_code}") 26 | except Exception as e: 27 | logger.error(f"Renewal request for {self.target} failed with error: {str(e)}") 28 | finally: 29 | self.renewing = False 30 | 31 | def renew(self, session: cfSession): 32 | cookie_invalid = False 33 | if self.renewing: 34 | return {"status": False, "reason": "Renew process undergoing, please be patient"} 35 | response = session.session.get(self.target) 36 | cookie_availability = response.status_code == 200 37 | 38 | cookie_status = cookie_availability 39 | if cookie_status: 40 | return {"status": False, "reason": "Cookie is valid"} 41 | else: 42 | cookie_invalid = True 43 | self._thread = threading.Thread(target=self._renew_backend, args=(session,)) 44 | self._thread.start() 45 | return {"status": True, "reason": "Cookie was invalid, recreating..." if (cookie_invalid) else "Cookies will be created soon"} 46 | 47 | def json_resp(jsondict, status=200): 48 | resp = jsonify(jsondict) 49 | resp.status_code = status 50 | return resp 51 | 52 | def isSiteValid(url): 53 | response = session.session.get(url) 54 | return response.status_code == 200 55 | 56 | def reverse_proxy(url, method, headers, data, params=None): 57 | if params: 58 | query_string = "&".join([f"{key}={value}" for key, value in params.items()]) 59 | target_url = f"{WEB_TARGET}{url}?{query_string}" 60 | else: 61 | target_url = WEB_TARGET + url 62 | res = session.get(target_url) 63 | content = res.content.decode('utf-8') 64 | return content 65 | 66 | @app.before_request 67 | def before_request(): 68 | if not isSiteValid(WEB_TARGET): 69 | renew_resp = renewer.renew(session) 70 | if not renew_resp["status"]: 71 | logger.warning(f"Failed to renew cookies for {WEB_TARGET}. Reason: {renew_resp['reason']}") 72 | return {"status": False, "reason": "Renewer is not initialized yet"}, 403 73 | 74 | @app.route("/", methods=["GET", "POST", "PUT", "DELETE", "PATCH"]) 75 | def proxy(path): 76 | headers = {key: value for (key, value) in request.headers} 77 | data = request.get_data() 78 | method = request.method 79 | res = reverse_proxy(path, method, headers, data, request.args) 80 | response = Response(res) 81 | return response 82 | 83 | @app.route("/", methods=["GET"]) 84 | def homeproxy(): 85 | headers = {key: value for (key, value) in request.headers} 86 | data = request.get_data() 87 | method = request.method 88 | res = reverse_proxy(request.path, method, headers, data, request.args) 89 | response = Response(res) 90 | return response 91 | 92 | @app.route("/getcookie",methods=["GET"]) 93 | def getcookie(): 94 | renew_resp = renewer.renew(session) 95 | if not renew_resp["status"]: 96 | return json_resp(renew_resp, status=403) 97 | else: 98 | return json_resp(renew_resp, status=200) 99 | 100 | if __name__ == "__main__": 101 | session = cfSession(directory=cfDirectory(CACHE_DIR), headless_mode=True) 102 | renewer = Renewer(target=WEB_TARGET) 103 | app.run("0.0.0.0", port=8080) -------------------------------------------------------------------------------- /compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | web: 3 | build: . 4 | container_name: cf-bypasser 5 | restart: unless-stopped 6 | ports: 7 | - 8080:8080 8 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | CFSession==1.5.0 2 | flask 3 | bs4 -------------------------------------------------------------------------------- /wsgi.py: -------------------------------------------------------------------------------- 1 | from app import app 2 | 3 | if __name__ == "__main__": 4 | app.run() --------------------------------------------------------------------------------