Lab_07 - Hacking From the Inside
Lab 7: Hacking From the Inside
1. Pod Breakout
Let's try creating a pod with the "privileged" attribute on the master node.
Hint
Make Pod Privileged:
Hint
Run Pod in specific k8s node:
Hint
Use the following kubectl command to determine the node hostnames:
Solution
breakout_pod.yaml:
Note: Replace <CURRENT_NODE>
with the hostname of the desired node.
Apply it using kubectl and see it it started successfully:
The pod did not start successfully in the master node, how can we fix it?
Hint
https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
Solution
Taint master node to allow running pods:
Delete and reapply the breakout pod:
The pod is started. Let's exec into it and break out of it to get "root" on the master node.
Hint
Solution
Start interactive alpine shell in the pod:
Use mount to determine that "/proc" is mounted as "rw" and the "upperdir" location of the overlay file system location:
Write the exploit file "exploit.sh":
local access exploit payload:
remote reverse shell payload:
Note: Replace <Attacker_IP>
with a valid IP.
Trigger exploit:
Note: Replace <NUMBER>
with a valid overlay number.
2. Network Spoofing
Let's create a pod with the "hostNetwork" attribute.
Hint
Set "hostNetwork" Pod:
Solution
network_pod.yaml:
Use kubectl apply:
Let's exec into the pod and install our tools to passively capture network trafic.
Hint
The ip and tcpdump tools will help!
Solution
Exec into the pod:
Install Tools:
Inspect network interfaces:
Capture network traffic on the localhost interface and write it to a file:
Inspect traffic and grep for a specific string:
Execute the following curl command from the jumphost in order to see that it is captured by tcpdump:
3. Node DoS
Let's create a "privileged" pod with the "hostPID" attribute.
Hint
Set "hostPID" Pod:
Solution
dos_pod.yaml:
Use kubectl apply:
Let's exec into the pod and try different actions such as:
listing all processes
killing processes
Hint
The ps and kill commands will help!
Solution
Exec into the pod:
List all processes on the node (all node processes and the processes of other pods on the node):
Start a process (e.g. vi very_important_file
) on the respective node in another terminal and kill it from inside the pod:
4. Automated Tools - trivy
Let's see what could be identified with a automated scanning tool like "trivy".
Hint
https://github.com/aquasecurity/trivy
Solution
Get and run trivy:
Last updated