summaryrefslogtreecommitdiff
path: root/net/smb4k/files/smb2nsmbrc
blob: fd5f06e013b91463f66f4bb903867c0e51ec37d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# Convert list of Windows/Samba boxes in local network to .nsmbrc format
# Args, if any passed directly to findsmb - network address and broadcast address
# $Id: smb2nsmbrc,v 1.4 2004/08/05 06:50:32 shelton Exp $

find="findsmb"			# Script to display boxes list
util="smbutil"			# Utility to convert plaintext password to hashed
outfile=".nsmbrctmp"		# Generated file name

# First, we check on presence findsmb
wfind=`whereis -b $find | awk '{print $2}'`

if [ -z $wfind ]; then
  echo FindSMB did not found in your system, please install samba package first
  exit 5
fi

# Second, we check on presence smbutil
wutil=`whereis -b $util | awk '{print $2}'`

if [ -z $wfind ]; then
  echo SMBUtil did not found in your system, please install samba package first
  exit 5
fi

# Now we ask username
echo -n "Please enter username (UPPER CASE!): "
read username

# Now we ask password and crypt by smbutil
password=`$util crypt`

# Now we detect all Windows/Samba boxes and taking their NetBIOS names
netnames=`findsmb $1 $2 | awk -f /usr/local/bin/smb2awk`

# And at least we generating temporarly file with username, password and
# sections for all detected boxes
for netname in $netnames
 do
  echo "[$netname:$username]" >> $outfile
  echo "password=$password" >> $outfile
  echo "" >> $outfile
 done