6.1 SEED Lab
3.1 Task 1: Copy that site!
attacker.html
attacker.css
把長寬設成最大值,然後 position 是 absolute 就好了。
Question:
- With the iframe inserted, what does the attacker’s website look like?
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 →
3.2 Task 2: Let’s Get Clickjacking!
修改成 transparent 就看不到了,然後調整一下 margin 。
Questions:
2. How does the appearance of the attacker’s site compare to that of the defender’s site?
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 →
3. What happens when you click on the “Explore Menu” button on the attacker’s site?
It will trigger "You Have Been Hacked!!"
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 →
4. Describe an attack scenario in which the style of clickjacking implemented for this Task leads to undesirable consequences for a victim user.
可能有人只是想要點擊 Explore Menu ,結果卻觸發另一個按鈕,而造成連結到其他的 malicious website 。
3.3 Task 3: Bust That Frame!
如果 top 不是自己,就會把 top 設定成自己。
Questions:
5. What happens when you navigate to the attacker’s site now?
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 →
雖然進入 http://www.cjlab-attacker.com 但會自動導到 http://www.cjlab.com/
6. What happens when you click the button?
就跟原本沒有 clijacking 一樣,不會發生被攻擊。
3.4 Task 4: Attacker Countermeasure (Bust the Buster)
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 →
allow-scripts:允許 defender 的 JS 執行(否則整個站會掛掉)
但是不包含 allow-top-navigation ,這樣就能阻止 defender 的 JS 嘗試跳出 iframe
7. What does the sandbox attribute do? Why does this prevent the frame buster from working?
它可以限制 iframe 裡面內容能做什麼(例如禁止彈出視窗、執行 JavaScript、改變父頁面等)。
8. What happens when you navigate to the attacker’s site after updating the iframe to use the sandbox attribute?
就變成原本的 attacker 的網站了,原本的 top 是否等於 self 的那個 script 就沒有用了
- What happens when you click the button on the attacker’s site?
就會導到 malicious website 了。
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 →
3.5 Task 5: The Ultimate Bust
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 →
Questions:
10. What is the X-Frame-Options HTTP header attribute, and why is it set to “DENY” to prevent the
attack?
完全不允許這頁被嵌入 iframe ,即使 attacker 加了 sandbox,瀏覽器會直接不顯示內容
- What is the Content-Security-Policy header attribute, and why is it set to “frame-ancestors ‘none’ ” to prevent the attack?
控制「誰可以當你的 iframe 父頁面」,它會指定誰可以用 <iframe>
, <frame>
, <object>
來載入你的網頁。
- What happens when you navigate to the attacker’s site after modifying each response header (one at a time)? What do you see when you click the button?
因為我們加入了 X-Frame-Options 和 CSP 的防護,現在我電腦的 firefox 直接不給我進去網站裡面了
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 →
6.2 SEED Lab
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 →
這是我們這題用到的 container 。
Task 1.A: Implement a Simple Kernel Module
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 →
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 →
Task 1.B: Implement a Simple Firewall Using Netfilter
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 →
1.
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 →
2.
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 →
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 →
我們可以直接送 ping 道 google.com
這是 drop 掉 ICMP


這是 drop 掉 Telnet


以下是 code
4.3 Task 2.A: Protecting the Router


- Yes, I can ping router
- No, I can't telnet into router
我們可以看到上面的指令讓我們可以 ping router ,但把 telnet 擋掉了。
4.4 Task 2.B: Protecting the Internal Network
按照下面去輸入:
-
Outside hosts cannot ping internal hosts.

可以看到我們沒辦法從外面 ping 到 internal hosts 。
-
Outside hosts can ping the router.

可以 ping router ip 。
-
Internal hosts can ping outside hosts.

我們在 192.168.60.6 container 裡面是可以 ping 到外面的
-
All other packets between the internal and external networks should be blocked.

這張是外部沒辦法送進來

這張是內部沒辦法送出去
可以看到其他的封包都必須被 block 住。
Task 2.C: Protecting Internal Servers


可以看到只能 telnet 192.168.60.5 ,但不能 telnet 192.168.60.6 和 192.168.60.7

可以看到可以對自己內部的 machine telnet ,但不能對外部的 telnet 。
Task 3.A: Experiment with the Connection Tracking
-
ICMP experiment:

ping 之前是沒有 connection tracking 的。

在 ping 的過程是有 connection tracking 的。

ping 結束的那個時刻也是有的。

但再過一陣子就沒有 connection tracking 了。
-
UDP experiment:

發送訊息前是沒有 connection tracking ,但發送之後就有了,但隔了大概 30 秒做左右又沒有 connection tracking 了。
-
TCP experiment:

TCP 比較有趣,還沒連線錢是沒有的,但是一旦建立連線就會有 connection tracking ,一直到結束過後一兩分鐘才會沒有 connection tracking ,如同老師上課說的,TCP 即使結束,它還要一點時間才能把狀態恢復,所以要等一段時間是正常的。
Task 3.B: Setting Up a Stateful Firewall


與 2.c 不同,現在我們是可以從裡面連出來的
Task 4: Limiting Network Traffic

在沒有第二行的情況下,我們傳送速率感覺上是沒有被限制的,還是很快

但加上第二行的時候,速度很明顯的被限制了,一開始還有點快,但後面就變緩慢了。
因為沒有第二條指令的時候不知道要怎麼處理超過限制的 packet ,就按照 default 的方式去傳。
有了第二條指令之後就將超過限制的 packet 丟掉了。
Task 5: Load Balancing
這裡是要做負載平衡
第一種是用均勻分配的機制

可以看到我們可以均勻的分配到 192.168.60.5, 192.168.60.6, 192.168.60.7 這幾個機器上面
我們只需要調整 --every <num>
以及最後的 destination 的 ip 就可以了。
第二種是機率分配的機制





可以看到就是靠機率去分配,我們要修改的就是 --probability P
後面的機率數值,以及 destination 要送到哪一個 ip 就可以了
我們就完成了
6.3 nftables
- Allow SSH connection from the WAN interface and redirect the packet
to some LAN computer.
建立 Docker 網路
建立 gateway container(兩張網卡)
進入 gateway container 的 shell
建立 LAN container(要被轉發過來的目標機器)
在 LAN container 裡安裝並啟動 SSH server
在 gateway container 裡設定 nftables
從 host 連線
會連到 LAN container!
2. Allow TCP dst port 80 and 8080 from the WAN interface.
測試 port 80 和 8080 是否成功被允許,可以在 LAN container 裡跑一個 HTTP server:
並在 host 上測試
-
Network Address Translation
-
Default: Drop all coming packets from the WAN interface.
6.4 Packet Filter through RAW Socket
進到 filter container
Raw Socket 的 code 。
命名成 packet_filter.c
因為 Raw socket 所以要用 root 跑
最後去做測試
6.5 libpcap
由於我家裡沒有乙太網路,我都是用電腦的無線網卡連接手機的個人熱點,所以我沒辦法使用 eth0 和 eth1 之類的乙太網路網卡界面。
因此若助教您要測試可能需要有無線網卡,我的無線網卡是
我會直接 assign 在我的程式裡面

上面是我的 output
要使用我的程式只需要
之後就可以成功攔截 DHCP 封包。
如果發現沒有攔截到任何封包,可以嘗試
這樣我們就完成這一題了