TibaMe: 道德駭客實務入門及CEH認證班
Teacher: 林煌錡 (Alex Lin)

The class on 4/8 introduced web server hacking, web application hacking and database injection. I separated the content into three parts. This note is about web server hacking.

Part1: Web server hacking

Web server

常用的Web server有:IIS, Apache, Apache Tomcat, NginX
駭客要駭入Web server前要先收集Server的資訊,如果知道Web server是用哪種,就可以針對這種Web Server找尋相應的漏洞,有的放矢。
所以作為開發者,應該盡量隱藏Server資訊。

Invalid Web Server Settings

設定不當就有可能引狼入室。

🔸 Unlimited uri access control

資源uri列表:https://en.wikipedia.org/wiki/List_of_URI_schemes
因爲資源uri是公開定義的,如果Server對資源存取不加以限制的話,就很容易被竊取資料。

🔸 Unnecessary services

不必要的service不要開,開了多餘的service就是找自己麻煩,給駭客可乘之機。
For example, service like remote desktop connection should not be enabled in a production server.

🔸 Use default account & password

Never ever use the default username & password in a production server.
For example, google “tomcat default username and password” and you will get the info. below.

And you can find more in github.
https://github.com/netbiosX/Default-Credentials/blob/master/Apache-Tomcat-Default-Passwords.mdown

🔸 Redundant files

多餘的檔案不要放,不然 your trash is someone’s treasure.

🔸 Debug mode

Production server should disable the debug mode.

🔸 Unlimited file access rights

Web server要限定可以看到的副檔名。

🔸 Web server vulnerabilities

架構本身存在漏洞,比如老師提到 STRUTS是一款Apache中常用的CMS,但 STRUTS 漏洞實在太多,很容易被攻擊。

駭客常用手法

🔸 CRLF

🔸 Web Cache Deception (網頁快取攻擊)

網頁快取是ㄧ種用cache來減少伺服器延遲的常用作法。 網頁快取常常存放在靜態網頁中,e.g. html, png, css… Server對這些靜態網檔案管控通常不嚴,如果快取檔案中有帳密訊息就很容易被竊取。

案例:ChatGPT的WCD漏洞。
駭客發現ChatGPT會用網頁快取來存放使用者的authentication data而且沒有讀取限制,於是製造一個link: https://chat.openai.com/api/auth/session/demo.css 寄給受害者,這裡demo.css可以是任意名稱,受害者看到ChatGPT的域名通常不疑有他,點開後會看到自己的authentication data可能也沒什麼感覺, 但殊不知駭客也可以用同一個link得到受害者所有authentication data,並且可以用這些authentication data來登入帳戶。這個漏洞已被ChatGPT修補完成,大家可以放心點開demo link.

Find more details regarding the ChatGPT’s WCD in the link below. And you can google “ChatGPT account takeover” for more information.
https://medium.com/@diegotellaroli05/account-takeover-in-chatgpt-e134ed11654d
https://www.ithome.com.tw/news/156205

🔸 Server-Side Request Forgery (SSRF) (伺服器端請求偽造)

SSRF大全: https://github.com/jdonsec/AllThingsSSRF
要練習SSRF攻擊的話,可以參考 https://github.com/m6a-UdS/dvca 架一個環境。

SSRF攻擊種類繁多

🔸 Cross-Site Request Forgery (CSRF)

Difference between SSRF & CSRF from ChatGPT:

In summary, while SSRF involves exploiting a server-side vulnerability to make unauthorized requests, CSRF involves exploiting a client-side vulnerability to trick the user into making unauthorized requests.

推薦閱讀:https://blog.techbridge.cc/2017/02/25/csrf-introduction/

常用工具

工具本身沒有善惡之分,駭客手裡就是尋找漏洞駭入系統的利劍,資安手裡就是修補防護的盾牌。
之後有時間試用的話再補充心得。

🔸 owasp-zap

網頁漏洞掃瞄工具。
https://www.zaproxy.org

🔸 Openvas

主機漏洞掃瞄工具。
https://www.openvas.org

🔸 Burpsuite Pro

老師提到這個工具可以用來http封包攔截重送。
https://zh.wikipedia.org/zh-tw/Burp_suite
https://portswigger.net/burp/pro

🔸 Acunetix (付費工具)

網頁漏洞掃瞄工具。
https://www.acunetix.com

🔸 Nessus

非常有名的漏洞掃瞄工具。
https://www.tenable.com/products/nessus
價格有點高。

🔸 Nikto

Kali內建掃瞄工具。
https://www.kali.org/tools/nikto/

防禦方法

駭客手法千變萬化,駭客工具層出不窮。對於防守方而言,當然要不斷加固自己的堤防。道高一尺,魔高ㄧ丈,相信這是一場永無止境的攻防之戰。

The image below is from Teacher Alex Lin‘s class PPT