laiyuchi
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 網頁安全.jpg ### 網站思維 **假設想偷東西?** 觀察 - 網站架構 - 基礎是否有更新? - 版本+POC - 網站功能 - 功能漏洞? - 攔截封包 - 網站防禦設備 - 設備否繞過? --- **先了解網站->再了解安全** ### 職涯發展 - ![](https://i.imgur.com/dUyy12S.png) ### 弱點 - ![](https://i.imgur.com/XtO9sS4.png) ### LAB - https://lab.feifei.tw/practice/warm/l1.php - 答案 - Repeater - CVE-2020-10385 - CVE-2016-1240 ### 瀏覽器原理 瀏覽器>request請求封包>伺服器>response取得封包(循環) **構建封包給伺服器,交由伺服器回應,也顯示網頁資訊** - [Mozilla Firefox](https://mozilla.org)(很方便有很多內建工具) - [Microsoft Edge](https://www.microsoft.com/zh-tw/edge)(被譽為微軟的翻身之作 ~~(雖然本身跟chrome差不多~~ ) - [Google Chrome](https://www.google.com/intl/zh-TW/chrome/)(記憶體怪獸) - [Opera](https://www.opera.com/) - [Brave](https://brave.com/)(自由且開原始碼) - [DuckDuckGo](https://duckduckgo.com/)(標榜使用者隱私) 新版EDGE很好用\( ̄︶ ̄*\)) ## 網頁組成 1. HTML 2. HTTP 3. URL | 前端 |後端 | | :----: | :----: | | 瀏覽器(client) | 伺服器(server) | | 電腦可見 |背後邏輯 | | cross-site scripting |injection | | HTML/CSS/javaScript | Node.js/PHP/Python | ### 前端 - 靜態網站練習 - https://fei3363.github.io/WebSecurityCourse/static/external.html - https://github.com/fei3363/WebSecurityCourse/blob/main/static/index.html - html - 網頁骨架 - CSS 做為網頁的動態,或顏色美觀等 通常會包在html的style標籤裡面 也可以利用檔案的模式引入html ```css= <style> h1 { color: blue; } <style> ``` - JS 也可以利用檔案的模式引入html 或利用script的標籤 ```javascript= <script> windows.alert('hello world') </script> ``` 程式語言+DOM+BOM 文件物件描述 瀏覽器物件模型 ### 後端 ##### 把自己電腦當伺服器 - 軟體 - XAMPP(不安全) - Apache - Nginx - IIS(聽說政府機關常用(?? - 合法滲透(行政院國家資通安全網路攻防演練) - 參加台灣好厲駭 --> 攻擊手遴選 --> 合法滲透政府 - https://isip.moe.edu.tw/wordpress/?p=2201 - 行政院國家資通安全會報技術服務中心 主辦 - 攻擊手遴選 - 合法滲透 --> 會去 台北/台南 #### PHP 歷史悠久 漏洞多 管理伺服器(回應封包 重新導向等) [laravel:超好用的免費PHP框架](https://laravel.com/) ```php= <?php echo "Hello world" ?> ``` #### 資料庫 *DBMS資料庫管理系統* ```sql= SELECT * FROM TABLE WHERE username = 123; ``` ##### SQL injection 注入某些東西,改變資料庫等 EX:在密碼填入欄位等,加入特殊的符號等 ```sql -- 我想知道 金額,日期、時間 來自姊姊的豬公 SELECT money,date,reason FROM moneypig where who='sister' --我想知道目前我有多少錢 SELECT SUM(money) FROM myDB.moneypig where who='sister' --經典的解法 ' or '1'='1' --(直接加在密碼欄位 ``` 或是加入 Java Script **[UNION攻擊](https://ithelp.ithome.com.tw/articles/10240102)** --- ## 網頁的溝通方式 **協定(Protocol)** * HTTP * TCP/IP ### HTTP https : 更安全的http 由瀏覽器建構封包 **無狀態協定** - 不保存狀態,不紀錄內容 所以才會有cookie 跟 Session #### 封包 可以透過開發者工具(F12)的網路功能(network)來錄製 **HTTP GET** 1.傳送請求 ``` GET /flag.html HTTP/1.1 ``` 傳送請求(參數) ``` GET /flag.php?para=123 HTTP/1.1 方法 路徑 版本 ``` 2.回應回傳 ()的部分是解釋 ``` HTTP/1.1 200 OK (版本 狀態) Date: Mon, 27 Jul 2009 12:28:53 GMT(日期) Server: Apache/2.2.14 (Win32)(服務版本) Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT(項目最後修改時間) Content-Length: 88(內容的大小) Content-Type: text/html(內容類型) Connection: Closeds(連線後的處理模式 EX:keep-alive ) (文件內容) <html> <body> <h1>Hello, World!</h1> </body> </html> ``` #### cookie 儲存使用者資料,因為http是無狀態通訊協定 換句話來講,可以間接的代表一個人的帳號or身分 因為伺服器只會認識妳各位的cookie 標頭裡面放入set-cookie 會有 * 名稱 * 值 * 時間 * 參數 開發者工具中的應用程式可以到cookie (EDGE截圖)![](https://i.imgur.com/OrtxBww.png) --- ### TCP 可靠的傳輸協定(類似的有UDP但是他不可考) ~~(拯救不少研究生的主題(破壞不少人學分的東東~~ #### 確保封包成功送達 三方交握(三次握手)three way handshake ![](https://i.imgur.com/yCXZUUB.png) --- ### DNS sever 網域名稱系統 **Domain Name System** 將域名跟IP做對應 #### 如何找到IP?? Google Public DNS: 8.8.8.8/8.8.4.4(IPv4) 2001:4860:4860::8888/2001:4860:4860::8844(IPv6) 打開你的CMD ![](https://i.imgur.com/CIAkeJ8.png) nslookup -> 透過域名找到IP位置的指令 ![](https://i.imgur.com/8SmbWX3.png) 其他常用的CMD指令(順便補充XD * ping * tracert * ipconfig --- ### lab - https://lab.feifei.tw/practice/basic/network.php - 答案 - 協定 - HTTP - 應用層 - 封裝 - ARP - 三方交握 - DNS - 139.162.81.48 - https://lab.feifei.tw/practice/basic/en_decode.php - 答案 - : - ? - \# - %20 - %E7%B7%A8%E7%A2%BC - root:password - admin:youGotIt - FEIFEI - https://lab.feifei.tw/practice/basic/http.php - 版本 - CRLF - Host - Content-Type - Content-Length - POST - Set-Cookie - 瀏覽器 ### curl 可以模仿瀏覽器送封包給伺服器,可以直接在CMD中使用,也能透過firefox達成類似的操作 預設方法是採用GET,用-X可以指定方法 - 利用指令模擬瀏覽器請求伺服器的工具 - answer - lab1 - curl 預設是 get - `curl https://lab.feifei.tw/practice/basic/curl/get.php` - lab2 - 題目要求用 POST + 參數 - -X 可以指定 POST - --data 指定參數內容 - `curl -v -X POST --data "data=good" https://lab.feifei.tw/practice/basic/curl/post.php` - lab3 - 題目說要查看 Set-Cookie - Set-Cookie 會放在回應封包的標頭 - -i 可以看回應封包 - `curl -i https://lab.feifei.tw/practice/basic/curl/getcookie.php` - lab4 - 題目說要指定 Cookie - -b 可以指定 Cookie - 你也可以於瀏覽器指定 - application > storge > cookie > add - `curl -b "flag=givemeflag" u8https://lab.feifei.tw/practice/basic/curl/sendcookie.php` - lab5 - OPTIONE 內容會在 Header 中 - -X 指定 Method - -i 看 Header - `curl -X "OPTIONS" -i https://lab.feifei.tw/practice/basic/curl/options.php` - `curl -X "MEOW" -i https://lab.feifei.tw/practice/basic/curl/options.php` - lab6 - curl 預設不會轉跳 - `curl -v https://lab.feifei.tw/practice/basic/curl/location.php` ### burpsiute ![](https://i.imgur.com/uINjLG0.png) ![](https://i.imgur.com/X7CIV4k.png) ![](https://i.imgur.com/liBzdsK.png) ![](https://i.imgur.com/bQ5KFwr.png) - Proxy - Forward - 攔截的封包送回去瀏覽器 - Drop - 攔截到的封包不要了 - Intercept is on - 開啟攔截封包的模式 - Action - 把攔截到封包丟到你想丟的功能 - Open Browser - 開啟內建的瀏覽器 #### 練習用 burpsiute 解 lab - repeater - 可以重送封包的功能 - ![](https://i.imgur.com/Cae4Nk5.png) - 點 HTTP - ![](https://i.imgur.com/E5tboYp.png) - ![](https://i.imgur.com/yedbgI3.png) - - lab1 ```htt GET /practice/basic/curl/get.php HTTP/1.1 Host: lab.feifei.tw ``` ![](https://i.imgur.com/CA59xwV.png) - Content-Type: application/x-www-form-urlencoded ```htt POST /practice/basic/curl/post.php HTTP/1.1 Host: lab.feifei.tw Content-Type: application/x-www-form-urlencoded Content-Length: 9 data=good ``` ![](https://i.imgur.com/ZesMKMw.png) - Get cookie ```htt GET /practice/basic/curl/getcookie.php HTTP/1.1 Host: lab.feifei.tw ``` ![](https://i.imgur.com/v7R8pOh.png) - send cookie ```htt GET /practice/basic/curl/sendcookie.php HTTP/1.1 Host: lab.feifei.tw Cookie: flag=givemeflag ``` ![](https://i.imgur.com/t9hsG4M.png) - OPTIONS ```htt OPTIONS /practice/basic/curl/options.php HTTP/1.1 Host: lab.feifei.tw ``` ![](https://i.imgur.com/UfMQtwN.png) ```htt MEOW /practice/basic/curl/options.php HTTP/1.1 Host: lab.feifei.tw ``` ![](https://i.imgur.com/pwDNmWl.png) - location ```htt GET /practice/basic/curl/location.php HTTP/1.1 Host: lab.feifei.tw ``` ![](https://i.imgur.com/V8HOlGY.png) - 爆破密碼 - ![](https://i.imgur.com/OqSVKlE.png) 1. 攔截登入封包 2. 丟到 intruder 3. 設定爆破類型(Cluster bomb) 4. 設定要爆破地方(帳號、密碼) 5. 設定帳號密碼字典檔 6. 開始爆破 --- ### 被動攻擊 常見的案例 1. 是你?!?!? * 騙你的帳號密碼 * 透過網址檢查是真的還是假的登入頁面 2. 你得獎了 * 騙你的個人資料 * 然後一直把你往下騙 3. 下載防毒軟體 * 透過假的下載連結或騙你下載惡意軟體 * 透過你的User-Agent知道你是用甚麼裝置 --- ### IDOR 尋找一些在網站裡面隱藏的資料 EX:有隱藏的圖片或資料等 攻擊我們能列入參數的地方 [現在我有冰淇淋](https://zeroday.hitcon.org/vulnerability/ZD-2020-01252) ### CTF - SQL injection ' union select 'admin' , 'password' # password 1 and 1=2 union SELECT 1,2,group_concat(schema_name) FROM information_schema.schemata # information_schema,myDb 1 and 1=2 union SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema='myDb' # ctfnews,secret 1 and 1=2 union SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_name='secret' # id,THIS_IS_FLAG 1 and 1=2 union SELECT 1,2,THIS_IS_FLAG FROM myDb.secret # # WEB入門 ## 資安倫理 資安是甚麼? 資訊(的)安全嗎??病毒??駭客?? 妨礙電腦使用罪(刑法第二編第三十六章) 主要:密碼學,系統安全,資訊攻防 BUT 注意法律安全 這些教學皆為理論,但如何使用皆須注意法律問題(白帽、黑帽) ## IF YOU WANT TO *HACK* SOMETHING ?? 如果你覺得有技術卻無處發揮 則: BUG BOUNTY PROGRAMS; [CTFtime](www.ctftime.org) 網路攻防練習手(2017~)(三月底,四月初) ## 網站漏洞原理 ### 假設想偷東西? 網站架構怎麼組成的 -- 基礎建設是否有更新 有多少功能可以使用 -- 功能是否有漏洞漏洞 網站是否有防禦設備 -- 設備是否可繞過 ### 瀏覽器原理 瀏覽器>請求封包>伺服器>取得封包(循環) ### 網頁組成 | 前端 |後端 | | :----: | :----: | | 瀏覽器(client) | 伺服器(server) | | 電腦可見 |背後邏輯 | | cross-site scripting |injection | | HTML/CSS/javaScript | Node.js/PHP/Python | #### 前端技術--CSS ```css= h1 { color: blue; } ``` #### 前端技術--Javascript - Javascript=**DOM**(文件物件模型)+**BOM**(瀏覽器物件模型)+**PL** - 可跟HTML、瀏覽器作互動 #### 前端技術--Static Webpage - 可利用[Github page](https://pages.github.com) - console : javascript #### 後端技術--PHP - 歷史悠久 - 漏洞多 ```php= <?php echo "Hello world" ?> ``` #### 後端技術--資料庫 ```sql= SELECT * FROM TABLE WHERE username = 123; ``` #### 本機技術 伺器軟體--Apache,Nginx,IIS 資料儲存--Database, Cache, File Storage 執行環境--作業系統,雲端環境,容器 #### 瀏覽器 **構建封包給伺服器,交由伺服器回應,也顯示網頁資訊** - [Mozilla Firefox](https://mozilla.org) - [Microsoft Edge](https://www.microsoft.com/zh-tw/edge) - [Google Chrome](https://www.google.com/intl/zh-TW/chrome/) - [Opera](https://www.opera.com/) - [Brave](https://brave.com/) - [DuckDuckGo](https://duckduckgo.com/) ##### 協定 TCP/IP: - 應用層 - 傳輸層 - 網路層 - 連接層 ![](https://i.imgur.com/R04S87Y.png) ### 溝通方式 > 你知道hackmd可以聊天嗎 ``` http:// >> feifei.tw >> :80 >> /study.php >> ?books=brother >> #top 協定 >> >> port ``` #### URL編碼 ``` %20 = " " ``` #### HTTP GET 1.傳送請求 ``` GET /flag.html HTTP/1.1 ``` 傳送請求(參數) ``` GET /flag.php?para=123 HTTP/1.1 ``` 2.回應回傳 ``` HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT Content-Length: 88 Content-Type: text/html Connection: Closeds <html> <body> <h1>Hello, World!</h1> </body> </html> ``` #### HTTP POST ``` POST /flag.php HTTP/1.1 --- header -- username=123&password=qwerty ``` #### Other (http1.1) | Method | 說明 | | :--:|:--:| | get | 取得資料 | | post | 提交指定資源 | | head | 取得標頭(沒有資料) | | options | 取得資源溝通方法 | | put | 取代指定資源 | | delete | 刪除指定資源 | | connect | 和指定資源標明的私服器之間建立隧道 | #### HTTP 狀態碼 | 類別 | 常見 | | :---: | :---: | | 1xx - 資訊回應 | 100 Continue 101 Switching Protocol | | 2xx - 成功回應 | 200 OK | | 3xx - 重定向 | 300 Reirects | | 4xx - 用戶端錯誤 | 401 Unauthoized 403 For Biden 404 Not Found | | 418 - I'm a teapot | The server refuses the attempt to brew coffee with a teapot. | | 5xx - 伺服器錯誤 | 500 Internal Server Error | #### HTTP Cookie **用來記得使用者的資料** - 登入後,伺服器回傳並設置cookie的值 - 再次訪問使用者的請求內會有cookie - 這時候伺服器就透過cookie來對應是哪個使用者 ``` Set-Cookie: FLAG=value ``` **cookie名稱、值、有效期限、其他參數** #### 請求工具 ```bash curl <target URL> ``` #### 攻擊方法 - 主動攻擊 - 直接攻擊脆弱網站 - 植入後門 (EX:[CCU中國文學系](https://zeroday.hitcon.org/vulnerability/search)) - 弱點(未開啟字串偵測): | 動作 | 作法 | | :---: | :---: | | 跟**資料庫**互動 | SQL injection | | 跟**系統**互動 | Command injection | | 跟**信件**互動 | Header injection | | 跟**檔案**互動 | Local File inclusion | | 跟**頁面**互動 | Cross Site Scripting(XSS) | | 跟**後端**互動 | IDOR | ##### SQL injection ```sql -- 我想知道 金額,日期、時間 來自姊姊的豬公 SELECT money,date,reason FROM moneypig where who='sister' --我想知道目前我有多少錢 SELECT SUM(money) FROM myDB.moneypig where who='sister' --以前的萬用解 ' or '1'='1' -- ``` - 被動攻擊 - 釣魚(Phishing) - Session Hijacking - Cross-site request forgery

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully