PeterDaveHello/nrd-list-downloader

GitHub: PeterDaveHello/nrd-list-downloader

自动从 WhoisDS.com 下载并汇总新注册域名列表的 Shell 脚本,便于配合 DNS 拦截工具提升网络安全。

Stars: 69 | Forks: 20

# nrd-list-downloader nrd-list-downloader 是一个 shell 脚本,可以自动下载、解压并汇总来自 [WhoisDS.com](https://www.whoisds.com/newly-registered-domains) 的新注册域名 (NRD) 列表。汇总后的 NRD 列表可以轻松应用于 [Pi-Hole][Pi-Hole]、[AdGuard Home][AdGuard Home] 和 [Blocky][Blocky] 等流行的域名拦截工具,以增强您的网络安全。 ## 什么是新注册域名 (NRD)? 新注册域名 (NRD) 是指最近刚刚注册的域名。它们通常具有风险,因为可能尚未投入实际运营,并且经常被用于恶意目的。例如,NRD 可能是 [停放域名][Domain Parking Wikipedia],其中包含广告或待售,这是域名注册商或经销商默认提供的。黑客经常利用 NRD 来传播恶意软件、托管钓鱼网站以及从事其他恶意活动。了解 NRD 带来的潜在威胁对于加强网络安全措施至关重要。 ## 为什么我们需要 NRD 列表? NRD 列表可以与 Pi-Hole、AdGuard Home 或 Blocky 等 DNS 拦截工具配合使用。通过整合 NRD 列表,这些工具可以与其他[威胁主机列表][threat-hostlist]一起,强化您的网络安全措施。 NRD 有时具有风险,因为黑客喜欢利用它们来传播恶意软件、钓鱼网站、网络犯罪或从事其他恶意活动。许多用于有害目的的 NRD 都是短命的,这使得传统的基于安全情报的防护在应对这些威胁时效果不佳。虽然也有合法网站使用 NRD,但拦截所有 NRD 可能会导致误报。然而,对良性 NRD 的拦截只会持续很短的时间。权衡利弊之后,这样做是值得的。 一些知名的 DNS 提供商(如 Cisco Umbrella、Akamai ETP (Enterprise Threat Protector) 和 NextDNS)也提供了在其服务中拦截 NRD 的选项。 ## 依赖项 此脚本使用了几个常见的命令行工具。请确保您已安装以下工具: - `mkdir`:用于创建目录 - `wc`:用于统计行数和单词数 - `base64`:用于编码和解码 Base64 数据 - `curl`:用于从远程 URL 下载内容 - `cat`:用于连接并显示文件内容 - `zcat`:用于读取 gzip 压缩数据 - `mktemp`:用于创建临时文件 - `date`:用于在系统中显示日期和时间 - `tr`:用于字符转换,例如删除字符 - `realpath`:用于规范化文件路径名 - `dirname`:用于提取文件所在的目录名 如果缺少其中任何工具,您通常可以使用系统的包管理器(例如 `apt`、`yum` 或 `pacman`)来安装它们。 ## 使用说明 首先,克隆此仓库或下载 `nrd-list-downloader.sh` 脚本,并授予其执行权限。然后,在终端中运行该脚本: ``` ~/nrd-list-downloader $ ./nrd-list-downloader.sh ``` 默认情况下,脚本会下载并汇总过去 7 天的免费 NRD 数据,将每天的数据保存在 `daily/free/` 中,并将其合并为一个单独的文件 `nrd-7days-free.txt`: ``` ~/nrd-list-downloader $ ./nrd-list-downloader.sh You are using nrd-list-downloader to download NRD(Newly Registered Domain) list ... NRD list of the last 7 will be downloaded. Download and decompress 2022-09-21 data ...137691 domains found. Download and decompress 2022-09-22 data ...55127 domains found. Download and decompress 2022-09-23 data ...187397 domains found. Download and decompress 2022-09-24 data ...118922 domains found. Download and decompress 2022-09-25 data ...60806 domains found. Download and decompress 2022-09-26 data ...82211 domains found. Download and decompress 2022-09-27 data ...103078 domains found. ... NRD list for the last 7 days saved to nrd-7days-free.txt, 745232 domains found. ``` 要指定自定义的数据时间跨度,请设置 `$DAY_RANGE` 变量,例如 `14`: ``` ~/nrd-list-downloader $ DAY_RANGE=14 ./nrd-list-downloader.sh You are using nrd-list-downloader to download NRD(Newly Registered Domain) list ... NRD list of the last 14 will be downloaded. Download and decompress 2022-09-14 data ...141531 domains found. Download and decompress 2022-09-15 data ...139059 domains found. Download and decompress 2022-09-16 data ...129216 domains found. Download and decompress 2022-09-17 data ...119194 domains found. Download and decompress 2022-09-18 data ...105884 domains found. Download and decompress 2022-09-19 data ...86455 domains found. Download and decompress 2022-09-20 data ...106169 domains found. daily/free/2022-09-21 existed with 137691 domains, skip the download and decompress process ... daily/free/2022-09-22 existed with 55127 domains, skip the download and decompress process ... daily/free/2022-09-23 existed with 187397 domains, skip the download and decompress process ... daily/free/2022-09-24 existed with 118922 domains, skip the download and decompress process ... daily/free/2022-09-25 existed with 60806 domains, skip the download and decompress process ... daily/free/2022-09-26 existed with 82211 domains, skip the download and decompress process ... daily/free/2022-09-27 existed with 103078 domains, skip the download and decompress process ... NRD list for the last 14 days saved to nrd-14days-free.txt, 1572740 domains found. ``` 结果将保存在 `nrd-14days-free.txt` 中。脚本不会重新下载 `daily/free/` 目录中已存在的每日数据,从而节省时间并避免冗余下载。 我们建议定期(每天或每周)运行 nrd-list-downloader,以保持您的 NRD 列表处于最新状态,并最大限度地发挥域名拦截工具的效用。 ### 付费账户支持 此脚本还支持 WhoisDS.com 上的付费账户以访问高级数据。要使用付费账户,请设置以下两个变量: - `PAID_WHOISDS_USERNAME` - `PAID_WHOISDS_PASSWORD` 您可以通过直接修改脚本,或者在运行脚本时将其作为环境变量传递来设置用户名和密码: ``` ~/nrd-list-downloader $ PAID_WHOISDS_USERNAME="johndoe@unknownexample.net" PAID_WHOISDS_PASSWORD="RAND.mPA$$W0rd" ./nrd-list-downloader.sh ``` 付费数据将存储在 `daily/paid/` 目录中,并汇总到 `nrd-7days-paid.txt` 文件内。 该脚本不包含检查这些凭据有效性的机制,因此请确保提供的信息准确无误。 ## NRD 风险参考 以下是一些说明为什么 NRD 具有风险的参考资料。您可以查看这些资料,自行决定是否对其进行拦截。 - Newly Registered Domains: Malicious Abuse by Bad Actors - Unit 42 - Palo Alto Networks - - Block newly-registered domains to reduce security threats - The State of Security - - Should We Blocklist Newly Registered Domains? - Uptycs - - Why blocking NRDs ? - The Newly Registered Domains category | Artica Wiki - 探索这些文章及其他资料,以更好地了解与 NRD 相关的风险,并为您的组织确定最合适的应对方案。 ## 许可证 GPL-3.0 (GNU GENERAL PUBLIC LICENSE Version 3)
标签:Cutter, DNS过滤, Shell脚本, 域名管理, 威胁情报, 开发者工具, 系统运维, 黑名单