2011年2月12日 星期六

偽裝nginx為IIS

nginx/0.9.4 以 FreeBSD 為例


# cd /usr/ports/www/nginx-devel/ && make patch

# vi work/nginx-0.9.4/src/http/ngx_http_header_filter_module.c 
static char ngx_http_server_string[] = "Server: nginx" CRLF;
EDIT
static char ngx_http_server_string[] = "Server: Microsoft-IIS/6.0" CRLF;

# vi work/nginx-0.9.4/src/http/ngx_http_special_response.c
static u_char ngx_http_error_tail[] =
"
nginx
" CRLF EDIT static u_char ngx_http_error_tail[] = "<hr><center>Microsoft-IIS</center>" CRLF # make install clean


兩個檔案的 patch 如下
ngx_http_header_filter_module.c.patch
--- old/work/nginx-0.9.4/src/http/ngx_http_header_filter_module.c   2010-06-30 22:39:28.000000000 +0800
+++ new/work/nginx-0.9.4/src/http/ngx_http_header_filter_module.c   2011-02-11 22:42:13.000000000 +0800
@@ -45,7 +45,7 @@
 };


-static char ngx_http_server_string[] = "Server: nginx" CRLF;
+static char ngx_http_server_string[] = "Server: Microsoft-IIS/6.0" CRLF;
 static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;

ngx_http_special_response.c.patch
--- old/work/nginx-0.9.4/src/http/ngx_http_special_response.c   2011-01-20 18:37:58.000000000 +0800
+++ new/work/nginx-0.9.4/src/http/ngx_http_special_response.c   2011-02-11 22:43:06.000000000 +0800
@@ -25,7 +25,7 @@


 static u_char ngx_http_error_tail[] =
-"<hr><center>nginx</center>" CRLF
+"<hr><center>Microsoft-IIS</center>" CRLF
 "</body>" CRLF
 "</html>" CRLF
 ;

也可存成檔案直接套用 patch
# patch -p1 < ngx_http_header_filter_module.c.patch
# patch -p1 < ngx_http_special_response.c.patch

沒有留言:

張貼留言