Oookish. Time to have some fun with Samba / CIFS, Windows 10 and Linux.
There's a couple of things you'll need to have, and some things you need to know, and I do suggest you have some kind of server machine for this. It's NOT, I REPEAT NOT a tutorial on how to share every file, from every machine, like we did in "the good ol' days.." It's messy, stupid, and not very user friendly, so stop doing that !!
And, you won't find anything here about using Samba Version 1, don't...really I mean it, don't !
Okay, so welcome to the ones I haven't scared away by now. Here I'm using a Windows Server 2019 as Server, configured with a static IP address. The workstation is Kali, and configured with a static IP. FOr the Kali machine, it really doesn't matter, it till work either way, using static or DHCP enabled makes no difference. What matter is the IP for the server that will host the shared files. Sharing the workstation files it's just for easy access from the server, for transfering them to the server, nothing else.
So, okay. I assume you know how to configure a setup like this yourself on windows either server or windows 10, so make a couple of network shares, and let's move on, shall we ?
The problem is that Windows turned off Samba version 1, so wee need a service called WSDD, you can find it here https://github.com/christgau/wsdd
In that zip file, there's a couple of files we'll need.
/wsdd-master/etc/systemd/wsdd.service. On Kali, copy that to /etc/systemd/system/wsdd.service
/wsdd-master/src/wsdd.py, copy that to /usr/bin/wsdd.py, and copy /wsdd-master/test/netlink_monitor.py and routesocket_monitor.py into /usr/bin
Now, we need to change the services file, it's in /etc/systemd/system/, remember ?. Mine looks like this
[Unit]
Description=Web Services Dynamic Discovery host daemon
; Start after the network has been configured
After=network-online.target
Wants=network-online.target
; It makes sense to have Samba running when wsdd starts, but is not required
;Wants=smb.service
[Service]
Type=simple
ExecStart=python3 /usr/bin/wsdd.py --shortlog
; Replace those with an unprivledged user/group that matches your environment,
; like nobody/nogroup or daemon:daemon or a dedicated user for wsdd
User=root
Group=root
; The following lines can be used for a chroot execution of wsdd.
; Also append '--chroot /run/wsdd/chroot' to ExecStart to enable chrooting
;AmbientCapabilities=CAP_SYS_CHROOT
;ExecStartPre=/usr/bin/install -d -o nobody -g nobody -m 0700 /run/wsdd/chroot
;ExecStopPost=rmdir /run/wsdd/chroot
[Install]
WantedBy=multi-user.target
Note the call to python3, it will throw an error if you don't specify the python3 interpreter, and try running it on python2.x. and next, be sure the paths are set correctly.
Next, we need to define a samba test share. We do that in /etc/samba/smb.conf
#
#======================= Global Settings =======================
[global]
## Browsing/Identification ###
netbios name = machine_name
workgroup = workgroup
encrypt passwords = yes
wins support = yes
#### Debugging/Accounting ####
# This tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/log.%m
# Cap the size of the individual log files (in KiB).
max log size = 1000
# We want Samba to only log to /var/log/samba/log.{smbd,nmbd}.
# Append syslog@1 if you want important messages to be sent to syslog too.
logging = file
# Do something sensible when Samba crashes: mail the admin a backtrace
panic action = /usr/share/samba/panic-action %d
####### Authentication #######
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
#======================= Share Definitions =======================
[homes]
comment = Home Directories
browseable = no
read only = yes
create mask = 0700
directory mask = 0700
valid users = %S
[storage]
path = /media/mountpoint
comment = comment
browseable = yes
read only = no
guest ok = yes
Reload the daemons with
systemctl daemon-reload
Start samba
systemctl start smbd
And, start wsdd
systemctl start wsdd
Now, your machine should appear in the workgroup. So how do we transfer files between machines ?
From windows, use the net use command in a terminal or in powershell
#Mount on windows
net use z: \\Linux_machine_name /USER:username password
Unmount on Windows
net use /DELETE z:
You can use the Linux machine IP also, for troubleshooting. It should work with the wsdd service too. If not, see if it's running with systemctl status wsdd and systemctl status smbd
Now, how do we mount windows shares in Linux ?, Well, that's another game. Use the cifs-utils, and mount for that. FIrst let's see what shares are on the win box.
smbclient -L machineip -U winuser -p winpassword
So, if you found a windows share, how do we mount it ?, By using the mount command like so.
mount -t cifs -o username=winuser,password=winpassword //winmachineip/share/ /media/mountpoint
For details see man mount and man mount.cifs. Or try an apropos cifs for options to the mount command.
Have fun :)