diff options
| author | 2019-09-02 12:47:13 +0100 | |
|---|---|---|
| committer | 2019-09-02 12:47:13 +0100 | |
| commit | 82bee70ca04d6d3e5e3a7fe102727c4925352314 (patch) | |
| tree | d3717e891b049ac75174e5209f09d42e328f256c | |
| parent | .upper() SASL mechanism name (diff) | |
| signature | ||
add mumble.py
| -rw-r--r-- | modules/mumble.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/mumble.py b/modules/mumble.py new file mode 100644 index 00000000..ce3638ca --- /dev/null +++ b/modules/mumble.py @@ -0,0 +1,33 @@ +import datetime, socket, struct +from src import ModuleManager, utils + +DEFAULT_PORT = 64738 + +class Module(ModuleManager.BaseModule): + @utils.hook("received.command.mumble") + @utils.kwarg("min_args", 1) + @utils.kwarg("help", "Get user and bandwidth stats for a mumble server") + @utils.kwarg("usage", "<server>[:<port>]") + def mumble(self, event): + server, _, port = event["args_split"][0].partition(":") + if port: + if not port.isdigit(): + raise utils.EventError("Port must be numeric") + port = int(port) + else: + port = DEFAULT_PORT + + ping_packet = struct.pack(">iQ", 0, datetime.datetime.now().microsecond) + s = socket.socket(type=socket.SOCK_DGRAM) + s.sendto(ping_packet, (server, port)) + + pong_packet = s.recv(24) + pong = struct.unpack(">bbbbQiii", pong_packet) + + ping = (datetime.datetime.now().microsecond - pong[4])/1000 + users = pong[5] + max_users = pong[6] + bandwidth = pong[7]/1000 # kbit/s + + event["stdout"].write("%s: %d/%d users, %.1fms ping, %dkbit/s bandwidth" + % (server, users, max_users, ping, bandwidth)) |
