黑帽联盟

标题: 修改nginx返回的默认的server信息 [打印本页]

作者: 定位    时间: 2024-3-7 14:22
标题: 修改nginx返回的默认的server信息
通过修改nginx源码来修改nginx返回的默认的server信息。


1、修改请求响应头中的server信息
修改前的代码和响应头中的server信息:
代码文件路径:nginx-1.21.4\src\http\ngx_http_header_filter_module.c


static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;

31.png



修改后的代码和响应头中的server信息:


static u_char ngx_http_server_string[] = "Server: parasaga" CRLF;
static u_char ngx_http_server_full_string[] = "Server: parasaga" CRLF;
static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;


32.png


2、修改nginx返回的默认页面中的server信息
修改前的代码和默认页面中的server信息:
代码文件路径:nginx-1.21.4\src\http\ngx_http_special_response.c


static u_char ngx_http_error_full_tail[] =
"<hr><center>" NGINX_VER "</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_build_tail[] =
"<hr><center>" NGINX_VER_BUILD "</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_tail[] =
"<hr><center>nginx</center>" CRLF
"</body>" CRLF
"</html>" CRLF


33.png


修改后的代码和默认页面中的server信息:


static u_char ngx_http_error_full_tail[] =
"<hr><center> parasaga </center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_build_tail[] =
"<hr><center> parasaga </center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_tail[] =
"<hr><center> parasaga </center>" CRLF
"</body>" CRLF
"</html>" CRLF

34.png





注:以上信息修改好后,需要编译安装,才能生效






欢迎光临 黑帽联盟 (https://bbs.cnblackhat.com/) Powered by Discuz! X2.5