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.

    Sunday, January 15, 2017

    How to change GitHub repo's preview image (sort of)

     Do you like having a photo of yourself as GitHub avatar but hate having it pop up as a preview when you post a repo on social media? Reed on!



    First things first, let me explain the "(sort of)" part o the title. Since there is no officially supported way from GitHub, at the time of writing, to achieve the desired result, the process described is a workaround, a hack, and thus entails a trade-off; you have to use a custom URL so anyone sharing directly the URL of your repo will get the original preview image.

    To achieve our goal we are going to utilize GitHub's project page generator that will generate a URL in the form : <username>.github.io/<repoName> (and this will be the link you will be sharing instead of the direct repo link that would be github.com/<username>/<repoName>). To better understand the process, we will see a general and an applied example in parallel. So in our case we will take one of my GitHub repos as an example github.com/panagiks/RSPET and the generated link will be panagiks.github.io/RSPET.

    GitHub's Project page generator

    GitHub provides a few ways to generate project pages, but for the purpose of this post we'll go with the gh-pages branch approach. First, create a new branch in your repo named "gh-pages" (no quotes) and empty it (delete all and any files that were at the source branch). Now create an empty file in the root of the newly created branch named "index.html". Now go to the repo's settings page and scroll down to the "GitHub Pages" section. There, in the "Source" section, you should see "gh-pages branch" selected in the drop-down menu, if not select it.

    Populating index.html

    The point is to create a webpage that will have the appropriate "meta" tags for social media to present it as if it was your GitHub repo, just changing the tags that correspond to the preview image. First make sure that you have uploaded the desired (new) preview image to a CDN (Content Distribution Network), I prefer Flikr for this because it's free and you can easily keep all your images in one place and also have them resized, but feel free to use any CDN you prefer the only thing that matters is that you have a URL pointing to the image. First is our example for github.com/panagiks/RSPET and following is the head section of the general index.html:

    In the body of index.html we only want it to redirect to the actual GitHub repo, to do that we do the following:



    Final Notes

    A helpful tool is Facebook's debug tool, from which you can see how Facebook will load and display your link as well as force its scrapper to rescrape your link. Finally, I intend to write a small script that will generate automatically the above "index.html" for any given GitHub repo, so stay tuned!
     

    Edit

    As promised, here's RGHPI, a script to automate the HTML generation step :)