close

[題目]

The purpose of this challenge is to demonstrate the MITRE Top 25 programming flaw: 'Use of a One-Way Hash without a Salt'.

 

This is the same vulnerable application from the previous challenge, still with missing authorization on the admin page where you can see the users and their passwords. The developers are now hashing the user password with an algorithm considered safe but is it enough?

Did you know that the site CrackStation.net maintains a list of known hashes for numbers and dictionary words, also known as a 'Rainbow Table'?

Obtain the password for user and login to solve the challenge. See if you can spot the problem in the code below.

 

<!--contents of administration page cwe327admin.jsp-->

...

byte [] hash = Crypto.getInstance().getHash(tmpPwd,"SHA256");

tmpPwd = Util.bytesToHex(hash);

...

 

[題目說明]

  這一題是要我們根據以上的JSP Java Code 找出漏洞可以讓我們知道某特定使用者密碼然後直接駭入該使用者帳號。

[弱點提示]

 

    The software uses a one-way cryptographic hash against an input that should not be reversible, such as a password, but the software does not also use a salt as part of the input.

From MITRE CWE759

 

  如果使用者資料庫之中並未把密碼適當地加密儲存那很容易被Hacker透過某種管道取得使用者密碼,因此無論何時都應該將使用者密碼做加密,同時加密用的演算法必須是夠安全難以破解的(MD4, MD5, SHA1, DES 是不安全的),但除此之外應該將密碼多加上一層隨機值salt做hash,這樣hacker即使取得安全層級演算法的密碼,也無法透過查表等方式還原,除此之外,盡量不要呈現使用者帳密資訊在頁面上。

 

[解答]

  1. 進入網頁: https://abc.xxx.elasticbeanstalk.com/cwe759
  2. 用demo與demo1234 帳密登入一般使用者頁面,該頁面是無法顯示使用者帳密資訊的。
  3. 只要把 URL 改成如下破解Admin管理密碼管理頁面(這是承襲Dojo 3的破解技巧): https://abc.xxx.elasticbeanstalk.com/cwe759admin.jsp?cwe759loggedin=1111 在該頁面取得user的tempory password hash:

  1. 但因為取得的密碼是SHA-1 hash過的,所以必須將密碼用線上工具還原,打開CrackStation.net頁面貼上hash code即可透過查表方式還原sha256密碼。
  2. 按下Crack Hashes即可得明碼。

  1. 按Logout鈕登出後用user 帳密登入頁面即可破解頁面。

 

[安全原理]

  該弱點被利用的關鍵在於hacker登入頁面後利用missing authorization漏洞成功看到cwe759admin.jsp網頁內容,該內容是使用者帳密列表,因此hacker很輕鬆地拿到user 的密碼,雖然該密碼經過SHA256加密,不容易透過工具破解,但由於某些簡單密碼仍可用查表mapping方式還原,因此密碼可能仍然不算安全,故最好多加一層salt機制以防止hacker拿到目標帳號與密碼,達成竊取帳號目的。

 

2019220日星期三

arrow
arrow

    jackterrylau 發表在 痞客邦 留言(0) 人氣()