Skip to content
This repository was archived by the owner on Feb 21, 2018. It is now read-only.

Commit 629cd21

Browse files
committed
services/autocloak: new module
This allows network administrators to have clients connecting from specific IP addresses have their vhost mangled so as to uniquely identify them in cases where a vhost is not set by services.
1 parent 2a22161 commit 629cd21

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

etc/config.json.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@
5959
"apikey": "asdfasdf"
6060
},
6161

62+
"autocloak": {
63+
"nick": "Gatekeeper",
64+
"user": "cloakbot",
65+
"host": "services.example.com",
66+
"gecos": "Automatic cloaker",
67+
68+
"list": {
69+
"127.45.123.69": "bnc.example.com"
70+
}
71+
},
72+
6273
"apikeys": {
6374
"worldweatheronline": "asdfasdfasdfasdf"
6475
}

modules/services/autocloak.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)