Nginx反向代理小记-附域名劫持案例

admin 2022年4月19日07:54:25评论214 views字数 2895阅读9分39秒阅读模式

Nginx反向代理小记-附域名劫持案例


反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时代理服务器对外就表现为一个反向代理服务器。


这里我们以Nginx为例,这里我的环境是ubuntu 16


修改配置文件进行代理(/etc/nginx/sites-available/default)

Nginx反向代理小记-附域名劫持案例

这里的目的是访问www.jumbojumbo.com实际上看到的是www.czjsy.com


我们测试下,可以看到没问题


Nginx反向代理小记-附域名劫持案例

现在我们想要替换其中的内容怎么办,添加如下参数


Nginx反向代理小记-附域名劫持案例


目的是把05001161替换成jumbo


Nginx反向代理小记-附域名劫持案例


添加完参数我们重启nginx会失败

Nginx反向代理小记-附域名劫持案例


通过上面的提示发现是我们的sub(s)_filter模块未安装,所以我们需要安装此模块

https://github.com/yaoweibin/ngx_http_substitutions_filter_module


./configure --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module=/usr/local/nginx-1.10.3/ngx_http_substitutions_filter_module

./configure --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module=/usr/local/nginx-1.10.3/ngx_http_substitutions_filter_module


再次重启nginx即可


Nginx反向代理小记-附域名劫持案例


通过我们上面反向代理的介绍和整个实操,我们可以想到以下几点邪恶的想法:

1、替换关键词插入恶意js

2、抓包获取用户传入的所有内容,包括账号密码等。


下面附上利用nginx反向代理进行域名劫持的案例,虽然失败了,但是值得学习,点击即可访问:


一次失败的针对白客联盟的渗透测试(域名劫持成功钓鱼失败)

原文始发于微信公众号(中国白客联盟):Nginx反向代理小记-附域名劫持案例

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年4月19日07:54:25
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Nginx反向代理小记-附域名劫持案例https://cn-sec.com/archives/783306.html

发表评论

匿名网友 填写信息