ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/contrib/os_pingspam.C
Revision: 1.6
Committed: Sat Sep 22 14:27:27 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +5 -4 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# Content
1 /**
2 * os_pingspam.C: ping spammer thingy
3 *
4 * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5 * Rights to this code are as documented in COPYING.
6 *
7 *
8 * Portions of this file were derived from sources bearing the following license:
9 * Copyright © 2005 William Pitcock, et al.
10 * Rights to this code are as documented in doc/pod/license.pod.
11 *
12 * $Id: os_pingspam.C,v 1.5 2007-09-16 18:54:43 pippijn Exp $
13 */
14
15 #include "atheme.h"
16 #include <libermyth.h>
17 #include "servers.h"
18 #include <ermyth/module.h>
19 #include <util/random.h>
20
21 static char const rcsid[] = "$Id: os_pingspam.C,v 1.5 2007-09-16 18:54:43 pippijn Exp $";
22
23 REGISTER_MODULE ("operserv/pingspam", false, "The Ermyth Team <http://ermyth.xinutec.org>");
24
25 char const * const notices[] = {
26 "Scanning for proxies.",
27 "Killing off bottlers.",
28 "LOL ok so like we are teh SKANZ0RZING j00 becuz well like OMG deze bots r h3r3 an liek they are FL00DING!!#@! ignore plz",
29 "gaben",
30 "Please ignore this notice.",
31 "Scanning for warez.",
32 "All your pr0n are belong to us!",
33 "Move over! This is the police!",
34 "This notice brought to you by Burma-Shave.",
35 "They're coming...",
36 ":)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(:",
37 "lolz!",
38 "<Hikaru> your a pagan",
39 "* Ads needs to shower soon",
40 "<Hik`Coding> Don't make me get Yakuza on you",
41 "beu fails it",
42 "BAN KAI~!$"
43 };
44
45 char phrases[][15] = {
46 "",
47 " please-ignore",
48 " proxy scan",
49 " ignore me",
50 " <3 neostats",
51 };
52
53 void pingspam (user_t *u);
54 static void os_cmd_pingspam (sourceinfo_t *si, int parc, char *parv[]);
55 static void os_cmd_autopingspam (sourceinfo_t *si, int parc, char *parv[]);
56
57 command_t const os_pingspam = { "PINGSPAM", "Spam a user with pings from every service, plus some bonus notices.", PRIV_OMODE, 1, os_cmd_pingspam };
58 command_t const os_autopingspam = { "AUTOPINGSPAM", "Spam connecting users with pings from every service, plus some bonus notices (setting).", PRIV_ADMIN, 1, os_cmd_autopingspam };
59
60 int spamming;
61 E cmdvec os_cmdtree;
62
63 static void
64 user_add_hook (user_t *u)
65 {
66 if (spamming)
67 pingspam (u);
68 }
69
70 static void
71 os_cmd_pingspam (sourceinfo_t *si, int parc, char *parv[])
72 {
73 char *target = parv[0];
74 user_t *u;
75
76 if (!target)
77 {
78 notice (opersvs.nick, si->su->nick, "Usage: \2PINGSPAM\2 <target>");
79 return;
80 }
81
82 if (!(u = user_find_named (target)))
83 {
84 notice (opersvs.nick, si->su->nick, "\2%s\2 is not on the network", target);
85 return;
86 }
87
88 pingspam (u);
89 notice (opersvs.nick, si->su->nick, "\2%s\2 has been pwned.", target);
90 snoop ("PINGSPAM: \2%s\2 -> \2%s\2", get_oper_name (si), target);
91 }
92
93 static void
94 os_cmd_autopingspam (sourceinfo_t *si, int parc, char *parv[])
95 {
96 char *mode = parv[0];
97
98 if (!mode)
99 {
100 notice (opersvs.nick, si->su->nick, "Auto-pingspam is currently \2%s\2", spamming ? "ON" : "OFF");
101 return;
102 }
103
104 if (strcasecmp (mode, "on") == 0 || atoi (mode))
105 {
106 spamming = 1;
107 notice (opersvs.nick, si->su->nick, "Auto-pingspam is now \2ON\2");
108 }
109 else
110 {
111 spamming = 0;
112 notice (opersvs.nick, si->su->nick, "Auto-pingspam is now \2OFF\2");
113 }
114 }
115
116 void
117 pingspam (user_t *u)
118 {
119 user_t *sptr;
120 node_t *n;
121 int i;
122
123 if (*globsvs.nick)
124 for (i = 0; i < 6; i++)
125 notice (globsvs.nick, u->nick, notices[gen_rand32 () % sizeof (notices) / sizeof (char *)]);
126
127 LIST_FOREACH (n, me.me->userlist.head)
128 {
129 sptr = static_cast<user_t *> (n->data);
130 phandler->privmsg (sptr->nick, u->nick, "\001PING %d%s\001", NOW, phrases[gen_rand32 () % sizeof (phrases) / sizeof (char *)]);
131 }
132 }
133
134 bool
135 _modinit (module *m)
136 {
137 spamming = 0;
138
139 os_cmdtree << os_pingspam;
140 os_cmdtree << os_autopingspam;
141
142 user_t::callback.add.attach (user_add_hook);
143
144 return true;
145 }
146
147 void
148 _moddeinit ()
149 {
150 os_cmdtree >> os_pingspam;
151 os_cmdtree >> os_autopingspam;
152 user_t::callback.add.detach (user_add_hook);
153 }