ورود

View Full Version : کمک و راهنمایی برای اجرای کد



smehrabi
سه شنبه 24 اردیبهشت 1392, 22:41 عصر
با سلام
از اساتید معظم خواهش میکنم کدهای ذیل که در لینک زیر آمده چطوری و تحت چه برنامه ای اجرا می شود.


http://ubercoder.blogspot.com/2006/11/shell-script-to-recover-adsl-passwords.html



Shell script to recover ADSL passwords


The following shell script will assist you in recovering an ADSL user name - password pair stored in an ADSL router. The script was tested to run on Knoppix 3.2 and 4.0 and should work on other distros as well. However, the devices that can be used with the script, I leave it for you to experiment with :)


Just copy the script to any file, lets say adsl.sh in your $HOME directory, then execute the following commands to run the script (i.e., give it execute permissions and run it!).


$ chmod +x $HOME/adsl.sh

$ $HOME/adsl.sh ipaddress username password


(If you are already in your home directory, just use chmod +x adsl.sh followed by ./adsl.sh)




The parameters of the script are,




ipaddress - Ip address of the router

username - Router configuration user name
password - Router configuration password



For example,




$ $HOME/adsl.sh 192.168.1.1 admin mypass


(where admin and mypass are the router user name and passwords respectively)


If in case you don't know the user name and password of the router configuration, then look it up in the manual pages of the router. The default values for user name and password for most routers are both 'admin'. So try your luck!


That's it. The script will try to download the configuration and match the lines with user name and password in it.


Enough story, here follows the shell script.




# ADSL Router Password Recovery Shell Script





#

# Copyright (c) 2006 by Ubercoder.
# www.ubercoder.blogspot.com (http://www.ubercoder.blogspot.com)
#
# Freely (re)distributable.



echo "adslpwd Shell-script by ubercoder, www.ubercoder.blogspot.com"
echo ""


echo "#!/usr/bin/expect


spawn telnet $1


expect {*ogin:}
send \"$2\r\"


expect {*sword:}
send \"$3\r\"


expect {*\-\>*}
send \"console enable\r\"


expect {*antum*}
send \"fm\r\"


expect {*antum*fm*}
send \"cat im.conf\r\"


expect {\#\send}
send \"home\r\"


expect {*antum*}
send \"exit\r\"


expect {*\-\>*}


send \"user logout\r\"


" > /tmp/adsl_tmp.sh


chmod +x /tmp/adsl_tmp.sh


echo "Downloading configuration..."
/tmp/adsl_tmp.sh > /tmp/adsl_tmp.tmp


echo "Done."
echo ""
set `cat /tmp/adsl_tmp.tmp | grep weLoginName`
echo "Username: $3"
set `cat /tmp/adsl_tmp.tmp | grep weLoginPassword`
echo "Password: $3"