TVT618

Build Kali Linux with Live-Build on Debian-based distros

Jul 24th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. Offensive Security use live-build to create their official Kali Linux releases and they encourage users to jump in and build customized versions of Kali Linux whenever users can. The documentation of the process is one of the most popular items on their documentation site, and the Kali Dojo also revolves around this topic. Offensive Security love it and our users love it.
  2.  
  3. One roadblock of live-build has always been the fact that you need a Kali Linux system to build a Kali Linux system. The reason for this is that small changes in both the original debootstrap and live-build packages are needed for building a Kali Linux ISO. In Kali Linux, these changes are already included, however in most Debian derivatives, some gentle massaging is needed to get ISOs to build.
  4.  
  5. Today, Offensive Security has updated their docs site to include instructions on how to build a custom Kali Linux ISO on other Debian-based distros like Debian 9 or Ubuntu 16.04 and 18.04. This will hopefully allow users running Debian derivatives to test the waters with Kali Linux and play with one of its cooler features.
  6.  
  7. Building a custom Kali Linux release with live-build is not as scary as it might sound so be sure to give it a chance!
  8.  
  9. Building Kali on Non-Kali Debian Based Systems
  10. You can easily run live-build on Debian based systems other than Kali. The instructions below have been tested to work with both Debian and Ubuntu.
  11.  
  12. First, we prep the system by ensuring it is fully updated, then proceed to download the Kali archive keyring and live-build packages. The latest versions of these packages can always be found at http://http.kali.org/pool/main/k/kali-archive-keyring/ and https://archive.kali.org/kali/pool/main/l/live-build/ respectively.
  13.  
  14. Open Terminal and enter the following commands:
  15. sudo apt update
  16. sudo apt -y upgrade
  17. wget https://http.kali.org/pool/main/k/kali-archive-keyring/kali-archive-keyring_2018.1_all.deb
  18. wget https://archive.kali.org/kali/pool/main/l/live-build/live-build_20180618kali1_all.deb
  19.  
  20. With that completed, we install some additional dependencies and the previously downloaded files:
  21. sudo apt -y install git live-build cdebootstrap debootstrap curl
  22. sudo dpkg -i kali-archive-keyring_2018.1_all.deb
  23. sudo dpkg -i live-build_20180618kali1_all.deb
  24.  
  25. With the environment all prepared, we start the live-build process by setting up the build script and checking out the build config.
  26. cd /usr/share/debootstrap/scripts/
  27. (echo "default_mirror http://http.kali.org/kali"; sed -e "s/debian-archive-keyring.gpg/kali-archive-keyring.gpg/g" sid) > kali
  28. sudo ln -s kali kali-rolling
  29. cd ~
  30. git clone git://git.kali.org/live-build-config.git
  31. cd live-build-config/
  32.  
  33. At this point, we have to edit the build.sh script to bypass a version check. We do this by commenting out the “exit 1” below.
  34.  
  35. # Check we have a good debootstrap
  36. ver_debootstrap=$(dpkg-query -f '${Version}' -W debootstrap)
  37. if dpkg --compare-versions "$ver_debootstrap" lt "1.0.97"; then
  38. if ! echo "$ver_debootstrap" | grep -q kali; then
  39. echo "ERROR: You need debootstrap >= 1.0.97 (or a Kali patched debootstrap). Your current version: $ver_debootstrap" >&2
  40. exit 1
  41. fi
  42. fi
  43.  
  44. With that change made, the script should look as follows:
  45.  
  46. # Check we have a good debootstrap
  47. ver_debootstrap=$(dpkg-query -f '${Version}' -W debootstrap)
  48. if dpkg --compare-versions "$ver_debootstrap" lt "1.0.97"; then
  49. if ! echo "$ver_debootstrap" | grep -q kali; then
  50. echo "ERROR: You need debootstrap >= 1.0.97 (or a Kali patched debootstrap). Your current version: $ver_debootstrap" >&2
  51. # exit 1
  52. fi
  53. fi
  54.  
  55. We can now build our ISO as normal: sudo ./build.sh --variant light --verbose
  56.  
  57. No Commitment Testing
  58. After you get Kali built, you might want to quickly test the ISO you created. There is a fast no commitment trial you can do with QEMU. On Ubuntu, you just have to prep the system by installing a few packages:
  59. sudo apt -y install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
  60. sudo adduser $(id -un) kvm
  61. newgrp kvm
  62.  
  63. With that out of the way, we will create a dynamic disk image to hold our Kali installation and then boot off our newly created ISO. Don’t worry about the disk size–it will grow as needed so you won’t suddenly fill your drive just by creating the disk:
  64. qemu-img create -f qcow2 kali-disk.img 100G
  65. kvm --name Kali -m 1024 -hda kali-disk.img -cdrom kali-linux-light-rolling-amd64.iso -boot d
  66.  
  67. At this point, you can run a live instance of Kali, or install it to the virtual disk. If we go ahead and install it, we would then later launch the newly created VM with the command:
  68. kvm --name Kali -m 1024 -hda kali-disk.img -boot c
  69.  
  70. There are few things as satisfying as running your own Linux install that you created and tweaked for what you need. With a way to build Kali on other Debian based distributions and a quick way to test it, why wait?
  71.  
  72. From Kali Linux: https://www.kali.org/tutorials/build-kali-with-live-build-on-debian-based-systems/
Add Comment
Please, Sign In to add comment