· 6 years ago · Oct 23, 2019, 07:12 PM
1__module_name__ = "EUT"
2__module_version__ = "0.9.anal.full.nelson"
3__module_description__ = "Emp user tools"
4
5# To use a browser other than the default one, set the path here
6# and set CUSTOM_BROWSER = True
7
8BROWSER = "C:\PATH\TO\BROWSEROFCHOICE.EXE"
9CUSTOM_BROWSER = False
10
11# Hostname checking
12CHECK_HOST = True # Set to False to disable
13MAX_HOSTS = 50
14HOST_CHANNELS_REG = r"^#(empornium-help)$" # Channels to check
15
16# API settings
17API_TOKEN = 'aa61e52db4fbd4ab0f87aac94a4a496f88c590c0d19238f4c15e9e4ffb7f81ab'
18API_URL = 'https://fuckitall.pervwerks.de/api/user'
19
20#---------------------------------------------------------------
21
22import hexchat
23import re
24import webbrowser
25import datetime
26# import requests
27from subprocess import call
28from collections import OrderedDict
29
30hosts = OrderedDict()
31queue = []
32
33def usearchemp(word, word_eol, userdata):
34 nick = re.sub(r"(disabled_|nologin_|pwned_)", "", word[1])
35
36 if CUSTOM_BROWSER:
37 call([BROWSER, "https://www.empornium.me/user.php?action=search&search=" + nick])
38 else:
39 webbrowser.open("https://www.empornium.me/user.php?action=search&search=" + nick)
40 return hexchat.EAT_ALL
41
42def join_msg(word, word_eol, userdata):
43 try:
44 nick, channel, host, account = word
45 except ValueError:
46 nick, channel, host = word
47
48 if re.search(r"emporniumme", nick, re.I):
49 return
50
51 # Hostname checking channels
52 if CHECK_HOST is True and re.search(HOST_CHANNELS_REG, channel, re.I):
53 # TODO: improve nick (remove disabled_)
54 check_host(host, nick, channel)
55
56 if re.search(r"empornium-help", channel, re.I):
57 # Directly add the user into the queue
58 add_to_queue(nick)
59
60 # Filter nick's prefixes
61 nick = re.sub(r"(?P<status>(?:disabled|nologin|pwned)?)_?(?P<nick>.*)", "\\g<nick> \x02(\\g<status>)", nick)
62 nick = re.sub(r"\(\)", "", nick)
63
64 context = hexchat.get_context()
65 context.prnt("\00310https://www.empornium.me/user.php?action=search&search=" + nick)
66
67 # Handle API info
68 # get_api_info(nick)
69
70# def get_api_info(nick):
71# context = hexchat.get_context()
72# try:
73# nick = 'TestingUser4'
74# url = API_URL + '?username=' + nick + '&api_token=' + API_TOKEN
75# resp = requests.get(url)
76# if resp.status_code == 200:
77# data = resp.json()
78# username = data['username']
79# ratio = data['ratio']
80# last_seen = data['last_seen']
81# class_name = data['class_name']
82# credits = data['credits']
83# info = "Username: " + username + " (" + class_name + ")" + ", last seen: " + last_seen + ", ratio: " + str(ratio) + ", credits: " + str(credits)
84# context.prnt("\00302" + info)
85# else:
86# context.prnt("\00304API call failed, got status " + resp.status_code)
87# except Exception as e:
88# context.prnt("\00304Exception:" + str(e))
89
90def part_msg(word, word_eol, userdata):
91 try:
92 nick = word[0]
93 except ValueError:
94 return
95
96 remove_from_queue(nick)
97
98def check_host(host, username, channel):
99 parts = host.split('@')
100
101 # Abort if weird hostname
102 if len(parts) != 2:
103 return False
104
105 hostname = parts[1]
106
107 if hostname in hosts:
108 sameUser = False
109 for dict in hosts[hostname]:
110 if dict['username'] == username:
111 sameUser = True
112 break
113 if not sameUser:
114 warn_host(username, hosts[hostname])
115 log_host(hostname, username, channel)
116 else:
117 log_host(hostname, username, channel)
118
119
120def add_to_queue(username):
121 if username not in queue:
122 queue.append(username)
123
124
125def remove_from_queue(username):
126 if username in queue:
127 queue.remove(username)
128
129
130def next_in_queue(word, word_eol, userdata):
131 count = len(queue)
132
133 if count:
134 msg = "\00313Next user in queue is " + queue[0] + " (" + str(count) + " users in the queue)"
135 else:
136 msg = "\00313There's no one in your queue! Lucky..."
137
138 hexchat.get_context().prnt(msg)
139
140def queue_call(word, word_eol, userdata):
141 try:
142 nick = word[1]
143 except ValueError:
144 return
145
146 blocked_msg = " Hi. You've been temporarily blocked because your password is a security threat."
147 blocked_msg += " Before going any further we need to verify you first. Where were you living when your account was created and who your internet provider?"
148 blocked_msg += " If you think you know the email address you used to register the account please include that as well."
149
150 announce_msg = ", a staff member has started a private conversation with you."
151
152 context = hexchat.get_context()
153 context.command("msg " + nick + blocked_msg)
154 context.command("bs say #empornium-help " + nick + announce_msg)
155
156 if nick in queue:
157 queue.remove(nick)
158
159def done_in_queue(word, word_eol, userdata):
160 if len(queue):
161 nick = queue[0]
162 hexchat.get_context().prnt("\00313Removed " + nick + " from the queue.")
163 del queue[0]
164 if len(queue):
165 hexchat.get_context().prnt("\00313Next user is " + queue[0])
166 else:
167 hexchat.get_context().prnt("\00313There's no one in your queue! Lucky...")
168
169def find_in_queue(word, word_eol, userdata):
170 try:
171 nick = word[1]
172 except ValueError:
173 return
174
175 try:
176 pos = str(queue.index(nick) + 1)
177 total = str(len(queue))
178 hexchat.get_context().prnt("\00313User " + nick + " is at position " + pos + " in queue (" + total + " users)")
179 except ValueError:
180 hexchat.get_context().prnt("\00313Could not find user in the queue...")
181
182def log_host(hostname, username, channel):
183 hosts[hostname] = []
184 hosts[hostname].append({'username': username, 'channel': channel, 'time': datetime.datetime.now().strftime('%d, %b %Y - %H:%M:%S')})
185 # If we've reached max hosts, we remove the oldest one
186 if len(hosts) > MAX_HOSTS:
187 hosts.popitem(False)
188
189def warn_host(username, host):
190 line = username + " shared the same hostname with: "
191 for u in host:
192 line = line + u['username'] + " (" + u['time'] + ", " + u['channel'] + ") | "
193 context = hexchat.get_context()
194 context.prnt("\00304" + line)
195
196def debug_len_hosts(word, word_eol, userdata):
197 context = hexchat.get_context()
198 context.prnt("There are currently " + str(len(hosts)) + " hosts stored.")
199
200def priv_with(word, word_eol, userdata):
201 nick = word[1]
202 stripnick = re.sub(r"(disabled_|nologin_|pwned_)", "", nick)
203 context = hexchat.get_context()
204 context.command("say " + nick + ", I'm going to PM you. Look for the tab with my name.")
205 hexchat.command("msg " + nick + " Hello " + stripnick + "!")
206 return hexchat.EAT_ALL
207
208def email_req(word, word_eol, userdata):
209 nick = word[1]
210 stripnick = re.sub(r"(disabled_|nologin_|pwned_)", "", nick)
211 context = hexchat.get_context()
212 context.command("say " + nick + ", Look for the tab with my name on it. Click on "
213 "that and post the email address you used to "
214 "register your acccount.")
215 hexchat.command("msg " + nick + " Please post it here " + stripnick)
216 return hexchat.EAT_ALL
217
218def inactive_msg(word, word_eol, userdata):
219 prefix = ""
220 if len(word) > 1:
221 prefix = word_eol[1].strip() + ", "
222
223 context = hexchat.get_context()
224 context.command("say " + prefix + "About how long has it been since you last logged in?")
225 return hexchat.EAT_ALL
226
227def pwned_msg (word, word_eol, userdata):
228 nick = word[1]
229 stripnick = re.sub(r"(disabled_|nologin_|pwned_)", "", nick)
230 context = hexchat.get_context()
231 context.command("say " + nick + ", I'm going to PM you. Look for the tab with my name.")
232 hexchat.command("msg " + nick + " Hi " + stripnick + ", you've been temporarily blocked because your password is a security threat. "
233 "Before going any further we need to verify you first. Where were you living when your account was created and who your internet provider? "
234 "If you think you know the email address you used to register the account please include that as well. ")
235 return hexchat.EAT_ALL
236
237def speedtest_msg(word, word_eol, userdata):
238 prefix = ""
239 if len(word) > 1:
240 prefix = word_eol[1].strip() + ", "
241
242 context = hexchat.get_context()
243 context.command("say " + prefix + "go to http://www.speedtest.net and click "
244 "[BEGIN TEST]. After it has finished click [Share this "
245 "result] and copy paste provided URL here.")
246 return hexchat.EAT_ALL
247
248def goodbye_msg(word, word_eol, userdata):
249 prefix = ""
250 if len(word) > 1:
251 prefix = word_eol[1].strip() + ", "
252
253 context = hexchat.get_context()
254 context.command("say " "No Problem. Welcome back to empornium. Make sure you're familiar "
255 "with the rules. To keep your account active you need to login "
256 "regularly. 4 months for Apprentice and Perv, 1 year for "
257 "Good Perv and higher. If you don't need anything "
258 "else you can exit the help channel.")
259 return hexchat.EAT_ALL
260
261def hackfix_msg(word, word_eol, userdata):
262 prefix = ""
263 if len(word) > 1:
264 prefix = word_eol[1].strip() + ", "
265
266 context = hexchat.get_context()
267 context.command("say " "It appears that your account was hacked. I'm going to reset your password, passkey, and "
268 "authentication key. Because we are resetting your passkey you will have to update any EMP torrents "
269 "you are seeding with the new announce URL. When I am finished you will have to reset your password "
270 "with the 'Password Recovery Tool' and the email address you provided. Any questions?")
271 return hexchat.EAT_ALL
272
273def passreset_msg(word, word_eol, userdata):
274 prefix = ""
275 if len(word) > 1:
276 prefix = word_eol[1].strip() + ", "
277
278 context = hexchat.get_context()
279 context.command("say " "OK, your account is enabled. Go to the login page and perform a password recovery. Make sure you "
280 "choose a strong password that is unique to this site. We recommend using a password generator or checking "
281 "your password on this site, https://haveibeenpwned.com/Passwords. When all that is done you should be able "
282 "to login. Once you are logged in we recommend enabling Two Factor Authentication (2FA) to make sure your "
283 "account stays secure.")
284 return hexchat.EAT_ALL
285
286def unload_eut(userdata):
287 hexchat.prnt('Unloading Emp Usertools')
288 hexchat.command('MENU DEL "$NICK/Lookup on Emp"')
289 hexchat.command('MENU DEL "$NICK/Last Online"')
290 hexchat.command('MENU DEL "$NICK/Email"')
291 hexchat.command('MENU DEL "$NICK/Start PM"')
292 hexchat.command('MENU DEL "$NICK/PWNED"')
293 hexchat.command('MENU DEL "$NICK/Speedtest"')
294 hexchat.command('MENU DEL "$NICK/Hackfix"')
295 hexchat.command('MENU DEL "$NICK/Pass Reset"')
296 hexchat.command('MENU DEL "$NICK/Goodbye"')
297
298
299hexchat.hook_unload(unload_eut)
300hexchat.hook_print("Join", join_msg)
301hexchat.hook_print("Quit", part_msg)
302hexchat.hook_print("Part", part_msg)
303hexchat.hook_print("Part with Reason", part_msg)
304hexchat.hook_command("usearchemp", usearchemp, help="/usearchemp <nick> searches for given user on emp, strips disabled_ if necessary")
305hexchat.hook_command("priw", priv_with, help="/priw <nick> privs with user and tells them how to reply")
306hexchat.hook_command("mailr", email_req, help="/requests account email address and tells them how to reply")
307hexchat.hook_command("inca", inactive_msg, help="/inca <nick> prints template inactive user message, <nick> is optional. Blame Blank for the weird shortcut.")
308hexchat.hook_command("pwndi", pwned_msg, help="/Intro to pwned accounts.")
309hexchat.hook_command("stest", speedtest_msg, help="/stest <nick> prints template speed test message, <nick> is optional.")
310hexchat.hook_command("gdby", goodbye_msg, help="/gdby <nick> prints goodbye message to user, <nick> is optional. Blame Blank for the weird shortcut.")
311hexchat.hook_command("hkfx", hackfix_msg, help="/hkfx <nick> sends fix message for hacked accounts, <nick> is optional.")
312hexchat.hook_command("pswrd", passreset_msg, help="/pswrd <nick> sends password reset message for accounts, <nick> is optional.")
313hexchat.hook_command("dbhostslen", debug_len_hosts, help="/dbhostslen shows the current number of stored hostnames.")
314hexchat.hook_command("next", next_in_queue, help="/next shows the next user in the queue.")
315hexchat.hook_command("done", done_in_queue, help="/done removes the first user in the queue.")
316hexchat.hook_command("queuefind", find_in_queue, help="/queuefind <nick> find the user in the queue.")
317hexchat.hook_command("queuecall", queue_call, help="/queue_call <nick> process the user in the queue.")
318# hexchat.hook_command("queuerm", queuerm, help="/queuerm <nick> removes a user from the queue.")
319# hexchat.hook_command("queueadd", queueadd, help="/queueadd <nick> adds a user to the queue.")
320
321
322hexchat.command('MENU ADD "$NICK/Lookup on Emp" "usearchemp %s"')
323hexchat.command('MENU ADD "$NICK/Last Online" "inca %s"')
324hexchat.command('MENU ADD "$NICK/Email" "mailr %s"')
325hexchat.command('MENU ADD "$NICK/Start PM" "priw %s"')
326hexchat.command('MENU ADD "$NICK/PWNED" "pwndi %s"')
327hexchat.command('MENU ADD "$NICK/Speedtest" "stest %s"')
328hexchat.command('MENU ADD "$NICK/Hackfix" "hkfx %s"')
329hexchat.command('MENU ADD "$NICK/Pass Reset" "pswrd %s"')
330hexchat.command('MENU ADD "$NICK/Goodbye" "gdby %s"')
331
332hexchat.prnt('Emp Usertools Loaded.')