1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| from flask import Flask, request, render_template_string import html
app = Flask(__name__)
BLACKLIST = [ 'init','globals','builtins','import','os','popen','read','request','application','TemplateReference', 'cycler','joiner','namespace','lipsum','getitem','config','for','eval','flashed','range','class','mro', 'subclasses','pyfile','shell','stdout','base','if','module','RUNCMD','format','args','values','form', 'cookies','headers','pragma','mimetype','origin','referrer','pop','attr','chr','free','palestine','with' ]
BLACKLIST += ['0','1','2','3','4','5','6','7','8','9']
BLACKLIST += ["'",'"',"`",'\\','/','.','_','[',']','{{','}}','#']
@app.route("/", methods=["GET", "POST"]) def home(): c = request.form.get('c') if request.method == 'POST' else None error_message = None rendered_template = None if c: c = c.lower() for item in BLACKLIST: if item in c: error_message = "Invalid input detected!" break else: rendered_template = html.unescape(render_template_string(c)) if "fr3e_p4le$t1ne&!" in rendered_template: try: with open('flag.txt', 'r') as flag_file: flag = flag_file.read() return f"Flag: {flag}" except FileNotFoundError: return "Flag file not found!"
return ''' <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Jinja-Master</title> <style> @import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-image: url('/static/image.jpg'); background-size: cover; background-position: center; font-family: 'VT323', monospace; color: #33FF33; }
.form-container { background-color: rgba(0, 0, 0, 0.7); padding: 20px; border-radius: 10px; box-shadow: 0px 0px 15px 5px rgba(0, 255, 0, 0.5); max-width: 400px; width: 100%; }
.form-container input[type="text"] { width: 100%; padding: 10px; margin: 10px 0; border: 2px solid #33FF33; border-radius: 5px; background-color: #000; color: #33FF33; font-size: 18px; box-sizing: border-box; }
.form-container input[type="submit"] { width: 100%; padding: 10px; background-color: #33FF33; border: none; border-radius: 5px; color: #000; font-size: 18px; cursor: pointer; transition: background-color 0.3s ease; box-sizing: border-box; }
.form-container input[type="submit"]:hover { background-color: #00FF00; }
.result, .error { margin-top: 20px; padding: 10px; border: 2px solid #33FF33; border-radius: 5px; background-color: #000; color: #33FF33; font-size: 18px; text-align: center; } </style> </head> <body> <div class="form-container"> <form method="post"> Enter template string: <input type="text" name="c"> <input type="submit" value="Submit"> </form> <div class="result">{{ rendered_template }}{{ error_message }}</div> </div> </body> </html> '''.replace("{{ error_message }}", error_message or "").replace("{{ rendered_template }}", rendered_template or "")
|