FORUMS
Remove All Ads from XDA

[APP] Native Android web server 1.1 - updated! (folder browsing, basic AUTH)

417 posts
Thanks Meter: 402
 
By viulian, Inactive Recognized Developer on 21st August 2011, 10:42 AM
Post Reply Email Thread
Hello,

I've managed to compile a small native web server for Android (but for now only tested on Sony X10 with 2.3.3 version). You will need root.

The main advantage is that you can quickly share photos / documents from your phone as long as there's WiFi available. The other phone needs just to have WiFi and a browser.

It is an Android port of the webserver source code found here: http://www.jbox.dk/sanos/webserver.htm which comes under BSD License.

Download

webserver-1.1.zip

Archive contents

webserver – Android binary
LICENSE – initial BSD License
android_port.patch – BSD licensed patch for webserver.c
README.txt – description on how to install / compile.

Installing

Since most mobile carriers block incoming traffic, you won’t probably be able to access your phone via GSM/3G data connection, only over WiFi.

You need to unpack the archive, and extract the webserver binary to a directory of your choice. Then:

Code:
adb push webserver /sdcard/
adb shell
su
cd /system/bin
cp /sdcard/webserver .
chmod 755 webserver
./webserver -u <username> -p <password> -s <port>
To stop just kill its pid ...

If you run in Terminal Emulator, just send it a Ctrl-C and it will exit.

Screenshots

Starting up the webserver (runs by default on port 80) and navigating to /sdcard/DCIM folder in the browser:





For more information about the porting process please check my website.

Change log

v1.0 - 21 Aug 2011
Initial port to Android
v1.1 23 - Aug 2011
Added command line options
Added listing of all local IPs (please check screenshot, it reports IPs and interfaces when starting up. Helps a lot to find out the WiFi IP, tun.ko is detected and works too)
Added Basic HTTP authentication for security

PS: if you have other rooted Android phones, I'm very interested in feedback if this works or not. I did not use anything specific to X10.

Thank you,
The Following 5 Users Say Thank You to viulian For This Useful Post: [ View ] Gift viulian Ad-Free
 
 
21st August 2011, 10:48 AM |#2  
Senior Member
Flag Bangalore
Thanks Meter: 320
 
Donate to Me
More
Quote:
Originally Posted by viulian

Hello,

I've managed to compile a small native web server for Android (but for now only tested on Sony X10 with 2.3.3 version). You will need root.

PS: if you have other rooted Android phones, I'm very interested in feedback if this works or not. I did not use anything specific to X10.

Thank you,

good to see someone working on not so generic stuff.... would like to help you with stuff althogh i am not that good at java.

Will be checking the webserver out....

i don't have any other phone however i am in a process of purchasing some tabs so might help you then....
The Following User Says Thank You to anantshri For This Useful Post: [ View ] Gift anantshri Ad-Free
21st August 2011, 10:51 AM |#3  
OP Inactive Recognized Developer
Thanks Meter: 402
 
Donate to Me
More
Thank you for feedback

Don't know if it will work in tablets (I did not test it on 3.0, only 2.3.3) .. but yes, if you will root them, please give it a shot!
21st August 2011, 11:14 AM |#4  
silveraero's Avatar
Senior Member
Flag Ho Chi Minh City
Thanks Meter: 191
 
More
Did you install this on your own X10? I need some pics.
21st August 2011, 11:47 AM |#5  
OP Inactive Recognized Developer
Thanks Meter: 402
 
Donate to Me
More
Quote:
Originally Posted by silveraero

Did you install this on your own X10? I need some pics.

Yes and I've also tested it on X10. I've attached two screenshots to the first post of the thread. Please check them:

a) I have started webserver within Terminal Emulator
b) Then I navigated to the photos folder, in the browser (192.168.1.6 is phone's IP over WiFi).
21st August 2011, 11:54 AM |#6  
Senior Member
Flag Bangalore
Thanks Meter: 320
 
Donate to Me
More
Quote:
Originally Posted by viulian

Yes and I've also tested it on X10. I've attached two screenshots to the first post of the thread. Please check them:

a) I have started webserver within Terminal Emulator
b) Then I navigated to the photos folder, in the browser (192.168.1.6 is phone's IP over WiFi).

just a quick comment

when you copy it to system/bin

you don't need to cd or ./

you cna directly run webserver

EDIT : i would suggest you do one more change.

right now if i understand correctly this can pose a security risk....

as it can give you all folders any file effectively all data any location...

Make changes such that which ever folder you navigate and start webserver from only that folder and its subfolders are accessiblle on webserver.

webserver is already in bin so we can run from anywhere


so if i want to share /sdcard/share

cd /sdcard/share
webserver


hope that will help.
The Following User Says Thank You to anantshri For This Useful Post: [ View ] Gift anantshri Ad-Free
21st August 2011, 11:56 AM |#7  
OP Inactive Recognized Developer
Thanks Meter: 402
 
Donate to Me
More
Quote:
Originally Posted by anantshri

just a quick comment

when you copy it to system/bin

you don't need to cd or ./

you cna directly run webserver

My bad! Yes, I was testing in /system/test when porting, and by reflex I typed it. I will leave it like that in descriptions, but you are right of course

Quote:
Originally Posted by anantshri

right now if i understand correctly this can pose a security risk....

as it can give you all folders any file effectively all data any location...

It's a difficult decision to start adding security to folders ...
Because next question will be: but I want to access more folders! Or, yes, I want everything but I also want to exclude these and these ... And just like any software product, more time will be spent fool-proofing it. Because if you add configuration files, then you need a ton of error messages (and support for noobs) to explain what is wrong and how to fix it.

This is just a working proof of concept. It works, and it uses so little memory as compared to other Java apps that might do the same thing ...

I also thought of security (since I wouldn't want to start it on a public WiFi) but to add support for username and password - as even allowing some folders is still risky 'cos anybody than then browse all the photos.

On my todo list:
a) add file upload feature (fork()-ing is unstable on Android, so CGI support can't be done reliably - it will have to be built in)
b) add support for username and password.
c) sorting (alphabetically and folders first).
The Following User Says Thank You to viulian For This Useful Post: [ View ] Gift viulian Ad-Free
21st August 2011, 12:24 PM |#8  
Senior Member
Flag Bangalore
Thanks Meter: 320
 
Donate to Me
More
Quote:
Originally Posted by viulian

My bad! Yes, I was testing in /system/test when porting, and by reflex I typed it. I will leave it like that in descriptions, but you are right of course


I was adding more while you replied

EDIT : i would suggest you do one more change.

right now if i understand correctly this can pose a security risk....

as it can give you all folders any file effectively all data any location...

Make changes such that which ever folder you navigate and start webserver from only that folder and its subfolders are accessiblle on webserver.

webserver is already in bin so we can run from anywhere


so if i want to share /sdcard/share

cd /sdcard/share
webserver


hope that will help.
21st August 2011, 12:27 PM |#9  
Senior Member
Flag Sydney
Thanks Meter: 95
 
More
why not just swiftp ?
21st August 2011, 12:29 PM |#10  
Senior Member
Flag Bangalore
Thanks Meter: 320
 
Donate to Me
More
Quote:
Originally Posted by phillu97

why not just swiftp ?

alternatives the more the merrier.
21st August 2011, 12:31 PM |#11  
Senior Member
Flag Sydney
Thanks Meter: 95
 
More
Quote:
Originally Posted by anantshri

alternatives the more the merrier.

haha, finee okays. but i enjoy the GUI and all .
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes