|
作者:Yiming Gong8 s: Q% p; Q: B* L7 P
http://security.zz.ha.cn
: p$ D0 e9 C1 b- g3 y默认情况下apache是会给client端回显版本号码的,可以测试如下,在client端使用nc联接起着apache的目的主机80端口,发送错误的get请求
. a3 r. X+ N7 D$ Y$ h1 [ N/ Cyiming# nc security.zz.ha.cn 80
& ^/ S9 \( ?1 o4 Yget index.lakdsjf# H. F/ o) F$ Q
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">. w! ^, P) w' S0 s: @
<html><head>) Z; j5 \% I6 K1 ^+ `- M- C
<title>400 Bad Request</title>
: ^: U1 {( W6 |# ] g</head><body># [, ^4 p* Q4 e/ o# f; H* h
<h1>Bad Request</h1>) j+ v1 H V1 y) ~ t9 M
<p>Your browser sent a request that this server could not understand.<br />3 i8 E1 \3 f j
</p>4 M5 [, d; S, Q& w5 q, J" g2 @+ s
<hr />
. C* K! c2 G6 A1 L9 S% c/ q& m# q<address>Apache/x.y.z Server at security.zz.ha.cn Port 80</address>, U% }9 |+ f" ~$ }0 `
</body></html>
. y, j6 G% V) }% O7 Y" W. A1 z) K1 X; v* I# `4 K b# [; h, z
我们看到上面显示了apache的版本号(:) 俺隐去了真实版本),这可不太好,能修改一下么?& A8 z6 S) c2 Q
答案是肯定的!1 J4 ~7 w: |2 p* L/ S, ~7 `6 m
改动apache的配置文件,找到ServerTokens和ServerSignature两个directive,修改默认属性:
) O5 T3 d* N( c, S+ n7 p; o如下
6 t4 i. @& G! O3 o, X* S* x+ _# and compiled in modules.
2 q" P. S6 A$ O$ I6 `0 O5 R! v, e4 r# B#2 p7 I* {$ O. M( J7 R7 ^/ h
# ServerTokens
4 U: x. p' Z: F# This directive configures what you return as the Server HTTP response
# b0 t- F3 e" |$ }9 _5 D( b8 `# Header. The default is 'Full' which sends information about the OS-Type* t, }- Y( ? l5 c$ b
# and compiled in modules.
( d" \0 u# n, m' a% C* {) G* ?# Set to one of: Full | OS | Minor | Minimal | Major | Prod
) I4 @' n* e# y. a+ w# where Full conveys the most information, and Prod the least." [6 Z: K) p0 y/ G4 Y5 }1 }, i9 K7 ]/ f
#) u. {( S% j: {
#ServerTokens Full
; r, i1 U" d! W: j5 {/ S* oServerTokens Prod
/ l$ m; v( {% r5 X3 s9 T. d#! a6 W0 k+ i# r! P) V# F0 M
# Optionally add a line containing the server version and virtual host$ ^. W4 d( i! S( e
# name to server-generated pages (internal error documents, FTP directory7 j/ ]; \5 P9 ?: A# G9 f% D& l3 @
# listings, mod_status and mod_info output etc., but not CGI generated$ b2 B0 ?# x6 J1 z$ v
# documents or custom error documents).
- V/ U5 l. d- T5 ]. t* d# Set to "EMail" to also include a mailt link to the ServerAdmin.
9 K1 | Y3 c6 p( F8 C# Set to one of: On | Off | EMail3 R1 S6 f; O+ N0 x- A$ c1 g
#
. [' v$ |1 O% }# k9 yServerSignature On
! J5 f+ V( f, K) U* _/ kServerSignature Off
) O& W. y [) B) L% c修改后重起apache,再看看,
& Q2 \" _9 v: O! b$ | kyiming# nc security.zz.ha.cn 80
) _3 q$ N( F6 ?4 A+ p. hget index.lakdsjf1 N7 ]$ [' p" ^. X7 d
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
. B2 r6 v+ i( A" s" A3 Z4 b, Y<html><head>& N: ?8 m" l, @
<title>400 Bad Request</title>
$ K$ |; v( D2 Z# }+ q# \3 X</head><body>
" `6 [/ f5 t; n6 s6 P* p7 _- {<h1>Bad Request</h1> m/ M! g! I/ o/ v$ w
<p>Your browser sent a request that this server could not understand.<br />4 u! z; g1 a6 N* }
</p>' S& o+ P6 I! L2 j s
</body></html>
$ T$ ~% t: a0 `% t2 a9 I, _7 }3 \ % M. e- g" j! A: J
|