home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 49 / cda49.iso / VNULabs / BrownOrifice / BOHTTPD-0.2 / BOHTTPD.pm < prev    next >
Encoding:
Perl POD Document  |  2000-08-11  |  4.5 KB  |  165 lines

  1. package BOHTTPD;
  2. use base Exporter;
  3. use CGI;
  4.  
  5. @EXPORT = qw(is_ms is_ie show_info show_header show_footer show_warning html_escape);
  6.  
  7. sub is_ms() { $ENV{HTTP_USER_AGENT} =~ /win/i }
  8. sub is_ie() { $ENV{HTTP_USER_AGENT} =~ /MSIE/ }
  9.  
  10. my @mysql = qw</usr/local/mysql/bin/mysql -uroot -proot -B brownorifice>;
  11.  
  12. sub db_update {
  13.   my $q = shift;
  14.   my $qe = CGI::escape($q);
  15.  
  16.   system @mysql, '-e', qq( DELETE FROM filez WHERE url = "$qe" );
  17.   system @mysql, '-e', qq( INSERT INTO filez (url) VALUES ("$qe") );
  18.  
  19.   1
  20. }
  21.  
  22. sub db_search {
  23.   my $q = shift;
  24.   my $dt = shift || 600;
  25.   my $qe = CGI::escape($q);
  26.  
  27.   my $q = qq(
  28.     SELECT url FROM filez WHERE url REGEXP ".*$qe.*"
  29.       AND time >= (NOW() - $dt)
  30.       LIMIT 100
  31.   );
  32.  
  33.   open my $in, "@mysql -e '$q' |";
  34.   <$in>;
  35.   my @h = <$in>;
  36.   close $in;
  37.  
  38.   chomp, $_ = CGI::unescape($_) for @h;
  39.   @h
  40. }
  41.  
  42. sub show_header {
  43.   print q<
  44.     <html>
  45.       <head>
  46.         <title>Brown Orifice HTTPD</title>
  47.       </head>
  48.       <body bgcolor="#ffffff">
  49.       <link rel="stylesheet" href="BOHTTPD.css">
  50.   >;
  51.  
  52.   if (open my $fp, 'BOHTTPD_logo.html') {
  53.     print while <$fp>;
  54.     close $fp;
  55.   };
  56. }
  57.  
  58. sub show_info {
  59.   print q<
  60.     <h3>Brown Orifice HTTPD</h3>
  61.     <ul>
  62.  
  63.     <p><b>2000.08.08</b></p>
  64.     <p>
  65.       Mystic Mayhem <code><mystic@mad.scientist.com></code> and
  66.       others suggest a product
  67.       called <a href="http://www.zonelabs.com/">ZoneAlarm</a> to defend
  68.       against this vulnerability.  According to MM, it displays
  69.       the quite prophetic warning "Do you want Netscape Application
  70.       File to act as a server?" when BOHTTPD is attempting to initialize.
  71.     </p>
  72.  
  73.     <p><b>2000.08.07</b></p>
  74.     <p>
  75.        That nasty file truncation problem should be fixed in the live
  76.        version and the upcoming 0.2 release.  Happy serving!
  77.     </p>
  78.  
  79.     <p><b>2000.08.05</b></p>
  80.     <p>
  81.        Right now I'm at the internet cafe (Club I) at 850 Folsom in
  82.        San Francisco (between 4th and 5th street).  I'll be here until
  83.        2:00 a.m. showing demos to anybody interested.
  84.     </p>
  85.  
  86.     <p>
  87.       A guy showed up here and made BOHTTPD multithreaded.
  88.       This new functionality is live right now, but not available
  89.       for download until I get some version control set up.
  90.     </p>
  91.  
  92.     <p>
  93.       <i>WHOA!</i>  I just saw a Windows 2000 system that was still running
  94.       BOHTTPD even after Netscape had been apparently terminated.  Even
  95.       the "Task Manager" showed no trace.
  96.     </p>
  97.  
  98.     <p><b>2000.08.03</b></p>
  99.     <p>
  100.        I've discovered a pair of new capbilities in Java, one residing
  101.        in the Java core and the other in Netscape's Java distribution.
  102.        The first (exploited in
  103.        BOServerSocket and BOSocket) allows Java to open a server
  104.        which can be accessed by arbitrary clients.  The second
  105.        (BOURLConnection and BOURLInputStream) allows Java to access
  106.        arbitrary URLs, including local files.
  107.     </p>
  108.  
  109.     <p>
  110.       As a demonstration, I've written Brown Orifice HTTPD for Netscape
  111.       Communicator.  BOHTTPD is a browser-resident
  112.       web server and file-sharing tool that demonstrates these
  113.       two problems in Netscape 
  114.       Communicator. BOHTTPD will serve files from a directory
  115.       of your choice, and will also act as an HTTP/FTP proxy
  116.       server.
  117.     </p>
  118.  
  119.     <p>
  120.       Click the button below to launch BOHTTPD in your Netscape Browser.
  121.       To see a list of links to browsers currently running BOHTTPD, check out
  122.       <a href="BOHTTPD_spy.cgi">BOHTTPD Spy</a>.  To get a copy of
  123.       the Brown Orifice site and source code, go to the
  124.       <a href="BOHTTPD_download.cgi">download page</a>.
  125.     </p>
  126.      
  127.  
  128.     <p><i><a href="http://www.brumleve.com/resume.html">Dan Brumleve</a></i> <code><<a href="mailto:dan%2Bsecurity@brumleve.com">dan+security@brumleve.com</a>></code>, <code>2000-08-03</code></p>
  129.     </ul>
  130.     <hr>
  131.   >;
  132. }
  133.  
  134. sub show_warning {
  135.   print q<
  136.     <p><font size=+1 color=red><blink>WARNING:</blink></font>
  137.       Brown Orifice is a <font color=red>SECURITY HOLE</font>,
  138.       not a toy.  Files in the directory you specify are likely
  139.       to be downloaded by other people.  You must completely exit
  140.       Netscape in order
  141.       to turn it off.
  142.     </p>
  143.   >;
  144. }
  145.  
  146. sub show_footer {
  147.   print q<
  148.     <hr>
  149.     <p><i><a href="http://www.brumleve.com/resume.html">Dan Brumleve</a></i> <code><<a href="mailto:dan%2Bsecurity@brumleve.com">dan+security@brumleve.com</a>></code>, <code>2000-08-03</code></p>
  150.       </body>
  151.     </html>
  152.   >
  153. }
  154.  
  155. sub html_escape {
  156.   local $_ = shift;
  157.   s/&/&/g;
  158.   s/"/"/g;
  159.   s/</</g;
  160.   s/>/>/g;
  161.   $_
  162. }
  163.  
  164. 1;
  165.