#!/usr/pkg/bin/bash exec 2>&1 printf "%s\r\n\r\n" "Content-type: text/html" echo '
'
# terminate 'er
echo Script disabled, sorry.
echo Hasta la vista, baby.
exit 0
# done
ip=$REMOTE_ADDR
browser="$HTTP_USER_AGENT"
echo $browser | grep -iq windows && echo Hmm... Windows... maybe...
if [ "$ip" ]; then
 echo Looking up NetBIOS name...
 nmblookup -A $ip > /tmp/$ip.$$.tmp
else
 echo Could not determine your IP...
 echo You must be pretty smart, so no way you\'re Sal.
 exit 0
fi
if [ ! -f /tmp/$ip.$$.tmp ]; then
 echo Got nothing back from NetBIOS lookup query
 echo You might be behind a firewall... can\'t tell if you\'re Sal or not.
 exit 0
fi
name="`grep '<00>' /tmp/$ip.$$.tmp | \
 grep -v '' | cut -d '<' -f 1 | \
 awk '{print $1,$2,$3,$4,$5,$6}'`"
if [ "$name" ]; then
 echo Your computer\'s name is: $name
else
 echo Could not determine NetBIOS name
 echo Maybe behind a firewall... can\'t tell if you\'re Sal or not.
 exit 0
fi
name="`echo $name | tr -cd 'A-Za-z0-9 ._-'`"
echo Attempting resource listing of $name...
smbclient -N -L "$name" -I $ip >> /tmp/$ip.$$.tmp
for disk in `awk '$2 ~ "^[Dd][Ii][Ss][Kk]$" {print $1}' /tmp/$ip.$$.tmp`; do
 disk="`echo $disk | tr -cd 'A-Za-z0-9_$'`"
 echo Attempting directory listing of $disk...
 smbclient '\\'"$name"'\'"$disk" -I $ip -N -c "dir" >> /tmp/$ip.$$.tmp
done
cat /tmp/$ip.$$.tmp
if ! grep -iq sal /tmp/$ip.$$.tmp && ! grep -iq wise /tmp/$ip.$$.tmp; then
 echo I don\'t think you\'re Sal. But I\'m not sure.
else
 echo I think you might be Sal. But I\'m not sure.
fi
echo 'Source code is here.'