import re, requests, flask from urllib.parse import urlparse app = flask.Flask(__name__) app.flag = '***CENSORED***' app.re_ip = re.compile('\A(\d+)\.(\d+)\.(\d+)\.(\d+)\Z') def valid_ip(ip): matches = app.re_ip.match(ip) if matches == None: return False ip = list(map(int, matches.groups())) if any(i > 255 for i in ip) == True: return False # Stay out of my private! if ip[0] in [0, 10, 127] \ or (ip[0] == 172 and (ip[1] > 15 or ip[1] < 32)) \ or (ip[0] == 169 and ip[1] == 254) \ or (ip[0] == 192 and ip[1] == 168): return False return True def get(url, recursive_count=0): r = requests.get(url, allow_redirects=False) if 'location' in r.headers: if recursive_count > 2: return '🤔' url = r.headers.get('location') if valid_ip(urlparse(url).netloc) == False: return '🤔' return get(url, recursive_count + 1) return r.text @app.route('/admin-status') def admin_status(): if flask.request.remote_addr != '127.0.0.1': return '🥺' return app.flag @app.route('/check-status') def check_status(): url = flask.request.args.get('url', '') if valid_ip(urlparse(url).netloc) == False: return '🥺' return get(url) @app.route('/') def index(): return '''

urlcheck v1

{{ d(status) }}
'''