Personal challenge. Sensible or stupidity?

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Personal challenge. Sensible or stupidity?

Post by lonewolff »

I am thinking of challenging myself by creating an entire website from a single C++ executable (to run server side) and possibly a MySQL database.

Has this been done before, do you guys know?

What do you think of this idea?
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Post by syedhs »

It is already been done many times before and the C++ application should adhere to CGI specification or if in Windows IIS, you can take advantage of NSAPI/ISAPI (not really sure either or both which are applicable). The keyword here is C++ app should be able to retrieve query and form string and then replied back by writing the output for an example.

I think the reason of doing it this way is because you wanna protect the source code especially if your customer can host your web app int their server. And there is this benefit from better performance.

Regarding protecting the source code, web script language can be obfuscated, so there is no real benefit in this area.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

Bummer, I thought I was onto something relatively new :lol:

So, with these sites, the entry point is something like http://www.whatever.com/index.exe ?
User avatar
triton
Greenskin
Posts: 138
Joined: Thu Mar 13, 2008 10:25 pm
Location: Portugal

Post by triton »

KevinMulder
Kobold
Posts: 28
Joined: Sat Sep 06, 2008 1:25 am

Post by KevinMulder »

lonewolff wrote:Bummer, I thought I was onto something relatively new :lol:

So, with these sites, the entry point is something like http://www.whatever.com/index.exe ?
... and millions of firewalls and internet protections system will deny to connect to your site, because the above url is like what mostly used in spam/trojans emails ...
--
Where I look onto the night sky watching the stars, I know those are just dead-pixels left around ...
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

KevinMulder wrote:
lonewolff wrote:Bummer, I thought I was onto something relatively new :lol:

So, with these sites, the entry point is something like http://www.whatever.com/index.exe ?
... and millions of firewalls and internet protections system will deny to connect to your site, because the above url is like what mostly used in spam/trojans emails ...
How can that be? The executable is run server side (not client side) and generates the HTML itself. So, this will work on a non Win32 platform that doesn't even know what an exe file is. Like Linux, Mac, Solaris, etc...
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Post by CABAListic »

lonewolff wrote: How can that be? The executable is run server side (not client side) and generates the HTML itself. So, this will work on a non Win32 platform that doesn't even know what an exe file is. Like Linux, Mac, Solaris, etc...
No, it's about the form of the URL ending in .exe. Usually URLs like that are download links, and some more paranoid firewalls would probably take exception to that (though I wouldn't find that particularly useful, seeing as how it would kill a lot of legal downloads, too).

Of course, the easy solution would be not to use that particular file extension. In fact, CGI applications are often called via mod_rewrite or similar mechanisms, anyway.
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

Hmmm. I'll have to do some testing. :roll:

In IIS, I initially had my exe folder set to 'script only' permissions and my brower was having a heart attack about it and was trying to download the exe. After setting IIS on my server to 'script & executables' my browser (on another machine) was now behaving as per what I wanted.

Anyone got a secure system (that they feel in pretty locked down) that wants to be a test bunny?
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

I have done a small test app at the following link;

Test website

All it does is call up a plain webpage (embedded in the exe) and uses parameter Ogre to display...

Hello Ogre

If you guys could give this a try for me to see if this works as intended or if it fails due to firewall / antivirus etc... That would be awesome.

I am guessing this should work fine for everyone as I cant see how a client system will see this as a security risk as nothing is actually being downloaded to the client machine (exe wise)
Last edited by lonewolff on Sun Sep 14, 2008 3:37 am, edited 1 time in total.
Zool
Halfling
Posts: 49
Joined: Sat Mar 29, 2008 6:56 pm

Post by Zool »

Wt, C++ Web Toolkit: http://www.webtoolkit.eu/wt
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

If anyone wants to give my test exe based site a go, the complete webiste source is as follows;

Code: Select all

#include <iostream>
#include <stdlib.h>
#include <stdio.h>

void main(int argc, char *args[], char *envp[])
{
	char name[128]="",input[4096];
	int length;
	std::cout<<"Content-type: text/html\n\n";

	sscanf(getenv("CONTENT_LENGTH"),"%d",&length);
	for(int i=0;i<length;i++)std::cin >>input[i];
	input[length]='\0';
	sscanf(input,"myname=%s",name);

	std::cout<<"<H1>Hello "<<name<<"</H1>\n";
}
Located here >> Test website

Let us know how it goes. I would love to test this firewall theory. I believe it will work fine. :D
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

Going by my IIS logs there have been a bunch of people who have tried the link.

I am interested were these successful? :?:
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

I love these sorts of challenges.

I remember doing this once, using .NET and winsock. However I couldn't test it on the internet with other people; I've always used Linux webservers.
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

Cool!

I started thinking about this topic yesterday, as I just started writing an app to email me input from a form from a website. So, far it seems to be working well.

Also using Winsock for that too (with C++). :D


So, anyone out there having any failures with my link?(<<Here) I am tending to think it will work fine, as nothing is run client side. It is my server generating the webpage dynamically. :wink:

So far my logs tell me nine people have tried and no-one has posted to say it didn't work for them. Am I to assume that I am right? 8)
User avatar
Nauk
Gnoll
Posts: 653
Joined: Thu May 11, 2006 9:12 pm
Location: Bavaria
x 36
Contact:

Post by Nauk »

I tried and it works fine, I think it is a good way for absolute freedom and creativity because you have nearly no limits there and a nice performance.

The downside probably will show when your application takes on size and becomes more complex, having to hit compile every change is a total nuisance (like .NET based Web-Applications), but then again depends what you want to do with it, but it is certainly fun to toy around with it :) and you can always add a a scripting language.

Curious to see where you will go with that.
warmi
Gnoll
Posts: 674
Joined: Sun May 27, 2007 3:56 am
Location: USA

Post by warmi »

Nauk wrote:I tried and it works fine, I think it is a good way for absolute freedom and creativity because you have nearly no limits there and a nice performance.

The downside probably will show when your application takes on size and becomes more complex, having to hit compile every change is a total nuisance (like .NET based Web-Applications), but then again depends what you want to do with it, but it is certainly fun to toy around with it :) and you can always add a a scripting language.

Curious to see where you will go with that.
Generally, these apps tend to be I/O bound anyway which means the choice of language is not that important (within reasonable bounds of course)
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

Nauk wrote:I tried and it works fine, I think it is a good way for absolute freedom and creativity because you have nearly no limits there and a nice performance.

The downside probably will show when your application takes on size and becomes more complex, having to hit compile every change is a total nuisance (like .NET based Web-Applications), but then again depends what you want to do with it, but it is certainly fun to toy around with it :) and you can always add a a scripting language.

Curious to see where you will go with that.
Thanks Nauk. I'll keep you informed. :wink:
User avatar
Thrakbad
Halfling
Posts: 73
Joined: Fri Mar 23, 2007 4:32 pm
Location: Essen, Germany
Contact:

Post by Thrakbad »

lonewolff wrote:Going by my IIS logs there have been a bunch of people who have tried the link.

I am interested were these successful? :?:
Works fine for me at work. But our firewall is not really restrictive.
User avatar
Minthos
Kobold
Posts: 37
Joined: Fri Apr 28, 2006 11:59 pm
Location: Norway

Post by Minthos »

You could always change the address to something other than .exe - .cgi for example.

Worked for me too btw, but I don't have any stupid filtering here (at home).
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Post by lonewolff »

Funnily enough. I have had quite a few people access my test exe site from a variety of platforms and no-one has reported a failure. I think it is safe to assume that this is a legit way of doing things. :wink:
User avatar
Nauk
Gnoll
Posts: 653
Joined: Thu May 11, 2006 9:12 pm
Location: Bavaria
x 36
Contact:

Post by Nauk »

As long as you are returning proper HTTP headers in ASCII form you should be fine, no matter what script / binary you call on the server.
User avatar
paddy
Greenskin
Posts: 136
Joined: Sun Aug 01, 2004 7:07 pm

Post by paddy »

The one performance issue is the fact the exe application instance is created, then terminated with each call, where it is more efficient to have the request be passed to a continuously running service - if I remember correctly.

The C++ code will run very efficiently should it have to do heavy lifting, so the trade off can quickly end up in your favor for any level of work, but for light weight requests it probably drags more.

Of course, if I recall correctly, most CGI based systems (at least on windows servers) work this way, launching the PERL interpreter for each request - but my information could be out of date.

I played with it about 8 years ago or so, but then switched to interpreted languages. Also, I still find URLs with .dll extensions - not sure what the differences are but that could be an avenue as well.
Post Reply