如何确保源站 IP 不会因为证书而暴露
本文最后更新于 340 天前,其中的信息可能已经有所发展或是发生改变。

证书信息是如何泄露源站 IP 的

当你对服务器请求了一个服务器上不存在的域名时,服务器会在你的 http 和 https 端口分别返回「默认站点」或「最后一个添加的站点」的数据,其中就包括证书 (会提示不安全,因为SNI不一致,但可以看到证书内容,其中包括域名),下图中 Subject: CN=***** 就是你证书的 SNI,也就是域名,例如下面这张图,此人把服务器面板的 SNI 暴露了出来;由于 Shodan , Censys 这种长期扫描互联网空间的服务存在,直接通过域名找到你 IP 的难度很低

CN = Common Name / 公用名称,对于 TLS 证书就是域名,对于代码签名证书就是组织信息

解决思路

解决这种问题有至少四种办法

  • 生成一张假的证书,写上假的域名
  • 使用不受主流浏览器支持的证书算法,导致浏览器无法握手(?
    Koori 想到的,可参考她的文章
  • 默认网站使用 IP 证书
  • 默认网站替换换为 Nginx 或 Apache 的默认页,伪装一个还没部署网站的新服务器,不会暴露证书,也不会很起眼

最简单的应该是第四种,如果您有一定技术能力且爱折腾,第一种和第三种方式也不错,至于如何生成自签名证书,可以查看本站另一篇文章 《XCA简易入门教程

设置方法

下面分别介绍原版 Nginx 和使用某面板的情况下的设置方法

原版

# nginx.conf

server {
listen 80 default_server;
server_name gofxxkyourself.sb;
...
}
# /www/wwwroot/gofxxkyourself.sb/index.html

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

宝塔面板

  • 新建一个网站,域名随意,纯静态,无数据库
  • 更改默认网站
  • 把网站暂停
  • 修改默认页 - 站点停止页
  • 替换为以下内容
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
  • 再访问就可以看到 (伪装成的) Nginx 初始页了
需要注意的是,有的时候使用 https 访问这个 IP 的时候,Nginx 可能使用其他部署在本服务器上网站的证书,你可以替换一张自签名证书给这个域名以解决此问题,详情参考 zikin.org/xca

至此,应该可以防止大部分情况下的源站 IP 泄露了。

暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇