Try   HackMD

NTU CSIE NASA 2024 HW0

NTNU 41047033S 洪軾凱

Network Administration

1. True/False (28 points)

  1. True
  2. False
  3. False
  4. True
  5. False
  6. False
  7. True

解釋:

  1. 因為 VPN 會將網路流量重新導向,使得封包看似來自 VPN 服務的伺服器。
  2. 如果設定 Port Forwarding,可以允許外部裝置通過特定 port 和內網 server 溝通。
  3. Gateway 也可以用軟體實作,也可以用來連接 LAN 和 WAN
  4. 因為是 http,沒有加密的網路協定,所以確實能很容易知道我傳的內容
  5. 沒有 NAT 的話,私有 IP 的裝置無法與外網通信;沒有 DNS,則無法將域名解析為 IP 地址。
  6. DDoS 是透過大量的請求癱瘓服務,可能可以透過流量分析和過濾解決(?
  7. 較長的密鑰意味著更多的可能密鑰組合,從而增加了破解的難度,通常來說是對的。但量子計算可能會打破這件事情,但暫且不談

2. ChatGPT (12 points)

  1. False
    • 無法保證任意兩台裝置的 MAC 都不一樣
    • MAC spoofing 可以竄改 MAC
  2. 不全面
    • 4G 是第四代移動通信技術的縮寫
    • 傳輸速度和頻率不是 4G 完整的定義
  3. 不完全正確
    • 正確:IPv4 使用 32 位元來表示地址,可用的 IPv4 地址正在枯竭
    • 若有新的裝置要聯網「不」一定需要使用新推出的 IPv6
    • IPv4 和 IPv6 目前並存中(地址重用、NAT 等方法實現)

3. Short Answer (35 points)

名詞解釋

(a) DHCP (Dynamic Host Configuration Protocol)

DHCP 是一種網絡協議,用於自動分配 IP 地址給網絡中的裝置,從而允許這些裝置加入網絡並進行通信。它還可以配置裝置的子網掩碼、預設網關、DNS 伺服器地址等。這使得網絡管理員不需要手動為每一台裝置配置網絡設置,簡化了網絡管理。

(b) VLAN (Virtual Local Area Network)

VLAN 是一種技術,允許將一個物理網絡分割成多個虛擬網絡,使得不同 VLAN 中的裝置即使在同一物理網絡上也無法直接通信,除非透過路由。這樣做可以提高網絡的安全性和效率,因為它可以將網絡流量和用戶群組隔離開來,便於管理和降低廣播域。

(c) Switch

Switch(交換機)是一種網絡連接裝置,用於連接多台網絡裝置,如電腦、打印機等,並在它們之間轉發數據。它可以根據數據包中的 MAC 地址信息,決定如何將數據有效地從一個裝置轉發到另一個裝置。與樞紐(Hub)相比,交換機能夠減少數據包碰撞,提高網絡效率。

(d) Broadcast storm

Broadcast storm(廣播風暴)是網絡上的一種現象,當過多的廣播消息同時在網絡上傳輸時,會消耗大量的網絡資源,導致網絡擁堵甚至網絡癱瘓。廣播風暴通常發生在樞紐或交換機配置不當時,例如,當多個裝置不斷地發送廣播請求,而這些請求又被不斷地複製和轉發給網絡上的所有裝置時。

合法 IP Address

  1. True, 未指定地址
  2. True, IPv6 回送地址
  3. True, IPv6 有效位址

TCP/IP model

應用層(Application Layer)

  • 功能:為應用軟體提供網絡服務,如文件傳輸、電子郵件和文件服務。
  • 例子:HTTP(網頁瀏覽)、SMTP(發送電子郵件)、FTP(文件傳輸)。

傳輸層(Transport Layer)

  • 功能:提供兩個系統間的數據傳輸服務,確保數據正確地從源頭到達目的地。
  • 例子:TCP(提供連接導向、可靠的數據傳輸)、UDP(提供無連接、最大努力傳送的服務)。

網際網路層(Internet Layer)

  • 功能:負責數據包的路由和轉發,確保數據包能夠跨越不同網絡傳輸到達目的地。
  • 例子:IP(定義數據包的地址和路由方式)、ICMP(用於傳送控制消息,如錯誤報告)。

資料鏈結層(Data Link Layer)

  • 功能:負責網路實體間的數據傳輸和錯誤檢查。
  • 例子:乙太網(Ethernet)中的 MAC 地址實現。

物理層(Physical Layer)

  • 功能:定義物理設備如何傳輸數據。
  • 例子:電纜、光纖、無線電波等物理傳輸媒介。

TCP/UDP

(a) TCP (Transmission Control Protocol)

TCP 是一種連線導向的協議,確保兩個網絡端點(例如,電腦、伺服器)之間可靠的、順序的和無錯誤的數據交換。它通過使用確認機制、序列號和重傳機制來實現這一點。TCP 用於需要高可靠性的應用,例如網頁、電子郵件和檔案傳輸。

(b) UDP (User Datagram Protocol)

UDP 是一種無連線的協議,提供了一種快速的數據傳輸服務,但不保證數據的順序、可靠性或完整性。UDP 不進行 handshake,因此它的延遲比 TCP 小。這種協議適用於不需要或可以自己處理錯誤恢復的 App,如各種串流。

(c) 比較優缺點和使用場景舉例

特性 / 協議 TCP UDP
可靠性 高(確保數據完整傳輸) 低(不保證數據完整傳輸)
順序保證 有(數據按發送順序到達) 無(數據可能亂序到達)
連線導向 是(需要建立連線) 否(無需建立連線)
延遲 較高(因連線建立和確認過程) 較低(直接發送數據)
頻寬消耗 較高(由於 Header 資訊和來回確認) 較低(Header 小)
擁塞控制 有(動態調整資料傳輸速率) 無(可能導致網絡擁塞而不自知)
適用場景 需要高可靠性的應用(如HTTP) 需要低延遲的應用(如視頻會議)

協定介紹

(a) LDAP (Lightweight Directory Access Protocol) / LDAPS (LDAP over SSL)

  • 用途:LDAP 是一種用於訪問和維護分佈式目錄信息服務的協定,常用於組織內的用戶和資源的管理。LDAPS 是透過 SSL 加密的 LDAP,提供更安全的數據傳輸。
  • 預設 port:LDAP 使用 389,LDAPS 使用 636。

(b) SMTP (Simple Mail Transfer Protocol)

  • 用途:SMTP 是一種用於傳送電子郵件的協定,主要用於電子郵件伺服器之間的郵件傳送以及電子郵件客戶端到伺服器的郵件提交。
  • 預設 port:25(傳統)、587(用於客戶端到伺服器的提交,支持加密)。

(c) SNMP (Simple Network Management Protocol)

  • 用途:SNMP 是用於管理和監控網絡設備(如路由器、交換機、伺服器、工作站等)的協定,允許從中央位置收集網絡設備的信息。
  • 預設 port:161(用於 SNMP 查詢),162(用於 SNMP traps,即警報通知)。

(d) HTTP (Hypertext Transfer Protocol) / HTTPS (HTTP Secure)

  • 用途:HTTP 是用於從伺服器傳輸超文本到本地瀏覽器的協定,是網絡上資料交換的基礎。HTTPS 是透過 SSL/TLS 加密的 HTTP,提供加密和安全的網絡數據傳輸。
  • 預設 port:HTTP 使用 80,HTTPS 使用 443。

4. Command Line Utilities (25 points)

IP address / domain name

nslookup www.ntu.edu.tw
nslookup csie.ntu.edu.tw
nslookup 140.112.30.25
nslookup 140.112.161.176

NT(N)U VPN

因為我不是台大學生,查了下規範沒辦法申請 NTU VPN,所以容我嘗試一次 NTNU VPN 以及師大資工的網域 ><

(a) IP Address

140.122.20.178

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 →

(b) domain name request

  1. DNS server IP

連線前 192.168.50.1

> nslookup csie.ntnu.edu.tw

Server:		192.168.50.1
Address:	192.168.50.1#53

Non-authoritative answer:
Name:	csie.ntnu.edu.tw
Address: 140.122.185.1

連線後 140.122.65.9

> nslookup csie.ntnu.edu.tw

Server:		140.122.65.9
Address:	140.122.65.9#53

Non-authoritative answer:
Name:	csie.ntnu.edu.tw
Address: 140.122.185.1
  1. routing path

連線前:

> traceroute 192.168.50.1
traceroute to 192.168.50.1 (192.168.50.1), 64 hops max, 52 byte packets
 1  rt-ax86u-a788 (192.168.50.1)  2.937 ms  3.644 ms  2.227 ms

連線後:中間有四台機器,詳見下方

> traceroute 140.122.185.1
traceroute to 140.122.185.1 (140.122.185.1), 64 hops max, 52 byte packets
 1  140.122.7.21 (140.122.7.21)  10.524 ms  5.146 ms  4.385 ms
 2  140.122.7.17 (140.122.7.17)  4.658 ms  7.013 ms  4.767 ms
 3  140.122.128.2 (140.122.128.2)  5.758 ms  5.334 ms  7.369 ms
 4  140.122.134.2 (140.122.134.2)  7.382 ms  9.692 ms  7.220 ms

140.112.30.158

  1. 只有一個 18763/tcp
  2. NASA{P4-3_Y0u_Found_M3!}
> nmap -p- 140.112.30.158
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-21 20:44 CST
Nmap scan report for 140.112.30.158
Host is up (0.011s latency).
Not shown: 65534 closed tcp ports (conn-refused)
PORT      STATE SERVICE
18763/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 105.86 seconds
~
> telnet 140.112.30.158 18763
Trying 140.112.30.158...
Connected to 140.112.30.158.
Escape character is '^]'.
NASA{P4-3_Y0u_Found_M3!}
Connection closed by foreign host.
~

System Administration - I want to join NASA!!!

1. Super Auto Penguin! (8 pts)

NASA{P1_I_4m_r00t!}

進到最高管理員權限

[nasa-intern@tux-penguin ~]$ sudo su
[sudo] password for nasa-intern:
[root@tux-penguin nasa-intern]# ./p1-checker
Wow, you ARE the super user! Here is an important message:
NASA{P1_I_4m_r00t!}

Screenshot 2024-02-21 at 20.01.27

2. Read the manual plz (8 pts)

NASA{P2_P4CM4N_1$_TH3_M4N}

照標題說的,問問辣個男人 (man)

$ man pacman

DESCRIPTION
       Pacman is a package management utility that tracks installed packages on a Linux system. It features dependency support, package groups, install and uninstall
       scripts, and the ability to sync your local machine with a remote repository to automatically upgrade packages. Pacman packages are a zipped tar format.
       NASA{P2_P4CM4N_1$_TH3_M4N}    
...

3. Telepathy (8 pts)

  1. 更新已安裝的 openssh
  2. 設定 VirtualBox portwarding
    • 參考資料
    • 注意 Host port 設定 22 會被撞到,可以試著用 2222
  3. 在本機環境 ssh 到機器

Screenshot 2024-02-21 at 11.36.51

4. Sudden Airdrop? (8 pts)

NASA{P4_Matryoshka_Files}

  1. unzip 解壓縮
  2. tar 解壓縮
    • 檔案也太多 好可怕
[root@tux-penguin nasa-intern]# cd airdrop
[root@tux-penguin airdrop]# cd p4/
[root@tux-penguin p4]# cat flag
NASA{P4_Matryoshka_Files}

5. Shifting Identity (8 pts)

NASA{P5_Th3_5PY_1s_Am0nG_U5}

  1. 編輯 /etc/hostname/etc/hosts 改成
  2. 記得重開機
  3. sudo usermod -c "Definitely Legit Guy" root
[root@totally-not-tux p5]# ./security
Mission accomplished! Here is your flag:
NASA{P5_Th3_5PY_1s_Am0nG_U5}

6. DIY Friendship (8 pts)

NASA{P6_W3_4r3_fri3nd5_n0t_f00d}

  1. sudo groupadd friends
  2. sudo useradd -m -G friends coolguy
  3. sudo usermod -aG friends root
[root@totally-not-tux p6]# ./friendship-test
Mission accomplished! Here is your flag:
NASA{P6_W3_4r3_fri3nd5_n0t_f00d}

7. Access Denied (8 pts)

NASA{P7_I5_th1s_TH3_h0m3w0rk_f0ld3er?}

  1. 開一個權限 710 的資料夾
  2. 把執行檔案丟進去並執行拿到 Flag
    • 其實不清楚原因,仍然搞不懂,只是亂試成功的
[nasa-intern@totally-not-tux p7]$ mkdir -m 710 hide
[nasa-intern@totally-not-tux p7]$ cp pentester hide/
[nasa-intern@totally-not-tux p7]$ cd hide/
[nasa-intern@totally-not-tux hide]$ ./pentester
Mission accomplished! Here is your flag:
NASA{P7_I5_th1s_TH3_h0m3w0rk_f0ld3er?}

8. Careless Cool Cat Commentator (8 pts)

NASA{P8_echo "Hello there!" | cowsay -f dragon-and-cow}
NASA{P8_echo "My name is MSI RTX 4090" | cowsay -f dragon-and-cow | lolcat}

Screenshot 2024-02-21 at 22.46.22

Discussed w/ 鍾詠傑

9. Novice Cryptographer (8 pts)

NASA{P9_I_Prefer_Arch}

  1. sed 把 gentoo 拿掉
  2. tr 換掉 table
  3. grep 找到 Flag
[nasa-intern@totally-not-tux p9]$ sed 's/gentoo//g' book | tr 'aFS9PoUYXyQEvDfc7bVqW5hg)s18NeziB6xt0(RJjumM{Zkw3d4CGnT}rOLKH2lpAI' 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789(){}' > book2
[nasa-intern@totally-not-tux p9]$ cat book3 | grep NASA{
 The gentoos ... until the gentoo chick NASA{P9_I_Prefer_Arch}hatches. By then, the chick is consuming around 1800 ml O2 per day.

10. Directory Maze (8 pts)

NASA{P10_D0_Y0U_F1ND_DA_W43}

find 找,直接看範例

[nasa-intern@totally-not-tux maze]$ find . -type f | grep 'NASA{'
./W/A/E/NASA{P10_D0_Y0U_F1ND_DA_W43}

11. Loop de Loop (10 pts)

  • NASA{P11_1_d1d_y0u_g3t_th3_51gn4l?}
  • NASA{P11_2_1_wi1l_b3_b4ck}
  • NASA{P11_kill -9}
  1. control+Z 來 suspend 程式
[nasa-intern@totally-not-tux p11]$ ./loop
I have occupied your terminal. Try to kill me, I dare you!
^Z
[2]+  Stopped                 ./loop
[nasa-intern@totally-not-tux p11]$ bg
[2]+ ./loop &
[nasa-intern@totally-not-tux p11]$ You suspended me, but I'm back!
But I will show some mercy and give you flag 1:
NASA{P11_1_d1d_y0u_g3t_th3_51gn4l?}
  1. kill
[nasa-intern@totally-not-tux p11]$ kill 1373
I'm not going to terminate that easily!
But I will show some mercy and give you flag 2:
NASA{P11_2_1_wi1l_b3_b4ck}
  1. SIGKILL 訊號強制停止程式 (kill -9)
[nasa-intern@totally-not-tux p11]$ kill -9 1373
[1]   Killed                  ./loop
[nasa-intern@totally-not-tux p11]$

reference

12. The Final Showdown (10 pts)

  1. unalias 暫時去掉
$ unalias vim 
$ unalias emacs
  1. /etc/cron.d/minute 的 Script 註解掉
    # */1 * * * * root /usr/src/nano_gang/check.sh
  2. 重開機
  3. .bashrcalias 改掉

Screenshot 2024-02-21 at 19.33.20

vim 才是真理

  1. 安裝 emacs(不知為何,裡面沒有安裝 emacs)
$ sudo pacman -Syu
$ sudo pacman -S emacs

我離不開 emacs 救命

https://chat.openai.com/share/59efd771-dee1-4071-a86c-caba2ed0c733
https://chat.openai.com/share/2176b99c-ef7f-47c7-9cb3-e75c8a530f19
https://chat.openai.com/share/14d4d932-795e-4aba-9188-88418b6a0611