Table of Contents
Tactics is a Windows server that contains a misconfigured SMB share, which offers two types of attack vectors. One is discoverable and easy to employ. The other involves the installation and deployment of a popular exploitation framework, while dearly effective, comes with its own disadvantages in terms of discoverability.
In this video we are going to take the right step, knowing the right path and perceiving the consequences of your attack vectors will prove vital to your career.
- We have already learned it from:
Dancing: Starting Point Hack The Box Walkthrough
This walkthrough provides a step-by-step guide to hacking the "Dancing" machine on the Hack The Box platform. It covers the process of gaining initial access, escalating privileges, and ultimately achieving full control over the target machine.
Enumeration
In order to get a general view of the target host, we will begin with an always-popular Nmap scan. However, we will be using a new switch for the scan.
Instead of the -sV service detection switch, we will be using -Pn. In a real-world environment, you should expect Firewalls to be present, intercepting connections at every step and denying all nonstandard connection requests or scan attempts. During a typical Nmap scan, the Nmap script will perform a form of complex ping scan, which most Firewalls are set to deny automatically, without question. Repeated denials will raise suspicion, and during a typical scan, a lot of the same requests will get denied.
The -Pn flag will skip the host discovery phase and move on straight to other probe types, silencing your active scanning to a degree. However small, this degree might prove the be the lifeline you needed before you even considered actively attacking the host.
- -Pn : Treat all hosts as online -- skip host discovery
- -sC : Equivalent to --scriot=default
According to the results of the nmap scan, the machine is running the Windows and the Server Message Block service on port 445. We have found our target.
Enumerate using the SMB Client tool
Inherently, SMB (Server Message Block) is a file-sharing protocol, which means that we might extract some useful by-products by exploring it. This can be achieved by using the smbclient tool.
In order to find the appropriate switches for this tool, we can use its help menu, which is accessed by typing the smbclient -h command.
This is, however, short and not very descriptive, but it suits our needs for now. Upon exploring the choices, we will settle on this command, in order to list the various available shares ( -L ) and to attempt a login as the Administrator account, which is the high privilege standard account for Windows operating systems.
Typically, the SMB server will request a password, but since we want to cover all aspects of possible misconfigurations, we can attempt a passwordless login. Simply hitting the Enter key when prompted for the Administrator password will send a blank input to the server. Whether it accepts it or not, we still need to discover.
Foothold
Foothold the SMB server using the SMB client tool
From here run the below command to get access to a share.
We got an smb interaction. Run help to check available help.
In order to retrieve the flag.txt file from the server, we can use the get flag.txt command. This will initialize a download with the output location being our last visited directory on our attacker VM at the point of running the smbclient tool.
We can now exit the smbclient command line and read the file we just downloaded using the cat command.
You have successfully retrieved the flag, congratulations!
Task Answers
TASK 1: Which Nmap switch can we use to enumerate machines when our packets are otherwise blocked by the Windows firewall?
Ans. -PnTASK 2: What does the 3-letter acronym SMB stand for?
Ans. Server Message BlockTASK 3: What port does SMB use to operate at?
Ans. 445TASK 4: What command-line argument do you give to `smbclient` to list available shares?
Ans. -LTASK 5: What character at the end of a share name indicates it's an administrative share?
Ans. $TASK 6: Which Administrative share is accessible on the box that allows users to view the whole file system?
Ans. C$
TASK 7: What command can we use to download the files we find on the SMB Share?
Ans. get
TASK 8: Which tool that is part of the Impacket collection can be used to get an interactive shell on the system?
Ans. psexec.py