NCNU-OpenSource
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    # 111 LSA 期中考題 - 上機考 ###### tags: `lsa` - Book mode https://hackmd.io/@ncnu-opensource/book ## 規則 ![](https://i.imgur.com/hJueRO7.png) - 如有問題請舉手發問。 - 請勿編輯本頁面。 - 請勿以私訊或聊天室等任何方式彼此溝通。 - 當然也請不要直接實體溝通啦... 那算作弊哦 - 可以上網自由地找資料、補充這學期相對應的共筆頁面。 - 上機需要 DEMO,DEMO 時若助教發現答案錯誤,學生可以有一次修正機會。 :::warning 本次考試作答環境以 Ubuntu 20.04 為主 ::: **We Are Watching You.** ## 上機 53% + 12% ### web server(21%)+(7%) :::info **配分標準 (7%)** * 連線成功且網頁顯示無誤 (7%) * 連線成功但網頁顯示有誤 (4%) * 連線失敗、配置錯誤 (0%) ::: ![](https://i.imgur.com/FCGqrAK.png) - 使用 nginx 設定以下 domain name 使他們連到對應的網頁 - `s<學號>.lsa.lb` - `:80`:load balance - `s<學號>.lsa.proxy` - `:80`:proxy 到 `ammon.bluet.org` - `s<學號>.lsa.apache` - `:8071`:課程資訊 - `s<學號>.lsa.lighttpd` - `:8072`:老師資訊 - `s<學號>.lsa.lighttpd/~<username>` - `:8072/~<username>`:學生資訊 - apache (8071) - 連線 8071 port,會顯示課程資訊 ```html= <head> <meta charset='UTF-8'> <h2>本課程的</h2> <h2>中文名稱: (請填寫內容) </h2> <h2>英文名稱: (請填寫內容) </h2> <h2>英文縮寫: (請填寫內容) </h2> </head> ``` - lighttpd (8072) - 連線 8072 port,會顯示老師資訊 ```=html <head> <meta charset='UTF-8'> <h1>LSA 的老師</h1> <h2>中文名字:(請作答)</h2> <h2>英文全名:(請作答)</h2> <h2>常用 ID:(請作答)</h2> </head> ``` - [加分題] 在網址後加入 `/~<username>`,顯示學生資訊 :::info 啟動模組 ``` #enable lighttpd config sudo lighttpd-enable-mod Enable module: <userdir> ``` 模組名稱:<userdir> ```s= sudo service lighttpd force-reload ``` **記得看指令輸出的訊息** ::: ```html= <head> <meta charset='UTF-8'> <h1>學生資訊</h1> <h2>學號</h2> <h2>姓名</h2> </head> ``` ### iptables (14%) (在七點講解前可以先跳過) > [橋接網路卡問題](https://hackmd.io/8dPDrWxhS-el-BchF5G5HQ?view) > [virtualbox NAT 設置](https://hackmd.io/@chofinn/ry42_JHvo) - 開放 NAT 的 80 port,透過連到 NAT 80 port, 可以連到 webServer 的 80 port (3%) - 開放 NAT 的 2222 port,連到此可以 ssh 進 webServer (3%) - 禁止外部 ssh 進 NAT (3%) - webServer 到 NAT 的流量都允許 (3%) - 其餘進來的流量或轉發都禁止 (2%) ### 你的是我的,我的還是我的(3%) 先用 c 寫出以下程式,然後透過 gcc compile 出 `whoareyou`,之後把執行檔的權限設為只有擁有者可以讀寫執行,其餘人能讀能執行,然後任何人執行該程式的時候都是印出擁有者的 uid。 - `vim SUID.c` ```c----= #include <stdio.h> #include <unistd.h> int main() { printf("The uid is: %d\n", geteuid()); return 0; } ``` - `gcc SUID.c -o whoareyou` - `./whoareyou` ![](https://i.imgur.com/ClhiMmh.png) ![](https://i.imgur.com/vxeEaee.png) ### 自動記時 (5%) 請使用 `crontab` 與 `date` 每隔一分鐘將檔案 `time.txt` 的內容設為當下時間。 :::info >瘟腥提示: >兩個命令如何使用,可以透過 `man` 查閱[name=蓬萊人偶] ::: ### God is always true (3%) 這裡有一個 `god.py` 的內容 ```=py execute(617) ``` 執行命令 `python god.py` 後會有錯誤訊息 請問要下甚麼命令,才可以把錯誤訊息存到 `OK.txt`,然後不會顯示錯誤訊息在畫面上 ### 火車快飛 (3%) 在主機新建一個使用者 `train`,登入此使用者之後會直接自動執行印出火車的命令 (sl),執行結束後,就直接登出 ### 無限列車 (4%) ![](https://i.imgur.com/eZjEbjp.png =70%x) >[圖片來源](https://kimetsu-no-yaiba.fandom.com/zh/wiki/%E9%AD%98%E5%A4%A2) + 魘夢收到無慘命令要去殺死柱和炭治郎,請你修改某個檔案,讓之後新增的使用者,預設每次開 `terminal` 的時候都會自動跑小火車 (sl) ### (加分題)Memento mori (5%) :::danger **準備好作答之後,請先找助教交卷,然後立即做答此題** **本題作答之後視為交卷,不可再繼續作答,須離開考場** **請最後再做這一題** **本題請以虛擬機作答** ::: :::danger **準備好作答之後,請先找助教交卷,然後立即做答此題** **本題作答之後視為交卷,不可再繼續作答,須離開考場** **請最後再做這一題** **本題請以虛擬機作答** ::: :::danger **準備好作答之後,請先找助教交卷,然後立即做答此題** **本題作答之後視為交卷,不可再繼續作答,須離開考場** **請最後再做這一題** **本題請以虛擬機作答** ::: 在 Ubuntu 20.04 應該下甚麼命令清除電腦裡該系統的所有檔案?

    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