|
| 1 | +""" |
| 2 | +Copyright (c) 2014, Sam Dodrill |
| 3 | +All rights reserved. |
| 4 | +
|
| 5 | +This software is provided 'as-is', without any express or implied |
| 6 | +warranty. In no event will the authors be held liable for any damages |
| 7 | +arising from the use of this software. |
| 8 | +
|
| 9 | +Permission is granted to anyone to use this software for any purpose, |
| 10 | +including commercial applications, and to alter it and redistribute it |
| 11 | +freely, subject to the following restrictions: |
| 12 | +
|
| 13 | + 1. The origin of this software must not be misrepresented; you must not |
| 14 | + claim that you wrote the original software. If you use this software |
| 15 | + in a product, an acknowledgment in the product documentation would be |
| 16 | + appreciated but is not required. |
| 17 | +
|
| 18 | + 2. Altered source versions must be plainly marked as such, and must not be |
| 19 | + misrepresented as being the original software. |
| 20 | +
|
| 21 | + 3. This notice may not be removed or altered from any source |
| 22 | + distribution. |
| 23 | +""" |
| 24 | + |
| 25 | +NAME="Autocloak" |
| 26 | +DESC="Manages automatic cloaks for bouncers" |
| 27 | + |
| 28 | +from structures import * |
| 29 | +from utils import * |
| 30 | + |
| 31 | +import md5 |
| 32 | + |
| 33 | +global client |
| 34 | + |
| 35 | +def initModule(cod): |
| 36 | + global client |
| 37 | + |
| 38 | + client = makeService(cod.config["autocloak"]["nick"], cod.config["autocloak"]["user"], |
| 39 | + cod.config["autocloak"]["host"], cod.config["autocloak"]["gecos"], |
| 40 | + cod.getUID()) |
| 41 | + |
| 42 | + cod.clients[client.uid] = client |
| 43 | + |
| 44 | + cod.sendLine(client.burst()) |
| 45 | + cod.log("Bursting autocloak client", "!!!") |
| 46 | + |
| 47 | + cod.s2scommands["EUID"].append(handleCloak) |
| 48 | + |
| 49 | + cod.sendLine(client.join(cod.channels[cod.config["etc"]["snoopchan"]])) |
| 50 | + |
| 51 | +def destroyModule(cod): |
| 52 | + global client |
| 53 | + |
| 54 | + cod.sendLine(client.quit()) |
| 55 | + cod.clients.pop(client.uid) |
| 56 | + |
| 57 | +def rehash(): |
| 58 | + pass |
| 59 | + |
| 60 | +def handleCloak(cod, line): |
| 61 | + #Check user's IP in the autocloak list |
| 62 | + if line.args[6] in cod.config["autocloak"]["list"]: |
| 63 | + cloaksuffix = cod.config["autocloak"]["list"][line.args[6]] |
| 64 | + ident = line.args[4] |
| 65 | + |
| 66 | + m = md5.new() |
| 67 | + m.update(ident) |
| 68 | + |
| 69 | + unique = m.hexdigest()[:16] |
| 70 | + |
| 71 | + host = "%s.%s" % (unique.upper(), cloaksuffix) |
| 72 | + |
| 73 | + cod.sendLine(":%s CHGHOST %s %s" % (client.uid, line.args[7], host)) |
| 74 | + cod.notice(line.args[7], "Your vhost has been uniquely randomized as a part of a policy set by your BNC host and network staff.", client) |
| 75 | + |
0 commit comments