-
Notifications
You must be signed in to change notification settings - Fork 0
/
emailusers.php
398 lines (354 loc) · 17.2 KB
/
emailusers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
// PHP Spam Poison (phpwpoison).
// 2004-2005 - Mario A. Valdez-Ramirez.
// 2017 - Robert Ian Hawdon.
// You can contact Mario A. Valdez-Ramirez
// by email at [email protected] or paper mail at
// Olmos 809, San Nicolas, NL. 66495, Mexico.
// Robert Ian Hawdon:
// https://robertianhawdon.me.uk/
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or (at
// your option) any later version.
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// ==================================
// Start of configuration options...
// ==================================
$pwp_scriptname = ""; // Name of the parent script. THIS MUST BE SET BEFORE USING.
$pwp_standalone = true; // If the script is included in another, set to false.
$pwp_minemails = 5; // Minimum emails per page.
$pwp_maxemails = 30; // Maximum emails per page.
$pwp_maxlevel = 15; // Deepest level to create links.
$pwp_word_file = "pwpwords.txt"; // Source word file, relative to calling script.
$pwp_total_words = 99204; // Lines in source word file.
$pwp_cache_file = "cache.txt"; // Cache word file, relative to calling script.
$pwp_cached_words = 300; // Words to extract from source word list.
$pwp_minword_len = 4; // Minimum length of words to use.
$pwp_maxword_len = 10; // Maximum length of words to use.
$pwp_cache_ttl = 7200; // Time before the cache file is rebuild (in seconds).
$pwp_minsleeptime = 10; // Minimum time to sleep before finishing page (in seconds).
$pwp_maxsleeptime = 30; // Maximum time to sleep before finishing page (in seconds).
$pwp_mintitle_words = 2; // Minimum words to use as title.
$pwp_maxtitle_words = 5; // Maximum words to use as title.
$pwp_mindummy_words = 10; // Minimum words to use in paragraphs.
$pwp_maxdummy_words = 25; // Maximum words to use in paragraphs.
$pwp_pre_dummypar = 2; // Numbers of paragraphs before email list.
$pwp_post_dummypar = 4; // Numbers of paragraphs after email list.
$pwp_presalt_user = 0; // Salt characters to add at the beginning of username in emails.
$pwp_postsalt_user = 2; // Salt characters to add at the ending of username in emails.
$pwp_presalt_dom = 2; // Salt characters to add at the beginning of domains in emails.
$pwp_postsalt_dom = 0; // Salt characters to add at the ending of domains in emails.
$pwp_numsalt_ratio = 10; // One out of X times a number is used as salt (0 = never).
$pwp_internat_ratio = 3; // One out of X times an international domain is used.
$pwp_link_firstratio = $pwp_maxdummy_words; // One out of each X words is converted to a link in first paragraphs.
$pwp_link_lastratio = $pwp_mindummy_words; // One out of each X words is converted to a link in last paragraphs.
$pwp_title_insertrate = 5; // Percentage of the time that the title is used as body text.
$pwp_symbol_ratio = 10; // One out of each X words is appended a punctuation symbol.
$pwp_use_spammer_list = false; // If we will include the spammer database as source of emails.
$pwp_spammer_file = "spammers.txt"; // Spammer list file, relative to calling script.
$pwp_spammer_ratio = 5; // One out of X emails a spammer email will be used.
$pwp_spammer_generate = true; // If random emails will be generated using spammer domains.
$pwp_spammer_genratio = 2; // One out of X times the spammer email is generated.
// The following variables contain the appearance of the generated page, use them to match the appearance of your website.
$pwp_html_preheader = "<html><head><title>\n";
$pwp_html_postheader = "</title><meta NAME=\"ROBOTS\" CONTENT=\"NOINDEX, NOFOLLOW\">\n</head>\n<body>\n";
$pwp_html_footer = "</body></html>\n";
// ==================================
// End of configuration options...
// ==================================
$pwp_script_version = "1.3.0";
function fpwp_getenv($name, $default) {
$env = getenv("PWP_" . $name);
if (!$env) {
return $default;
}
return $env;
}
// Get config from environment vars or leave as previously set above, if absent.
$pwp_scriptname = fpwp_getenv("SCRIPTNAME", $pwp_scriptname);
// Get the URL and split it, finding the target and the level...
$pwp_req_uri = $_SERVER["REQUEST_URI"];
if (!$pwp_req_uri) {
$pwp_req_uri = $HTTP_SERVER_VARS["REQUEST_URI"];
if (!$pwp_req_uri) {
$pwp_req_uri = $_ENV["REQUEST_URI"];
if (!$pwp_req_uri) {
$pwp_req_uri = getenv("REQUEST_URI");
}
else $pwp_req_uri = "";
}
}
$pwp_url_array = explode ("/", $pwp_req_uri);
$pwp_target = $pwp_url_array[(count ($pwp_url_array) - 1)];
if ($pwp_target == $pwp_scriptname) {
$pwp_target = "";
}
else {
unset ($pwp_url_array[(count ($pwp_url_array) - 1)]);
}
$pwp_level = preg_replace("/[^[:digit:]_]/", "", $pwp_target);
if (is_numeric ($pwp_level)) { $pwp_level = abs ($pwp_level); } else { $pwp_level = 0; }
$pwp_target = preg_replace("/[^[:alpha:]_]/", "", $pwp_target);
$pwp_scripturl = implode ("/", $pwp_url_array);
// Set some constants...
$pwp_common_symbols = array (".", ".", ".", ".", ",", ",", ",", ",", ",", ",", ",", ";", ";", ";", "?", "!");
$pwp_end_symbols = array (".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "?", "!");
// Based on stats at http://www.webhosting.info/registries/global_stats/
$pwp_tldomains = array ("com", "com", "com", "com", "com", "com", "com", "com", "com", "com", "com",
"com", "com", "com", "com", "com", "com", "com", "com", "com", "com", "com",
"com", "com", "com", "com", "com", "com", "com", "com", "com", "com", "com",
"com", "com", "com", "com", "com", "com", "com", "com", "com", "com", "com",
"net", "net", "net", "net", "net", "net", "net", "net",
"net", "net", "net", "net", "net", "net", "net", "net",
"org", "org", "org", "org",
"biz", "biz", "info", "info", "edu", "gov");
// Based on stats at http://www.webhosting.info/domains/country_stats/
$pwp_ctldomains = array ("de", "de", "de", "de", "de", "de", "de", "de", "de", "de",
"de", "de", "de", "de", "de", "de", "de", "de", "de", "de",
"uk", "uk", "uk", "uk", "uk", "uk", "uk", "uk", "uk", "uk",
"uk", "uk", "uk", "uk", "uk", "uk", "uk", "uk", "uk", "uk",
"ca", "ca", "ca", "ca", "ca", "ca", "ca", "ca", "ca", "ca",
"ca", "ca", "ca", "ca", "ca", "ca", "ca", "ca", "ca", "ca",
"fr", "fr", "fr", "fr", "fr", "fr", "fr", "fr", "fr", "fr",
"cn", "cn", "cn", "cn", "cn", "cn", "cn", "cn", "cn", "cn",
"kr", "kr", "kr", "kr", "kr", "kr", "kr", "kr", "kr", "kr",
"au", "au", "au",
"jp", "jp", "jp",
"es", "es", "es",
"it", "it", "it",
"hk", "hk", "hk",
"nl", "nl", "nl",
"in", "in", "in",
"dk", "dk", "dk",
"tr", "tr", "tr",
"at", "at", "se", "se", "ky", "ky", "ch", "ch", "no", "no",
"fi", "be", "mx", "ru", "br", "vg", "pl", "th", "ie",
"cz", "sg", "ar", "my", "il", "ir", "nz", "tw", "pt", "za",
"bg", "id", "ro", "mc", "ua", "ve");
// Read the source word list, extract some words and store them in the cache file.
function fpwp_fill_wordcache ($sourcefilename, $targetfilename, $totalsourcewords, $totaltargetwords, $ttl) {
global $pwp_minword_len, $pwp_maxword_len;
if ($totalsourcewords > $totaltargetwords) {
$wordsratio = round ($totalsourcewords / $totaltargetwords);
}
else {
$wordsratio = 1;
}
if (($sourcefilename) && ($targetfilename)) {
if ((file_exists ($targetfilename) && is_writable ($targetfilename) && ((time () - filemtime ($targetfilename)) > $ttl)) || !file_exists ($targetfilename)) {
if (file_exists ($sourcefilename) && is_readable ($sourcefilename)) {
$sourcefile = fopen ($sourcefilename, "rb");
$targetfile = fopen ($targetfilename, 'wb');
}
$ignorecount = 1;
$randomline = rand (1, $wordsratio);
if (($sourcefile) && ($targetfile)) {
while ($wordcontent = fgets ($sourcefile, 1024)) {
if ($ignorecount == $randomline) {
$wordcontent = preg_replace("/[^[:alpha:]_]/", "", strtolower ($wordcontent)) . "\n";
if ((strlen ($wordcontent) >= $pwp_minword_len) && (strlen ($wordcontent) <= $pwp_maxword_len)) {
fwrite ($targetfile, $wordcontent);
}
}
elseif ($ignorecount >= $wordsratio) {
$ignorecount = 1;
$randomline = rand (1, $wordsratio);
}
$ignorecount++;
}
@fclose ($targetfile);
@fclose ($sourcefile);
}
}
}
}
// Load the words from the cache file to memory.
function fpwp_load_words ($sourcefilename, $pagetitle, $insertrate) {
if (file_exists ($sourcefilename) && is_readable ($sourcefilename)) {
$wordlist = file ($sourcefilename);
$tinserts = round (count ($wordlist) / (100 / $insertrate));
if (count ($wordlist) > 0) {
foreach ($wordlist as $key => $value) { $wordlist[$key] = trim ($value); }
}
if ($pagetitle) {
for ($wc = 0; $wc < $tinserts; $wc++) { $wordlist[] = $pagetitle; }
}
return $wordlist;
}
else {
return false;
}
}
// Load the spammer emails from the spammers file to memory.
function fpwp_load_spammers ($sourcefilename) {
if (file_exists ($sourcefilename) && is_readable ($sourcefilename)) {
$spammerlist = file ($sourcefilename);
return $spammerlist;
}
else {
return false;
}
}
// Add a short random string to the beginning or end of a given string.
function fpwp_add_salt ($textstr, $presalt, $postsalt) {
global $pwp_numsalt_ratio;
$presaltstr = "";
$postsaltstr = "";
if ($presalt > 0) {
for ($sc = 1; $sc <= $presalt; $sc++) {
if (rand (1, $pwp_numsalt_ratio) == $pwp_numsalt_ratio) {
$presaltstr .= chr (rand (ord ("0"), ord ("9")));
}
else {
$presaltstr .= chr (rand (ord ("a"), ord ("z")));
}
}
}
if ($postsalt > 0) {
for ($sc = 1; $sc <= $postsalt; $sc++) {
if (rand (1, $pwp_numsalt_ratio) == $pwp_numsalt_ratio) {
$postsaltstr .= chr (rand (ord ("0"), ord ("9")));
}
else {
$postsaltstr .= chr (rand (ord ("a"), ord ("z")));
}
}
}
return ($presaltstr . $textstr . $postsaltstr);
}
// Convert to uppercase the first letter of each sentence.
function fpwp_ucfirst ($string) {
global $pwp_end_symbols;
if ($string) {
$strarray = explode (" ", $string);
$totwords = count ($strarray);
$restart = false;
for ($cw = 0; $cw < $totwords; $cw++) {
if ($restart) {
$strarray[$cw] = ucfirst ($strarray[$cw]);
}
$restart = in_array (substr ($strarray[$cw], -1), $pwp_end_symbols);
}
$strarray[0] = ucfirst ($strarray[0]);
return (implode (" ", $strarray));
}
return ("");
}
// Create a paragraph using the word list, optionally create links within.
function fpwp_build_dummytext ($totalwords, &$wordlist, $linkratio, $title) {
global $pwp_common_symbols, $pwp_end_symbols, $pwp_scripturl, $pwp_symbol_ratio, $pwp_level, $pwp_maxlevel;
if (count ($wordlist) > 1) {
shuffle ($wordlist);
if ($totalwords > count ($wordlist)) {
$totalwords = count ($wordlist);
}
$newlist = array_rand ($wordlist, $totalwords);
$newtext = "";
foreach ($newlist as $word) {
if ((rand (1, $linkratio) == $linkratio) && ($wordlist[$word] != $title) && ($pwp_level < $pwp_maxlevel)) {
$insertpos = rand (1, strlen ($wordlist[$word])) - 1;
$newlink = substr ($wordlist[$word], 0, $insertpos) . ($pwp_level + 1) . substr ($wordlist[$word], $insertpos, strlen ($wordlist[$word]));
$newlink = $pwp_scripturl . "/" . $newlink;
$newtext .= "\n<a href=\"" . $newlink . "\">" . $wordlist[$word] . "</a>";
}
else {
$newtext .= $wordlist[$word];
}
if (rand (1, $pwp_symbol_ratio) == $pwp_symbol_ratio) {
$newtext .= $pwp_common_symbols[array_rand ($pwp_common_symbols, 1)];
}
$newtext .= " ";
}
$newtext = substr ($newtext, 0, -1);
if (in_array (substr ($newtext, -1), $pwp_end_symbols)) {
$newtext = substr ($newtext, 0, -1);
}
$newtext = fpwp_ucfirst ($newtext);
$newtext .= $pwp_end_symbols[array_rand ($pwp_end_symbols, 1)];
return $newtext;
}
}
// Create a domain name.
function fpwp_build_domain (&$wordlist) {
global $pwp_tldomains, $pwp_ctldomains, $pwp_internat_ratio;
$newdomain = $wordlist[array_rand ($wordlist, 1)];
$newdomain .= "." . $pwp_tldomains[array_rand ($pwp_tldomains, 1)];
if (rand (1, $pwp_internat_ratio) == $pwp_internat_ratio) {
$newdomain .= "." . $pwp_ctldomains[array_rand ($pwp_ctldomains, 1)];
}
return $newdomain;
}
// Create an username.
function fpwp_build_username (&$wordlist) {
return $wordlist[array_rand ($wordlist, 1)];
}
// Extract domain name from email address.
function fpwp_extract_domain ($email) {
return strstr ($email, "@");
}
// Create an email link.
function fpwp_build_maillist ($totalmails, &$wordlist, &$spammerlist) {
global $pwp_presalt_user, $pwp_postsalt_user, $pwp_presalt_dom, $pwp_postsalt_dom, $pwp_spammer_ratio, $pwp_spammer_generate, $pwp_spammer_genratio;
echo "<p>\n";
for ($ce = 1; $ce < $totalmails; $ce++) {
$newemail = "";
if ($spammerlist && (rand (1, $pwp_spammer_ratio) == $pwp_spammer_ratio)) {
if ($pwp_spammer_generate && (rand (1, $pwp_spammer_genratio) == $pwp_spammer_genratio)) {
$newuser = fpwp_add_salt (fpwp_build_username ($wordlist), $pwp_presalt_user, $pwp_postsalt_user);
$newdom = fpwp_extract_domain (trim ($spammerlist[array_rand ($spammerlist, 1)]));
if ($newdom) {
$newemail = $newuser . $newdom;
}
}
else {
$newemail = trim ($spammerlist[array_rand ($spammerlist, 1)]);
}
}
else {
$newuser = fpwp_add_salt (fpwp_build_username ($wordlist), $pwp_presalt_user, $pwp_postsalt_user);
$newdom = fpwp_add_salt (fpwp_build_domain ($wordlist), $pwp_presalt_dom, $pwp_postsalt_dom);
$newemail = $newuser . "@" . $newdom;
}
if ($newemail) {
echo "<a href=\"mailto:" . $newemail . "\">" . $newemail . "</a><br>\n";
}
}
echo "</p>\n";
}
//#####################################
// Main program.
//#####################################
if ($pwp_scriptname) {
if ($pwp_standalone) { echo $pwp_html_preheader . $pwp_target . $pwp_html_postheader; }
fpwp_fill_wordcache ($pwp_word_file, $pwp_cache_file, $pwp_total_words, $pwp_cached_words, $pwp_cache_ttl);
$pwp_words = fpwp_load_words ($pwp_cache_file, $pwp_target, $pwp_title_insertrate);
if ($pwp_use_spammer_list) {
$pwp_spammers = fpwp_load_spammers ($pwp_spammer_file);
}
else {
$pwp_spammers = false;
}
if ($pwp_words) {
echo "<h1>" . fpwp_build_dummytext ($pwp_mintitle_words + rand (0, ($pwp_maxtitle_words - $pwp_mintitle_words)), $pwp_words, 0, $pwp_target) . "</h1>\n";
for ($pc = 1; $pc <= $pwp_pre_dummypar; $pc++) {
echo "<p>" . fpwp_build_dummytext ($pwp_mindummy_words + rand (0, ($pwp_maxdummy_words - $pwp_mindummy_words)), $pwp_words, $pwp_link_firstratio, $pwp_target) . "</p>\n";
}
echo fpwp_build_maillist ($pwp_minemails + rand (0, ($pwp_maxemails - $pwp_minemails)), $pwp_words, $pwp_spammers);
if ($pwp_maxsleeptime > 0) {
sleep ($pwp_minsleeptime + rand (0, ($pwp_maxsleeptime - $pwp_minsleeptime)));
}
for ($pc = 1; $pc <= $pwp_post_dummypar; $pc++) {
echo "<p>" . fpwp_build_dummytext ($pwp_mindummy_words + rand (0, ($pwp_maxdummy_words - $pwp_mindummy_words)), $pwp_words, $pwp_link_lastratio, $pwp_target) . "</p>\n";
}
}
if ($pwp_standalone) { echo $pwp_html_footer; }
}
else echo "<p>DON'T FORGET TO CONFIGURE THE SCRIPT!</p>";
?>