annotate mod_version_spoofed/mod_version_spoofed.lua @ 6403:13c61a068c71

mod_pubsub_serverinfo: Include hostname in default pubsub node name This change ensures that every host publishes to a unique node by default, which is important when publishing info about multiple hosts. The old default node name was "serverinfo" The new default node name is in the format "serverinfo/example.com" where example.com is automatically replaced by the publishing host's name. This affects existing deployments in the following ways: - If you already configured pubsub_serverinfo_node explicitly in your config, then nothing will change, your current configuration will still be used. - If you did not specify it in your config (i.e. used the default) then the module will switch to publishing to the new node. If your configuration is correct this shouldn't be noticed, because the new node will automatically be created and configured by the module. If you want, you can clean up the old 'serverinfo' node using: prosodyctl shell pubsub delete_node pubsub.example.com serverinfo
author Matthew Wild <mwild1@gmail.com>
date Wed, 11 Feb 2026 09:40:30 +0000
parents cc42d3548452
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6270
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
1 -- Prosody IM
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
2 -- Copyright (C) 2025-2025 Nicholas George
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
3 -- Original mod_version copyright
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
4 -- Copyright (C) 2008-2010 Matthew Wild
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
5 -- Copyright (C) 2008-2010 Waqas Hussain
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
6 --
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
7 -- This project is MIT/X11 licensed. Please see the
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
8 -- COPYING file in the source package for more information.
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
9 --
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
10 -- This is a fork of mod_version that implements the ability to spoof server information.
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
11 -- This should replace mod_version in the modules_enabled list. Do not load both as they
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
12 -- will conflict.
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
13
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
14 local st = require "util.stanza";
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
15
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
16 module:add_feature("jabber:iq:version");
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
17
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
18 local query = st.stanza("query", {xmlns = "jabber:iq:version"})
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
19 :text_tag("name", module:get_option_string("server_name", "Prosody"))
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
20 :text_tag("version", module:get_option_string("server_version", prosody.version));
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
21
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
22 if not module:get_option_boolean("hide_os_type") then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
23 local platform;
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
24 local spoofed_platform = module:get_option_string("server_platform", nil);
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
25 if not spoofed_platform then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
26 if os.getenv("WINDIR") then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
27 platform = "Windows";
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
28 else
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
29 local os_version_command = module:get_option_string("os_version_command");
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
30 local ok, pposix = pcall(require, "prosody.util.pposix");
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
31 if not os_version_command and (ok and pposix and pposix.uname) then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
32 local uname, err = pposix.uname();
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
33 if not uname then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
34 module:log("debug", "Could not retrieve OS name: %s", err);
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
35 else
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
36 platform = uname.sysname;
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
37 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
38 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
39 if not platform then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
40 local uname = io.popen(os_version_command or "uname");
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
41 if uname then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
42 platform = uname:read("*a");
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
43 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
44 uname:close();
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
45 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
46 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
47 if platform then
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
48 platform = platform:match("^%s*(.-)%s*$") or platform;
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
49 query:text_tag("os", platform);
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
50 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
51 else
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
52 query:text_tag("os", spoofed_platform);
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
53 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
54 end
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
55
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
56 module:hook("iq-get/host/jabber:iq:version:query", function(event)
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
57 local origin, stanza = event.origin, event.stanza;
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
58 origin.send(st.reply(stanza):add_child(query));
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
59 return true;
cc42d3548452 mod_version_spoofed: add new evil module
Nicholas George <wirlaburla@worlio.com>
parents:
diff changeset
60 end);