Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Nicely done. I appreciate your sense of humor. I realize you are joking when you say "replacing apache". Here's my attempt to deobfuscate it.

<SPOILER FOLLOWS>
# Modified a little to get the spacing right # and to use strict. # Some of this code looks like an example from # The Perl Cookbook by Tom Christiansen p.606 use strict; use IO::Socket; # Specify the server home directory, port, # and "page found" status my $home_dir="/tmp/"; my $port=1280; my $response="HTTP/1.1 200 OK\nServer: "; $response .= "PimpHTTPD\nConnection: close\n\n"; my $file_name; # Open a listener server on the port we specified my $server=new IO::Socket::INET->new(Listen=>1, LocalPort=>$port)||die("Can't listen: $!"); # Accept equests from the client while(my $client=$server->accept()) { # Read client requests into scalar while(my $request=<$client>) { # Parse the file name to read in from the # GET request $file_name=$1 if($request=~/^GET\s+(\S+)/i); # Request is finished if there is a blank line last if($request=~/^\r?\s*\r?$/); } # Unescape escaped characters in the file name $file_name=~s/%([0-9A-Fa-f][0-9A-Fa-f])/hex($1)/g; # Ignore requests that try to read from the # parent directory. if($file_name =~ /\.\.\//) { $response="INVALID URL" } else { # It's a good file name-- let's read it. # Open the in file and add it to the response. if(open(INFILE,"<$home_dir$file_name")) { while(<INFILE>) { $response.=$_; } close(INFILE); } else { # If we can't open the file, show the error. $response="$home_dir$file_name:$!" } } # Output the response to the client. print $client $response; # Close the client. $client->close; }
-- Zeno - Barcelona Perl Mongers http://barcelona.pm.org http://www.javamonks.org

In reply to Re: Replace Apache by zeno
in thread Replace Apache by Weathros

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-06-29 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (96 votes). Check out past polls.

    Notices?