Quantcast
Channel: xda-developers - Android Software and Hacking General [Developers Only]
Viewing all articles
Browse latest Browse all 3614

[GUIDE] [BIN] Busybox 1.23.0 Snapshot and Building On Android (from Ubuntu chroot..)

$
0
0
About Busybox: busybox.net/about.html
More on Busybox: busybox.net

This is just for anyone who wants to try, and especially those without access to a PC.

Things we'll need besides your phone:
- "Android Terminal Emulator" app
- "Complete Linux Installer" app
-internet/wifi
- latest "busybox" source


1) We need to get Ubuntu or Debian booted for a sufficient build environment. I've used both on Android but I like the better stocked terminal in the Ubuntu images. I used the app "Complete Linux Installer" which is free and works beautifully, very simple and easy. In the app you want to follow the short instructions to download an Ubuntu image, rename it to ubuntu.img, and place it in a folder named ubuntu in /sdcard. Then hit menu in the app and click the terminal screen icon that says "Launch". An Ubuntu terminal will now open in Android Terminal Emulator. Super quick and easy.

2) Let's download GCC and ncurses-devel (libncurses5-dev) as some crucial build environment tools.
Code:

apt-get install -y gcc libncurses5-dev
3) Now the cool thing about this chroot Ubuntu environment is that we still have access to the sdcard to transfer files between Android environment and the chroot jail. Extract your downloaded busybox source to your Ubuntu home with something like:
Code:

cd
tar -xf /sdcard/Download/busybox*bz2
cd busybox*

4) Now we can build busybox statically. The first thing we do is generate a Makefile by running "make" with a "defconfig" (default configuration file) Usually you will run "make configure" with other programs, but busybox compiles more like a kernel, so it uses a defconfig which has a huge checklist of options.

Busybox source already comes with a couple defconfigs specifically for Android in the folder configs/ from the root of the source directory. (After successfully compiling busybox, we can go back and customize one; this entails that for each "CONFIG ..." line we see, we can uncomment it and mark it "y" or "n" to configure some option... This can be more easily done from a terminal busybox menu interface with "make menuconfig". You just need to crank font down to 7 or use telnet/ssh) For now we'll copy a defconfig already made to the root of the source directory for use.
Code:

cp configs/android_defconfig .
make defconfig

If all goes well, we now have a Makefile and are ready to compile:
Code:

LDFLAGS=-static make
Let "make" crank out the binary for a couple minutes. The extra variable we set before make is an environment variable to compile statically. When compiling is complete we'll have a few different busybox binaries at the root of the source directory. We use the one named "busybox".

5) Now let's copy it to /system/usr/bin to install for test usage.
Code:

cp ./busybox /sdcard
(Open a new terminal tab to get into Android Environment)
sysrw
mkdir -p /system/usr/bin
cp -f /sdcard/busybox /system/usr/bin
chmod 0555 /system/usr/bin/busybox
/system/usr/bin/busybox --install -s /system/usr/bin
sysro

.. and done. Run some scripts and enjoy your static busybox!

:
--------------- --------------- --------------- ---------------
:

***** Attached is a busybox static binary (v1.23.0 August 2014 snapshot, 374 applets included!, 1.37MB size) *****
Since it's up-to-date it has some nice extras most people haven't seen like a "-I" option for xargs! Yes, that is correct, busybox xargs has its testicles back.
Code:

e.g.
> echo Hello | xargs -I{} echo {} world!


Attached Files
File Type: zip busybox.zip - [Click for QR Code] (988.1 KB)

Viewing all articles
Browse latest Browse all 3614

Trending Articles