aFish
    • 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
    • Invite by email
      Invitee

      This note has no invitees

    • 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
    • Note Insights
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
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
  • Invite by email
    Invitee

    This note has no invitees

  • 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
    4/12 LSA (http2,CTF) === # 混雜模式 (promiscuous mode) [wiki](https://zh.wikipedia.org/wiki/%E6%B7%B7%E6%9D%82%E6%A8%A1%E5%BC%8F) 混雜模式是網路卡的一種模式,開啟後可以接收全部經過此網路卡的封包(預設關閉,關閉狀態下只會接收給自己的封包) 使用`ifconfig`可以查看網路卡資訊(`< 這裡面是模式 >`) ![](https://i.imgur.com/ThhUJFi.png) > ifconfig 網卡名稱 promisc  開啟混雜模式 > ifconfig 網卡名稱 -promisc 關閉混雜模式 # HTTP2 ### Version - HTTP/1.0 (第一版 1999年問世) - HTTP/1.1 (第二版 修正了一些缺點 沿用至今) - HTTP/2 (2015年5月正式發表) ### Compare - 1.0 每次請求都要建立TCP連線,完成後馬上斷開TCP連線。 假如一個網頁中有多個圖片,則要分別建立好幾次TCP連線來載入圖片。 缺點 : 需要建立多個生命短暫的TCP連線 ***demo*** telnet - 1.1 改善1.0的缺點,支援持久連線。 一個網頁如果有多張圖片(多項內容)則不需要重複建立TCP連線,但是單獨的網頁則還是需要建立新的TCP連線。 1.1版本允許client不用等待上一次請求結果返回,就可以發出下一個請求。server端則是用請求順序來分辨每一次接受到的請求,避免混淆。此舉降低了client等待時間。 ***demo*** keep-alive - 2.0 一個TCP連線就可以下載好所有資源 二進位的封包讓伺服器更快解析資料(與1.1一樣將TCP連線分為好幾個Stream,每一個Stream中可以傳若干個Message,然後每個Message由多個二進位的Frame組成) 使用HPACK演算法壓縮Header 一定要有TLS/SSL憑證(http2本身沒要求,瀏覽器有要求) 解決對頭阻塞 ([HOL blocking](https://zh.wikipedia.org/zh-tw/%E9%98%9F%E5%A4%B4%E9%98%BB%E5%A1%9E)) websocket 閱讀:[更快更安全: 每個網站都應該升級到 HTTP/2](https://ihower.tw/blog/archives/8489) :::info [http2 test](http://www.http2demo.io/) 3-Way Handshaking ![handshark](https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/38/03/metablogapi/2021.080613_0416_SSLHandshak2.png) ::: # apache 三種模式 設定檔 `httpd.conf` prefork MPM - 古老 - 穩定 process vs thread Apache啟動前先fork子程序,等待requests。每一個子程序只有只有一個thread,同時間內只能處理一個請求。 子程序佔用系統資源,多個requests時會被放進queue中,等到有空閒子程序時才被處理。 ``` <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxRequestWorkers 250 MaxConnectionsPerChild 0 </IfModule> ``` worker MPM 也會預先fork子程序,但是數量較少,是一種thread跟子程序混用的模式。server收到requests會分配到一個thread(thread比程序更輕量,因為跟父程序共用記憶體),但是一個thread如果掛了,其他正常運作的thread也會一起掛掉。 所以要thread跟子程序共用才不會導致一個thread掛掉服務完全中斷,而是一部分服務中斷。 如果是keep-alive的連接方式,thread會一直被佔用,即使沒有新的requests進來。 ``` <IfModule mpm_worker_module&gt; StartServers 3 MinSpareThreads 75 MaxSpareThreads 250 ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0 </IfModule&gt; ``` event MPM 最新模式,跟worker模式很像,但是解決了keep-alive會佔用thread的缺點。event模式多使用了一個thread來管理keep-alive類型的thread,等待有請求進來的時候才將keep-alive的thread佔用,沒有請求的時候則釋放。 ``` <IfModule mpm_event_module> StartServers 3 MinSpareThreads 75 MaxSpareThreads 250 ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0 </IfModule> ``` 優缺點 [參考文章](http://blog.jobbole.com/91920/?utm_source=hao.jobbole.com&utm_medium=relatedArticle) # CTF write up # SUID/SGID/SBIT ## Set UID - SUID 權限僅對二進位程式有效; - 執行者對於該程式需要具有 x 的可執行權限; - 本權限僅在執行該程式的過程中有效; - 執行者將具有該程式擁有者的權限。 ## Set GID 用在檔案上 - SGID 對二進位程式有用; - 程式執行者對於該程式來說,需具備 x 的權限; - 執行者在執行的過程中將會獲得該程式群組的支援! 用在資料夾 - 使用者若對於此目錄具有 r 與 x 的權限時,該使用者能夠進入此目錄; - 使用者在此目錄下的有效群組(effective group)將會變成該目錄的群組; - 用途:若使用者在此目錄下具有 w 的權限(可以新建檔案),則使用者所建立的新檔案,該新檔案的群組與此目錄的群組相同。 ## Set Bit - 當使用者對於此目錄具有 w, x 權限,亦即具有寫入的權限時; - 當使用者在該目錄下建立檔案或目錄時,僅有自己與 root 才有權力刪除該檔案 [參考連結](http://linux.vbird.org/linux_basic/0220filemanager.php#suid_set) # Capabilities Linux Kernel 2.2 之後才有 - 將 root 權限細分爲各種領域 - 在進行特權操作時會先檢查 euid 是否爲 root,再檢查是否有所需功能之 capabilities 範例: CAP_CHOWN 0 允許改變檔的所有權 CAP_NET_RAW 13 允許使用原始(raw)套接字 CAP_SYS_PTRACE 19 允許跟蹤任何進程 [參考](http://rk700.github.io/2016/10/26/linux-capabilities/)

    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