DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2010-08-19 06:15:52

zachlac
New member
Registered: 2010-08-17
Posts: 4

Modifying build-in web server

I want to keep the default web server, but I want to modify/add a few things.  I'm going through the ASP code, and have admittedly very little experience with ASP.  They use a bunch of functions repeatedly to populate the pages: getSamba() and get_text().  These always contain simply a number, I assume a reference into a table of text somewhere.  Where can I find these functions?

If this is a dumb question, you can just point me to a resource.  Or point out my stupidity.

Offline

 

#2 2010-08-19 07:06:59

chriso
Member
Registered: 2009-03-29
Posts: 74

Re: Modifying build-in web server

I'm guessing what you are doing is browsing to a page and right clicking and asking for the page source, right?
And you see the a link like http://dlink-nas/web/main_menu.asp?id=3352228, so figure there is some ASP code that you can change somewhere.

Well I may be wrong about this, but I think all these pages are created on the fly by a program (webs), and so you have no chance of modifying them.  If you want your own web pages you will have to run another web server.

I base this on the fact that /mnt/web_page has one file (goweb.htm), which has something like this in it.
<script>
location.replace("http://192.168.2.105/web/login.asp")
</script>

And /web and /mnt/web_page have no ASP files in them.  /web has configuration/data files and the programs that is the web server /web/webs.

Offline

 

#3 2010-08-19 11:09:21

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Modifying build-in web server

I wanted to add some applications of my own and read some of the source code of web server. It's all located in /web.
What I found was a mixture of html, asp and java script. So far so good. However, I also found on forms POST messages that were sent to .../goform/... pages.

I did some reading on the goahead site, which made the web server application integrated into the DNS-323 (the application name is webs, as chriso noted in a previous post). What I found is that these goform pages are actual function hooks compiled into the webs binary, that D-Link added to the application at compile-time.

Unfortunately the webs application is closed source. I see no way we could modify the web-server content, unless these changes are cosmetic in nature. For anything meaningful like writing add-ons of our own we'll need a level of access to the webs source code we just can't have.


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#4 2010-08-19 17:21:08

zachlac
New member
Registered: 2010-08-17
Posts: 4

Re: Modifying build-in web server

Yeah, I dug into the /web section, found all of the ASP code, but it seemed like the meat of the functions just aren't there.  It makes sense that they've integrated it into the webs program.  I'm no web programming expert, but I couldn't make too much sense of it.  Do you know if those ASP pages under /web/web are generated at runtime, or could I throw some hooks in there to display my own pages? 

Basically, the 321 doesn't have too much memory, and I'm loath to run two web servers if I don't need to.  However, I don't want to get rid of the D-Link web interface.  Going for the minimum-changes approach.

Last edited by zachlac (2010-08-19 17:21:29)

Offline

 

#5 2010-08-19 19:23:03

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Modifying build-in web server

zachlac wrote:

Yeah, I dug into the /web section, found all of the ASP code, but it seemed like the meat of the functions just aren't there.  It makes sense that they've integrated it into the webs program.  I'm no web programming expert, but I couldn't make too much sense of it.  Do you know if those ASP pages under /web/web are generated at runtime, or could I throw some hooks in there to display my own pages?

Well, it's in a ramdrive. You'll need to replace/modify those files on every boot. I don't know ASP either, but it seems easy enough. If you'll elaborate more about what you'd like to achieve maybe other members of this community will be able to help decide if it's doable or not.


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#6 2010-08-20 08:24:24

chriso
Member
Registered: 2009-03-29
Posts: 74

Re: Modifying build-in web server

When I wrote the last message I was chasing the wrong link so here is some for information for you.

First off even though the file types are ASP, most of the code is actually JavaScript so that it what you want to look at not ASP.  JavaScript is client based, which means that it can not interact with the OS at all (no Linux commands).  It is good for creating web pages and interacting with the user, but you need something like PHP or Perl, actually perform commands on the server.  For this web server it seems to be getting code to be run by referencing /goform/COMMAND, which most like webs is configured to pick up and perform the given command.

So I think the biggest problem you are going to have is the fact that this web server doesn't support another language like PHP or Perl so that you can call Linux commands to actually get things done.

A few special notes.
/web/web is a link on /sys/crfs, which is a read only file system, and even if you mount it writable you are going have permission and other problems.

It is possible to move the code to say your hard drive or USB drive to run it from there where it is easy to change and it doesn't have to be re-modified after every reboot.

What you would do one time is like:
mkdir /mnt/HD_a2/web
cp -R /web/web/* /mnt/HD_a2/web/

The next would have to be put in something that runs on every reboot.
rm /web/web
ln -S /mnt/HD_a2/web /web/web

__________ Edit
I forgot:

/ffp/bin/killall webs
/web/webs &

To restart the web service.

Last edited by chriso (2010-08-20 15:13:08)

Offline

 

#7 2010-08-20 10:05:02

Stargrove1
Member
Registered: 2010-08-11
Posts: 16

Re: Modifying build-in web server

I was also thinking of a web interface to start/stop programs. I would also be interested in enhancing the existing interface. Unfortunately I am not able to do something by myself. I hope you could find a way.

Offline

 

#8 2010-08-20 17:12:38

zachlac
New member
Registered: 2010-08-17
Posts: 4

Re: Modifying build-in web server

I'll see what I can do next week.  Remounting the ramdisk as read-write doesn't sound like a great idea...I'm thinking I'll probably just bite the bullet and install the separate webserver, just run it on port 8080 or something.  Anybody have a statistic on how much memory it takes?  I don't have too much left on the 321 to play with.

Offline

 

#9 2010-08-21 02:50:31

chriso
Member
Registered: 2009-03-29
Posts: 74

Re: Modifying build-in web server

zachlac wrote:

I'll see what I can do next week.  Remounting the ramdisk as read-write doesn't sound like a great idea...I'm thinking I'll probably just bite the bullet and install the separate webserver, just run it on port 8080 or something.  Anybody have a statistic on how much memory it takes?  I don't have too much left on the 321 to play with.

Are you really talking about the RAM?  The RAM gets used for the file system, but all add one programs should be stored on a hard disk or USB Flash drive.  Then there is the running programs, and of course that is going to depend on what is running at any given time, and can even swap out a bit, if it doesn't get excessive.  lighttpd is suppose to be very lightweight (and by default runs on 8080, if using ffp examples), but I don't have it running to check.  But I would think it depends on what commands you are running on it, PHP/ no PHP, so I'm not sure if there is "one answer".  "webs" on my DNS-323 goes about 11% when displaying pages and stuff.  Lighttpd seems very easy to run once you have ffp installed.

I just turned on lighttpd without PHP and at idle it is using 5% of the memory.

Last edited by chriso (2010-08-21 03:15:39)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB