[Android Software/Hacking General [Developers Only]] Edge-Case:
Updated.

Disclaimer, I am not resposible for anything you do, and what works for me may not work for you. To start I am running Cyanogenmod 10 on a Galaxy s III sprint, rooted, busybox, and whatever else you may need.

First :Anything being done on the PC is being done on Kali Linux:

Create a custom kali.img as per http://docs.kali.org/armel-armhf/kali-linux-arm-chroot without a desktop as its not needed. I tried to make a list of packages you can use to have them get installed during the process, and have posted it here, alternatively one can run apt-get install and then copy and past the list into the command line over ADB or use the "testautokimg.sh" if you have trouble making one on your own, I'd rather have you make one than to upload one and everybody worry about rootkits and other evils. This script is setup to be used for this purpose but the img may also be used as a normal img to chroot into.

Second

Push the kali.img file to your phone, push it to "/storage/sdcard0/kali, make a folder called "/storage/sdcard0/kali" if one does not exist on your internal sdcard this is the root of your internal storage, not the root of your phone, if you don't have space on your internal sdcard you can put it an external one but a few lines of code will need to be changed in the script that is currently named "test.sh" as everything is still experimental.

I am still working on the script and will update it as often as I can.

Third

Download and move test.sh to "/system/bin/" and then make it executable

If you have trouble with this try on your phone or over ADB:

su
mount -wo remount systemfs /system
cp -i [location you pushed test.sh to] /system/bin
chmod 0755 /system/bin/test.sh

Then execute test.sh with:

test.sh

When it askes you if you would like to overwrite choose no for now. You should get a new prompt, go ahead and use the 'set' command to check your PATH variable and also 'which nmap' to make sure everything is available. You should now be able to explore the experimental Kali-Android hybrid system. Hope u Enjoy.

Please don't hesitate to improve on this with sanity checks and error handling, posting the improvments would be great. Ultimately I am going to get this all set up in the boot.img effectively making the mod persistant across reboots. As it is, a reboot will clean the changes, which is a good thing for now, some config, .rc, and other types of files clash in the etc folder but for now I havn't noticed too much harm form mounting the etc directory to androids root (again, this is my experience) but for safty's sake each device will eventually need to have those clashing files patched up to allow both systems the configurations they need to be in synch. Also the "linker" I think may not be right, to get it seamless I think the systems need to be built from scratch together. But hey, I thik this is a great place to start.

[Edit Aug 3, 2013] I finally got around to looking through the etc dir, less work then I thought with a fresh kali.img anyways. I just added a couple lines before mounting to Androids root we gotta make sure some files will still be available afterwards, this should only need to be done once as they wont get deleted off the kali.img file, but since it's interactive you can not overwrite or if Android updated you can overwrite if you choose to. Just make sure you note which files conflict and at least 'cat' their contents and see which one you want if your not going to make a new one that handles any options that are on one but not the other.

[Edit Aug 4, 2013](1) I uploaded a script to automate the kali.img creation. (2) I changed HOME="/sdcard" in test.sh

READ ME STILL DEBUGGING!

[About 'testautokimg.sh'] (1) Download (2) rename to "testautokimg.sh" (3) make executable (chmod +x ./testautokimg.sh) (4) Before exicuting make sure to rename or delete any existing ~/arm-stuff directory, run while logged in as root, and make sure debootstrap and qemu-user-static are installed.

NOTE: Because a large number of programms being installed this will take several hours, make sure you have the time to babysit things as it runs!

This will install a lot of programs and create the kali.img file in ~/arm-stuff/image directory, once complete push it to your device. I think the standard location for the img file is /storage/sdcard0/kali/kali.img if you put it on an external sdcard for whatever reason be sure to modify the mounting script "test.sh"