Network Share for the Home and Penetration Testing
Samba is a powerful network file-sharing service that enables collaboration, and data accessibility across
your own home, and organizational networks. By following this guide, deploying your own Samba services allows you to:
- Centralize your notes and files without using cloud storage providers
- Eliminate the need for an Internet connection or bandwidth to access files that may be large and consume a lot of bandwidth
- Attack your own network storage service, exploiting and learning about Samba misconfigurations, and security vulnerabilities in older versions of Samba and its clients.
First we need to create a VM, we are going to use the VM template I created in the article below. These
instructions are only for Rocky Linux, please follow the guide to learn
how to create a Rocky Linux Virtual Machine, and convert it to a template.
Creating a Virtual Machine Template
Install Samba
Update your system
sudo dnf update
sudo dnf install samba samba-client samba-common
SMB is the Samba file sharing service.
NMB is a NetBIOS package used for name resolution for users to easily identify and connect to your file sharing service.
Configuring your Samba service
Add firewall rules to allow your server connections to our Samba service
sudo firewall-cmd --add-service=samba --permanent
sudo firewall-cmd --reload
Edit the Samba configuration file to add Shared directories. You will likely create more for individual users and groups but this is beyond the scope of setting up your first shared network directory. The brackets [] indicate the network service name, please replace it with something you would like to call it. The path variable defines the share directory path of where it will reside on your machine.
path = /srv/samba/share
browseable = yes
writable = yes
guest ok = yes
Add users yo tour machine and your Samba service, then change their passwords:
Test Samba Configuration
sudo testparm
Change SELinux policies to allow users to access these directories (OPTIONAL)
RHEL and RHEL-like operating systems will have SELinux installed, enabled, and enforced. SELinux can and will prevent access to your SMB shares on RHEL, and RHEL-like systems like our Rocky Linux instance. To confirm SELinux is enforcing its policies run the command below:
sudo setenforce 0
Lets create an exception in SELinux to not enforce policies on the directories that are hosting Samba shares. Apply the File Context of Samba Share type to our directory where we are hosting our shares.
Apply available contexts recursively to our home shares directory. Will apply samba_share_t context.
sudo restorecon -R /srv/samba
ls -laZ /srv/samba/share
Access Shared Directories
Penetration Testing with Samba
NIST Vulnerability Database search for vulnerabilities that use or mention exploiting Samba service, or using Samba for data-exfiltration.
NIST Vulnerability Search Results for SMB
Comments
Post a Comment