軟體弱點掃描
TRANSCRIPT
軟體開發測試實務研習-軟體弱點掃描報告人:亂馬客日 期: 2015/08/07Docs : https://doc.co/fDKqw8
2
Agenda Why Tools 常見問題
SQL Injection Cross Site Scripting(XSS) Misconfiguration Hash Insecure direct object reference
3
WHY?
4
SonyPicture.com
Over 1,000,000 users’s personal information, Including passwords, email, home address, …..
5
Yahoo奇摩緊急修補搜便利網站SQL Injection漏洞
6
8
Tools
9
人肉搜索 - Wireshark
10
人肉搜索 - Fiddler
11
開發工具 -VS.NET
12
開發工具 -VS.NET
13
白箱工具 - Checkmarx
14
黑箱工具 - AppScan
15
白名單 ? 請帖
16
黑名單 ? 通緝令
17
常見問題 SQL Injection Cross Site Scripting(XSS) Misconfiguration Hash Insecure direct object reference
18
SQLInjectio
n
19
SQL Injection 體驗 http://goo.gl/53RTpt
點選任一個分類 將值改成 3 ( 有 22 筆資料 )
?ProductSubCategoryId=3 再將值改成 3 or 0 = 0 ( 有 504 筆資料 )
?ProductSubCategoryId=3 or 0=0
20
SQL Injection 體驗 -2 將值改成 r
?ProductSubCategoryId=r
21
SQL Injection 體驗 -3 Blind 攻擊 找出 Table Name
?ProductSubCategoryId=(SELECT name FROM sysobjects WHERE id = (SELECT TOP 1 id FROM (SELECT TOP 1 id FROM sysobjects WHERE xtype=CHAR(85) ORDER BY id) sq ORDER BY id desc))
改成 2, 3 ….
22
SQL Injection 體驗 -4 Blind 攻擊 找出 Column Name
?ProductSubCategoryId=(SELECT COL_NAME((SELECT TOP 1 id FROM (SELECT TOP 3 id FROM sysobjects WHERE xtype=CHAR(85) ORDER BY id) sq ORDER BY id desc), 3) )
23
SQL Injection 體驗 -5 取得 信用卡號 (Table:CreditCard, Column:
CardNumber) ?ProductSubCategoryId=(SELECT TOP 1
CardNumber FROM dbo.CreditCard )
24
SQL Injection 體驗 -7 字串的也可以哦 !
點選「 Search 」 輸入 a ,可以查出 a 開頭的產品 輸入 a’or 1=1 -- ,就可以查出所有的產品
常使用在 Login 的畫面
25
SQL injection
http://tdd-2012-1/injection/Product.aspx?ProductSubCategoryId = 1
SELECT * FROM Product WHERE ProductSubCategoryID = 1
Trusted
Untrusted
26
Source of untrusted data From the user
URL via a query string or route Posted via a form
From the browser Cookies Request headers
From other locations External services database
27
Approaches to whitelisting Type conversion
Int, date, GUID … Regular expression
Email, phone Know good values
Countries, Products …
28
解法 Type conversion & 參數化
29
XSS
30
XSS 體驗 Reflected XSS http://goo.gl/XqBbly
輸入 lager
再輸入 <i>lager</i> 可以發現 斜體字了。
31
XSS 體驗 -2 Persistent XSS
輸入 ch
輸入 RM
32
Persistent XSS 除了取 cookie 外 也有可能導到惡意的網坫
33
如何寫 MySpace 的 XSS
34
那些內容需要 Encode 呢 ? CSS HTML HTML attribute HTML form URL JavaScript LDAP distinguished name LDAP filter URL URL path XML XML attribute
35
針對不同的內容 Encode <i>Lager</i>
Context Encoded stringHTML <I>Lager</I>JavaScript \x3ci\x3eLager\x3c\x2fi\x3eCSS \00003Ci\00003ELager\0003C\00002Fi\00003E
36
Anti-Cross Site Scripting Library Encoding Method Should Be Used If … Example/PatternHtmlEncode Untrusted input is used in HTML output except when
assigning to an HTML attribute.<a href="http://www.contoso.com">Click Here [Untrusted input]</a>
HtmlAttributeEncode Untrusted input is used as an HTML attribute <hr noshade size=[Untrusted input]>
JavaScriptEncode Untrusted input is used within a JavaScript context <script type="text/javascript">…[Untrusted input]…</script>
UrlEncode Untrusted input is used in a URL (such as a value in a querystring)
<a href="http://search.msn.com/results.aspx?q=[Untrusted-input]">Click Here!</a>
VisualBasicScriptEncode Untrusted input is used within a Visual Basic Script context
<script type="text/vbscript" language="vbscript">…[Untrusted input]…</script>
XmlEncode Untrusted input is used in XML output, except when assigning to an XML attribute
<xml_tag>[Untrusted input]</xml_tag>
XmlAttributeEncode Untrusted input is used as an XML attribute <xml_tag attribute=[Untrusted input]>Some Text</xml_tag>
37
Misconfiguration
38
Misconfig 體驗 http://goo.gl/PABY47
點 Widgets 修改 url
CategoryId=x
39
Misconfig 體驗 -2 Int64 ?
將值改成 3000000000 ?CategoryId=3000000000
40
帳號 / 密碼…全都… ..
41
Misconfig 體驗 -3 misconfig/trace.axd
點 /Widgets.aspx 那個詳細資料 機敏資料 Cookies 實體路徑 LOCAL_ADDR IIS 版本
42
Misconfig 體驗 -4Elmah( 錯誤記錄模組 )
在 google 中輸入 inurl:elmah.axd "error log for“ inurl:elmah.axd aspxauth
43
設定 Config For ASP.NET
For Elmah
<customErrors mode=“RemoteOnly” redirectMode=“ResponseRewrite defaultRedirect=“~/Error.aspx” />
<trace enabled=“true”localOnly=“true”/>
44
Hash
45
46
存放密碼的方式 純文字 加解密 Hash Salted Hash
48
加 Salt
49
Insecure direct object
reference
50
Insecure direct object reference體驗 在 google 上輸入以下的資料
filetype:rtf | filetype:ppt | filetype:pptx | filetype:csv | filetype:xls | filetype:xlsx | filetype:docx | filetype:doc | filetype:pdf " 機密資料禁止 " site:gov.tw
51
Insecure direct object reference體驗 - 2 http://goo.gl/T25ibb
rm/111111 (rm 登入,密碼 6 個 1) 按下 F12 錄網路 按下 View
52
Insecure direct object reference體驗 - 3 點選那個 link
輸入 林志玲
53
要加以限制
54
Google 找名單
55
Q&A