域名被恶意Cname或空间IP被恶意指向后处理

域名被恶意Cname或空间IP被恶意指向后处理

本处理方案是已经解析了一段时间情况下的对抗措施,旨在让对方域名停掉或不再造成影响。

旨在: 帮助用户处理域名被CNAME,或IP空间被未授权解析。恶意CNAME等场景也适用。

连接其基本原理,以及指向的手段和预防方法,可以参考: 关于 域名或IP空间被人恶意CNAME或解析:

https://huasci.com/archives/yu-ming-bei-bie-ren-cname

文章目录结构

第一步: 使用nginx配置反向代理

第二步: 配置警告页 (警告页可植入谷歌分析以及谷歌广告[可选])

第三步: 向各搜索引擎以及平台举报

第一步。使用nginx配置反向代理

1.编写反向代理软件配置

vim  /etc/nginx/nginx.conf

2.配置自签ssl证书

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /www/ssl/.acme.sh/default/default.key -out /www/ssl/.acme.sh/default/default.cer

注意,该证书立即签发立即失效,就应该这样子做。建议不要留组织名等信息,这个警告页本来就应该提醒警告ssl有问题。

3.配置nginx核心

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.

include /usr/share/nginx/modules/*.conf;

events {

    worker_connections 4096;

}

http {

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;

    tcp_nopush          on;

    tcp_nodelay         on;

    keepalive_timeout   65;

    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;

    default_type        application/octet-stream;

    gzip  on;

    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    gzip_vary on;

    gzip_min_length 1024;

    gzip_proxied any;

    gzip_comp_level 6;

    gzip_buffers 16 32k;

    gzip_http_version 1.1;

    # Load modular configuration files from the /etc/nginx/conf.d directory.

    # See http://nginx.org/en/docs/ngx_core_module.html#include

    # for more information.

    include /etc/nginx/conf.d/*.conf;

	# 限速区域

    limit_req_zone $http_cf_connecting_ip zone=warn_zone:10m rate=5r/s;

	

	# 隐藏 Nginx 版本

    server_tokens off;

    server {

        listen       80        default_server;

        listen       [::]:80   default_server;

        

		listen 443 ssl default_server;

		listen [::]:443 ssl default_server;

		server_name  _;

		

		

		# SSL 证书配置

    	ssl_certificate /www/ssl/.acme.sh/default/default.cer;

    	ssl_certificate_key /www/ssl/.acme.sh/default/default.key;

		

		# 安全头

		add_header X-Frame-Options "DENY" always;

		add_header X-Content-Type-Options "nosniff" always;

		add_header X-XSS-Protection "1; mode=block" always;
        # 如果使用该条,则警告页css样式失效

		# add_header Content-Security-Policy "default-src 'none'; frame-ancestors 'none';" always;

		add_header Referrer-Policy "no-referrer" always;

		add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

		add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0" always;

		

        # Load configuration files for the default server block.

        include /etc/nginx/default.d/*.conf;

   

		location / {


			# warning.html 警告页面在稍后代码中,可自行取用

			root /www/info/var/html;

			try_files /warning.html =404;

			
			# 限制请求方法

			limit_except GET {

				deny all;

			}

			# 限制请求速率

			limit_req zone=warn_zone burst=10 nodelay;

		}

		# 日志

		access_log /var/log/nginx/illegal_access.log main;

		error_log /var/log/nginx/illegal_error.log;

		
        # 如果已经没有任何劫持行为,可以使用444直接断开连接
		# return 444;

    }

}

第二步。构建警告页系统

# 路径自行创建
mkdir -p /www/info/var/html

# 进入到相关目录
cd /www/info/var/html

#编辑警告页
vim warning.html

警告页代码如下:

<!DOCTYPE html>
<html lang="zh-CN">

<head>

    <meta charset="UTF-8">
    <!-- 植入谷歌广告,可自行使用 标头认证 ca-pub-5228643650090606 -->
	<meta name="google-adsense-account" content="ca-pub-5228643650090606">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>紧急安全警告</title>

	<script async custom-element="amp-auto-ads"

        src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">

	</script>

    <!-- 植入谷歌广告,可自行使用 ca-pub-xxxxxxxxxxx -->
	<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxx"

     crossorigin="anonymous"></script>
    
    <!-- 植入谷歌分析,自行使用 G-xxxxxxxx -->
	<script async src="https://www.googletagmanager.com/gtag/js?id=G-xxxxxxxx"></script>

    <style>

        body {

            font-family: Arial, sans-serif;

            text-align: center;

            padding: 30px;

            background-color: #ffebee;

            color: #b71c1c;

            line-height: 1.6;

        }

        .warning {

            background-color: #ffffff;

            border: 2px solid #ef5350;

            padding: 30px;

            margin: 0 auto;

            max-width: 920px; /* Slightly increased for better proportion */

            border-radius: 10px;

            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);

        }

        h1 {

            color: #d32f2f;

            font-size: 28px;

            margin-bottom: 20px;

        }

        p {

            font-size: 18px;

            margin-bottom: 15px;

        }

        .strong {

            color: #d32f2f;

            font-weight: bold;

        }

        .hr {

            border: 1px solid #ef5350;

            margin: 20px 0;

        }

        a {

            color: #000dffb3;

            text-decoration: underline !important;

            font-weight: bold;

        }

        a:hover {

            text-decoration: underline;

        }

    </style>

</head>

<body>
<!-- 植入谷歌广告,可自行使用 ca-pub-xxxxxxxxxxx -->

<amp-auto-ads type="adsense"

        data-ad-client="ca-pub-xxxxxxxxxxx">

</amp-auto-ads>

<div class="warning">

    <h1>紧急安全警告!</h1>

    <h2>[非官方网站,该域名使用CNAME劫持]</h2>

    <p><strong>警告:</strong>该域名疑似由诈骗分子持有,存在严重欺诈行为,已被相关信息安全机构锁定并无法访问。为保护您的财产安全,请立即停止访问并退出该网站!</p>

    <p>如您与该域名存在任何纠纷,请使用 WHOIS 工具查询该域名的注册信息以获取联系方式,并立即拨打 <strong>110</strong> 报警,联系当地警方寻求协助。</p>

    <p class="strong">报警电话:110</p>

    <p>信息安全机构和官方对于假冒行为造成的损失概不负责!</p>

    <p>如果您执意访问,我们对此不负任何责任。</p>

    <p><a href="https://cyberpolice.mps.gov.cn/" target="_self">继续访问</a></p>

    <div class="hr"></div>

    <h1>Urgent Security Warning!</h1>

    <h2>[The unofficial website, which USES cname hijack]</h2>

    <p><strong>WARNING:</strong> This domain is suspected to be held by scammers and is involved in fraudulent activities. It has been locked and is inaccessible by relevant cybersecurity authorities. To safeguard your financial security, please exit this website immediately!</p>

    <p>If you have any disputes related to this domain, please use WHOIS to query the domain’s registration details for contact information and report to the authorities by calling <strong>911</strong> for assistance.</p>

    <p class="strong">Emergency Contact: 911</p>

    <p>Information security agencies and officials are irresponsible for the loss of fake behavior!</p>

    <p>If you are committed to visiting, we will not be responsible for this.</p>

    <p><a href="https://www.911.gov/" target="_self">Continue Accessing</a></p>

</div>

<script>

    window.dataLayer = window.dataLayer || [];

    function gtag(){dataLayer.push(arguments);}

    gtag('js', new Date());
    // 加入谷歌分析,追踪有多少域名进行了恶意解析行为 G-xxx谷歌分析号

    gtag('config', 'G-xxx谷歌分析号');

</script>

</body>

</html>

页面展示效果:

1,可以追踪到恶意解析,以及相关数据

2,可以植入谷歌广告,访问量大还能获取到收益

3,可警告用户这是非官网

4,起到一定免责作用

5,避免品牌受损

6,利用这个警告页,可以去搜索引擎要求更新内容,这样子该域名就没有这个关键词了,后续所有排名将降低。

第三步。向各域名平台,ICANN机构等发送举报信息。

这里很多平台不一定有作为,但是尽量能去举报和发送的都去处理。尤其是谷歌等搜索引擎系统,各大互联网平台。这样子域名会被拉入到黑名单系统,后续就没有任何排名,以及被各平台拦截。

对于谷歌可以直接使用请求更新即可:

点击移除搜索结果 -> 选择 结果已过时我想请求刷新即可,这样子就不会影响到你的关键字

选择 : 刷新某个已更改的网页在google中的过期搜索结果

自动显示网址

其他各操作以及举报等,找到入口即可。这里不再过多叙述。

Comment

华计科技: 中华自主研发设计

华计科技为您提供咨询服务,IT技术支持和项目开发: (+86) 156 2654 0671

联系我们