Debian Codegraph @

modules/contrib/src/os_pingspam.c

raw
1 /*
2 * Copyright (c) 2005 William Pitcock, et al.
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * ping spammer thingy
6 */
7
8 #include "atheme-compat.h"
9
10 static const char *notices[] =
11 {
12 "Scanning for proxies.",
13 "Killing off bottlers.",
14 "LOL ok so like we are teh SKANZ0RZING j00 becuz well like OMG deze bots r h3r3 an liek they are FL00DING!!#@! ignore plz",
15 "gaben",
16 "Please ignore this notice.",
17 "Scanning for warez.",
18 "All your pr0n are belong to us!",
19 "Move over! This is the police!",
20 "This notice brought to you by Burma-Shave.",
21 "They're coming...",
22 ":)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(:",
23 "lolz!",
24 "<Hikaru> your a pagan",
25 "* Ads needs to shower soon",
26 "<Hik`Coding> Don't make me get Yakuza on you",
27 "beu fails it",
28 "BAN KAI~!$"
29 };
30
31 static const char *phrases[] =
32 {
33 "",
34 " please-ignore",
35 " proxy scan",
36 " ignore me",
37 " <3 neostats",
38 };
39
40 static bool spamming = false;
41
42 static void
43 pingspam(user_t *u)
44 {
45 user_t *sptr;
46 mowgli_node_t *n;
47 int i;
48 service_t *svs;
49
50 if((svs = service_find("global")) != NULL)
51 for(i = 0;i < 6;i++)
52 notice(svs->me->nick, u->nick, "%s", notices[rand() % sizeof(notices) / sizeof(char*)]);
53
54 MOWGLI_ITER_FOREACH(n, me.me->userlist.head)
55 {
56 sptr = n->data;
57 msg(sptr->nick, u->nick, "\001PING %ld%s\001",
58 time(NULL),
59 phrases[rand() % sizeof(phrases) / sizeof(char*)]
60 );
61 }
62 }
63
64 static void
65 user_add_hook(hook_user_nick_t *data)
66 {
67 user_t *u;
68
69 u = data->u;
70 if (u == NULL)
71 return;
72 if (is_internal_client(u))
73 return;
74 if (spamming)
75 pingspam(u);
76 }
77
78 static void
79 os_cmd_pingspam(sourceinfo_t *si, int parc, char *parv[])
80 {
81 char *target = parv[0];
82 user_t *u;
83
84 if(!target)
85 {
86 command_fail(si, fault_badparams, "Usage: \2PINGSPAM\2 <target>");
87 return;
88 }
89
90 if(!(u = user_find_named(target)))
91 {
92 command_fail(si, fault_nosuch_target, "\2%s\2 is not on the network", target);
93 return;
94 }
95
96 pingspam(u);
97 command_success_nodata(si, "\2%s\2 has been pwned.", target);
98 logcommand(si, CMDLOG_ADMIN, "PINGSPAM: \2%s\2", target);
99 }
100
101 static void
102 os_cmd_autopingspam(sourceinfo_t *si, int parc, char *parv[])
103 {
104 char *mode = parv[0];
105
106 if(!mode)
107 {
108 command_success_nodata(si, "Auto-pingspam is currently \2%s\2", spamming ? "ON" : "OFF");
109 return;
110 }
111
112 if(strcasecmp(mode, "on") == 0 || atoi(mode))
113 {
114 spamming = true;
115 command_success_nodata(si, "Auto-pingspam is now \2ON\2");
116 }
117 else
118 {
119 spamming = false;
120 command_success_nodata(si, "Auto-pingspam is now \2OFF\2");
121 }
122 }
123
124 static command_t os_pingspam = {
125 .name = "PINGSPAM",
126 .desc = N_("Spam a user with pings from every service, plus some bonus notices."),
127 .access = PRIV_OMODE,
128 .maxparc = 1,
129 .cmd = &os_cmd_pingspam,
130 .help = { .path = "contrib/pingspam" },
131 };
132
133 static command_t os_autopingspam = {
134 .name = "AUTOPINGSPAM",
135 .desc = N_("Spam connecting users with pings from every service, plus some bonus notices (setting)."),
136 .access = PRIV_ADMIN,
137 .maxparc = 1,
138 .cmd = &os_cmd_autopingspam,
139 .help = { .path = "contrib/autopingspam" },
140 };
141
142 static void
143 mod_init(module_t *const restrict m)
144 {
145 service_named_bind_command("operserv", &os_pingspam);
146 service_named_bind_command("operserv", &os_autopingspam);
147
148 hook_add_event("user_add");
149 hook_add_user_add(user_add_hook);
150 }
151
152 static void
153 mod_deinit(const module_unload_intent_t ATHEME_VATTR_UNUSED intent)
154 {
155 service_named_unbind_command("operserv", &os_pingspam);
156 service_named_unbind_command("operserv", &os_autopingspam);
157
158 hook_del_user_add(user_add_hook);
159 }
160
161 SIMPLE_DECLARE_MODULE_V1("contrib/os_pingspam", MODULE_UNLOAD_CAPABILITY_OK)