Wednesday, May 16, 2012

Android Web Server using "lophttpd"

Android platform can be easily altered to meet most of our specifications. Today we'll launch a web server from an Android phone. We need

Decompress the binaries from their tar files

Use winrar in windows or if you are on terminal emulator, navigate to the folder where you have downloaded the binaries

$cd /sdcard/<folder-housing-.tar-file-downloaded-from-net>

and type 

$tar -x -f lhttpd-android-bin-0.tar

Incase it doesn't work try

#tar -x -f lhttpd-android-bin-0.tar


#busybox tar -x -f lhttpd-android-bin-0.tar

Now we have to get the binaries into the phone. Use adb push if you are on Command Prompt

C:\<path-to-android-sdk>\platform-tools>adb.exe push C:\<path-to-decompressed-binaries-folder>\lhttpd /data/local/tmp

Or else if you already have path variable pointing to Android SDK

C:>adb.exe push C:\<path-to-decompressed-binaries-folder>\lhttpd /data/local/tmp

or else cp it using Terminal Emulator.

#cd /sdcard/<folder-housing-lhttpd-binaries>/lhttpd
#cp lhttpd /data/local/tmp

or else 

#cp /sdcard/<path-to-decompressed-binaries/lhttpd /data/local/tmp

If you are on Command Prompt get adb shell. Connect your phone to computer using usb cable. Make sure you have enabled USB debugging. you'll find it under Settings > Applications > Development

C:\<path-to-android-sdk>\platform-tools>adb.exe shell

or if path variable exists

C:\>adb.exe shell

you must now get $ prompt. Enter root by typing


Now whatever you are using you have access to the root shell. Change to the directory /data/local/tmp

#cd /data/local/tmp

Now lets run our web server

#./lhttpd -u root -i -R /sdcard -p 8000 -q

-p 8000 refers to the broadcast port and -q refers to quite mode. For more details type


Now got to your browser on mobile and type




You must see this screen

Now if you are connected to internet on a data pack. Go to and copy down your IP.

Or enable Wi-Fi hotspot on your phone. You must find it in Settings > Wireless and Networks > Tethering & portable hotspot

Now open Terminal Emulator and type


Copy down IP address against wl0. Now connect your computer to the hotspot or Get it online and type in the IP address in the address bar.




Now that you have your own webserver. This thing is safe as it runs in a chroot ed  environment. But I wouldn't recommend running it for long times as it isn't safe.

Incase you want to take a look at the source

No comments:

Post a Comment