Raspberry Pi Disk Encryption

With the advent of smaller, faster ARM hardware such as the new Raspberry Pi 2 (or even 3!)(which now has a Kali image built for it), we’ve been seeing more and more use of these small devices as “throw-away hackboxes“. While this might be a new and novel technology, there’s one major drawback to this concept – and that is the confidentiality of the data stored on the device itself. Most of the setups we’ve seen do little to protect the sensitive information saved on the SD cards of these little computers. This fact, together with a nudge from friends is what prompted us to create a LUKS encrypted, NUKE capable Kali Linux image for our Raspberry Pi devices. The following article describes the process, so you can repeat it and make your own shiny shiny.

Birds Eye View of the Disk Encryption Process

The process described below was tried and tested successfully on a Raspberry Pi B+ and a Raspberry Pi 2/3 (henceforth collectively called “RPi”). but it should be trivial to port these instructions to any ARM device running Kali. Before we begin, let’s take a minute to quickly describe what we’ll be doing – as while this process is not complicated, it is involved. This is basically our spiel:

  1. We download the required Kali RPi image and dd it to an SD card.
  2. We chroot to the RPi image and install/update several files in preparation for our crypted boot.
  3. We create an initramfs file which includes Dropbear and freshly generated SSH keys.
  4. We rsync the modified rootfs to a temporary backup location and then delete the rootfs partition from the SD card.
  5. We then recreate an encrypted partition to which we restore the root partition data. That’s it!

If all goes well, the RPi will boot and then LUKS will kick in and ask for a password to decrypt the root drive, while simultaneously opening a Dropbear SSH session through which you can SSH in and provide the boot decryption password. Oh yeah, did we mention this image also has LUKS NUKE capabilities?

Getting Your Hands Dirty

As always, all our ARM dev is done on a Kali amd64 machine and we’ve made sure that we have all the dependencies we need. We download the latest Kali RPi3 image (2017.1), extract it, and dd it to our SD card, which in our case showed up as /dev/sdb2 – adapt as necessary!

dd if=/root/kali-2017.3-rpi3.img of=/dev/sdb bs=4M

Once dd’d, we mount the various partitions and chroot into the Kali RPi3 image:

mkdir -p /mnt/chroot/boot

mount /dev/sdb2 /mnt/chroot/
mount /dev/sdb1 /mnt/chroot/boot/

mount -t proc none /mnt/chroot/proc
mount -t sysfs none /mnt/chroot/sys
mount -o bind /dev /mnt/chroot/dev
mount -o bind /dev/pts /mnt/chroot/dev/pts
apt-get install qemu-user-static

cp /usr/bin/qemu-arm-static /mnt/chroot/usr/bin/
LANG=C chroot /mnt/chroot/

We then update our image and install some essential packages we will need for this process:

apt-get update
apt-get install busybox cryptsetup dropbear-initramfs

We create an initial initramfs file, which will trigger the dropbear SSH key generation. We first find out the modules directory version number as follows (this will change between different image versions and Kali releases):

root@kali:/# ls -l /lib/modules/ |awk -F” ” ‘{print $9}’
4.9.59-Re4son-Kali-Pi+

We then use that version info to generate an initial initramfs file.

mkinitramfs -o /boot/initramfs.gz 4.9.59-Re4son-Kali-Pi+

We change the default root password.

passwd

Next, we modify the boot parameters in cmdline.txt and config.txt.

nano /boot/cmdline.txt

…and add / change the following parameters:

root=/dev/mapper/crypt_sdcard cryptdevice=/dev/mmcblk0p2:crypt_sdcard rootfstype=ext4

Next create or add to /boot/config.txt:

echo initramfs initramfs.gz >> /boot/config.txt

Now we deal with the Dropbear SSH access. We copy over SSH private key from our laptop, or, create one specifically for doing this:

Copying:

cp /root/.ssh/id_rsa.pub /etc/dropbear-initramfs/authorized_keys
chmod 0600 /etc/dropbear-initramfs/authorized_keys

Creating (on the host machine, NOT in the chroot:

ssh-keygen -N “” -f kali-luks-unlock
cat kali-luks-unlock.pub > /mnt/chroot/etc/dropbear-initramfs/authorized_keys
chmod 0600 /mnt/chroot/etc/dropbear-initramfs/authorized_keys

And limit the SSH connection to allow interaction with the cryptroot application only.

nano /etc/dropbear-initramfs/authorized_keys

We paste the following before the ssh public key begins.

command=”/scripts/local-top/cryptroot && kill -9 `ps | grep -m 1 ‘cryptroot’ | cut -d ‘ ‘ -f 3`”

Then to ensure we get cryptsetup in the initramfs, we edit the cryptsetup initramfs hook.

echo “CRYPTSETUP=y” >> /etc/cryptsetup-initramfs/conf-hook

We then edit fstab and crypttab with our configured boot device and exit the chroot:

cat > /etc/fstab <<EOF
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mapper/crypt_sdcard / ext4 defaults,noatime 0 1
EOF

echo crypt_sdcard /dev/mmcblk0p2 none luks > /etc/crypttab

During our tests, we noticed that in some instances, the USB ports take a while to wake up, which can kill the initrd Dropbear network initialization. To fix this, we introduce a 5-second sleep in the configure_networking function located in the initrd itself:

nano /usr/share/initramfs-tools/scripts/functions

change:

configure_networking()
{

to:

configure_networking()
{

echo “Waiting 5 seconds for USB to wake”
sleep 5

Note: Do NOT add the “…” they are a placeholder to mean there is more stuff there, that we aren’t editing.

Save the file then regenerate the initramfs and exit the chroot. You can ignore the cryptsetup and device-mapper warnings.

mkinitramfs -o /boot/initramfs.gz 4.9.59-Re4son-Kali-Pi+
exit

Now we proceed to tear down the chroot and backup our rootfs partition:

umount /mnt/chroot/boot
umount /mnt/chroot/sys
umount /mnt/chroot/proc
umount /mnt/chroot/dev/pts
umount /mnt/chroot/dev
mkdir -p /mnt/backup
rsync -avh /mnt/chroot/* /mnt/backup/

Once the backup is done, we unmount everything:

umount /mnt/chroot

Now we delete the existing 2nd partition on the SD card and recreate an empty one, which we will set up for LUKS encryption.

echo -e “d\n2\nw” | fdisk /dev/sdb
echo -e “n\np\n2\n\n\nw” | fdisk /dev/sdb

Unplug your SD card and plug it back in to have the new partitions register, then start setting up your encrypted partition.

cryptsetup -v -y –cipher aes-xts-plain64 –key-size 256 luksFormat /dev/sdb2
cryptsetup -v luksOpen /dev/sdb2 crypt_sdcard
mkfs.ext4 /dev/mapper/crypt_sdcard

Once ready, we restore the rootfs backup to the now encrypted partition.

mkdir -p /mnt/encrypted
mount /dev/mapper/crypt_sdcard /mnt/encrypted/
rsync -avh /mnt/backup/* /mnt/encrypted/
umount /mnt/encrypted/
rm -rf /mnt/backup
sync

Then we unmount and close the volume.

cryptsetup luksClose /dev/mapper/crypt_sdcard

That’s it!

Now all that remains is to boot up the RPi using the modified SD card. The initramfs will load Dropbear and get a DHCP address on your local LAN (you can also hardcode an IP), allowing you to SSH to the booting RPi and enter a decryption password. Once the password is accepted, Dropbear will exit and the RPi will continue to boot. You should see something like the following:

root@kali:~# ssh -i key 192.168.13.37
The authenticity of host ‘192.168.13.37 (192.168.13.37)’ can’t be established.
RSA key fingerprint is a6:a2:ad:7d:cb:d8:70:58:d1:ed:81:e8:4a:d5:23:3a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.13.37’ (RSA) to the list of known hosts.
Unlocking the disk /dev/mmcblk0p2 (crypt_sdcard)
Enter passphrase: cryptsetup: crypt_sdcard set up successfully
Connection to 192.168.13.37 closed.
root@kali:~#

Can I Have Some LUKS NUKE With That Pi?

If you are not familiar with the [Kali Linux LUKS NUKE] (https://www.kali.org/how-to/nuke-kali-linux-luks/) feature then you’re missing out. Although this stage is optional, it allows you to configure and apply an emergency self-destruct password to your LUKS encrypted drive. To do this, we simply define a Nuke password on our encrypted partition:

root@kali:~# cryptsetup luksAddNuke /dev/sdb2
Enter any existing passphrase: (existing passphrase)
Enter new passphrase for key slot: (new nuke passphrase)
root@kali:~#
With the Nuke password defined, you can now remotely wipe the LUKS decryption keyslots, making the data on the SD card inaccessible.

Raspberry Pi Disk Encryption Video

In order to give a bit more visual context to the process, we made a short video which shows the sequence of commands used to get LUKS disk encryption working on a Raspberry Pi B+. Enjoy!

Setting up LUKS disk encryption on a Raspberry Pi running Kali Linux. Also supports LUKS Nuke features!

Kali Linux USB Persistence

USB Persistence & Encrypted Persistence

In this workshop, we will examine the various features available to us when booting Kali Linux from USB devices. We will explore features such as persistence, creating LUKS encrypted persistence stores, and even dabble in “LUKS Nuking” our USB drive. The default Kali Linux ISOs (from 1.0.7 onwards) support USB encrypted persistence.

0x01 – Start by imaging the Kali ISO onto your USB stick (ours was /dev/sdb). Once done, you can inspect the USB partition structure using parted /dev/sdb print.

dd if=kali-linux-2016.2-amd64.iso of=/dev/sdb bs=1M

0x02 – Create and format an additional partition on the USB stick. In our example, we create a persistent partition of about 7 GB in size:

root@kali:~# parted
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.

(parted) print devices
/dev/sda (480GB)
/dev/sdb (31.6GB)

(parted) select /dev/sdb
Using /dev/sdb

(parted) print
Model: SanDisk SanDisk Ultra (scsi)
Disk /dev/sdb: 31.6GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
1      32.8kB  2988MB  2988MB  primary               boot, hidden
2      2988MB  3050MB  64.9MB  primary  fat16

(parted) mkpart primary 3050 10000
(parted) quit
Information: You may need to update /etc/fstab.

0x04 – Encrypt the partition with LUKS:

cryptsetup –verbose –verify-passphrase luksFormat /dev/sdb3

0x05 – Open the encrypted partition:

cryptsetup luksOpen /dev/sdb3 my_usb

0x06 – Create an ext3 filesystem and label it.

mkfs.ext3 /dev/mapper/my_usb
e2label /dev/mapper/my_usb persistence

0x07 – Mount the partition and create your persistence.conf so changes persist across reboots:

mkdir -p /mnt/my_usb
mount /dev/mapper/my_usb /mnt/my_usb
echo “/ union” > /mnt/my_usb/persistence.conf
umount /dev/mapper/my_usb
cryptsetup luksClose /dev/mapper/my_usb

Now your USB stick is ready to plug in and reboot into Live USB Encrypted Persistence mode.

Multiple Persistence Stores

At this point we should have the following partition structure:

root@kali:~# parted /dev/sdb print

We can add additional persistence stores to the USB drive, both encrypted or not…and choose which persistence store we want to load, at boot time. Let’s create one more additional non-encrypted store. We’ll label and call it “work”.

0x01 – Create an additional, 4th partition which will hold the “work” data. We’ll give it another 5GB of space.

root@kali:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) print
Model: SanDisk SanDisk Ultra (scsi)
Disk /dev/sdb: 31.6GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
1      32.8kB  2988MB  2988MB  primary               boot, hidden
2      2988MB  3050MB  64.9MB  primary  fat16
3      3050MB  10.0GB  6947MB  primary

(parted) mkpart primary 10000 15000
(parted) quit
Information: You may need to update /etc/fstab.

0x02 – Format the fourth partition, label it “work”.

mkfs.ext3 /dev/sdb4
e2label /dev/sdb4 work

0x03 – Mount this new partition and create a persistence.conf in it:

mkdir -p /mnt/usb
mount /dev/sdb4 /mnt/usb
echo “/ union” > /mnt/usb/persistence.conf
umount /mnt/usb

Boot the computer, and set it to boot from USB. When the boot menu appears, edit the persistence-label parameter to point to your preferred persistence store!

Emergency Self Destruction of Data in Kali

As penetration testers, we often need to travel with sensitive data stored on our laptops. Of course, we use full disk encryption wherever possible, including our Kali Linux machines, which tend to contain the most sensitive materials.

root@kali:~# cryptsetup luksAddNuke /dev/sdb3
Enter any existing passphrase:
Enter new passphrase for key slot:

Now dump the keyslots to see the changes:

root@kali:~# cryptsetup luksDump /dev/sda5
Device /dev/sda5 doesn‘t exist or access denied.
root@kali:~# cryptsetup luksDump /dev/sdb3
LUKS header information for /dev/sdb3

Version:          1
Cipher name:      aes
Cipher mode:      xts-plain64
Hash spec:        sha1
Payload offset:   4096
MK bits:          256
MK digest:        f7 17 b9 a7 9f 7f 9b 21 f2 b9 40 78 c2 97 f5 f0 c2 bb 28 8b
MK salt:          f5 a4 80 02 e7 21 0d 7e 5a 64 f4 96 78 a3 15 3c
09 7b 3f 41 80 2b 5c bf c5 de 92 70 69 bb 34 b2
MK iterations:    64500
UUID:             96793acb-c2d3-45b7-aed9-1af952386556

Key Slot 0: ENABLED
Iterations:             258064
Salt:                   df 3c d6 03 4a 78 ce ef 62 fd f1 56 25 d4 c5 96
2a 12 bb 94 4b d7 cf c1 0a b5 27 47 09 ae 31 46
Key material offset:    8
AF stripes:             4000
Key Slot 1: ENABLED
Iterations:             259108
Salt:                   30 07 ff ef fc f5 74 65 04 f7 66 87 77 f1 74 4f
7d 2f 76 e2 71 e7 6a 9c 6d c1 c1 7b 80 53 cb c1
Key material offset:    264
AF stripes:             4000
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
root@kali:~#

Backup you LUKS keyslots and encrypt them:

cryptsetup luksHeaderBackup –header-backup-file luksheader.back /dev/sdb3
openssl enc -d -aes-256-cbc -in luksheader.back.enc -out luksheader.back

Now boot into your encrypted store, and give the Nuke password, rather than the real decryption password. This will render any info on the encrypted store useless. Once this is done, verify that the data is indeed inacessible.

Lets restore the data now. We’ll decrypt our backup of the LUKS keyslots, and restore them to the encrypted partition:

openssl enc -d -aes-256-cbc -in luksheader.back.enc -out luksheader.back
cryptsetup luksHeaderRestore –header-backup-file luksheader.back /dev/sdb3

Our slots are now restored. All we have to do is simply reboot and provide our normal LUKS password and the system is back to its original state.

Building Custom Kali ISOs

One of the most powerful features of Kali Linux is the ability to create your own flavors of the distribution containing customized tools, desktop managers, and services. This workshop will show you how to create your own personalized Kali Linux ISO, customizing virtually every aspect using the live-build utility and making efficient use of the various meta-packages available in Kali.

The Awesomeness of Live Build

0x00 – Begin by updating the repos, installing the prerequisites, and checking out a fresh version of live-build-config from the Kali Git repositories:

apt update
apt install git live-build cdebootstrap devscripts -y
git clone git://git.kali.org/live-build-config.git
cd live-build-config

0x01 – Overwrite the default Kali package list, including only the packages you want. In the video, we simply edited the list and changed a few package names.

cat > kali-config/variant-default/package-lists/kali.list.chroot << EOF
kali-root-login
kali-defaults
kali-menu
kali-debtags
kali-archive-keyring
debian-installer-launcher
alsa-tools
locales-all
dconf-tools
openssh-server
EOF

0x02 – Add a customised syslinux boot entry which includes a boot parameter for a custom preseed file.

cat << EOF > kali-config/common/includes.binary/isolinux/install.cfg
label install
menu label ^Install Automated
linux /install/vmlinuz
initrd /install/initrd.gz
append vga=788  quiet file=/cdrom/install/preseed.cfg locale=en_US keymap=us hostname=kali domain=local.lan
EOF

0x03 – Customise the ISO build. In this example, we’ll have the SSH service start by default. To do this, we can use a chroot hook script which is placed in the “hooks” directory:

echo ‘systemctl enable ssh’ >>  kali-config/common/hooks/01-start-ssh.chroot
chmod +x kali-config/common/hooks/01-start-ssh.chroot

0x04 – Next, we download a wallpaper and overlay it. Notice how chroot overlayed files are placed in the includes.chroot directory.

Capture

0x05 – Add a preseed file that will run through a default Kali installation with no input (unattended). We can include a ready made preseed configuration and alter it as needed:

mkdir -p kali-config/common/debian-installer

wget https://raw.githubusercontent.com/offensive-security/kali-linux-preseed/master/kali-linux-full-unattended.preseed -O kali-config/common/debian-installer/preseed.cfg

0x06 – Let’s include a Nessus Debian package into the packages directory for inclusion into our final build. Since we used a 64 bit build, we’re including a 64 bit Nessus Debian package. Download the Nessus .deb file and place it in the packages.chroot directory:

mkdir kali-config/common/packages.chroot
mv Nessus-*amd64.deb kali-config/common/packages.chroot/

0x07 – Now you can proceed to build your ISO, this process may take a while depending on your hardware and internet speeds. Once completed, your ISO can be found in the live-build root directory.

./build.sh -v

Kali Linux Trademark Policy

Kali Linux and Offensive Security want to promote the widespread recognition of our trademarks among the Internet community however, we also need to ensure our trademarks solely identify our company and our products. At the heart of our trademark policy is trust – we want to avoid the public from being confused into believing they are dealing with Kali Linux and/or Offensive Security when, in fact, they are not. This is of particular importance with regards to the development and distribution of trusted penetration testing distribution such as Kali Linux.

This document identifies and the describes our trademarks and provides guidance as to their fair use. We are generally quite accommodating when it comes to fair and honest use of our trademarks so if you are so inclined, feel free to contact us for further guidance.

Some of our Trademarks

tm
tm
tm
tm
tm

Use in Print, Web, Media and Public Display

It is important to maintain the look and spelling of the trademarks. Please do not modify the marks. Examples of modifying the marks include abbreviating names, adding logos to the marks, or combining the marks with other words. We recommend you use the trademarks in the exact form as we use them.

The Offensive Security trademarks are to designate the source of our products and services. We encourage others to use the marks so long as they are used to identify the products and services of Offensive Security. We do not want to confuse the public into believing that they are dealing with us, when in fact, they are not.

The first mention of an Offensive Security trademark should be accompanied by a symbol indicating whether the mark is a registered trademark “®” or an unregistered trademark “™”. Please refer to the above list for the appropriate symbol to use and if in doubt, use “™”.

The use of an Offensive Security trademark should be set apart from surrounding text, either by capitalizing it or by italicizing, bolding or underlining it. The Offensive Security trademarks are to designate the source of our products and services.

When using an Offensive Security trademark in written materials, you should provide a statement indicating that the [trademark] is a trademark of Offensive Security. For example:

“KALI LINUX ™ is a trademark of Offensive Security.” This statement can be provided directly in your text, or as a footnote or an endnote.

The use of Offensive Security trademarks in your domain names is prohibited because such use will lead to the confusion of customers. Any other use outside of the scope of the Trademark Policy is not permitted without express written permission of Offensive Security.

You may make t-shirts, desktop wallpaper, or other merchandise with Offensive Security Marks on them, though only for yourself and your friends (meaning people from whom you don’t receive anything of value in return). You can’t put the trademarks on anything that you produce commercially (whether or not you make a profit) — at least not without receiving written permission.

Contact

If you have any questions or comments, or wish to report misuse of the Offensive Security trademarks, please contact us.

Kali Linux Open Source Policy

Kali Linux is a Linux distribution that aggregates thousands of free software packages in its main section. As a Debian derivative, all of the core software in Kali Linux complies with the Debian Free Software Guidelines.

As the specific exception to the above, Kali Linux’s non-free section contains several tools which are not open source, but which have been made available for redistribution by Offensive Security through default  or specific licensing agreements with the vendors of those tools.

If you want to build a Kali derivative, you should review the license of each Kali-specific non-free package before including it in your distribution — but note that non-free packages which are imported from Debian are safe to redistribute.

More importantly, all of the specific developments in Kali Linux’s infrastructure or its integration with the included software have been put under the GNU GPL.

If you want more information about the license of any given piece of software, you can either check debian/copyright in the source package or /usr/share/doc/package/copyright for a package that you have already installed.

Kali’s Relationship With Debian

The Kali Linux distribution is based on Debian Testing. Therefore, most of the Kali packages are imported, as-is, from the Debian repositories. In some cases, newer packages may be imported from Debian Unstable or Debian Experimental, either to improve user experience, or to incorporate needed bug fixes.

Forked Packages

In order to implement some of Kali’s unique features, we had to fork some packages. The Kali development team strives to keep such packages to a minimum by improving the upstream packages whenever possible, either by integrating the feature directly, or by adding the required hooks so that it’s straightforward to enable the desired features without further modifying the upstream packages themselves.

Each package forked by Kali is maintained in a Git repository with a “debian” branch so that updating a forked package can be easily done with a simple git merge debian in its master branch.

Additional Packages

Beyond this, Kali incorporates many additional packages which are specific to the penetration testing and security auditing field. The majority of these packages constitute “free software” according to Debian’s Free Software Guidelines. Kali intends to contribute those packages back to Debian and to maintain them directly within Debian.

To facilitate this, Kali packaging strives to comply with the Debian Policy and follow the best practices in use in Debian.

Penetration Testing Tools Policy

Kali Linux Tools Policy

One of the key tasks in transitioning from Backtrack Linux to Kali was combing through the packages and selecting the “best of breed” from what was available.

We realize that there are many tools or scripts that can do the same job. Some are clearly better than others in some respect, some are more a matter of personal preference. With this in mind, keeping an updated, useful penetration testing tool repository is a challenging task. The Kali Development team uses some of these questions to help decide whether a specific tool should be included in Kali Linux.

  • Is the tool useful/functional in a Penetration Testing environment?
  • Does the tool overlap functionality of other existing tools?
  • Does the licensing of the tool allow for free redistribution?
  • How much resources does the tool require? Will it work in a “standard” environment?

The answers to questions such as these, among other considerations, help us come to a decision whether the tool should be included in Kali.

Most of the members of the Kali development team are working penetration testers, and we rely on our combined experience and expertise to select the best tools to add the most value to the Kali distribution as we continue its development.

Tools which are specifically aimed at DOS, DDOS or anonymity are rarely used in legitimate engagements, and are therefore not installed by default in Kali Linux.

New Tool Requests

We are always open to adding new and better tools to our distribution, but we ask that a case be made for each tool. Please put some thought and effort into the tool submission, and please do not just send the developers a one line request. Submissions for new tool requests can be made through our Kali Linux bug tracker.

Kali Linux Update Policies

The majority of the packages comprising the Kali Linux distribution are drawn directly from the Debian repositories. For those packages which have been incorporated into Kali Linux “as-is” — i.e. the vast majority — security updates arrive at essentially the same time for Kali Linux as for the main Debian distribution.

Other packages are supported on a best-effort basis by the Kali Linux development team.

Kali Network Service Policies

Kali Linux is a penetration testing toolkit, and may potentially be used in “hostile” environments. Accordingly, Kali Linux deals with network services in a very different way than typical Linux distributions. Specifically, Kali does not enable any externally-listening services by default with the goal of minimizing exposure when in a default state.

Default Disallow Policy

Kali Linux, as a standard policy, will disallow network services from persisting across reboots by default.

The following example can be seen when attempting to install a tool which would by default would start a network proxy service on TCP port 3142:

root@kali:~# apt-get install apt-cacher-ng

Setting up apt-cacher-ng (0.7.11-1) …
update-rc.d: We have no instructions for the apt-cacher-ng init script.
update-rc.d: It looks like a network service, we disable it.

root@kali:~#

Notice how the update-rc.d script disallowed persistence of the apt-cacher-ng daemon by default.

Overriding the Default Policy

In certain situations, you may actually want certain services to persist over reboots. To allow for this, you can enable a service to persist through reboots using the systemctl command as follows:

root@kali:~# systemctl enable apt-cacher-ng
Synchronizing state of apt-cacher-ng.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apt-cacher-ng
insserv: warning: current start runlevel(s) (empty) of script `apt-cacher-ng‘ overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `apt-cacher-ng’
 overrides LSB defaults (0 1 6).

Service whitelists and blacklists

Service whitelists and blacklists can be found in the /usr/sbin/update-rc.d file. You can edit this file to explicitly allow or deny services the ability to automatically start up at boot time.

root@kali:~# tail -95 /usr/sbin/update-rc.d |more

__DATA__
#
# List of blacklisted init scripts
#
apache2 disabled
avahi-daemon disabled
bluetooth disabled
cups disabled
dictd disabled
ssh disabled

#
# List of whitelisted init scripts
#
acpid enabled
acpi-fakekey enabled
acpi-support enabled
alsa-utils enabled
anacron enabled

Kali Linux Root User Policy

Most Linux distributions, quite sensibly, encourage the use of a non-privileged account while running the system and use a utility like sudo when and if escalation of privileges in needed. This is sound security advice: this provides an extra layer of protection between the user and any potentially disruptive or destructive operating system commands or operations. This is especially true for multiple user systems, where user privilege separation is a requirement — misbehavior by one user can disrupt or destroy the work of many users.

Kali Linux, however, as a security and auditing platform, contains many which tools can only run with root privileges. Further, Kali Linux’s nature makes its use in a multi-user environment highly unlikely.

For these reasons, the default Kali user is “root”, and no non-privileged user is created as a part of the installation process. This is one reason that Kali Linux is not recommended for use by Linux beginners who might be more apt to make destructive mistakes while running with root privileges.