Skip to content

Commit

Permalink
Update assets/image
Browse files Browse the repository at this point in the history
  • Loading branch information
dAd0qbu committed Apr 8, 2024
1 parent 9a19a75 commit 18487fa
Show file tree
Hide file tree
Showing 24 changed files with 23 additions and 23 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
16 changes: 8 additions & 8 deletions blogs/CTF/2024/cyber-apocalypse-2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ As the leader of the Revivalists you are determined to take down the KORP, you a


- Bài cho chúng ta web đơn giản, cho phép lưu các note vào folder của server.
![image](assets/upload_027d2f043ec9d329a790d55cf4bf034e.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024.png)
- File flag nằm ở `/` và được đặt tên random
```bash
# Change flag name
Expand Down Expand Up @@ -143,7 +143,7 @@ In "The Ransomware Dystopia," LockTalk ...(sh1t)... against the encroaching dark
:::

- App cho 3 API Endpoints
![image](assets/upload_4b8732d6f5341db0d6e2a4936317023b.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024-1.png)
Có hai endpoint quan trọng là `get_ticket` để lấy jwt token và `flag` để lấy flag dựa vào jwt token.
```python
@api_blueprint.route('/get_ticket', methods=['GET'])
Expand Down Expand Up @@ -176,15 +176,15 @@ khi GET đến thì sẽ bị proxy chặn lại, ACL kiểm tra nếu url bắt
> Hoặc dựa vào haproxy version hiện tại là 2.8.1, bị dính lỗ hổng bảo mật [CVE-2023-45539](https://www.cvedetails.com/cve/CVE-2023-45539/)

![image](assets/upload_0e510b20e843bf54d1055981089ade3a.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024-2.png)
Đã có jwt với role là `guest`, ta cần tìm cách edit jwt để có thể chỉnh thành `admin`.
Mà ở đây app sử dụng [python-jwt v3.3.3](https://pypi.org/project/python-jwt/) để xử lý jwt. Đây cũng là một phiên bản cũ và bị dính lỗ hổng bảo mật [CVE-2022-39227](https://nvd.nist.gov/vuln/detail/CVE-2022-39227) cho phép ta chỉnh sửa, giả mạo jwt mới với sign cũ.

Đến đây ta chỉ cần dựa vào CVE-2022-39227 chỉnh sửa jwt token từ role `guest` thành `administrators` và GET `/api/v1/flag` với jwt token để lấy flag.

### Về CVE-2022-39227
`python-jwt` sau đó đã cập nhật lên v3.3.4 để fix lỗi ([#88ad9e6](https://github.com/davedoesdev/python-jwt/commit/88ad9e67c53aa5f7c43ec4aa52ed34b7930068c9)), cụ thể thêm hàm để check jwt format
![image](assets/upload_3b9a8d610d16da8f7d268737bee3975c.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024-3.png)
Ở phiên bản cũ, ta có thể đưa vào JSON string thay vì JWT string format, dẫn đến việc giả mạo dữ liệu mà vẫn có thể verify thành công.

Khi GET `/api/v1/flag` cùng jwt, app sẽ gọi hàm verify jwt được truyền vào
Expand Down Expand Up @@ -233,7 +233,7 @@ Nếu đưa vào JWT đã bị thay đổi theo jwt format thì sẽ verify th
self.verify(key, alg)
```
Tập trung vào trường hợp `json_decode` thành công. Code sẽ lấy payload (claims), signature, protected (header) từ `djws` và tiến hành verify.
![image](assets/upload_bf5b37a2b2f4abbc97d9f6df646b18b3.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024-4.png)
Ta cần đưa vào jwt thỏa mãn:
- Là dạng JSON string
- Sau khi split kí tự '.' chia ra 3 phần: header, payload và \_ (KHÔNG QUAN TRỌNG 💣💥💥)
Expand Down Expand Up @@ -264,12 +264,12 @@ Sẽ thành
}
```
Sau khi split, header sẽ là `{"eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9` nhưng vẫn có thể decode và loads thành công
![image](assets/upload_e3a48eaeb0a7a0423afc4df7839003e9.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024-5.png)

Sau đó jwt được deserilize và verify
![image](assets/upload_47b0a8c7c7a3dee7f6499b9da873b52d.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024-6.png)
Cuối cùng jwt được verify qua JWSCore, vì param `header` được truyền vào từ `protected` nên khi tạo JSONG string, mình phải dùng `protected`.
![image](assets/upload_ac3e2db5abe29277e5dc9664ab0686f1.png)
![image](assets/cyber-apocalypse-2024/cyber-apocalypse-2024-7.png)


---
Expand Down
30 changes: 15 additions & 15 deletions blogs/CTF/2024/picoctf-2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ categories:

PicoCTF2024 là giải Weekly đầu tiên trong năm 2024 của CLB và cũng có thể xem là giải debut của team mình dù đã hoạt động từ lâu. Dù không thể giải quyết hết tất cả các challenge nhưng KHÔNG QUAN TRỌNG 💣💥💥, bọn mình cũng đã cố gắng hết sức.

![image](assets/image.png)
![image](assets/picoctf-2024/picoctf-2024.png)

Dưới đây là writeup của một số bài trong PicoCTF

Expand All @@ -22,7 +22,7 @@ How well can you perfom basic binary operations?
Start searching for the flag here `nc titan.picoctf.net`
:::
Bài yêu cầu connect tới server nc và trả lời một số câu hỏi trong thời gian nhất định. Sau khi trả lời đủ sau câu sẽ yêu cầu trả lời lại câu hỏi cuối cùng để confirm và gửi flag.
![image](assets/image-1.png)
![image](assets/picoctf-2024/picoctf-2024-1.png)


Đây là script của mình để solve bài này.
Expand Down Expand Up @@ -78,19 +78,19 @@ Can you abuse the banner?
Additional details will be available after launching your challenge instance.
:::
Trước tiên ta cần trả lời một số câu hỏi đơn giản, sau khi trả lời xong sẽ được xài bash
![image](assets/image-2.png)
![image](assets/picoctf-2024/picoctf-2024-2.png)

Kiểm tra thì thấy có script python đang chạy ở `/root`
![image](assets/image-3.png)
![image](assets/picoctf-2024/picoctf-2024-3.png)
Ở đây có file `flag.txt` nhưng bị giới hạn quyền chỉ cho user `root` đọc file.

Còn có `script.py` của user `root`, cho phép ta đọc nội dung của file đó.
Đọc thử file `script.py` sẽ thấy code sẽ đọc nội dung từ file `/home/player/banner` và print ra khi chạy sript
![image](assets/image-4.png)
![image](assets/picoctf-2024/picoctf-2024-4.png)

--> Ta có thể xài symlynk để khi đọc file `/home/player/banner` nó sẽ tự trỏ tới file `/root/flag.txt` để đọc và print ra.
Sau khi tạo symlink, kiểm tra sẽ thấy banner trỏ tới flag.txt
![image](assets/image-5.png)
![image](assets/picoctf-2024/picoctf-2024-5.png)
Bây giờ chỉ việc nc lại là có flag

> Bài này còn một cách khác là leo quyền lên root với password là `iloveyou` 🤨
Expand All @@ -105,14 +105,14 @@ Bài cho phép ta sử dụng command nhưng lại ban gần như hầu hết c
--> Mình nghĩ đến hướng sử dụng [wildcards](https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm) để thay thế.

Trước tiên cần tìm flag file nằm đâu, sau khi fuzz thì mò ra nó nằm ở `blargh/flag.txt`
![image](assets/image-6.png)
![image](assets/picoctf-2024/picoctf-2024-6.png)

Tiếp theo ta cần tìm cách đọc file flag
Vì có thể xài ký tự số nên mình tìm các lệnh có chứa ký tự số có thể xài được
![image](assets/image-7.png)
![image](assets/picoctf-2024/picoctf-2024-7.png)

Ta thấy có base32 (base64) có thể xài được nên có thể sử dụng `/???/???/????32` để gọi đến `/usr/bin/base32` và đọc file
![image](assets/image-8.png)
![image](assets/picoctf-2024/picoctf-2024-8.png)

> Ngoài ra còn một số lệnh có thể sử dụng như `/usr/bin/diff3`, `/usr/bin/pdb3.8` (vì script chạy với python3.8)
>
Expand All @@ -127,16 +127,16 @@ You can download the source [here](https://artifacts.picoctf.net/c_atlas/34/app.
The website is running [here](http://atlas.picoctf.net:53436/). Can you log in?
:::
App sử dụng database là MongoDB, khi POST `/login` sẽ gửi JSON gồm email và password cho server
![image](assets/image-9.png)
![image](assets/picoctf-2024/picoctf-2024-9.png)

Query của MongoDB ta có thể thêm vào một object có key là `$regex` để match query thỏa điều kiện của regex đó.
Như thế, ta chỉ cần đưa vào email là `joshiriya355@mumbama.com` và password match `.*`.

Tuy nhiên nếu đưa object vào password sẽ bị lỗi, vì ở phần code xử lý sẽ check password bắt đầu bằng "{" và kết thúc bằng "}" là syntax của JSON, khi đó code sẽ tự parse string đó thành JSON object
![image](assets/image-10.png)
![image](assets/picoctf-2024/picoctf-2024-10.png)

Giờ chỉ việc POST lên với password là JSON string sẽ được token, decode token và ra flag
![image](assets/image-11.png)
![image](assets/picoctf-2024/picoctf-2024-11.png)

## WEB: Trickster
:::info Challenge
Expand All @@ -162,9 +162,9 @@ Code sẽ check file có phải PNG hay không dựa vào
- Tên file có chứa ".png"

Vì Backend sử dụng PHP/8.0.30, ta chỉ cần upload file php lên chạy hàm `shell_exec` để RCE
![image](assets/image-12.png)
![image](assets/picoctf-2024/picoctf-2024-12.png)

![image](assets/image-13.png)
![image](assets/picoctf-2024/picoctf-2024-13.png)
##

Check out mah teammates' blog: [@clowncs](https://clowncs.github.io/picoctf2024/), [s1gm4🦆](https://s19ma.github.io/posts/2024/picoCTF_2024.html)
Check out mah teammates' blog: [@clowncs](https://clowncs.github.io/picoctf2024/), [s1gm4🦆](https://s19ma.github.io/posts/2024/picoCTF_2024.html), [n3g4tee](https://hackmd.io/@n3g4tee/H16kbFm0T).

0 comments on commit 18487fa

Please sign in to comment.