Annotate

mod_version_spoofed/mod_version_spoofed.lua @ 6325:6ea80b73d8f2

mod_http_oauth2: Only require redirect URIs when using grant types that need it In the Device flow, no redirect URI is used because the client instead receives responses by polling. It is therefore unnecessary to enforce a requirement that these include redirect URI(s).
author Kim Alvefur <zash@zash.se>
date Thu, 03 Jul 2025 15:42:42 +0200
parent 6315:cc42d3548452
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6315
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);