diff --git a/tab-sorcery.sh b/tab-sorcery.sh index 3162ace..6e0f4c1 100644 --- a/tab-sorcery.sh +++ b/tab-sorcery.sh @@ -4,6 +4,7 @@ # $1 == Domain to scan # $2 == Nameserver to do the zone transfer from # $3 == Default username for connections +# $4 == Windows password file (optional and unencrypted plain text; use at your own risk!) scan_domain=$1 scan_ns=$2 @@ -14,6 +15,13 @@ case "$SORC_GEOM_RDP" in *) geom_rdp='1600x900';; esac +# Check for a plain text password files for Windows hosts +# (Disclaimer: This is highly insecure and unrecommended.) +case "$SORC_PASS_FILE" in + [~$/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*) pass_file=$SORC_PASS_FILE;; + *) pass_file=/dev/null;; +esac + get_hostip () { #host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'` host_ip=`echo $zone_xfer | grep $1 | grep A | awk '{print $3}'` @@ -30,7 +38,16 @@ while read host <&3; do get_hostip ${host} alias ${host_short}="${connect_cmd} ${user_name}@${host_ip}" elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"windows"' ]; then - connect_cmd="rdesktop -g $geom_rdp" + if [ -f $pass_file ]; then + if pass_line=`grep $host_short $pass_file`; then + winpass=`awk -F= '{print $2}' <<< "$pass_line"` + connect_cmd="rdesktop -g $geom_rdp -p $winpass" + else + connect_cmd="rdesktop -g $geom_rdp" + fi + else + connect_cmd="rdesktop -g $geom_rdp" + fi get_hostip ${host} alias ${host_short}="${connect_cmd} -u ${user_name} ${host_ip}" elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"cisco"' ]; then