1101 LSA 期中上機考解答版
期中上機考解答版,不包含 Web Server
A. 檔案權限設定 4%
1. 請在家目錄底下建一個檔案名稱為 1101LSA_學號
,並依照以下條件設定存取權限 (2%)
- 擁有者可以 「 讀、寫、執行 」
- 跟擁有者同一群組的可以 「 讀、執行 」
- 其他人只能 「執行 」
- 無論任何人在執行當下都會自動被變身為「此檔案擁有者」的身份和權限
解答
- 建立檔案名稱為
1101LSA_學號
- 設定檔案權限
2. 檔案執行時會顯示以下內容: (2%)
解答
- 檔案內容
- 測試執行
B. Forward Agent 4%
開啟並設定 Forward Agent 功能,使私鑰在 firewall 上進行轉送,不需要透過帳號密碼才能連進 internal zone 和 DMZ
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
解答
- 到本地端主機的 /etc/ssh 底下,將 ssh_config 檔案裡 ForwardAgent 設為
yes
- 到遠端端主機的 /etc/ssh 底下,確認 sshd_config 檔案裡 AllowAgentForwarding 為
yes
- 將金鑰加入 authentication agent
- 若私鑰檔名為 default key 時,則不須接私鑰路徑
C. iptables 20%
MOLi 大學的阿明近期想針對學校資安部分做加強
想要先幫學生們過濾封包抵擋攻擊
並保護防火牆,只留需要的功能其餘皆不准進來
便委託小美幫忙架設,
阿明針對防火牆要夠酷提了幾點要求:
題目沒講的不能做到
EX: internal zone 不能 ping DMZ 的設備
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- internal zone 的所有要去外網的封包會經由 firewall 送出去 (3%)
- 在 firewall 開 port 80 (public network) 導向 DMZ 中的 web-server 的 80 port,並且 web-server 要能夠知道使用者的 IP (3%)
- DMZ 可以透過 firewall 向 lsa.kija.io 建立 http 連線 (3%)
- 准許外網 ssh 連線至 firewall (3%)
- internal zone 中的 student 可以透過 private IP ssh 連線至 DMZ 中的 web-server,並且 web-server 要能夠知道使用者的 IP (3%)
- 所有對外的 DNS request 皆會被 firewall 導向 1.1.1.1 (3%)
- (WARRING) INPUT, FORWARD chain 預設的 policy 為 DROP (2%)
只要不符合以上要求,就是個不夠酷的防火牆
各位小美們,請幫忙小明實作個防火牆
檢驗方式(可能不只用以下方式檢驗)
通用:看 iptables 的規則
1 會也只會透過 firewall 向外網發出封包(ex: ping 8.8.8.8)
2 在學校開起瀏覽器,打上 firewall 的 ip 可成功顯示網頁
4 從學校網路任意電腦可 ssh 至 firewall
5 看相關設定
6 tcpdump
en5 外網
en6 internal
en7 dmz
解答
- internal zone 的所有要去外網的封包會經由 firewall 送出去 (3%)
- 在 firewall 開 port 80 (public network) 導向 DMZ 中的 web-server 的 80 port,並且 web-server 要能夠知道使用者的 IP (3%)
- DMZ 可以透過 firewall 向 lsa.kija.io 建立 http 連線 (3%)
- 准許外網 ssh 連線至 firewall (3%)
- internal zone 中的 student 可以透過 private IP ssh 連線至 DMZ 中的 web-server,並且 web-server 要能夠知道使用者的 IP (3%)
- 所有對外的 DNS request 皆會被 firewall 導向 1.1.1.1 (3%)
- (WARRING) INPUT, FORWARD chain 預設的 policy 為 DROP (2%)
D. Web Server 28% (可以分次 DEMO)
不提供解答,請自行實作
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
由於 web server 需架在 DMZ 上,DMZ 需要完成 iptables 的第四條指令才能連進 web server
如果不知道如何設定 iptables 第三、四題的指令,可以跟助教索取答案,但總分會扣 8 分
以下 service 需架在 DMZ 中的 web server 上
E. [加分題] 火車快飛 5%
做不出來夠酷的防火牆,至少做個有點酷的火車吧
- 在 firewall 主機新建一個使用者
train
,登入此使用者之後會直接自動執行印出火車的指令,執行結束後,就直接登出
解答
- 安裝 sl
- 新增使用者 train
- 找出 sl 指令的位置
- 編輯 /etc/passwd ,更改使用者登入後使用的 script ( 將後面 /bin/bash 改成 /games/sl )
- 就可以測試啦!