KNet 2.0 Beta

Developed or developing a new product in PureBasic? Tell the world about it.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

KNet 2.0 Beta

Post by Killswitch »

Hey,

I've completed a beta version of KNet 2.0! The original versions (1.0-1.04c) were based around the Atomic webserver, however I've now rebuilt the server from the ground up. I used Atomic as a guide but almost all of the code is new.

Opening the server is easy. Just click on 'Open', you'll then be prompted to select your websites path (KNet creates www as a defualt), then to chose your index page finally you can choose a custom 404 error page (if you click cancel KNet will still work, it'll just send out 404 headers if a page cannot be found).

You can also create your own MIME type deffinitions by editing MIME.txt (if MIME.txt doesn't exist KNet recreates the defualt MIME file). It follows this format:

<extension> <MIME>

For example:

htm text/htm

The space is very important!

Please keep in mind that this is the beta version and there are a few features missing. In the release version there will be HTTP header logs, mimimise to systray, no directory traversing - and anything more you guys suggest.

Download

(Source is included!)

If you find any bugs, or have any suggestions then please do tell me! Either post here or email me at evil_grunger@hotmail.com .
Last edited by Killswitch on Wed May 11, 2005 5:00 pm, edited 1 time in total.
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Found some errors

It says that 2 is connected when only 1 is connected. Get 4 when I refresh.
The gadgets on the window doesn't resize with the window.
When I refresh the page for the third time I get this error:
"An attempt to read or write to/from an address to which that process isn't allowed."
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Tommeh
Enthusiast
Enthusiast
Posts: 149
Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom

Post by Tommeh »

Yup i've seen those errors as well

Knet, i've said this so many times before... STOP DIRECTORY TRAVERSAL!

When i run it, i can go to http://localhost/../main.pb, which shows me the source code for the server, which i should not be able to.

Its good you've moved away from Atomic Server example, but you still have a long way to go. You also do not make any checking before reading in the URL or any other data.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Bug!

Run Knet...
Then start the server...

Then replace index.htm and instant crash.... Access violation!

Also: Hit the refresh button 2\ 3 times and crash...
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

no directory traversing
That is stopped in 1.0 - 1.04c but I didn't see any point putting it in this release as it's beta and only a few people will be using it as a test.

The attempted read to/write to error is a weird one I have no idea why it happens (only that it does) but I had thought I'd killed it.

I'll get right on it.
~I see one problem with your reasoning: the fact is thats not a chicken~
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Hey again,

I really can't fgure out this bug - I don't know what is causing the crash. Any ideas from looking at the source?
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Peter,

In line 147 of Main.pb you allocate *Buffer. This is outside any loops, so it is just run once when the server starts up.

In line 214 you Free *Buffer. This is inside the loop, so it is called every time you processess a Data NetworkServerEvent.

The whole thing is complicated because when SendFile allocates a buffer, the same address for *FileBuffer is return as *Buffer.

My guess is that a stack is used internally to keep track of memory allocation, and you're falling of the end of it.

Balancing you're AllocateMemory and your FreeMemory should solve the problem.

btw: what license are you providing this code under. Would I be okay to build something on top of this?
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

The read to/write to error should be fixed now, I've tested this code under XP Pro and it deffinatly works, however I did run a test on 98 but it didn't (I'm not sure if I ran the new version, so try it anyway).

Thanks for the help so far!

BTW: (Thanks for reminding me) This code is completly freeware, you can change/modifiy use and abuse it all however you want. All I ask is that you mention that I wrote the base code, and if you can be bothered that you send me a little email about your project (just as I'm curious as to how my source will be used).

Request filtering has been added, so /../bob.txt won't work anymore.


Download Beta 2
~I see one problem with your reasoning: the fact is thats not a chicken~
Post Reply