Created
September 29, 2025 18:21
-
-
Save imeesa/cbe9ae5a7a83838f4143c525a0e3aef6 to your computer and use it in GitHub Desktop.
X-Real-Ip is a custom header from nginx, change to your cloudflare header or whatever
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, request, render_template, redirect | |
| import requests | |
| def get_isp_name(ip: str, token: str = None) -> str: | |
| try: | |
| url = f"https://api.ipinfo.io/lite/{ip}?token=nope" | |
| response = requests.get(url, timeout=5) | |
| response.raise_for_status() | |
| data = response.json() | |
| org = data.get("as_name", "Unknown ISP") | |
| return org, "https://" + data.get("as_domain", "www.youtube.com/watch?v=xvFZjo5PgG0") | |
| except requests.RequestException as e: | |
| return f"Error: {e}" | |
| app = Flask(__name__) | |
| @app.route("/") | |
| def warning_page(): | |
| return render_template("template.html.j2", isp_title=get_isp_name(request.headers.get("X-Real-IP"))[0], isp_link=get_isp_name(request.headers.get("X-Real-IP"))[1]) | |
| if __name__ == "__main__": | |
| app.run(debug=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Security Threat Detected</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| margin: 0; | |
| background-color: white; | |
| color: #333; | |
| } | |
| /* Header */ | |
| .header { | |
| background-color: black; | |
| padding: 20px; | |
| text-align: left; | |
| } | |
| .header img { | |
| height: 30px; | |
| } | |
| .optimum-logo { | |
| font-size: 32px; | |
| font-weight: bold; | |
| color: white; | |
| } | |
| .optimum-logo span { | |
| color: #00a0e4; | |
| } | |
| /* Alert Box */ | |
| .alert { | |
| background-color: #d0021b; | |
| color: white; | |
| padding: 15px; | |
| font-size: 20px; | |
| font-weight: bold; | |
| text-align: center; | |
| } | |
| /* Main Content */ | |
| .content { | |
| padding: 20px; | |
| max-width: 700px; | |
| margin: auto; | |
| text-align: center; | |
| } | |
| .content p { | |
| font-size: 16px; | |
| line-height: 1.5; | |
| } | |
| /* Buttons */ | |
| .buttons { | |
| margin-top: 20px; | |
| } | |
| .btn { | |
| display: inline-block; | |
| padding: 10px 20px; | |
| margin: 5px; | |
| font-size: 14px; | |
| text-decoration: none; | |
| border-radius: 3px; | |
| } | |
| .btn-primary { | |
| background-color: #0078c8; | |
| color: white; | |
| } | |
| .btn-link { | |
| color: #0078c8; | |
| text-decoration: underline; | |
| } | |
| /* Footer */ | |
| .footer { | |
| margin-top: 30px; | |
| font-size: 12px; | |
| color: #555; | |
| } | |
| .footer a { | |
| color: #0078c8; | |
| text-decoration: underline; | |
| } | |
| </style> | |
| <script> | |
| function cont() { | |
| window.location.href="https://www.youtube.com/watch?v=xvFZjo5PgG0"; | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <!-- Header --> | |
| <div class="header"> | |
| <div class="optimum-logo">{{isp_title}}</div> | |
| </div> | |
| <!-- Alert --> | |
| <div class="alert">Security threat detected</div> | |
| <!-- Main Content --> | |
| <div class="content"> | |
| <h3>For your protection, do not continue to this site.</h3> | |
| <p> | |
| Our intelligent network has determined this site could be a threat | |
| causing you to install dangerous software or trick you into revealing | |
| personal information, like passwords, phone numbers or credit card | |
| data. | |
| </p> | |
| <div class="buttons"> | |
| <a href="#" onclick="cont()" class="btn btn-primary">Go back</a> | |
| <a href="#" onclick="cont()" class="btn btn-link">Continue anyway</a> | |
| </div> | |
| <div class="footer"> | |
| You are protected by | |
| <a href="{{isp_link}}">{{isp_title}}'s built in security</a>. | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
template.html.j2 has to be in the templates/ subdirectory
MIT