2 # snip (c) copyright 2000 by plasmoid / thc <plasmoid@pimmel.com>
4 # snippy lil' snip script that shows accessible smb-netbios shares
5 # in a given ip-range. - requires smbclient and nbtscan.
7 # $Id: snip,v 1.2 2001/04/18 19:17:59 plasmoid Exp $
9 # set the right paths here, if smbclient and nbtscan are not within your
15 if [ "`$ECHO -n`" != "-n" ] ; then
19 $ECHO "snip (c) copyright 2000 by plasmoid / thc <plasmoid@pimmel.com>"
22 $ECHO "usage: snip <scan_range>"
23 $ECHO "<scan_range> what to scan. can either be single IP like "
24 $ECHO " xxx.xxx.xxx.xxx or range of addresses in one "
25 $ECHO " of two forms xxx.xxx.xxx.xxx/xx or "
26 $ECHO " xxx.xxx.xxx.xxx-xxx."
30 if [ "x$GNUECHO" = "x1" ] ; then
31 $ECHO -n " - snipping $1: "
33 $ECHO " - snipping $1: \c"
36 servers=`$NBTSCAN -s : $1 | grep \<server\> | \
37 sed s/" "/"%"/g | cut -d : -sf 1,2,4`
40 if [ "x$GNUECHO" = "x1" ] ; then
41 $ECHO -n " - searching shares: "
43 $ECHO " - searching shares: \c"
45 for i in $servers ; do
47 i=`$ECHO $i | sed s/"%"/" "/g`
49 ip=`$ECHO $i | cut -d : -sf 1`
50 host=`$ECHO $i | cut -d : -sf 2 | awk '{ print $1 }'`
51 user=`$ECHO $i | cut -d : -sf 3`
53 if [ "x$user" = "x<unknown>" ] ; then
54 smbarg="-I $ip -L $host -N"
56 smbarg="-I $ip -L $host -N -U $user"
59 output=`$SMBCLIENT $smbarg | grep Disk | awk '{ print $1 }'`
61 if [ "x$user" = "x<unknown>" ] ; then
62 result="$result\n$SMBCLIENT //$host/$j -I $ip -N"
64 result="$result\n$SMBCLIENT //$host/$j -I $ip -N -U $user"
67 if [ "x$GNUECHO" = "x1" ] ; then