--- # Challenge 1: waiting-an-eternity ![](https://hackmd.io/_uploads/SyOKh78qh.png) Một trang web đơn giản với lời thách thức chỉ cần đợi đến thiên thu. Ok, bây giờ ta vào burp suite để xem nào ![](https://hackmd.io/_uploads/Hywgp7U52.png) Có vẻ trang web gợi ý chúng ta tới một endpoint gì đó khác ở đây ![](https://hackmd.io/_uploads/HyON67852.png) Cookie đã được set giá trị time vậy có vẻ chỉ cần thay đổi giá trị này về giá trị rỗng là ta có thể lấy được flag, vì theo gợi ý của tác giả là ta phải đợi đến thiên thu mà :< ![](https://hackmd.io/_uploads/rJCa67L9n.png) Flag : amateursCTF{im_g0iNg_2_s13Ep_foR_a_looo0ooO0oOooooOng_t1M3} # Challenge 2: latek ![](https://hackmd.io/_uploads/SJEzA7Iqh.png) Có vẻ giống như một trang web chuyển đổi sang file PDF thông qua pdfTeX pdfTeX is an extension of TeX which can produce PDF directly from TeX source, as well as original DVI files. pdfTeX incorporates the e-TeX extensions. pdfTeX also has a variety of other extensions, perhaps most notably for microtypography line breaking features. The microtype package provides a convenient interface for LaTeX. Sau một hồi tìm kiếm một vài lỗ hổng thì có vẻ nó có phép chúng ta có thể thực thi file inclusion thông qua việc sử dụng ```\verbatiminput```: https://texfaq.org/FAQ-verbfile ![](https://hackmd.io/_uploads/BkbceNLqn.png) ![](https://hackmd.io/_uploads/H1qslNI52.png) Vậy bây giờ chỉ cần lấy flag thôi ![](https://hackmd.io/_uploads/rJD1WEI53.png) Flag: amateursCTF{th3_l0w_budg3t_and_n0_1nstanc3ing_caus3d_us_t0_n 0t_all0w_rc3_sadly # Challenge 3: funny factorials ![](https://hackmd.io/_uploads/BJrzzNLc3.png) Có vẻ trang web cung cấp một công cụ tính giá trị của n! ![](https://hackmd.io/_uploads/rJJDMELqn.png) Ban đầu mình nghĩ liệu có phải là SSTI hay không nhưng có vẻ bài này author không sử dụng template đi sau vào source code thì mình thấy có một số điểm ``` from flask import Flask, render_template, request import sys app = Flask(__name__) def factorial(n): if n == 0: return 1 else: try: return n * factorial(n - 1) except RecursionError: return 1 def filter_path(path): # print(path) path = path.replace("../", "") try: return filter_path(path) except RecursionError: # remove root / from path if it exists if path[0] == "/": path = path[1:] print(path) return path @app.route('/') def index(): safe_theme = filter_path(request.args.get("theme", "themes/theme1.css")) f = open(safe_theme, "r") theme = f.read() f.close() return render_template('index.html', css=theme) @app.route('/', methods=['POST']) def calculate_factorial(): safe_theme = filter_path(request.args.get("theme", "themes/theme1.css")) f = open(safe_theme, "r") theme = f.read() f.close() try: num = int(request.form['number']) if num < 0: error = "Invalid input: Please enter a non-negative integer." return render_template('index.html', error=error, css=theme) result = factorial(num) return render_template('index.html', result=result, css=theme) except ValueError: error = "Invalid input: Please enter a non-negative integer." return render_template('index.html', error=error, css=theme) if __name__ == '__main__': sys.setrecursionlimit(100) app.run(host='0.0.0.0') ``` Ta có thay đổi theme thông qua ?theme=themes/theme2.css ![](https://hackmd.io/_uploads/HkmW74U92.png) Có vẻ ta lại có thể thực thi file inclusion tuy nhiên nó lại bởi filter bởi ```filter_path()``` Để bypass qua nó chúng ta có thể sử dụng ![](https://hackmd.io/_uploads/HJP-VN85n.png) Boom !! We got flag ![](https://hackmd.io/_uploads/SyELE4L52.png) Flag: amateursCTF{h1tt1ng_th3_r3curs10n_l1mt_1s_1mp0ssibl3}