executing CGI programs using C++
Results 1 to 4 of 4

Thread: executing CGI programs using C++

  1. #1
    Member
    Join Date
    Sep 2007
    Posts
    51

    Lightbulb executing CGI programs using C++

    I am currently trying to write a simple web server program in C++. The only problem that I have come across, so far, is that I would like my web server to be able to execute CGI (Common Gateway Interface) programs, but I'm not sure how to accomplish this.

    I know that I need to be able to execute the CGI program and some how redirect the output of this program back to the network connection. I am thinking along the lines of using the exec system calls (execlp, execvp etc.) in some way.

    If anyone could offer me some ideas, I would greatly appreciate it.


    Thanks in advance,

    user0182

  2. #2
    Super Moderator
    Know-it-All Master Beaver

    Join Date
    Jan 2003
    Posts
    3,914
    Hey Hey,

    First you have to decide what your CGI programs are... and what CGI languages you support.

    CGI = Common Gateway Interface as you mentioned, however many people assume that CGI == PERL... this is not the case. CGI describes any application that performs server-side scripting.

    Your Web Server could execute perl directly... and return the output... Or it could execute php, python or almost any other language.

    Your CGI's could actually be other compiled C++ programs. Unfortunately I don't think there's an answer for "How do I execute CGI programs"... at least not until you define a spec.

    Questions to Answer:
    1. What languages will I support?
    2. Will I fully support the language, or will I support a subset?
    3. Will I implement the vendor supplied method of processing the language, or will I write my own processor.
    4. Ultimate question... Do you want it to be a CGI, or do you just want to support the language?

    Now let's look at #4 a bit. You could read into the SAPI/ISAPI implementation of PHP (as an example language) and implement the SAPI module, alternately you could implement the executable as a CGI (technically a CGI)... In the end both will product the same result. the choice is yours.

    Let me know if I've left you more confused than you already were, or if I've cleared things up.

    Peace,
    HT
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".

  3. #3
    Member
    Join Date
    Sep 2007
    Posts
    51
    thanks for your reply. at this point I am only concerning myself with CGI which has been written in other compiled languages (i.e. C).

    regards,

    user0182

  4. #4
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    A CGI program is just that, a program, an executable if you will. The variables like ?page=12 etc. will be fed to it as arguments and the program gets executed. The program's output (stdout) will be fed back to the (web) client connected to it.

    It doesn't matter which language was used to create that executable. The only thing that matters are the arguments passed to it and it's output.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

Similar Threads

  1. Executing external programs x86 assembly/Windows?
    By el-half in forum Code Review
    Replies: 4
    Last Post: June 23rd, 2004, 09:17 AM
  2. Many programs in RAM
    By slick8790 in forum Miscellaneous Security Discussions
    Replies: 12
    Last Post: December 13th, 2003, 09:34 AM
  3. Newbies, list of many words definitions.
    By -DaRK-RaiDeR- in forum Newbie Security Questions
    Replies: 9
    Last Post: December 14th, 2002, 08:38 PM
  4. Solaris Hardening
    By R0n1n in forum *nix Security Discussions
    Replies: 3
    Last Post: November 20th, 2002, 02:20 PM
  5. Denail Of Service FAQ
    By Ennis in forum The Security Tutorials Forum
    Replies: 4
    Last Post: November 15th, 2001, 07:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •