Thursday, August 16, 2007

Shell Script - rdesktop.sh

This script hasn't been perfected yet but I almost lost it once. So, here it is so I don't almost loose it again. I know it would be semi-easy to re-create but hey, why re-create when you can just go back and find it again!

I use this so I can automatically pull up computers at work after hours and do maintenance. You can either leave the password field blank or put it in the script to auto-login for you. IF you put the password into the script, be careful. Someone may be able to read your script and get your password!

I do need to update this script. For some reason if it doesn't find port 3389 open on a remote host in the list it will spit out the results from 'nmap --help'. This is ok as it will just move onto the next IP but if you know how to fix it I would love to know how. Keep checking back for updates.


rdesktop.sh


#! /bin/bash

clear

echo "Enter First 3 Octets (x.x.x):"
read ipthree
echo "Enter 4th Octet FIRST IP:"
read ipfirst
echo "Enter 4th Octet ENDING IP:"
read iplast

iprange=`echo $ipthree | cut -d. -f1-3`

# Use If First IP Range Is Giving Trouble - CAUTION, May Give Unwanted Results If 'ipthree' Is Fatfingered
#iprange=`echo $ipthree`

for (( i = $ipfirst ; i <= $iplast ; i++ ))
do
nmaplist=`nmap -P0 -p3389 $iprange.$i | grep -B2 open | grep Interesting | cut -d" " -f4 | cut -d: -f1`

rdesktop -k en-us -a 16 -u Administrator -p "" $nmaplist
done

1 comment:

Unknown said...

dude i was writing a c# application
to do things like this but i am going to go linux can you figure if this thing logged in successfully or not im writing a security tool for backtrack and could use some help

if you can get this thing to notify on sucessful or failed login we are golden

my tool is crazy ill explain soon