# 從攻擊到防禦:系統化學習網站安全與滲透測試的實戰思維 - 林子婷 (飛飛/Phoebe 菲比) {%hackmd @JSDC-tw/B1loEcwJZl %} ###### tags: `JSDC2025` :::warning 本議程不提供錄影 ::: Slido:https://app.sli.do/event/vhZCMLyA7wpp7P7MVz2rxr 回饋表單: https://forms.gle/STQBD5GjsMzsDuSq8 程式碼: https://github.com/fei3363/ithelp_web_security_2024 > 開始做筆記 講者林子婷/飛飛 主要在做滲透測試 ## 聲明 這次講座目標是提升學員資安的實力 不要做一些違法的事情 ## 從 HTTP Response 查看 `X-Power-By: Express` 從回應可以大概看出網站的基礎建設是什麼 但知道這是 nodejs 真的會改變什麼嗎? ### 攻擊者的視角 #### 滲透測試 利用惡意攻擊者的思維 針對應用程式、系統 進行測試並了解系統安全性 最後提供一份測試報告 #### Http Response 可知 Node.js 還有哪些? - `X-powered-By` - `connect.sid`, express 的慣例 沒有修改 cookie 名稱很有可能洩漏我們的架構是什麼 ## 完整錯誤訊息在前端 - 方便 Debug 但是忘記了 - 生態系痕跡 - (讓慣例留在我們的圈子就好) - Wappalyzer - 揭露使用套件 - Http req + res according 攻擊者知道是 node 之後會有影響嗎? 會,但沒想像大 - SQL Injection (如果用關聯式資料庫) - RDB - XSS(前端永遠是戰場) - Auth 認證與授權漏洞 - Sensitive information - SSRF # SQL Injection - 拼接 SQL 常出現 - 請求照片支援 - 例如繞過登入驗證 練習題會提供 API 內 - id=${id}, id = '' - 出現詳細的資料了 輸入 1 order by 1 基於第一個欄位去排序 輸入 1 order by 7 時出現錯誤訊息,就知道後端資料庫只有六個欄位 就可以用 union select 去查詢版本 ```sql= 0 union select null, version(), null, --- ``` ```sql= 0 union select * from information_schema.tables where table_schema='public' ``` 大象(PostgreSQL)的內部資料表 information_schema ```sql= string_agg ``` # XSS 直接輸出不轉譯 ```js= const { key word } = requ.query res.send(`your keyword ${keyword}`) ``` if `keyword == alert('document.cookies')` JWT Token - 轉譯工具是開放的 ... # Sensitive Data ```js= dq.query('select * from') ``` # SSRF ```js= await axios.get(req.query.url) ``` 知道內網 Domain 就可以將內網的東西 response 回來啦 額外測試項目 - Prototype Pollution - Event Loop - npm # Prototype Pollution Object.prototype merge ```js= { "__proto__": { "isAdmin": true } } ``` # SSTI 模板引擎語法 - 講者列出不同的語法 ```json= { "payload": "{{7*7}}" } // -> 49 ``` 請圖片支援 ```js {{: "pwnd" }} ``` # Node.js matter Know how to defent - Prototype Pollution - Type Coercion - `eval()` - npm dependencies - Typosquatting - 惡意語法 - .env, config - Vibe coding 會硬編碼 node.js Snyk -> multi languages Express - helmet - Content-Security-Polity - `app.disable('x-power-by')` - sessionId -> 改成 PHP 的 - express-validator - `safeObject = Object.create(null) ` - 黑名單不建議,容易被繞過 - npm audit - CVE 70% 漏洞與語言無關,但 20% 也很重要 ... OWASP 特定技術測試 30% SSDLC 視角 從開發階段就開始 > 聊天區 > 給自己太多方便,別人就會利用這些當隨便 --- {%hackmd @JSDC-tw/jsdc2025_sponsor %}
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.