# HMVLabs-Venus Writeup
~~話說這個flag長得特別**屌**~~
[TOC]
## 開始挑戰
用 `ssh` 連線
```bash=
ssh -p 5000 hacker@venus.hackmyvm.eu
```
```
Host: venus.hackmyvm.eu
Port: 5000
User: hacker
Pass: havefun!
````
## Mission
### 0x01
```
################
# MISSION 0x01 #
################
## EN ##
User sophia has saved her password in a hidden file in this folder. Find it and log in as sophia.
```
按照任務說找到 hidden file `.myhiddenpazz` 裡面有密碼

用 `su` 切換帳號登入 `sophia`

這樣就可以找到 flag 了

---
### 0x02
```
################
# MISSION 0x02 #
################
## EN ##
The user angela has saved her password in a file but she does not remember where ... she only remembers that the file was called whereismypazz.txt
```
根據提示用 `find` 指令搜尋`hereismypazz.txt`
```bash=
find / -name 'hereismypazz.txt' 2>/dev/null
```
> `2>/dev/null` 的用意是不讓錯誤訊息顯示出來
一樣用 `su` 指另登入 `angela` 的帳號就可以得到 flag 了

---
### 0x03
```
################
# MISSION 0x03 #
################
## EN ##
The password of the user emma is in line 4069 of the file findme.txt
```
根據提示開啟 `findme.txt` 中的第 4069 行
```bash=
sed -n '4069p' findme.txt
```
一樣登入 `emma` 的帳號就可以得到 flag 了

---
### 0x04
```
################
# MISSION 0x04 #
################
## EN ##
User mia has left her password in the file -.
```
根據提示要開啟檔名為`-`的檔案
但是因為`-`在 terminal 中會被視為 標準輸入(stdin)
所以不能直接開啟
可以用這兩種方式開啟檔案,一個是用路徑的方式開,一個是直接開啟當前目錄全部檔案
```bash=
cat ./-
cat ./*
```
切換帳號至 `mia` 即可得到 flag

---
### 0x05
```
################
# MISSION 0x05 #
################
## EN ##
It seems that the user camila has left her password inside a folder called hereiam
```
根據提示使用 `find` 指令尋找 `hereiam` 這個資料夾
```bash=
find / -name 'hereiam' -type d 2>/dev/null
```
一樣切換帳號至 `camila` 就可以得到 flag 了

---
### 0x06
```
################
# MISSION 0x06 #
################
## EN ##
The user luna has left her password in a file inside the muack folder.
```
根據提示進到 `muack` 資料夾,發現裡面都是資料夾
使用 `find` 指令尋找當前目錄所有檔案
```bash=
find . -type f
```
一樣切換帳戶到 `luna` 即可得到 flag

---
### 0x07
```
################
# MISSION 0x07 #
################
## EN ##
The user eleanor has left her password in a file that occupies 6969 bytes.
```
根據提示仍是使用 `find` 指令尋找大小為 `6969字節` 的檔案
```bash=
find / -size 6969c 2>/dev/null
```

一樣切換帳號至 `eleanor` 即可得到 flag
---
### 0x08
```
################
# MISSION 0x08 #
################
## EN ##
The user victoria has left her password in a file in which the owner is the user violin.
```
根據提示用 `find` 指令尋找密碼
```bash=
find / -type f -user violin 2>/dev/null
```
一樣切換帳號至 `victoria` 即可得到 flag

---
### 0x09
```
################
# MISSION 0x09 #
################
## EN ##
The user isla has left her password in a zip file.
```
根據提示解壓縮 `passw0rd.zip` 時發生錯誤
```
victoria@venus:~$ unzip passw0rd.zip
Archive: passw0rd.zip
checkdir error: cannot create pwned
Permission denied
unable to process pwned/victoria/passw0rd.txt.
```
用 `find` 指令尋找 `passw0rd.txt`
一樣切換帳號至 `isla` 即可找到 flag

---
### 0x10
```
################
# MISSION 0x10 #
################
## EN ##
The password of the user violet is in the line that begins with a9HFX (these 5 characters are not part of her password.).
```
根據提示說明使用 `grep` 指令尋找開頭為 `a9HFX` 的字串
```bash=
grep "^a9HFX" passy
```
一樣切換帳號至 `violet` 即可取得 flag

---
### 0x11
```
################
# MISSION 0x11 #
################
## EN ##
The password of the user lucy is in the line that ends with 0JuAZ (these last 5 characters are not part of her password)
```
根據提示使用 `grep` 指令尋找結尾為 `0JuAZ` 的字串
```bash=
grep "0JuAZ$" end
```
> `$` 表示結尾
一樣切換至 `lucy` 即可得到 flag

---
### 0x12
```
################
# MISSION 0x12 #
################
## EN ##
The password of the user elena is between the characters fu and ck
```
根據提示使用 `grep` 尋找 `fu` 開頭 `ck` 結尾的字串
```bash=
grep "^fu.*ck$" file.yo
```
> `.*` 表示中間未知的字串

---
### 0x13
```
################
# MISSION 0x13 #
################
## EN ##
The user alice has her password is in an environment variable.
```
根據提示可以知道密碼在環境變數當中,使用 `env` 指令查看環境變數
```bash=
env
```
就可以找到密碼了
```
PASS=Cgecy2MY2MWbaqt
```
---
### 0x14
```
################
# MISSION 0x14 #
################
## EN ##
The admin has left the password of the user anna as a comment in the file passwd.
```
根據提示他說 `admin` 把密碼寫在註解裡面
用 `grep` 指令從 `/etc/passwd` 中查找 `alice` 的密碼
```bash=
grep "alice" /etc/passwd
```
得到下面這串
```
alice:x:1014:1014:w8NvY27qkpdePox:/pwned/alice:/bin/bash
```
> 下面我依序說明每個冒號分隔出的區塊代表的是什麼
> `alice` -> 用戶名
> `x` -> 加密後密碼,因為移至 `/etc/shadow` 所以用 `x` 代替
> `1014` -> 用戶UID
> `1014` -> 用戶GID
> `w8NvY27qkpdePox` -> GECOS 字段,也可以簡單理解為補充說明、註解
> `/pwned/alice` -> 這個用戶的家目錄,以這個用戶登入時,若在這個目錄下則顯示 `~`
> `/bin/bash` -> 用戶的預設 shell
所以我們就可以得到密碼 `w8NvY27qkpdePox`
---
### 0x15
```
################
# MISSION 0x15 #
################
## EN ##
Maybe sudo can help you to be natalia.
```
根據提示使用 `sudo -l` 查看 sudo 權限得到以下結果
```
User anna may run the following commands on venus:
(natalia) NOPASSWD: /bin/bash
```
可以得知 `anna` 可以使用 `bash` 指令
而 `natalia` 使用 `bash` 不需要密碼
使用 `sudo -u` 切換使用者帳號並進入 `bash`
```bash=
sudo -u natalia bash
```
---
### 0x16
```
################
# MISSION 0x16 #
################
## EN ##
The password of user eva is encoded in the base64.txt file
```
根據提示將 `base64.txt` 中的密碼 decode
```bash=
cat base64.txt | base64 -d
```
解密後就可以登入`eva` 了
---
### 0x17
```
################
# MISSION 0x17 #
################
## EN ##
The password of the clara user is found in a file modified on May 1, 1968.
```
根據提示要搜尋修改時間在 1968 年的檔案
但是因為 Unix 時間的起點是 1970 年 1 月 1 日
所以最早的時間戳記只能追溯到 1970 年
2024 - 1970 = 54, 54*365 = 19710
使用`find`指令和 `+mtime` 來查找 19710 天前修改的文件
```bash=
find / -mtime +19710 -type f 2>/dev/null
```
---
### 0x18
```
################
# MISSION 0x18 #
################
## EN ##
The password of user frida is in the password-protected zip (rockyou.txt can help you)
```
根據提示將 `protected.zip` 下載至本地
```bash=
scp -P 5000 clara@venus.hackmyvm.eu:~/protected/zip .
```
使用 `zip2john` 將密碼提取出來
在使用 `john` 搭配 `rockyou.txt` 爆破密碼
```bash=
zip2john protected.zip > hash
john --wordlists=rockyou.txt hash
```
成功找到密碼 `pass123`
重新登入至 `clara` 並解壓縮
出現錯誤訊息:
```
checkdir error: cannot create pwned
Permission denied
unable to process pwned/clara/protected.txt.
```
使用 `find` 尋找 `protected.txt`
```bash=
find / -name "protected.txt" 2>/dev/null
```
---
### 0x19
```
################
# MISSION 0x19 #
################
## EN ##
The password of eliza is the only string that is repeated (unsorted) in repeated.txt.
```
根據提示需要找到唯一有重複的字串,使用 `uniq` 指令
```bash=
uniq -d repeated.txt
```
---
### 0x20
```
################
# MISSION 0x20 #
################
## EN ##
The user iris has left me her key.
```
查看當前目錄發現有一個 `.iris_key` 的檔案
打開發現是 ssh_key
直接複製起來,在本地新增一個檔案並貼上
> 因為是自己建立的所以要記得調整權限
> ```bash=
> chmod 600 iris_key
> ```
```bash=
ssh -i .iris_key -p 5000 iris@venus.hackmyvm.eu
```
---
### 0x21
```
################
# MISSION 0x21 #
################
## EN ##
User eloise has saved her password in a particular way.
```
打開目錄下的 `eloise`
通靈出這個應該是 base64
使用 base64 to jpg 的[工具](https://base64.guru/converter/decode/image/jpg)
就可以得到密碼 `yOUJlV0SHOnbSPm` 了
---
### 0x22
```
################
# MISSION 0x22 #
################
## EN ##
User lucia has been creative in saving her password.
```
根據說明此密碼被加密過
用 Cyber Chef 的 Magic 試看看
找出加密方式為 `hexdump`
得到密碼 `uvMwFDQrQWPMeGP`
---
### 0x23
```
################
# MISSION 0x23 #
################
## EN ##
The user isabel has left her password in a file in the /etc/xdg folder but she does not remember the name, however she has dict.txt that can help her to remember.
```
按照提示查看 `/etx/xdg` 但發現權限不足無法讀取資料夾
於是改用路徑爆破
```bash=
for pass in $(cat dict.txt); do
if [ -e "/etc/xdg/$pass" ]; then
echo "$pass"
fi
done
```
成功找到 `readme` 這個檔名,直接用 `cat` 打開 `/etc/xdg/readme`
就可以得到密碼 `H5ol8Z2mrRsorC0` 了
---
### 0x24
```
################
# MISSION 0x24 #
################
## EN ##
The password of the user freya is the only string that is not repeated in different.txt
```
根據提示使用 `uniq ` 尋找唯一不重複的字串 `EEDyYFDwYsmYawj`
```bash=
uniq -u different.txt
```
---
### 0x25
```
################
# MISSION 0x25 #
################
## EN ##
User alexa puts her password in a .txt file in /free every minute and then deletes it.
```
根據提示他說每秒會建立一個 `.txt` 然後馬上刪除它
所以我們設定一個迴圈,監測直到 `/free` 下面有 `.txt` 就馬上打開並結束迴圈
這樣就可以得到密碼 `mxq9O3MSxxX9Q3S` 了
```bash=
while true; do
if cat /free/* 2>/dev/null; then
break
fi
done
```
---
### 0x26
```
################
# MISSION 0x26 #
################
## EN ##
The password of the user ariel is online! (HTTP)
```
他說 `arial` 的密碼在線上
用 `curl` 查看 `localhost` 就可以得到密碼 `33EtHoz9a0w2Yqo`
```bash=
curl localhost
```
---
### 0x27
```
################
# MISSION 0x27 #
################
## EN ##
Seems that ariel dont save the password for lola, but there is a temporal file.
```
當前目錄一下有個 `.goas.swp`
google 之後發現這是一個 `Vim` 的交換文件 會暫存編輯記錄
使用 `vim -r` 復原紀錄
```bash=
vim -r goas
```
把下圖這個檔案多餘的字刪掉 只剩下密碼

因為當前目錄的權限沒有 `w` 所以這個檔案沒辦法存在當前目錄

`/tmp` 目錄可以寫入檔案 把檔案儲存至 `/tmp` 目錄

用另存新檔的方式儲存檔案
```vim=
:w /tmp/goas.txt
```
爆破 `lola` 的密碼 `d3LieOzRGX5wud6`
```bash=
for pass in $(cat /tmp/goas.txt); do
echo "$pass" | su lola 2>/dev/null
if [ $? -eq 0 ]; then
echo "$pass"
break
fi
done
```
---
### 0x28
```
################
# MISSION 0x28 #
################
## EN ##
The user celeste has left a list of names of possible .html pages where to find her password.
```
當前目錄下有個 `pages.txt` 根據提示這些當中有密碼的 `.html` 名稱
一樣用爆破的 用網頁的 `status code` 來判斷網頁是否存在
```bash=
for name in $(cat pages.txt); do
pass=$(curl -s -o /dev/null -w "%{http_code}" localhost/$name.html)
if [ $pass -eq 200 ]; then
echo $name
break
fi
done
```
找到後訪問這個頁面就可以找到密碼 `VLSNMTKwSV2o8Tn`
```bash=
curl localhost/cebolla.html
```
---
### 0x29
```
################
# MISSION 0x29 #
################
## EN ##
The user celeste has access to mysql but for what?
```
使用 `celeste` 的帳號密碼登入 mysql
```bash=
mysql -u celeste -pVLSNMTKwSV2o8Tn
```
> 密碼的地方要注意不能空格 錯誤示範:-p VLSNMTKwSV2o8Tn
因為先前的密碼長度都是 15 所以用密碼長度來過濾一下
```mysql=
show databases;
use venus;
show tables;
select * from people where length(pazz)=15;
```
得到這些帳密
```mysql=
+-----------+----------+-----------------+
| id_people | uzer | pazz |
+-----------+----------+-----------------+
| 16 | sfdfdsml | ixpeqdsfsdfdsfW |
| 44 | yuio | ixpgbvcbvcbeqdW |
| 54 | crom | ixpefdbvvcbrqdW |
| 58 | bael | ixpesdvsdvsdqdW |
| 74 | nina | ixpeqdWuvC5N9kG |
| 77 | dsar | ixpeF43F3F34qdW |
| 78 | yop | ixpeqdWCSDFDSFD |
| 79 | loco | ixpeF43F34F3qdW |
+-----------+----------+-----------------+
```
用 `su` 檢測找到 `nina` 這個帳號登入即可
---
### 0x30
```
################
# MISSION 0x30 #
################
## EN ##
The user kira is hidding something in http://localhost/method.php
```
直接用 `curl` 訪問 `http://localhost/method.php` 得到
```
I dont like this method!
```
嘗試過後發現只有使用 `PUT` 這個 method 訪問才能得到密碼 `tPlqxSKuT4eP3yr`
---
### 0x31
```
################
# MISSION 31 #
################
## EN ##
The user veronica visits a lot http://localhost/waiting.php
```
用 `curl` 訪問 `http://localhost/waiting.php` 得到
```
Im waiting for the user-agent PARADISE.
```
把 User-Agent 設為 `PARADISE` 就可以得到密碼 `QTOel6BodTx2cwX`
---
### 0x32
```
################
# MISSION 0x32 #
################
## EN ##
The user veronica uses a lot the password from lana, so she created an alias.
```
題目就直接寫了 使用 `alias` 指令就可以得到密碼 `UWbc0zNEVVops1v`
```bash=
alias
```
---
### 0x33
```
################
# MISSION 0x33 #
################
## EN ##
The user noa loves to compress her things.
```
他說他喜歡壓縮東西 在目錄底下有個 `zip.gz`
用 `gzip` 解壓縮
```bash=
gzip -d zip.gz
```
但是解壓縮失敗 使用 `file` 查看檔案類型
```bash=
file zip.gz
```
發現是 `tar` 檔
```bash=
tar xvf zip.gz
```
因為本地資料夾限制不能讀寫 解壓縮到到 `/tmp/fearnot` 目錄處理
> 因為原先的 `/tmp` 目錄中有一個沒有寫入權限的 `pwned` 目錄
> 所以先建立一個自己的資料夾
> 記得要指定壓縮的目錄 不然一樣會權限不足
```bash=
mkdir /tmp/fearnot
tar xvf zip.gz -C /tmp/fearnot
```
直接開啟檔案就可以得到密碼 `9WWOPoeJrq6ncvJ`
```bash=
cat /tmp/fearnot/pwned/lana/zip
```
---
### 0x34
```
################
# MISSION 0x34 #
################
## EN ##
The password of maia is surrounded by trash
```
trash 是個 `DATA` 直接打開是亂碼
用 `strings` 查看可視字元就可以找到密碼 `h1hnDPHpydEjoEN`
```bash=
strings trash
```
---
### 0x35
```
################
# MISSION 0x35 #
################
## EN ##
The user gloria has forgotten the last 2 characters of her password ... They only remember that they were 2 lowercase letters.
```
根據提示直接把密碼用爆破的爆出來
> ~~我覺得作者會很白目放很後面 所以從z試到a~~
```bash=
prefix="v7xUVE2e5bjUc"
for c1 in {z..a}; do
for c2 in {z..a}; do
pass="${prefix}${c1}${c2}"
echo "$pass" | su gloria 2>/dev/null
if [ $? -eq 0 ]; then
echo "$pass"
exit
fi
done
done
```
果然從後面來一下就找到密碼 `v7xUVE2e5bjUcxw`
---
### 0x36
```
################
# MISSION 0x36 #
################
## EN ##
User alora likes drawings, that's why she saved her password as ...
```
打開 `image` 發現是個 QR Code
掃完就有密碼 `mhrTFCoxGoqUxtw`
---
### 0x37
```
################
# MISSION 0x37 #
################
## EN ##
The user julie has created an iso with her password.
```
使用 `isoinfo` 工具檢查 `iso` 檔 發現裡面有個 `zip` 檔
```bash=
isoinfo -i music.iso -l
```
下載到本地後 掛載到虛擬機上 然後就可以訪問這個映像檔
解壓縮 `zip` 檔後 就可以找到密碼 `sjDf4i2MSNgSvOv`
~~但是這個太麻煩了 我們直接`貓`他就可以了~~
---
### 0x38
```
################
# MISSION 0x38 #
################
## EN ##
The user irene believes that the beauty is in the difference.
```
直接使用 `diff` 指令查看 `1.txt` 和 `2.txt` 的差異
```bash=
diff 1.txt 2.txt
```
得到在第 174 行有不同 兩個都試過後得到密碼 `8VeRLEFkBpe2DSD`
```
174c174
< 8VeRLEFkBpe2DSD
---
> aNHRdohjOiNizlU
```
---
### 0x39
```
################
# MISSION 0x39 #
################
## EN ##
The user adela has lent her password to irene.
```
當前目錄有三個檔案 `id_rsa.pem`、`id_rsa.pub`、`pass.enc`
可以推測是需要我們解密出原先的密碼
使用 `openssl` 工具
```bash=
openssl pkeyutl -decrypt -inkey id_rsa.pem -in pass.enc
```
> `-inkey` -> 私鑰
> `-in` -> 密文
得到密碼 `nbhlQyKuaXGojHx`
---
### 0x40
```
################
# MISSION 0x40 #
################
## EN ##
User sky has saved her password to something that can be listened to.
```
打開 `wtf` 有一串摩斯密碼 根據提示去線上找[解密工具](https://codepen.io/hdsbook/full/rNOBrdL)
```
.--. .- .--. .- .--. .- .-. .- -.. .. ... .
```
得到密碼 `PAPAPARADISE` 但發現大寫過不了 改成小寫就可以了 `papaparadise`
---
### 0x41
```
################
# MISSION 0x41 #
################
## EN ##
User sarah uses header in http://localhost/key.php
```
使用 `curl` 指令查看 `http://localhost/key.php` 後得到
```
Key header is true?
```
於是自己發送 key 的值為 true 的 header 就可以得到密碼 `LWOHeRgmIxg7fuS`
```bash=
curl -H 'key:true' http://localhost/key.php
```
---
### 0x42
```
################
# MISSION 0x42 #
################
## EN ##
The password of mercy is hidden in this directory.
```
當前目錄下有個 `...` 的檔案 打開就可以得到密碼 `ym5yyXZ163uIS8L`
---
### 0x43
```
################
# MISSION 0x43 #
################
## EN ##
User mercy is always wrong with the password of paula.
```
他說 `mercy` 常常輸入錯誤 `paula` 的密碼
查看 `bash` 的紀錄 `.bash_history` 這樣就能找到密碼 `dlHZ6cvX6cLuL8p`
---
### 0x44
```
################
# MISSION 0x44 #
################
## EN ##
The user karla trusts me, she is part of my group of friends.
```
使用 `groups` 查看發現當前除了有 `paula` 的群組 還有一個 `hidden` 群組
用 `find` 尋找屬於 `hidden` 的檔案 就可以找到密碼 `gYAmvWY3I7yDKRf`
```bash=
find / -group hidden -exec cat {} \; 2>/dev/null
```
---
### 0x45
```
################
# MISSION 0x45 #
################
## EN ##
User denise has saved her password in the image.
```
用 `exiftool` 查看圖片
```bash=
exiftool yuju.jpg
```
就可以在 `About` 找到密碼 `pFg92DpGucMWccA`
```
About : pFg92DpGucMWccA
```
---
### 0x46
```
################
# MISSION 0x46 #
################
## EN ##
The user zora is screaming doas!
```
根據題目提到的 `doas` google 後發現是個類似 `sudo` 的工具
使用 `doas` 指令和 `denise` 的密碼進入 `zora` 的 bash
```bash=
doas -u zora bash
```
`zora` 的密碼 `BWm1R3jCcb53riO`
---
### 0x47
```
################
# MISSION 0x47 #
################
## EN ##
The user belen has left her password in venus.hmv
```
嘗試 `find` 指令 沒有找到 `venus.hmv`
改用 `curl` 就可以找到密碼 `2jA0E8bQ4WrGwWZ`
```bash=
curl venus.hmv
```
---
### 0x48
```
################
# MISSION 0x48 #
################
## EN ##
It seems that belen has stolen the password of the user leona...
```
打開 `stolen.txt` 得到
```
$1$leona$lhWp56YnWAMz6z32Bw53L0
```
觀察開頭為 `$1$` 得知是使用 `md5` 算法 回到本地用 `john` 破解密碼
```bash=
echo '$1$leona$lhWp56YnWAMz6z32Bw53L0' > hash
john --format=md5crypt hash
```
得到密碼為 `freedom`
---
### 0x49
```
################
# MISSION 0x49 #
################
## EN ##
User ava plays a lot with the DNS of venus.hmv lately...
```
使用 `dig` 和 `nslookup` 查看 DNS 紀錄都沒找到東西
改去 `/etc/bind` 檢查紀錄 直接打開 `db.venus.hmv` 就可以找到密碼 `oCXBeeEeYFX34NU`
```bash=
cat /etc/bind/db.venus.hmv
```
---
### 0x50
```
################
# MISSION 0x50 #
################
## EN ##
The password of maria is somewhere...
```
這題就是純粹通靈 密碼是前面的摩斯密碼
```
.--. .- .--. .- .--. .- .-. .- -.. .. ... .
```
---
### 0x51
```
################
# MISSION 0x51 #
################
## EN ##
Congrats!
```
---
## Hidden
### 0xH
在 `0x01` 中按照任務說找到 hidden file 發現有一個檔案叫做`...`
打開就可以得到 flag 了
---
### 0xK
在 `0x29` 中的 mysql 時
```mysql=
show databeses;
use venus;
show tables;
select * from people;
```
就可以 user `haha` 的 `pazz` 找到 flag 了
---
### 0XE
在 `0x30` 中使用 `PATCH` 這個 method 就可以取得 flag 了
```bash=
curl -X PATCH http://localhost/method.php
```