|
作者:Yiming Gong. V% s# r, v9 d% [( q- i+ I9 W a* s
http://security.zz.ha.cn
/ n# t) v: b5 F$ x默认情况下apache是会给client端回显版本号码的,可以测试如下,在client端使用nc联接起着apache的目的主机80端口,发送错误的get请求
5 x. Z2 X- d* M6 q; M/ Hyiming# nc security.zz.ha.cn 800 y1 {. a3 C, U. n$ E6 u y
get index.lakdsjf( }# Z+ |7 ?" a3 }
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
' u0 L) z- J& k1 b' w, [<html><head>
# J- N1 U# N4 u+ c% o/ T5 m+ Q6 a<title>400 Bad Request</title>
; e" [5 p% l( p/ ]# ~. n$ M</head><body>
8 M& d- k1 ~. d5 t8 T! u3 z<h1>Bad Request</h1>
4 R8 }. K7 n7 r$ z- _0 E1 X w<p>Your browser sent a request that this server could not understand.<br />/ d- m0 f* N' Z/ o6 e9 b5 q
</p>
2 U1 w. D& \6 c, a& N<hr />
7 ^7 [9 {& f: b2 }<address>Apache/x.y.z Server at security.zz.ha.cn Port 80</address>" x9 A3 K3 U9 [: u* F. u
</body></html>
2 A/ L' V. \* X
2 F' @1 I( I# P: l, w, X% ?我们看到上面显示了apache的版本号(:) 俺隐去了真实版本),这可不太好,能修改一下么?# L# u9 p: n8 l
答案是肯定的!7 {% N# s+ c; j4 |8 T6 V9 `
改动apache的配置文件,找到ServerTokens和ServerSignature两个directive,修改默认属性:
% q7 ]5 E! n2 \6 s4 i; r1 ~如下
) e; q0 x* J8 o- }5 A: h# and compiled in modules.& H5 s' q9 b2 R* u: s
#
. Q3 g9 S+ ^ H4 E; v# ServerTokens* c' M6 i! v s. D% j6 J! ~
# This directive configures what you return as the Server HTTP response
5 E9 d, P1 o+ X6 G; p! X* F# Header. The default is 'Full' which sends information about the OS-Type
: M, V8 j. U! n% w3 a/ _# and compiled in modules.. D9 v3 Z% w7 D' `
# Set to one of: Full | OS | Minor | Minimal | Major | Prod# E( h+ B7 l4 d
# where Full conveys the most information, and Prod the least.8 H B+ H) p( [
#
$ U7 l: c) d0 _2 T0 q#ServerTokens Full
$ a( B4 F: c! a; f$ {) JServerTokens Prod / ]' G) j5 l$ L4 a/ j
#
+ E+ N. g! i( c( k0 W0 [# Optionally add a line containing the server version and virtual host
K4 ~* k' ~9 V1 V# name to server-generated pages (internal error documents, FTP directory
" i6 s! _% _- v) n$ d6 J4 h# listings, mod_status and mod_info output etc., but not CGI generated
: \ Y2 _, T0 b# documents or custom error documents).
" n* q. @3 _, I# Set to "EMail" to also include a mailt link to the ServerAdmin.5 }- A5 B, F! d8 D
# Set to one of: On | Off | EMail
- ^' C6 f7 r* k. o, A. H#/ r; R8 X9 b6 c& d
ServerSignature On
$ U/ x. N4 g% E- p. p& P5 t2 FServerSignature Off ( `5 s' n S1 t% w2 F% m
修改后重起apache,再看看, # j$ D' G2 d" ~) [* ]* O- M
yiming# nc security.zz.ha.cn 80# G( {6 @2 S3 r2 l
get index.lakdsjf
- I1 a) P# k8 e' q- V/ f8 }( y<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">9 ]; ?- R0 }; S# H
<html><head>, z; F$ G A! w+ v2 `2 P
<title>400 Bad Request</title>
" ~ ^# G. H/ J2 i</head><body>
. T- _" w" U" P: I& ]. Z<h1>Bad Request</h1>2 L3 O5 C0 f2 T- X7 [: V
<p>Your browser sent a request that this server could not understand.<br />1 s: Z) a3 p$ t, s0 `- N# n9 v
</p>
8 g A1 O5 x7 l' p</body></html>
: @' o9 g, Z; E' B
( f/ P# l7 L3 Y4 x# h
|