Hack The Box: 'Starting Point' [memo]
+
-
Composed of 18 machines (divided in 3 tiers), it combines good questions + simple exercices to start off on the right foot.
Few notions to remember:
The ping command allow us to see if a server is up or down. The ttl value give us a hint on the OS used (Linux: ~64 / Windows: ~128):
ping <ip>
Nmap is a scanning tool which find out open ports on a machine. A complete scan can be done using -sC -sV flags.
-sC performs a script scan (some of them are considered intrusive), -sV will detect what versions are running on what port,
-Pn helps when ping probes are blocked (treat all hosts as online / skip host discovery):
nmap -sC -sV <ip>
nmap -sC -Pn <ip>
The command to connect to a server running telnet service is the following:
telnet <ip>
FTP (file transfer protocol) use a communication system called client-server model, it usually runs on port 21 and is not encrypted!
Here are the commands to: connect / activate passive mode / list files / get a file:
ftp <ip>
passive
ls
get <filename>
SMB stands for "Server Message Block", it's a protocol usually running on port 139 (on Linux) or 445 (on Windows).
The following commands allow us to: list the shares on the server / get a shell / download a file:
smbclient -L <ip>
smbclient '\\<ip>\<share>'
get <filename>
RDP, the "Remote Desktop Protocol" is used on Windows and runs on port 3389. To use it we run xfreerdp, a command-line tool.
The flags used here allow us to respectively: select target IP / ignore the security certificates / use username "Administrator".
xfreerdp /v:<ip> /cert:ignore /u:Administrator
Gobuster is a brute-forcing tool for directories discovery. Here is a example command:
gobuster dir --url <ip> -w <wordlist>
SQL (Structured Query Language), is designed for managing data. SQL Service > Databases > Tables > Columns + Row = Data.
When not properly protected, we can bypass a web authentification form by adding '# to the username. Which will comment out the password, find the corresponding entry in the database and allow the login. Its most common type of vulnerabilities: SQL injection!
SELECT * FROM users WHERE username='admin'# AND password='a'
Mysql (or Mariadb) helps us to connect to the database from the terminal:
mariadb -h <ip> -u <user>
And then list all databases / enter a database / list all the tables / list all the data inside a table:
SHOW databases;
USE <database>;
SHOW tables;
SELECT * FROM <table>;
Netcat is used as a port listener, it's a direct and easy command-line tool to create a connection between two machines. Useful for reverse shells.
The flags corresponds to: -l listening-mode / -v verbose / -n numeric-only ip / -p port:
nc -lvnp <port>
Linux -> Windows terminal command: ls -> dir / cat -> type.
Also Powershell includes the best features of other popular shells, allowing us to run more common commands:
dir <folder>
type <file>
powershell -c <command>
Impacket is a "collection of Python classes for working with network protocols". Here is an example of how to run the mssqlclient.py script toward a Windows machine having the MS SQL service on port 445:
python3 mssqlclient.py <user>@<ip> -windows-auth
A lot of informations can be found inside the command-line history file. Find it on Linux / Windows:
cat ~/.bash_history mssqlclient.py
type C:\Users\<user>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
On linux, the following command delete the complete history:
history -c