路由器上的密码恢复

 

 

实验说明:密码恢复在很多的模拟器上做不了,但没想到Packet Tracer 就可以做,因为他能模拟到通断电的那个状态,呵呵,所以PT在NA的作用还是很大的,实际情况应该与上面的的拓扑有点不一样,因为我没配PC,有可能你们远程登录的时候是用PC的,但应该也要按那个开关键,所以我就不把PC作出来了,反正结果还是一样
实验步骤:

Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ho r1
r1(config)#enable secret cisco             //设置了加密码码为CISCO
r1(config)#end
r1#copy run sta                                     //保存到配置文件中
Destination filename [startup-config]?
Building configuration...
[OK]
r1#reload                                            //重启电脑
Proceed with reload? [confirm]
r1>                   //现在的操作就是模拟我们忘了进入特权模式的密码时该怎么做,之前的只是准备工作

r1>en
Password:
% Bad secrets   
              
//忘记密码登不上去

r1>                                  //此时到路由上把开关关闭再打开

 

关闭电源,再打开

此时会出现下面路由解压的情况

r1>System Bootstrap, Version 12.1(3r)T2, RELEASE SOFTWARE (fc1)
Copyright (c) 2000 by cisco Systems, Inc.
cisco 2811 (MPC860) processor (revision 0x200) with 60416K/5120K bytes of memory

Self decompressing the p_w_picpath :
############################### 
                //解压,此时在键盘上马上按下Ctrl+Break键进入rommon救援模式
monitor: command "boot" aborted due to user interrupt
rommon 1 > confreg 0x2142
                    //默认寄存值为0x2102现修改为0x2142让他不经过配置文件启动(也就是绕过了配置文件)
rommon 2 > reset                               
//重启电脑


System Bootstrap, Version 12.1(3r)T2, RELEASE SOFTWARE (fc1)

         --- System Configuration Dialog ---

Continue with configuration dialog? [yes/no]: n            //出现setup 设置模式


Press RETURN to get started!

 

Router>en
Router#copy start run
                   //能进入特权模式了,想怎么样都可以,可以把start-config的东西倒出来
Destination filename [running-config]?

518 bytes copied in 0.416 secs (1245 bytes/sec)
r1#
%SYS-5-CONFIG_I: Configured from console by console
r1#
r1#conf t
Enter configuration commands, one per line. End with CNTL/Z.

r1(config)#enable secret yutian                //修改加密密码为yutian
r1(config)#end
r1#
%SYS-5-CONFIG_I: Configured from console by console
r1#copy run startup-config                        //保存
Destination filename [startup-config]?
Building configuration...
[OK]
r1#
r1#conf t
r1(config)#config-register 0x2102
     //修改寄存值,让他从NVRAM中找配置文件
r1(config)#end
r1#reload                            

 
Press RETURN to get started!


r1>
r1>en
Password:

r1#                //密码已经恢复过来了

扩展:交换机的密码恢复与路由差不多,因为交换机上没有那个开关键,所以做不了,但实际中我们可以直接重启电源来实现

虽然命令有点不一样,但思想是一样的,都是通过救援模式修改寄存值,绕过配置文件进入特权模式,之后修改密码,再把寄存值改回从配置文件启动

命令如下:

1. 加电按住MODE键大约15s

2. flash-init

load-helper

4.Dir flash       //查看配置文件,找到config.text文件

5.Rename flash:config.text flash:config.old //重命名配置文件,这样是因为交换机启动找不到config.text这样就能进去设置模式了

6.boot

7.#rename flash:config.old flash:config.text     //把源文件修改回来

8.#copyflash:config.text system:running-config

9.改密码 保存到NVRAM

本文引自:http://hi.baidu.com/jisuanji%B0%AE%BA%C3%D5%DF/blog/item/c1a99dde4a85d5aacc116643.html