Docker Images
Quick Docker Setup
The fastest way to setup docker is via the following script.
curl -sSL https://get.docker.com/ | sh
This script automatically downloads and sets up Docker for use on your computer. You can then check if it's installed correctly by doing:
docker run hello-world
This will test if everything was installed correctly by fetching an image and running it. You can then check containers running with:
docker ps -a
Holy Build Box
Compiling on Linux is awkward and there's a lot of problems. Compiling on a modern machine for an older one is difficult there might be some ways to overcome it like statically linking but it just generally causes more issues. There is one way around this. Either setting up a really old machine for compiling or an easier way and quicker way is by using the Holy Build Box.
Afterwards install Holy Grail Box. Holy Grail Box is separated into two versions. For x86 and x86-64 binaries.
docker run phusion/holy-build-box-32
docker run phusion/holy-build-box-64
docker run -t -i --rm phusion/holy-build-box-64:latest bash
Holy Build Box is a container that mimics a CentOS 5 distribution, since it is so old compiling
inside this should let us run binaries on a wide amount of distributions. In order to compile
binaries; first make a new directory using "mkdir" and any docker command given inside that directory
will use that directory as the working directory for compiling files. Before starting to compile be sure
to put whatever c file you wish to use in that directory. There are two ways to compile.
For 32-Bit, the line linux32
is needed before bash
:
docker run -t -i --rm \
-v `pwd`:/io \
phusion/holy-build-box-32:latest \
/hbb_exe/activate-exec \
linux32 bash -x -c 'gcc $CFLAGS /io/hello.c -o /io/hello $LDFLAGS'
For 64-Bit just take off the linux32
option:
docker run -t -i --rm \
-v `pwd`:/io \
phusion/holy-build-box-64:latest \
/hbb_exe/activate-exec \
bash -x -c 'gcc $CFLAGS /io/hello.c -o /io/hello $LDFLAGS'
If you would like to run the container and inspect it. The following will start it up with bash. You can then use it like any other linux distribution.
docker run -t -i --rm phusion/holy-build-box-64:latest bash
However, by itself the environment will show that it doesn't have any tools like GCC or glib and other
libraries. Using the which gcc
command will show that it is not included. However, you can fix this by
running the following script.
/hbb_exe/activate-exe
Kali Linux Docker
Sometimes using a VM can be a hassle espeically if you have an underpowered machine. A good alternative is docker. You can easily setup a kali docker image and start working right from the terminal.
docker pull kalilinux/kali-linux-docker
docker run -it kalilinux/kali-linux-docker /bin/bash
# We update and search for Kali Metapackages
apt-get update && apt search kali-linux
#In this case I install the full kali, which is around 15GB.
apt install kali-linux-all
#I also install this to make life easier when searching for binaries.
apt install mlocate
exit
#Now we need to make a new image
docker commit <CONTAINER ID> myKaliDocker
#View Docker Images
docker images
#To run your new Docker image, the --rm option deletes the container after exit.
#If you want persistence you can run it without the option
docker run -it myKaliDocker
docker run --rm -it myKaliDocker
#Alternatively to run it with host interfaces attached
docker run -it --net=host myKaliDocker /bin/bash
Docker saves changes to each container made as long as you don't delete the container or use the --rm
option. To exit and stop a container just type exit
. To start a stopped container do the following:
docker start -ai <CONTAINER ID>
Every container that is started anew starts off clean. So if you made important changes be sure to commit a new image or just keep running the same container.