web application vulnerabilities 主要的exploitative behavious有以下 defacing websites stealing credit card information exploiting server-side scripting exploiting buffer overflows dns attack dos attack ddos attack employ malicious code 攻擊步驟 1 scanning 2 information gathering 3 testing 4 planning the attack 5 launching the attack web application threats常見有以下 cross-site scripting/xss flaws sql injectin command injection flaws cookie/session poisoning parameter/form tampering buffer overflow directory travesal/forceful browsing cryptographic interception cookie snooping authentication hijacking log tampering error message interception attack obfuscation platform exploits dmz protocol attacks security management exploits web services attacks zero-day attacks network access attacks tcp fragmentation
OSWAP提出的幾個常見弱點 SQL Injection XSS(Cross-Site Scripting) Insecure Direct Object References(不安全的物件參考) Security Misconfiguration (不當的安全組態設定) Sensitive Data Exposure (敏感資料暴露) CSRF(Cross Site Request Forgery,跨站冒名請求) Using Components with Known Vulnerabilities(使用已知漏洞元件) .................... XSS(cross-site scripting) flaws attacker uses a web application to send malicious code 在不安全的網站中植入惡意script 惡意script可能會用來取得帳號密碼,信用卡等機密資訊,或在client植入間諜程式 惡意script大部份是javascript,其他可能的還包括Java,VBScript,ActiveX,Flash,HTML,...etc XSS原理如下 在< script>< /script>中,放入script即可觸發XSS ex: < script > alert('XSS');< / script> 主要分兩種attack: stored attacks:the injected code is permanently stored on the target servers in a database reflected attack:the injected code takes another route to the victim,such as in an email message 目地:偷session cookie以取得權限,或執行javascript
流程大致如下 1 reflected attacks:將惡意網頁放入email寄出 stored attacks:透過表單植入網頁或url植入網頁中 ex:http://web.com/index.asp?name= < script > evilscript() < /script> 2 使用者開啟後自動執行惡意script ... CSRF(Cross Site Request Forgery) 惡意的HTTP指令被當成合法的指令來執行 流程 1攻擊者在有CSRF弱點的網站中插入一段惡意指令 2當使用者瀏覽器登入某些網站,也還未登出時 3瀏覽到有CSRF弱點的網站,觸發惡意指令 4由於使用者未登出網站,這些惡意程式利用使用者登入網站的身份執行惡意行為 ex: 惡意使用者在有CSRF弱點的留言版插入一段指令 ...omit< script>.../logout=1 < /script>...omit... 當已登入facebook的使用者看到有CSRF弱點的留言版時, 就會觸發logout指令,將使用者強迫登出 ps: CSRF 利用的是使用者對於瀏覽器的信任而達到攻擊目的 XSS 則是利用使用者對於網站本身的信任 refer http://mycck.blogspot.tw/2008/04/csrf.html countermeasures 1.validate all headers,cookies,query strings,form fields,hidden fields,...all parameters against a rigorous specification 2.adopt a stringent security policy 3.filtering script output can also defeat xss vulnerabilities
ps: beef:backtrack內建的tool,可用來實作XSS reference http://publish.it168.com/2007/0704/20070704004201.shtml http://security.ctocio.com.cn/wpsummary/436/8266436_2.shtml http://en.wikipedia.org/wiki/Cross-site_scripting
ps: javascript的URL偽協議 協議說明符加上任意的javascript代碼,當瀏覽器讀到這樣的URL時就會執行 ex:< img src="javascript:alert('XSS');"> 當img標記內有一個onerror()事件,且圖片沒有正常輸出便可觸發這個事件,事件中加入任意script也會執行 ex:< img src=" http://xss.jpg" onerror=alert('XSS')> ps: Attack用來躲避"javascript字串過濾"的方法 方法1,在javascript中加入多個tab鍵 ex: < IMG src="jav ascript:alert('XSS');" 方法2,在javascript中加入& # x 0 9編碼字符 ex:< IMG src="jav & # x 0 9 ; ascript:alert('XSS');" 方法3,在javascript中加入字符 ex:< IMG src="jav & # x 0 A ; ascript:alert('XSS');" 方法4,在 javascript中的每個字符間加入換行符 ex:< IMG src="j r n a r n v r n r nascript:alert('XSS');" 方法5,對"javascript:alert('XSS')"採用完全編碼 ex:< IMG src=& # x 6 A & # x 6 1 & # x 7 6 & # x 6 1 & # x 7 3 & # x 6 3 & # x 7 2 & # x 6 9 & # x 7 0 & # x 7 4 & # x 3 A & # x 6 1 & ...omit 方法6,使用10進制完全編碼或使用16進制完全編碼 ...
sql injectin sql injection uses sql query to directly manipulate the database
也稱資料隱碼攻擊, 攻擊者在輸入的字串中夾帶非法的SQL指令,就可讓資料庫誤認為是合法的SQL指令而執行 ps: SQL指令可取得資料庫管理權限,任意存取或刪除資料庫中資料,...等 ... command injection flaws relay the malicious code through a web application to another system 手法同 SQL Injection,但透過命令列之執行(如 cmd.asp),最終可取得主機管理權限 因管理權限喪失,駭客可經由此受駭主機向內部其餘系統進行攻擊與資料竊取 countermeasures 1.use language-specific libraries that avoid problems due to shell commands 2.validate the data provided to prevent any malicious content 3.structure requests so that all supplied parameters are treated as data,rather than potentialy executable content 4.j2ee environments allow the use of the java sandbox,which can prevent the execution of system commands
... Insecure Direct Object References 網站直接透過user的輸入來存取資源,這可讓攻擊者任意的存取重要檔案, ex: 程式碼有一段直接寫入到檔案 ...omit... echo writefile($_GET['file']); ...omit... 正常的情況下 http://xxxxx/report.php?file=2014report.txt 寫入到2014report.txt這個檔案 但惡意的使用會變成如下 http://xxxxx/report.php?file=index.html 寫入到index.html把首頁覆蓋? parameter/form tampering a simple form of attack aimed directly at the application's business logic takes advantage of the hidden fields that work as the only security measure in some application 駭客經由 Parameter 或 Form 輸入之參數變更,經由非正常方式取得資訊 客戶機密資料外洩、密碼遭竄改,並可取得更高權限之使用者帳戶 countermeasures field validity checking .. Security Misconfiguration
網站安全沒有設定好 常見的問題有以下幾種:
default password 預設帳密沒有刪除或更改,攻擊者可透過嘗試不同預設帳密的方式直接入侵
third-party example vulnerability 有許多套件的範例程式有漏洞,若沒刪除這些範例程式,攻擊者可透過範例程式的漏洞入侵
directory traversal/forceful browsing 未關閉Directory listing功能或瀏覽權限沒設好 攻擊者可找出所有網站上的檔案,或得到你的原始碼 countermeasure 設定存取權限,修補漏洞 error message interception 錯誤訊息直接回傳在使用者頁面上,使攻擊者得到額外的資訊 透過瀏覽器錯誤的回傳值,可得知系統的架構與版本等資訊,藉以蒐集相關弱點資訊 countermeasure website cloaking ... Using Components with Known Vulnerabilities 網站使用有問題的第三方的元件或函式庫 countermeasures 隨時關心third-party module的最新版本並時常更新 ... Sensitive Data Exposure 常見的有以下 敏感資料未加密就儲存 若網站的資料庫被入侵時,將會直接洩漏出每個人的敏感資料,像帳密...等 countermeasures 密碼須使用不可逆的演算法加密後再存在資料庫 cryptographic interception 網站在與使用者傳輸敏感資料時未使用SSL加密連線,導致傳輸有可能被攔截竊聽造成使用者的帳密被盜用 雖使用複雜的 SSL 加密,但駭客可透過檔案暫存時的疏忽取得未受保護的憑證資訊 客戶帳號、密碼與信用卡等機密外洩,並可計算出加密方式,竊取更多資訊 countermeasures 使用SSL安全連線來傳輸 ... cookie/session poisoning allows an attacker to inject the malicious content,modify the user's on-line experience,and obtain the unauthorized information 駭客透過修改 Cookie 或 Session 中數值,輾轉取得他人權限或機密資料 客戶機密資料外洩、密碼遭竄改,並可透過較高權限用戶進行其他攻擊行為 countermeasures 1.加密cookie 2.implement cookie's timeout 3.cookie's需綁ip ... cookie snooping 因 Cookie 常以簡單加密儲存於使用者端,駭客可透過破解其加密取得個人機密資訊 個人資訊遭竊取,任意刪除或變更使用者權限,並進行不合法交易 ps: 一般cookie編碼並非加密,會使用簡單的base64或rat13,要解回來十分容易 countermeasure 1.加密cookie 2.cookie綁ip 3.使用ssl
... authentication hijacking 駭客可經由不安全的憑證管理,取得合法使用者的權限 使用者權限遭竊取,任意變更刪除使用者資訊或密碼,並取得非法服務內容 countermeasure 1.使用secure channel 2.使用ssl ... buffer overflow the corrupt execution stack of a web application 以應用程式設計時之疏忽,使其出現緩衝區溢位錯誤,並同時執行非法程式 可於主機端直接建立最高管理權限,並植入間諜程式,進行擴散攻擊行為 countermeasure 1.validate input length in forms 2.using stackguard or stackshield ... attack obfuscation 將原本的攻擊使用url-encoding,unicode或utf-8編碼,或切塊在做其他改變特徵之類的動作...等,以避免被偵測到 駭客將攻擊的程式碼經偽裝傳送至應用程式端,以進行各種攻擊行為 可於系統上植入間諜程式,回傳各種機密資訊,並透過內部網路攻擊其他主機系統 countermeasures thoroughly inspect all traffic block or translate unicode,utf8,url-encoding to detect attacks ... tcp fragmentation 駭客將攻擊字串分散於傳輸之封包內,藉以躲避入侵防禦設備,進而攻擊系統 透過攻擊程式,可植入間諜程式或取得主機管理權限,並進而攻擊其他主機 將 pakcet切割成更小的fragment,並設定成push fragment要求設備立即處理而不是馬上重組,導致無法將此packet重組回來 an attack directly against a web server would specify that the "push" flag is set,which would force every packet into the web server's memory using tcp fragmentation can: avoid detection by surreptitiously delivering pieces of the attack directly into a web server slip the attacks directly past technologies that perform deep packet inspection countermeasure use packet filtering devices and firewall rules to thoroughly inspect the nature of the traffic directed at a web server ... log tampering 駭客透過變更連結記錄,誘使系統自動刪除或變更入侵的痕跡 連結記錄之變更,使系統管理員無法查詢或追蹤駭客攻擊的紀錄,更無法進行蒐證 attacker 攻擊完後,會修改或刪除log,或大量塞資料給log,導致管理者無法正常分析log countermeasure 使用數位簽章 ... security management exploits an exploit of security management can lead to the modification of protection policies 有經驗的駭客其目標可能於資訊安全的管理弱點,並企圖造成整體資安系統崩潰 資安系統崩潰,各駭客通行無阻,無限制變更各種資訊,植入任何程式,並於變更連結記錄後造成蒐證作業難度倍 關閉安全程式,讓管理者誤以為程式還在執行安全工作 ... platform exploits 駭客利用已知的應用系統弱點進行各種相對應的攻擊行為 透過系統已知漏洞,取得應用程式管理權限,造成資料洩密或植入其他間諜程式 常見的web application platform有 bea weblogic,coldfusion,ibm websphere,microsoft .net,sun java ... zero-day attacks 駭客利用應用程式或系統弱點撰寫攻擊程式,用以癱瘓企業網路或竊取重要資訊 攻擊發起時,將造成網路通訊極度延遲,並就攻擊程式不同,進行各式非法攻擊 countermeasures 1.一但發生時,關閉相關 services 2.enforce stringent security policies 3.deploy a firewall and enable heuristics scanning ps: no security solution can claim tat they will totally protect against all zero-day attacks ... dmz protocol attacks 駭客利用某應用系統環境中存在的通訊協定之已知弱點進行攻擊,取得重要系統之權限 應用程式系統受駭,擴散至一級防護區其餘主機,所有資訊遭竊,管理權限遭變更 dmz會連外部也會連內部,一但dmz被攻破,也會影響到內部 countermeasures deploy a robust security policy and sound auditing policy use signatures to detect and block well-known attacks ... web services attacks 駭客利用各種已知服務弱點進行攻擊,以取得管理權限或進行資料變更 藉以取得管理權限或植入非法程式,竊取本機資訊,並攻擊其餘應用程式伺服器 countermeasures shutdown unnecessary services ............................................... 攻擊tool:burp suite 功能: 含多種網路安全工具 可找出網站內所有連線 有網站弱點掃描 含網站攻擊功能 可攔截http request並更改 常見的有以下 burp:positioning palyload burp proxy:intercepting http/s traffic,可看曾經連過那邊 burpsuit: 其他攻擊tool有 instant source:edit web page code tool wget:一次檢查多個網頁很有效率 websleuth:看web page結構 blackwidow: 看web結構做分析 sitescope:看現在網路狀況 wsdigger:web services test,測試sql injection,xss cookiedigger:比對cookie ssl digger:分析ssl強度 windowbomb:hacking tool,視窗炸彈 curl:hacking tool,a multi-protocol transfer library 相關防護與掃描tool-OWASP提供 webgoat:可幫助學習web vulnerability webscarab:可截取一些資訊,可幫助學習 zap attack proxy:含scan,intercepting proxy,spider,...等,類似paros proxy 相關防護與掃描tool有 paros proxy:可截取並修改網頁內容 dotdefender:web application firewall acunetix web scanner:web vulnerability scanner appscan:web application scanner,made by ibm accessdiver:test tool falcove web vulnerability scanner: netbrute:可scan多主機,smb emsa web monitor:看web連線狀態 keepni:看網頁現在狀況 watchfire appscan:made by ibm webwatchbot:monitor tool ratproxy:audit tool mapper refer http://mmdays.com/2013/12/11/owasp_top_10/ 上課講義:面對企業Web化趨勢,如何蒙其利,避其害
|