Skip to content

Junner1st/ping-command-injection-lab

Repository files navigation

Ping Command Injection Lab

This lab provides isolated shell sessions under gVisor for practicing command injection vulnerabilities.

Prerequisites

Install required tools:

./install_requirements.sh

Ensure gVisor is installed:

curl -fsSL https://gvisor.dev/install | sh
which runsc

Pre-start Configuration

Configure containerd for gVisor

Edit /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl to include:

{{ template "base" . }}

[plugins."io.containerd.runtime.v1.linux"]
  shim_debug = true
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runsc]
  runtime_type = "io.containerd.runsc.v1"

Then:

sudo systemctl restart k3s

Set LAB_TOKEN in docker-compose.yml and environment

Generate a service account token:

kubectl create token lab-controller -n hackersir-lab --duration=8760h

Update docker-compose.yml with the new token in LAB_TOKEN environment variable.

Export in shell if needed:

export LAB_TOKEN="<token>"

Building and Importing Images

Build the session image:

docker build -t hackersir/session:latest .

Import to k3s:

docker save hackersir/session:latest | sudo k3s ctr images import -

Starting and Restarting

Start the lab:

./start.sh

Restart components:

docker compose restart controller

Stop:

./stop_all.sh

Troubleshooting

401 Unauthorized

Regenerate token and update docker-compose.yml:

kubectl create token lab-controller -n hackersir-lab --duration=8760h
# Update LAB_TOKEN in docker-compose.yml
docker compose restart controller

503 Service Unavailable / Pod Pending

Label the node for gVisor support:

kubectl get nodes --show-labels
kubectl label node <node-name> runtime.gvisor.dev/support=true

If ImagePullBackOff, rebuild and reimport image:

docker build -t hackersir/session:latest .
docker save hackersir/session:latest | sudo k3s ctr images import -

Other Issues

Check controller logs:

docker compose logs controller

Verify Kubernetes connectivity:

docker compose exec metrics-proxy kubectl get ns

Common kubectl Commands

View pods:

kubectl get pods -n hackersir-lab

View nodes:

kubectl get nodes --show-labels

Check pod details:

kubectl describe pod <pod-name> -n hackersir-lab

View logs:

kubectl logs <pod-name> -n hackersir-lab

About

A classic command injection lab that have an entry allows you to enter an address to ping.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published