Skip to content

Instantly share code, notes, and snippets.

@bannsec
Last active February 17, 2024 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bannsec/11c380b14193f78252854edea323ffbe to your computer and use it in GitHub Desktop.
Save bannsec/11c380b14193f78252854edea323ffbe to your computer and use it in GitHub Desktop.
Silly Docker Helpers
# Alias to automatically forward in relevant display stuff.
# docker-run -it --rm ubuntu:jammy
alias docker-run="sudo docker run -e DISPLAY=$DISPLAY -v ${XAUTHORITY:-~/.Xauthority}:/xauth:ro -v /tmp/.X11-unix/:/tmp/.X11-unix -e XAUTHORITY=/xauth"
# Bash function to help with running commands in the docker namespace
# docker-nsenter mycontainer -n ss
function docker-nsenter {
PID=`sudo docker inspect $1 -f '{{.State.Pid}}'`
shift
sudo nsenter -t $PID $@
}
# Restrict a running container so it cannot talk to internal ip space
# docker-restrict-container <container_name>
function docker-restrict-container {
docker-nsenter $1 -n iptables -I OUTPUT -d 10.0.0.0/8 -j DROP
docker-nsenter $1 -n iptables -I OUTPUT -d 172.16.0.0/12 -j DROP
docker-nsenter $1 -n iptables -I OUTPUT -d 192.168.0.0/16 -j DROP
docker-nsenter $1 -n iptables -I OUTPUT -p udp --dport 53 -j ACCEPT
}
# Ensure dockerd is running
# Try multiple things. Geared to work on wsl but should work elsewhere.
if ! ps aux | grep -q "[d]ockerd"; then
echo "Starting Docker"
if ! sudo systemctl 2>/dev/null; then
sudo /etc/init.d/docker start
else
sudo systemctl start docker
fi
fi

Step1: Run the container

docker-run  -it --cap-add=NET_ADMIN --cap-add=NET_RAW --device=/dev/net/tun --name htb parrotsec/core

Step2: Modify your htb vpn config to disable ipv6

proto udp4 
pull-filter ignore "ifconfig-ipv6"

Step3: Install and run openvpn

apt update; apt install -y openvpn
openvpn ./myconf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment