Tô Đỉnh Nguyên

@to016

Student, CTFer, web warrior

Joined on Jun 12, 2022

We're all here to learn

  • Sau đợt thi học kì kết thúc năm 2 xong thì mình cũng rảnh nên quyết định kiếm vài chall java cũ mấy năm trước mà đấm (thực ra là bị nó đấm ngược 😗). Lướt trên git repo của mấy tiền bối thì bắt gặp một bài về java deserialization hay về JSF. Qua bài này thì mình học được rất nhiều thứ: setup + debug ... nhưng cũng tốn tầm 3 - 4 ngày để solved 😔. Không luyên thuyên nữa bắt tay vào chall thôi Contact me : https://t.me/isthatgeorge3301 Sơ lược về challenge Mô tả Set up Bài này tác giả cho source để build local. Có thể build thông qua README.md (docker) hoặc README.txt (cái này mình dùng để cài thẳng vào máy ảo cho việc remote debug, tí nữa sẽ đề cập cụ thể). Note: ở file setup.sh, chỉnh lại như sau để không bị lỗi unrecognised service
     Like 2 Bookmark
  • Crypto CommonRSA Common modulus attack script: from Crypto.Util.number import long_to_bytes from sage.all import xgcd with open("pubkey.txt", "r") as f: n, e1, e2 = list(map(int, f.read().splitlines()))
     Like 1 Bookmark
  • Web Zerggling Base on the current version of gnuboard , we can figure out the sqli bug due to loose comparison image So the final payload is image
     Like 1 Bookmark
  • Source: https://github.com/to016/CTFs/tree/main/2023/d3ctf/ezjava Gồm 2 services registry (public) và server (internal) flag được lưu bên phía server Cả 2 đều được build dựa trên spring framework Registry exploit Về phần registry ta thấy có định nghĩa về controller cũng như các "serializer"
     Like  Bookmark
  • Mình tham gia giải lần này chủ yếu là để lấy lại cảm giác tay khi chơi ctf (gọi là tìm lại cái phong độ tí ti đã mất cũng được 🤣), mặc dù bản thân không giỏi các dạng đề về client side nhưng ở post này cũng xin gửi đến mọi người 2 bài, mà thật ra là mình cũng chỉ giải được có mỗi 2 câu này. peanut-xss Tổng quan Trang web cho phép người dùng soạn thảo nội dung bằng html đồng thời hỗ trợ tính năng "expandable, embeddable explanations" với thư viện nutshell. Source của trang chủ yếu nằm ở front end và bên cạnh nutshell, thư viện DOMPurify được sử dụng cho mục đích sanitize html.
     Like 4 Bookmark
  • User flag Scan dải port mặc định với nmap Từ output có thể thấy một dịch vụ web được public ra ngoài ở port 8080. Access vào với ip và port tương ứng, được redirect đến http://icinga.cerberus.local:8080/icingaweb2/authentication/login -> Map hostname này với ip tương ứng vào /etc/hosts để tiện cho tiếp tục khai thác. Icinga là một hệ thống giám sát mã nguồn mở linh hoạt và mạnh mẽ được sử dụng để giám sát hiệu năng của các máy chủ và dịch vụ được nối mạng. Nó có thể được sử dụng để theo dõi tải và thời gian hoạt động của một nhóm web workers, dung lượng đĩa trống trên thiết bị lưu trữ, mức tiêu thụ bộ nhớ trên dịch vụ lưu trữ, v.v. Sau khi thiết lập đúng, Icinga có thể cung cấp tổng quan nhanh về trạng thái số lượng lớn máy chủ và dịch vụ cũng như thông báo, lập lịch thời gian chết và lưu trữ lâu dài dữ liệu hiệu suất.
     Like  Bookmark
  • 3Services Bài này ban đầu mình muốn thiết kế theo kiểu double pivoting để nó hướng "redteam" một tí, nhưng sau khi làm xong thì phát hiện ra cần phải nới lỏng một vài điều kiện khác để có thể áp dụng được và kết quả là dù mình đã bỏ đi kĩ thuật đó nhưng cũng k ngăn được việc nó trở thành một chall web 3 trong 1 🥺, rất xin lỗi những ai đã làm chall này của mình. Note nhanh về solution của từng service sẽ như sau: Service 1 SQLi thông qua mysql local variable POST /index.php?page=register&user=<@urlencode>admin'into @a,@c,@,@#<@/urlencode> HTTP/1.1 Host: 127.0.0.1 Content-Length: 72
     Like  Bookmark
  • Yêu cầu: Đọc toàn bộ lý thuyết về SQL Injection tại đây: https://portswigger.net/web-security/sql-injection Hoàn thành các bài labs thuộc chủ đề SQL Injection tại: https://portswigger.net/web-security/all-labs Ouput: Chụp ảnh các bài labs đã giải được Viết writeups các bài đã giải được Điểm số sẽ tính theo tỉ lệ các bài labs giải được
     Like  Bookmark
  • Lab: CSRF vulnerability with no defenses This lab's email change functionality is vulnerable to CSRF. To solve the lab, craft some HTML that uses a CSRF attack to change the viewer's email address and upload it to your exploit server. You can log in to your own account using the following credentials: wiener:peter Bài lab này bị lỗi csrf ở tính năng change email, ở request dùng cho tính năng này ta thực hiện Generate CSRF POC Và Add option auto submit script để html form được tự động submit
     Like  Bookmark
  • Lab: CORS vulnerability with basic origin reflection This website has an insecure CORS configuration in that it trusts all origins. To solve the lab, craft some JavaScript that uses CORS to retrieve the administrator's API key and upload the code to your exploit server. The lab is solved when you successfully submit the administrator's API key. You can log in to your own account using the following credentials: wiener:peter Login với account được cung cấp, tại My account có hiện API key của user wiener Check qua HTTP history, nhận thấy request đến /accountDetails trả về header Access-Control-Allow-Credentials -> có thể được cấu hình để hỗ trợ CORS
     Like  Bookmark
  • Yêu cầu: Đọc toàn bộ lý thuyết tại đây: https://portswigger.net/web-security/information-disclosure https://portswigger.net/web-security/logic-flaws Hoàn thành các bài lab thuộc hai chủ đề Information Disclosure và Business Logic Vulnerabilities tại: https://portswigger.net/web-security/all-labs Ouput: Chụp ảnh các bài labs đã giải được Viết writeups các bài đã giải được
     Like  Bookmark
  • Directory traversal Reading arbitrary files via directory traversal Lab: File path traversal, simple case Access vào bài lab, chọn view details một product, ta để ý thấy sẽ có một request GET /image?filename=38.jpg Path traversal để đọc file passwd Common obstacles to exploiting file path traversal vulnerabilities
     Like  Bookmark
  • Lab: Exploiting XXE using external entities to retrieve files This lab has a "Check stock" feature that parses XML input and returns any unexpected values in the response. To solve the lab, inject an XML external entity to retrieve the contents of the /etc/passwd file. Access vào bài lab, ở chức năng Check stock Một POST request được gửi lên server với nội dung định dạng xml Ta khai báo mới một external entity xxe trỏ đến nội dung file passwd và đọc được nội dung của file này
     Like  Bookmark
  • Lab: DOM-based open redirection This lab demonstrates a DOM-based redirection vulnerability that is triggered by web messaging. To solve this lab, construct an HTML page on the exploit server that exploits this vulnerability and calls the print() function. Khi ta click vào một bài post, tag a "Back to Blog" chứa một đoạn mã JS như sau <div class="is-linkback"> <a href='#' onclick='returnUrl = /url=(https?:\/\/.+)/.exec(location); if(returnUrl)location.href = returnUrl[1];else location.href = "/"'>Back to Blog</a> </div> Vậy nếu trong URL có dạng ?url=https... thì có thể redirect tới đó
     Like  Bookmark
  • Lab: Modifying serialized objects This lab uses a serialization-based session mechanism and is vulnerable to privilege escalation as a result. To solve the lab, edit the serialized object in the session cookie to exploit this vulnerability and gain administrative privileges. Then, delete Carlos's account. You can log in to your own account using the following credentials: wiener:peter Sau khi login vào account wiener:peter, server trả về một cookie mới cho ta Thử base64 decode chuỗi này, nhận thấy đây là dạng serialized data trong php Theo như mô tả yêu cầu của đề thì có lẽ như ta phải leo quyền để có quyền hạn như user admin, bởi vì chuỗi serialized data này không hề được mã hóa cũng như đảm bảo tính toàn vẹn nên ta hoàn toàn có thể chỉnh sửa thuộc tính admin:false hiện tại thành admin:true.
     Like  Bookmark
  • Lab: Basic server-side template injection This lab is vulnerable to server-side template injection due to the unsafe construction of an ERB template. To solve the lab, review the ERB documentation to find out how to execute arbitrary code, then delete the morale.txt file from Carlos's home directory. Bài lab có hint cho ta là server sử dụng ERB template trong ruby và có thể injection được, để ý thấy GET param message được xuất hiện trong response: Search document của ERB template, ta thấy có thể sử dụng <% %> để chạy ruby code và trong ruby, có thể dễ dàng thực thi system command với backtick
     Like  Bookmark
  • Lab: Web cache poisoning with an unkeyed header This lab is vulnerable to web cache poisoning because it handles input from an unkeyed header in an unsafe way. An unsuspecting user regularly visits the site's home page. To solve this lab, poison the cache with a response that executes alert(document.cookie) in the visitor's browser. Thử gửi một request bất kì hai lần, ta thấy response header thay đổi như sau X-Cache: miss -> X-Cache: hit => Server có sử dụng cache, và bên cạnh đó còn dựa vào request header X-Forwarded-Host để tạo ra các resource 1 cách tự động, như trong hình dưới thuộc tính src của tag script được thay đổi dựa trên header này. Setup lại exploit server Send request 2 lần để poison cache Kết quả
     Like  Bookmark
  • Lab: Basic password reset poisoning This lab is vulnerable to password reset poisoning. The user carlos will carelessly click on any links in emails that he receives. To solve the lab, log in to Carlos's account. You can log in to your own account using the following credentials: wiener:peter. Any emails sent to this account can be read via the email client on the exploit server. Trang web này có chức năng Forgot password, khi ấn forgot một mail sẽ được gửi đến cho user như sau Ý tưởng sẽ là lợi dụng host header để ghi đè giá trị host trong email thành exploit server của ta và steal reset password token Access log:
     Like  Bookmark
  • Lab: HTTP request smuggling, basic CL.TE vulnerability This lab involves a front-end and back-end server, and the front-end server doesn't support chunked encoding. The front-end server rejects requests that aren't using the GET or POST method. To solve the lab, smuggle a request to the back-end server, so that the next request processed by the back-end server appears to use the method GPOST. Theo gợi ý của đề bài, front end server sử dụng CL để "cắt request", còn backend server thì sử dụng TE, vậy ta có thể áp dụng cách khai thác như sau: Content-Length là 6 => front end server chỉ thấy có một request tuy nhiên khi được forwared đến back end server, nó dùng TE và thấy có tới tận 2 request => ấn send 1 lần nữa lúc này request mới sẽ được append vào phần còn lại và ... "Unrecognized method GPOST" Lab: HTTP request smuggling, basic TE.CL vulnerability This lab involves a front-end and back-end server, and the back-end server doesn't support chunked encoding. The front-end server rejects requests that aren't using the GET or POST method.
     Like  Bookmark
  • Lí thuyết Lab: Authentication bypass via OAuth implicit flow This lab uses an OAuth service to allow users to log in with their social media account. Flawed validation by the client application makes it possible for an attacker to log in to other users' accounts without knowing their password. To solve the lab, log in to Carlos's account. His email address is carlos@carlos-montoya.net. You can log in with your own social media account using the following credentials: wiener:peter. OAuth flow sẽ như sau (từ 46 -> 59)
     Like  Bookmark