Status Hider
一款用于 Minecraft 服务器的网络安全模组,旨在将服务器爬虫拒之门外,防止其获取在线玩家数据、MotD(服务器描述)等信息,同时为你提供一些实用的功能。
为什么需要它
作为一名服务器管理员,我经常看到连接尝试的日志或未捕获的网络错误(例如反复出现的 connection reset by peer 消息),即使大规模封禁 IP 也无法解决这些问题。
但当我看到一条来自所谓 “ServerSeekerV2” 用户的连接尝试日志时,我终于忍无可忍并决定采取行动。该日志显然链接到了 ServerSeekerV2 软件,这彻底向我证明,确实有人无所事事地开发软件扫描网络以寻找 Minecraft 服务器,了解哪些服务器在线、何时在线,以及在特定时间段有哪些玩家在游玩,并存储和交叉比对生成的数据,以便可能用于恶意目的来完善玩家画像。
因此,我深入研究了整个服务器 Ping 和登录网络协议,并制作了这款模组,以增加服务器所有者及其玩家的隐私保护。
让我安静地获取数据
不。请尊重他人的隐私。
工作原理
文件
模组会存储有关连接尝试和已知玩家的一些信息。因此,会在服务器主目录中创建三个附加文件:
-
player_ip_cache:此文件存储有关至少成功加入过服务器一次的玩家的信息。每个条目(一行代表一个条目)包含玩家名称、UUID 以及该玩家已知 IP 地址的哈希列表。它使模组能够判断传入连接是否来自已知玩家,从而决定模组的大部分整体行为。你可以随意删除或修改条目,但如果某行无法被正确解析为有效条目,模组将在服务器控制台中报错。 -
request_metrics:此文件存储模组对各种 IP 地址的连接尝试、Ping 请求等的记忆。每行(条目)由 IP 哈希、来自该 IP 的 Ping 尝试次数、来自该 IP 的登录尝试次数组成,以及在该 IP 被封禁期间(如果已被封禁)的所有总体请求(登录或 Ping 等)数量。此文件对于自动封禁 IP 功能特别有用。 -
ip_whitelist:此文件存储允许 Ping 服务器的任何白名单 IP 的正则表达式列表,无论是否注册了玩家。这对于通常由第三方托管服务提供的服务器面板最为相关,这些面板定期运行服务器 Ping 以向服务器所有者提供分析数据。请注意,这不会影响玩家加入服务器的能力,他们不需要被列入白名单! -
ip_limit_list:此文件的格式与ip_whitelist相同。 仅在启用相应的游戏规则时才相关。 它确定了一系列模式,非本地源必须匹配这些模式才能建立与服务器的连接。
为什么使用 IP 哈希
模组尽可能使用 IP 哈希,这不仅是为了减少处理的数据量,也是为了减少任何可能访问服务器文件的第三方所暴露的信息。显然,考虑到服务器本身可以在日志中存储所有 IP 地址,这可能不是最相关的,但在服务器被入侵的情况下,直接暴露最少的玩家信息仍然是一个更好的立场。由于哈希允许产生一致且永远不会从同一初始值改变的结果,但不容易从结果反推出初始值,这是一种在一定程度上模糊潜在恶意因素数据的手段。
游戏规则
模组额外添加了一组自定义游戏规则,每个规则都允许控制其各种功能:
status_hider:reduced_ping_data:设置从谁那里减少 Ping 数据详情,例如隐藏已连接玩家列表、提供虚假的最大在线/最大玩家数以及隐藏 MotD。默认设置为未知或被封禁的 IP。status_hider:restrict_ping:切换是否切断来自未知 IP 地址(未链接到任何已经加入过服务器的玩家)的任何 Ping 请求。默认启用。status_hider:log_restricted_requests:切换是否在模组阻止 Ping 请求时记录日志。status_hider:enable_fancy_motd:切换 高级 MotD 功能。默认启用。status_hider:enforce_ip_ban:切换 真实 IP 封禁 功能。默认启用。status_hider:auto_ban_unknown_ip_after_requests:设置未知 IP 地址在自动被封禁之前可以进行多少次请求;将其设置为 0 以禁用此功能。接受 0 到 100 之间的值,默认为 10。status_hider:log_banned_ip_requests:设置应多久在服务器控制台中记录来自被封禁 IP 的请求。更具体地说,指示多少请求中应该记录一次(使用取模运算);1 意味着每次,20 意味着每 20 个请求中的 1 个;将其设置为 0 以禁用此功能。接受 0 到 100 之间的值,默认为 10。status_hider:limit_allowed_ip:切换是否限制连接到匹配 IP 允许列表模式的源(默认为false)。
真实 IP 封禁
在原版代码中,IP 封禁仅在玩家登录序列的非常后期进行检查,并且在处理 Ping 请求时被完全忽略。总而言之,这是一个相当薄弱的功能。
因此,这款模组将其提升到了一个新的水平,使得任何来自被封禁、未列入白名单(不匹配任何 ip-whitelist 条目)的 IP 地址的请求都不会得到任何响应。
因此,任何被封禁的 IP 在发起请求时都会处于挂起状态,就像服务器未运行一样。 此外,每收到来自封禁 IP 的第 10 次请求,服务器都会在控制台中记录该信息,以便让服务器管理员了解封禁该 IP 的相关性。
华丽的 MOTD
既然模组已经能够将玩家与其 IP 地址关联起来,我认为这也是一个利用 MOTD(服务器提示消息)来欢迎玩家的绝佳机会。
因此,如果服务器 MOTD 中包含 {username},它将被自动替换为匹配的玩家名称(如果有)。
此外,鉴于对全球 IP 地址使用方式的基本了解,我决定在模组内包含一个按国家/地区划分的已分配 IP 范围文件*,这使得模组能够猜测并替换 MOTD 中的任何 {country} 为可能匹配的国家/地区名称,如果未找到则替换为 unknown。
ip ranges file
这个文件相当精简,尽管体积仍然很大,这构成了模组 jar 包文件大小的主要部分。
将其打包在一起是为了避免使用第三方 API,因为这违背了本模组的两个目标:
- 不向第三方提供超出必要的数据。使用第三方 API 意味着允许它们知道哪些 IP 正在加入服务器,从而得知玩家的 IP。
- 不操纵或暴露超出必要的更多数据。大多数用于 IP 地址地理定位的第三方 API 远远超出了本模组的需求,并且意味着获取其他潜在恶意模组可以拦截的数据。虽然确实其他模组本身就可以获取所有这些相关信息,但不过度暴露这些信息只是一种良好的实践。
此文件由 ayra.ch 免费提供的数据生成,经过简化处理,以去除不可用的值并提高国家/地区名称的可读性。
命令
本模组添加了一个自定义命令,除了提供一种在运行时重新加载缓存或指标文件的方法外,还允许手动编辑文件的一些有用替代方案。(由于 IP 白名单文件不需要经常编辑,因此仅在服务器启动时加载)。其权限级别要求为 4(默认原版 OP 级别,可在 server.properties 文件中更改,每个玩家的值可以在原版的 ops.json 文件中修改)。
/status_hider forget <profileOrIP 允许服务器管理员在运行时从玩家 IP 缓存中删除条目。配置文件或 IP 可以是 IP 地址或玩家名称。任何与其中之一匹配的条目都将从 IP 缓存中完全移除。
/status_hider registerIP <ip> [<name>] 允许服务器管理员将特定 IP 注册到特定或自动生成的名称下。如果该 IP 已在现有条目中注册,则该命令不会执行任何操作。如果该名称已有条目存在,则提供的 IP 将添加到其中。否则,将创建一个带有随机 UUID 的新条目,并将其列为该 IP。
/status_hider reload [cache|metrics|whitelist|limit_list] 允许服务器管理员重新加载 IP 缓存文件、请求指标文件、白名单文件或限制列表文件,如果不指定则全部重新加载。(请注意,根据服务器的活动情况,您可能希望在修改文件后尽快运行此命令,因为运行时缓存或指标的任何更改都将完全覆盖文件)
/status_hider whitelist <pattern> 允许服务器管理员在不重启服务器的情况下向 IP 白名单添加新的 RegEx 条目。
/status_hider unwhitelist <pattern> 允许服务器管理员在不重启服务器的情况下从 IP 白名单中删除 RegEx 条目。(现有条目将为模式自动补全提供建议)
/status_hider test <ip> 允许服务器所有者了解 IP 的哈希值,正如它在缓存或指标文件中存储的那样。这对于细微的修改尤其相关,例如手动从玩家条目中删除特定的 IP。
Status Hider
A network security mod for Minecraft servers, meant to keep server crawlers out of your face and preventing them access to your online players data, MotD, and such, all the while adding some neat features for you to use.
Why
As a server administrator myself, I was often seeing logs of connection attempts, or uncaught network errors
(e.g. the recurrent connection reset by peer message), that even mass IP-banning simply couldn't help with.
But I finally ticked and decided to act when I saw a log of a supposed connection attempt from a 'ServerSeekerV2' user, which obviously linked to the ServerSeekerV2 software, proving to me once and for all that there were people out there that had nothing better to do that have software scanning the net for Minecraft servers, to know which ones are online and when, and who is playing on them at set times, storing and cross-comparing the generated data to possibly dress up players profiles that could then be used for ill intents.
So I took upon myself to dive into the whole server ping and login network protocol, and made this mod to allow more privacy to server owners and their players.
Let me get data in peace
No. Respect people's privacy.
How it works
Files
The mod stores some information about connection attempts and known players. As such, three additional files are created in the server's main directory:
-
player_ip_cache: this file stores some information about players that have properly joined the server at least once. Each entry (one line being one entry) holds the player name, UUID, and a list of the player's known IPs' hashes. It allows the mod to know if an incoming connection is from a known player, and thus determines most of the mod's overall behaviour. You may at will remove or modify an entry, but the mod will yell in the server's console if a line cannot be properly parsed in a valid entry. -
request_metrics: this file stores the mod's memory of connection attempts, ping requests, and alike, from various IP addresses. Each line (entry) is composed of the IP hash, the number of ping attempts from the IP, the number of login attempts from the IP, and the number of overall requests (login or ping alike) all the while the IP address has been banned - if it has been banned. This file is particularly useful for the auto-IP-ban feature. -
ip_whitelist: this file stores a list of RegEx expressions of any whitelisted IP that are allowed to ping the server regardless of registering a player or not. This is only truly relevant for server panels, most often provided by third-party hosting services, that regularly run server pings in order to provide some analytics to the server owners. Note that this does not impact players' ability to join the server, they do not need to be whitelisted! -
ip_limit_list: this file follows the same format as theip_whitelist. It is only relevant if the appropriate gamerule is enabled. It determines a collection of patterns that any non-local source must match in order to establish a connection to the server.
Why IP hashes
The mod deal with IP hashes as much as it can, not only in order to reduce the processed data, but also what it may expose to any potential third party that could get access to the server files. Obviously, considering servers can by themselves store any and all IP in the logs, it may not be the most relevant, but in the event of a server getting compromised, exposing the least player information directly remains a better standing point. Since hashing allows to produce consistent results that will never change from a same initial value, but not easily allow for figuring out the initial value from the result, it is a mean to somewhat obscure data from potentially malicious factors to some extent.
Gamerules
The mod additionally adds a set of custom gamerules, each allowing to control its various features:
status_hider:reduced_ping_data: sets from whom to reduce ping data details, such as hiding the connected players list, providing fake max online/max player counts, and hiding the MotD. Set to unknown or banned IPs by default.status_hider:restrict_ping: toggles whether to cut short to any ping request coming from an unknown IP address (not linked to any player that has already joined the server). Enabled by default.status_hider:log_restricted_requests: toggles whether to log when the mod blocks out a ping request.status_hider:enable_fancy_motd: toggles the fancy motd feature. Enabled by default.status_hider:enforce_ip_ban: toggles the real IP-ban feature. Enabled by default.status_hider:auto_ban_unknown_ip_after_requests: sets how many requests can an unknown IP address can make before automatically getting IP-banned ; set it to 0 in order to disable the feature. Accepts values between 0 and 100, set to 10 by default.status_hider:log_banned_ip_requests: sets how often should requests from banned IPs be logged in the server's console. More specifically, indicates out of how many requests should it be logged (uses modulo) ; 1 would mean every time, 20 would mean every one request out of 20 ; set it to 0 to disable the feature. Accepts values between 0 and 100, set to 10 by default.status_hider:limit_allowed_ip: toggles whether to restrict connections to sources matching the IP allow list patterns (defaults tofalse)
Real IP Ban
In the vanilla code, IP bans are only checked very late in the player login sequence, and completely ignored when it comes to ping requests. All in all, it is a rather weak feature.
As such, this mod takes it to a whole other level, and makes it so that any request whatsoever, from a banned, non-whitelisted (not matching any ip-whitelist entry) IP address, will purely and simply never be answered to.
Thus, any banned IP will be left hanging when making a request, as if the server was not running. Additionally, every 10 request from a banned-ip, the server will mention it in the console, so as to let server administrators know of the relevance of an IP ban.
Fancy MOTD
Since the mod already links up players and their IP adresses, I figured it also was an occasion to create a fancy way to welcome players, using the MotD.
As such, any {username} in the server's MotD will be automatically replaced with a matching known player name, if any.
Additionally, knowing some basics of how IP addresses are used across the globe, I decided to include inside the mod a
file of per-country allocated IP ranges*, which enables the mod to guess and replace any {country}
in the MotD with a possibly matching country name, or unknown if none was found.
ip ranges file
This file is a rather minimalistic file, albeit still pretty big, which makes up for most of the mod jar's file size.
It is a bundled file in order to avoid using a third party API, which would go against two of this mod's goals:
- Not giving more data than required to third parties. Using a third party API would mean allowing them to know what IPs are joining the server, and thus, what are the players' IPs.
- Not manipulating or exposing more data than needed. Most third party APIs for IP address geolocation go far and beyond the needs of this mod, and would imply fetching data that other, potentially malicious, mods, could intercept. And while it is true that other mods could already get all these information by themselves, not exposing it even more is but only a good practice.
This file was produced from data provided free of use by ayra.ch, after simplification, for both removing unusable values as well as for country name readability.
Command
This mod adds a custom command, that allows for some useful alternatives to manually editing files, besides also a way
to reload the cache or metrics file at runtime. (the ip whitelist file is only loaded at server startup, due to its
nature of not needing to be edited often). It has a permission level requirement of 4 (default vanilla OP level,
can be changed in the server.properties file, per-player values can be modified in the vanilla ops.json file)
/status_hider forget <profileOrIP allows server admins to remove an entry from the player IP cache at runtime.
The profile or IP can either be an IP address or a player's name. Any entry matching with either will be completely
removed from the IP cache.
/status_hider registerIP <ip> [<name>] allows server admins to register a specific IP under a specific or
auto-generated name. If the IP is already registered in an existing entry, the command will not do anything.
If an entry already exists for that name, then the provided IP will be added to it. Otherwise, a new entry with a
random UUID will be created with that IP listed for it.
/status_hider reload [cache|metrics|whitelist|limit_list] allows server admins to either reload the IP cache file,
the request metrics file, the whitelist file, the limit list file, or all if not specified.
(beware that depending on your server's activity, you may want to run the command quickly after modifying the file,
as any changes in the runtime cache or metrics will overwrite the file completely)
/status_hider whitelist <pattern> allows server admins to add a new RegEx entry to the IP whitelist without having
to restart the server.
/status_hider unwhitelist <pattern> allows server admins to remove a RegEx entry from the IP whitelist without
having to restart the server. (existing entries will be suggested for patter auto-completion)
/status_hider test <ip> allow server owners to know an IP's hash, as it is to be stored in the cache or metrics files.
This is especially relevant for minute modifications such as manually removing a specific IP from a player's entry.
下载 Status Hider
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Status Hider
下载 Status Hider
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Status Hider
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Status Hider
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Status Hider
下载 Status Hider
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Status Hider
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Status Hider
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Status Hider
修复 IP 地址被归入无名(-)国家范围的问题
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧