Making a Boot2root machine with docker
Last updated
Was this helpful?
Last updated
Was this helpful?
I've been trying to learn about Docker recently and experiment with it and I thought what would be a better way to test my basics than to make a dockerized boot2root machine, so here we are.
The boot2root machine we'll be implementing is a very simple one
The first thing to do would be install docker which you can install from and then pull an Ubuntu latest image from docker to work with.
Following the above you'll be inside the docker image with root privileges. One thing you should remember is that this is image is stripped of everything nothing is installed from the start. You have to install the basic needed tools and ones you're gonna use for boot2root manually including sudo
Now you have to manually start all the services that you'll be using in this machine which are FTP and SSH
Now we have to configure the ports for ftp and ssh to allow traffic through them,
Without setting the root directory for the ftp it'll just show empty when you connect to it.
We need to make a ftpuser
and also make a directory in /var
for the ftp server and give it appropriate permissions.
We also need to edit the vsftpd.conf
file to allow anon login and also set the root directory.
Now just add a file with user creds you wanna give for ssh or any other hint
At the end you have to restart the service for the changes to take place
These commands make a backup copy of our config, and gives it permissions so that it cant be tampered with and restarts the service with all the implemented changes.
Make lower privilege user for the user flag
For privilege escalation I thought of letting the user run cat
and ls
meaning he can list and read the files in the root directory.
To do this we have to edit the sudoers file, run the below command as root
and add the following to your user
add your root flag to root.txt in the /root
directory and then we just have add appropriate permissions to the user and root flags and we are good to go
Don't forget to restart all the services before doing the sanity check
Do a sanity check to see if everything you restarted and updated is working perfectly. We need to get the ip-address of the container to test it out. We can do this by
After you get the ip you can do your checks with the ftp server and ssh with the accounts you created. If everything is working fine we can move on to commit the image and push it to docker hub.
After all this the one thing we need to do is make your docker container available to the whole world wide web. To do this we have to commit your docker container.
Exit your container after making all the changes and testing it.
Use the above command to get the container-id of the container you just exited.
You can now check your new image using
you'll be prompted to enter the access token. Now to upload on to docker hub you need to tag it and then push it.
The docker-compose file for this image is very simple
you just need to run the below command in the same directory as the file for the container to be up and running
If you make any changes to to .yaml
file make sure to take the container down before running it again
Hope you learnt something about docker or about configuring boot2root machines, If you're interested check out my other blogs too.
To upload this onto docker hub, you first need to make an account on . Click on your profile image and go to account settings. Click on Security in the left navigation and add New Access Token. Copy your access token and back in your terminal do the following