This comprehensive guide covers the installation, configuration, and troubleshooting of a secure Samba file share on Kali Linux, with detailed solutions for common access issues.
---
PART 1: SAMBA CONFIGURATION
1. Installation and Basic Setup
1.1 Install Samba
Update your package list and install the required Samba packages:
sudoaptupdatesudoaptinstallsamba
1.2 Create the Share Directory
Create the directory that will be shared:
sudomkdir-p/mnt/notes
---
2. Samba Configuration File
Edit the Samba configuration file:
sudonano/etc/samba/smb.conf
Scroll to the end of the file and add your share configuration:
**Configuration Parameters Explained:**
**guest ok = no**: Requires authentication (username/password). Set to 'yes' for null session access.
**read only = yes**: Allows viewing and downloading files only, no modifications or deletions.
**valid users = kabi**: Restricts access to specified user(s) only.
Save and exit the file (Ctrl+X, then Y, then Enter).
---
3. Resolving NT_STATUS_ACCESS_DENIED
The **NT_STATUS_ACCESS_DENIED** error typically indicates issues with Samba authentication or system file permissions.
3.1 Add User to Samba Database (Critical Step)
Samba maintains its own password database, separate from the Linux system password. Add the Linux user to Samba's password database:
You will be prompted to enter and confirm a password. This password is used for Samba authentication and can differ from the Linux system password.
3.2 Set Linux File System Permissions
Ensure the Samba user has appropriate permissions on the shared directory:
**Permission Breakdown:**
**7 (rwx)**: Owner (kabi) can Read, Write, and Execute
**5 (r-x)**: Group and Others can Read and Execute
3.3 Restart Samba Services
Apply all configuration changes by restarting the services:
**Verify services are running:**
---
4. Testing the Connection
Use smbclient to verify the connection from your client machine:
When prompted, enter the Samba password you set in Step 3.1.
**Successful connection will show:**
---
PART 2: RPCCLIENT ENUMERATION GUIDE
Overview
rpcclient is a powerful command-line tool from the Samba suite used for executing Remote Procedure Call (RPC) functions. It enables system administrators and security professionals to manage and gather information from remote SMB/CIFS servers.
**Key Information:**
Feature
Details
Purpose
Interact with and test MS-RPC functionality on remote servers
Primary Use
Remote user/group management, security policy querying, system enumeration
Security Context
Extensively used in Active Directory and Samba enumeration during penetration tests
Dependency
Requires target server to have RPC services (SAMR, LSARPC) accessible
---
Basic Connection Syntax
1. Authenticated Connection
The most common and effective connection method:
2. Null Session / Anonymous Connection
Used to check if the server permits anonymous RPC access:
**Note:** Null sessions are typically blocked on modern, secured systems.
---
Essential Enumeration Commands
Once connected (when you see the rpcclient> prompt), use these commands:
Queries Local Security Authority (LSA) information
Domain SID, LSA database information
Utility Commands
Command
Description
help or ?
Displays list of all available commands
quit or exit
Closes the rpcclient session
debuglevel [level]
Sets debugging level (0-10) for troubleshooting
---
Command Line Execution (Non-Interactive Mode)
Execute commands directly without entering the interactive prompt using the -c flag:
---
Advanced Technique: RID Cycling
**RID Cycling** is a penetration testing technique used to discover valid usernames by sequentially querying RIDs, even when enumdomusers is restricted.
**Concept:**
RIDs typically start at 500 (Administrator) and increment for each new user
Loop through RID values and query each one using queryuser
Valid users will return information, invalid RIDs will return an error
**Manual RID Cycling Example:**
**Automated RID Cycling Script:**
**Security Implication:** This technique is valuable during security assessments when standard enumeration methods are blocked or filtered.
---
Troubleshooting Common Issues
**Issue 1: Connection Refused**
Verify Samba services are running: sudo systemctl status smbd nmbd