Cybersecurity[4]
Command Injection & XSS
Claire
- 北資一六社長 x 網管
- 競程是舊愛 而且我很爛
- 新歡大概是資安
- 但我都只打水題
樹枝爆肝仔
Who am I

1
Command Injection
2
XSS
Index
Command Injection
Command Injection
-
後端程式會呼叫作業系統指令(shell command)
-
使用者輸入被拼到指令字串裡
-
攻擊者可以插入額外指令讓伺服器去執行
Command Injection
- 透過這個漏洞去執行伺服器的命令
- 遠端程式碼執行(Remote Code Execution)
- 我忘記我有沒有講過了 有的話我們回憶一下
- Command

Command Injection
- 透過這個漏洞去執行伺服器的命令
- 遠端程式碼執行(Remote Code Execution)
- 我忘記我有沒有講過了 有的話我們回憶一下
- 命令連接

Command Injection
- 一些可能會用到的指令

Command Injection
- 命令連接
- 在作業系統中執行命令可連續執行多個命令
- 常用的 Payload
Command Injection
- 網站網址:https://shop.com/status?productID=123&storeID=22
-
$ stock <productID> <storeID>可以看此商品是否有存貨
- 在 productID 打
& echo hahahaha & - & 可讓指令依序分開執行
- 結果
$ stock <productID> <storeID>Error - productID was not provided
aiwefwlguh
22: command not foundXSS
XSS
- Cross-Site Scripting
- 攻擊者能在別人的網站上執行 javascript 程式碼
- 流程:
- 駭客在受害網站注入 XSS
- 讓用戶接觸到 URL
- 用戶點擊 URL,把自己的資料藉由受害網站傳給駭客
Reflected XSS
- 請求中夾帶惡意語法或程式碼
- 將惡意程式會藏在網址
- 通常要用社交工程釣魚讓用戶點 URL
- 畢竟 URL 看起來很詭異
- 以短網址或 HTML Encoder 欺騙用戶
http://www.example.com/upload.asp?id=<script>alert(1);</script>DOM-Based XSS
- Document Object Model,文件物件模型
- 把一份 HTML 文件內的各個標籤都定義成物件
- 注入 "> 來提前結束原本屬性值,插入惡意的 HTML 標籤
- 利用 img 的 onerror 事件
<img src=# onerror=”alert(1)”><svg onload=alert(1)>Stored XSS
- 不需要使用社交工程釣魚
- 將 Javascript 儲存在伺服器的資料庫
- ex. 注入留言板,用戶瀏覽網頁時會載入留言板的 Javascript 進而使用戶受到攻擊
留言欄位:我是壞人! <script>alert(1);</script>Labs
- https://portswigger.net/web-security/os-command-injection/lab-simple
- https://portswigger.net/web-security/cross-site-scripting/reflected/lab-html-context-nothing-encoded
-
https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-document-write-sink
- https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-innerhtml-sink
- https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-document-write-sink-inside-select-element
- https://portswigger.net/web-security/cross-site-scripting/stored/lab-html-context-nothing-encoded
Practice
Thank You!

Cybersecurity[4]
By Claire Pan
Cybersecurity[4]
- 20