Sunday, February 12, 2017

Kali Linux on Android (Feb 2017)



So a few months back (Sept. 2016) I wrote a piece here about installing Kali Linux on an Android device. Unfortunately that guide is no longer valid, as Kali Sana the branch of Kali on which it was based has been deprecated and removed from the official repositories and is only available on backup repositories and is set to be removed from those too in the near future. So a new challenge appeared. The obvious route was to check if Linux Deploy's out of the box method was working this time. But again there were a few quirks prohibiting a smooth installation and execution. So this is an updated guide as of Feb. 2017 on how to install and lunch Kali Linux on an Android mobile device. You will notice that a lot of the steps are the same, that's because the base approach is the same it's a few details that had to be changed.

The Requirements

Preparation

  1. Partition the SD and format each partition (THIS WILL DELETE YOUR DATA). You'll need:
    • 1st Partition 512 MB formatted in FAT32
    • 2nd Partition the rest of the SD formatted in EXT2
  2.  Install the APPs listed above
  3. Open Link2SD
  4. You should be greeted by this screen

    1. Select ext2 and press ok
    2. When prompted reboot your device
  5. Open BusyBox
    1. Press INSALL 

    Installation

    1. Open Linux Deploy (From here on ensure constant Wifi connection and power)
      1. Press your phone's menu button
      2. Press status
      3. Under Available mount point there should be something like /data/sdext2, make note of that.
      4. Press the button on the right (looks like a download icon)
      5. In Distribution select Kali Linux
      6. In Distribution Suite select kali-rolling
      7. In Architecture select armhf
      8. In Installation type select Directory
      9. In Installation Path type in the path you took note of before
      10. (Optional)  Change Username & Password
      11. Set DNS server to 8.8.8.8 (Google's Public DNS server) since the default tends to fail
      12. Set Localization to en_US.UTF-8
      13. Under the Init Menu check enable
      14. Under Init System choose sysv
      15. Under SSH check enable
      16. Under SSH Settings > SSH options write the following
        1. ServerAliveInterval 15
        2. This will ensure the connection doesn't timeout during the installation of packets that can take up to hours.
      17. (Optional) Enable GUI options like VNC (won't get into it here)
      18. Press Menu > Install
      19. This might take a while ...
      20. When you see "<<<install" on Linux Deploy's logs the installation has finished
      21. Press Menu > Configure
      22. (If there was no error your system is now ready to boot).
      23. Here's where things change. DON'T PRESS START!
      24. Exit Linux Deploy by pressing the App's menu button and then Exit.
      25. Open Terminal Emulator
        1. su
        2. /data/data/ru.meefik.linuxdeploy/bin/linuxdeploy shell
        3. service ssh start
        4. exit
        5. exit
        6. This should Start Kali
      26. After every restart of the mobile device Kali has to start as demonstrated in the previous step (will provide automation script in following article)
      27. I have yet to find how to stop Kali without rebooting the device (which is what Linux Deploy does when you press stop). If anyone has any ideas feel free to drop a comment
    2. Now from ConnectBot ssh to yourusername@localhost
      1. sudo apt-get update
      2. sudo apt-get dist-upgrade
      3. (if prompted)
        sudo apt-get autoremove
      4. sudo apt-get install kali-linux-full
      5. PATIENCE, since this will download around 4GB of data
      6. The above is the most error prone part of the process. Ensure CONSTANT internet access and UNINTERRUPTED power to the mobile device. 
    3.  If everything went right you should now have a working setup of Kali Linux on your Android phone
    4. (Optional) If you don't need to SSH into you mobile's Kali from another device, consider limiting SSH access only from localhost.
    Hope this helps a few people skip a bit of the frustration. Have fun!

    Disclaimer: Make sure you understand what you are doing and follow the above AT YOUR OWN RISK. I had no problem during the above procedure, carried out multiple times on a couple devices, this isn't to say that problems cannot occur.