//flex table opened by JP

Click to See Complete Forum and Search --> : Apache running a .exe from cgi-bin?


kpm547
07-14-2005, 12:51 AM
I'm having problems running a .exe file from apache 2. It wants to download the file instead of execute the file. I have apache installed ona Widnows 2000 server. The file is in the cgi-bin. The file works on another webserver I have running. That server is Xitami.

Anyone know how to get apache to execute the exe file?

CompGeek01
07-14-2005, 09:42 AM
Talk about insecure :( I didn't think webservers could/should even do this. I'm not even sure why you'd need to!

fishybawb
07-14-2005, 09:54 AM
Have you set up the ScriptAlias in your configuration file? There should be a line like


ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"


in your httpd.conf file.

I used to write guestbooks in C and then run them from cgi-bin - I'm not sure how less secure it is. Then I learnt Perl ;)

CompGeek01
07-14-2005, 10:00 AM
That is true, I just would worry about having execution privs with a server that might have upload access. Buffer overflows/vulnerabilities are a lot easier in C than Perl :D

kpm547
07-14-2005, 11:27 AM
Yes I have set up the alias in the httpd.conf file.

The reason we are using a exe file is the program is written in C. We have been using it for years and now what a more robust server, but can't get it to work on apache. It may be insecure, but we don't have the time to totally rewrite the programs in perl. (Partly because we don't know Perl).

Upon furth notice, the file is actually executed as we have log as well, but it doesn't print anything to the browser like it supposed to.

Anymore suggestions on how to get this to work? I've searched google and tried a few things, but just won't work. Thanks. :)

ScaryBinary
07-14-2005, 01:56 PM
You might need to tweak or add an AddHandler (http://httpd.apache.org/docs-2.0/mod/mod_mime.html#addhandler) section, like:AddHandler cgi-script .exeThis will tell apache that it should execute .exe files like a normal CGI file.

kpm547
07-14-2005, 04:17 PM
You might need to tweak or add an AddHandler (http://httpd.apache.org/docs-2.0/mod/mod_mime.html#addhandler) section, like:AddHandler cgi-script .exeThis will tell apache that it should execute .exe files like a normal CGI file.

I've already got that as well. It seems to actually execute the file, but the html output is not sent to the client. Instead it asks to download. We have a log file that goes with the program and it writes to the log file but not to the browser. Very wierd.

Anymore suggestions?

ScaryBinary
07-14-2005, 09:09 PM
Do you have the source code?

I've never dealt with using C as a server-side script. I don't know how you'd dump output to the browser (for example, would just writing using "stdio" work, or is there a library or something missing?).

...so, just so I understand (sorry, it's been a rough day), the browser attempts to download the output of the exe file (and not the exe file itself)?

kpm547
07-15-2005, 11:32 AM
Do you have the source code?

I've never dealt with using C as a server-side script. I don't know how you'd dump output to the browser (for example, would just writing using "stdio" work, or is there a library or something missing?).

...so, just so I understand (sorry, it's been a rough day), the browser attempts to download the output of the exe file (and not the exe file itself)?

No, the browser tries to download the .exe file, but the file has been executed, but did not sent the html to the browser.

As for the source code, I didn't program it myself. My co-worker did. Unfortunately he doesn't want to give out the source code as he's worried about it being used elsewhere. Anyway, he said that the program uses a print statment to print html. Beyond that I have no idea how it works. All I know is it worked on a different server, but not on apache.