I'm trying to run a cgi executable file through a html form as in this code:
<html>
<head>
<title>CGI Form</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<form action="C:\WWW\cgi-bin\y.exe" method="get">
<input type="text" name="string1" />
<input type="text" name="string2" />
<input type="text" name="string3" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
And here it is the cgi code compiled as y.exe and saved in the path specified in the action:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char *buffer, string1[100], string2[100], string3[100], merged[300];
buffer = getenv("QUERY_STRING");
if(buffer == NULL)
{
printf("<p>Error: No data</p>");
}
else
{
if(sscanf(buffer, "string1=%s&string2=%s&string3=%s", string1, string2, string3) != 3)
{
printf("Data missing!");
}
else
{
strcpy(merged, string1);
strcat(merged, string2);
strcat(merged, string3);
printf("Content-Type: text/html\n\n");
printf("<html>\n"
"<head>\n"
"<title>CGI Form Merge Strings</title>\n"
"</head>\n"
"<body>\n"
"Merged string is: %s\n"
"</body>\n"
"</html>\n", merged);
}
}
return 0;
}
I've tried to reconfigure the httpd.conf file with this:
AddHandler cgi-script .exe
ScriptAlias /cgi-bin/ "C:/WWW/cgi-bin/"
and
<Directory "C:/WWW/cgi-bin">
AllowOverride All
Options +ExecCGI
Options FollowSymLinks
Require all granted
AddHandler cgi-script .cgi
AddHandler cgi-script .exe
</Directory>
However this does not fix the problem.