Mercurial > prosody-modules
annotate mod_version_spoofed/mod_version_spoofed.lua @ 6319:04c3273cb81f
mod_auth_cyrus: Add empty 'profile' table to SASL handler objects
This is for compatibility with Prosody's built-in util.sasl objects.
A SASL profile table usually includes methods supported by the backend, which
can be used by SASL mechanism handlers to perform operations (such as testing
the password). It also optionally contains a 'cb' field with channel binding
method handlers.
The Cyrus backend doesn't support channel binding, and doesn't have the same
concept of auth backend methods (it handles all that internally, and Prosody
has no insight or control over it).
Thus, we create an empty profile which informs Prosody that the SASL handler
does not support any of the auth or channel binding methods. Some features
will not work, but they didn't work anyway. This just makes it explicit.
This fixes a traceback in mod_sasl2_fast, which expected SASL handlers to
always contain a 'profile' field.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 04 Sep 2025 10:14:46 +0100 |
| parents | cc42d3548452 |
| children |
| 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); |
