A CTF (Capture The Flag) Boot To Root (B2R) is a type of cybersecurity challenge where participants are tasked with gaining unauthorized access to a computer system (the "Boot" part) and then obtaining and eventually capturing a specific flag or set of flags (the "Root" part). The flags could be strings of text, files, or other data that prove the participant has successfully compromised the system.
In these challenges, participants typically start with minimal information about the target system and have to use various techniques, including vulnerability analysis, exploitation, privilege escalation, and more, to gain access and ultimately root access to the system. The challenges often simulate real-world scenarios and are designed to test participants' skills in penetration testing, exploit development, reverse engineering, and other cybersecurity domains. They can be hosted online or in-person as part of cybersecurity competitions, training events, or educational exercises.
Task 1 - Deploy the machine
Install docker.io (if you do not already have it installed) -> sudo apt install docker.io
Download machine from DockerLabs website and setup lab:
unzip trust.zip
sudo bash auto_deploy.sh trust.tar
and we obtained IP machine -> 🎯 Target IP: 172.17.0.2
We can put the IP in the file to associate it with an easier to remember name:
suecho"172.17.0.2 trust">>/etc/hosts
Create a directory for machine on a dedicated folder and subdir containing: nmap,content,exploits,scripts
mkdir-pDockerLabs/trustcdDockerLabs/trustmkdir{nmap,content,exploits,scripts}# At the end of the LabCTRL+C#To stop running machinesed-i'$ d'/etc/hosts# To clean up the last line from the /etc/hosts file# To repair potential problem during activitiessudosystemctlrestartdockersudodockerstop $(dockerps-q)sudodockercontainerprune-force
Task 2 - Reconnaissance and Exploitation
I prefer to start recon by pinging the target, this allows us to check connectivity and get OS info.
Sending these three ICMP packets, we see that the Time To Live (TTL) is ~64 secs. this indicates that the target is a *nix system, while Windows systems usually have a TTL of 128 secs.
2.1 Ports in listening and relative services
Of course, we start looking for information about our target by scanning the open ports with the nmap tool
nmap-Pn-n-p0-trust
PORTSTATESERVICE22/tcpopenssh80/tcpopenhttp
There're two open port (22, 80), analyze them searching more info about services version and potential vulns:
nmap-A-sVC-p22,80trust-oNnmap/port_scan
PORTSTATESERVICEVERSION22/tcpopensshOpenSSH9.2p1Debian2+deb12u2 (protocol 2.0)|ssh-hostkey:|25619:a1:1a:42:fa:3a:9d:9a:0f:ea:91:7f:7e:db:a3:c7 (ECDSA)|_256a6:fd:cf:45:a6:95:05:2c:58:10:73:8d:39:57:2b:ff (ED25519)80/tcpopenhttpApachehttpd2.4.57 ((Debian))|_http-title:Apache2DebianDefaultPage:Itworks|_http-server-header:Apache/2.4.57 (Debian)MACAddress:02:42:AC:11:00:02 (Unknown)Warning:OSScanresultsmaybeunreliablebecausewecouldnotfindatleast1openand1closedportAggressive OS guesses: Linux 2.6.32 (96%), Linux 3.2 - 4.9 (96%), Linux 4.15 - 5.8 (96%), Linux 2.6.32 - 3.10 (96%), Linux 5.0 - 5.5 (96%), Linux 3.4 - 3.10 (95%), Linux 3.1 (95%), Linux 3.2 (95%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (95%), Linux 2.6.32 - 2.6.35 (94%)
NoexactOSmatchesforhost (test conditionsnon-ideal).NetworkDistance:1hopServiceInfo:OS:Linux; CPE:cpe:/o:linux:linux_kernel
command
result
sC
run default scripts
sV
enumerate versions
A
aggressive mode
Pn
no ping
oN
output to file with nmap formatting
As always we begin our exploration from port 80, where we know there is a web server, so we execute the whatweb command to extract more information and then view the content using the browser
whatwebhttp://trust
Let's display the default Apache page, try analysing the source page with CTRL+U
But we don't discover nothing of interisting.
2.2 Brute force hidden web directory
Now, we try to find potential hidden directory using gobuster: