Set Up Local SMB Server
In this step, we will set up a local SMB (Server Message Block) server using Samba. SMB is a network file sharing protocol that allows applications on a computer to access files and resources on a remote server. Samba is a free software re-implementation of the SMB networking protocol. This will provide a target for our Hydra SMB attack in later steps.
First, let's install Samba. Open your terminal in the ~/project
directory.
sudo apt update
sudo apt install samba -y
This command updates the package lists and then installs the Samba package. The -y
flag automatically answers "yes" to any prompts during the installation.
Next, we need to configure Samba. We'll start by backing up the original configuration file.
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
Now, let's create a new, simplified configuration file. We'll use nano
to edit the configuration file.
sudo nano /etc/samba/smb.conf
Paste the following configuration into the nano
editor. This configuration creates a shared directory named share
that is accessible to everyone on the network.
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = fileserver
security = user
map to guest = bad user
name resolve order = bcast host lmhosts wins
[share]
path = /home/labex/project/share
browsable = yes
writable = yes
guest ok = yes
read only = no
Press Ctrl+X
, then Y
, then Enter
to save the file.
Now, let's create the shared directory.
mkdir ~/project/share
sudo chmod 777 ~/project/share
This creates a directory named share
in your ~/project
directory and sets its permissions to 777, which means everyone has read, write, and execute permissions. Note: In a real-world scenario, you would want to use more restrictive permissions. We are using 777 for simplicity in this lab environment.
Next, we need to add a Samba user. This user will be used to authenticate to the SMB server. We'll use the labex
user that already exists on the system. First, set a Samba password for the labex
user.
sudo smbpasswd -a labex
You will be prompted to enter a new password for the labex
user. Enter a password and confirm it. Remember this password, as you will need it later.
Finally, restart the Samba service to apply the changes.
sudo systemctl restart smbd nmbd
Important Note: The systemctl
command might not work directly in the Docker container environment. If you encounter an error, you can try restarting the Samba services using the following commands:
sudo /etc/init.d/smbd restart
sudo /etc/init.d/nmbd restart
Now, your local SMB server is set up. You have created a shared directory named share
and added the labex
user with a Samba password.