The paranoid #! Security Guide
Table of Contents:
Introduction
Basic Considerations
BIOS-Passwords
Encryption
Making TrueCrypt Portable
Hardware Encryption
Attacks on Full-Disk-Encryption
Attacks on encrypted Containers
Debian's encrypted LVM pwned
Solutions
eCryptfs
Encrypting SWAP using eCryptfs
Tomb
Advanced Tomb-Sorcery
Keyloggers
Software Keyloggers
Defense against Software Keyloggers
Hardware Keyloggers
Defense against Hardware Keyloggers
Secure File-Deletion
BleachBit
srm [secure rm]
Other Ways to securely wipe Drives
Your Internet-Connection
ipkungfu
Configuring /etc/sysctl.conf
Modem & Router
Intrusion-Detection, Rootkit-Protection & AntiVirus
Snort
RKHunter
RKHunter-Jedi-Tricks
chkrootkit
Tiger
Lynis
debsums
sha256
ClamAV
DNS-Servers
Using secure and censor-free DNS
DNSCrypt
Firefox/Iceweasel
Firefox-Sandbox: Sandfox
Firefox-Preferences
Plugins
Addons
SSL-Search-Engines
Flash-Settings
about:config
Prevent Browser-Fingerprinting
TOR [The Onion Router]
TOR-Warning
I2P
Freenet
Secure Peer-to-Peer-Networks
Mesh-Networks
Proxies
Proxy-Warning
VPN (Virtual Private Network)
The Web
RSS-Feeds
Secure Mail-Providers
Disposable Mail-Addresses
Secure Instant-Messaging/VoIP
TorChat
OTR [Off-the-Record-Messaging]
Secure and Encrypted VoIP
Social Networking
Facebook
Alternatives to Facebook
Passwords
pwgen
KeePass
Live-CDs and VM-Images that focus on security and anonymity
Further Info/Tools
Introduction
Hi all!
This is my first attempt to contribute something to the community. Basically you can find everything I write here somewhere else on the web or in some book - but exactly that is the problem. You can literally spend weeks digging up all this stuff. And to save you some trouble I thought: "Heck, let's just put this into a little manual."
You're dealing with a somewhat paranoid security setup for debian-based systems like #!.
[This is the end-user and not the |-|4xx0|2-version. We are not getting into virtual-virtual-virtual-machine-double-vpn-ssh-proxy-chain-from-your-internet-cafe-type-stuff.]
In this small guide I simply provide several "recipes" for securing both your box and your internet-connection and web-applications. I won't go into the why of all of this in too much detail as I want to provide a simple how-to that people can follow to make their system more secure without having to read through hundreds of pages of explanations. This information can easily be found elsewhere. If you're interested in a certain topic then just fire up a web-search and give it a read.
This guide is not exhaustive of course. As they say, security is a process - and so this guide can only be a place to start which needs to be adjusted to your personal needs.
If you consider to use this information and you find something to be too overcautious for your particular need - just ignore it and move on. One last thing before we begin: I am not a "security-guru" (far from it) - but more appropriately (as my nick suggests) some dude wrapping his head around things...
Basic considerations
BIOS-Passwords
For the physical security of your data you should always employ encrypted drives. But before we get to that make sure you set strong passwords in BIOS for both starting up and modifying the BIOS-settings. Also make sure to disable boot for any media other than your harddrive.
Encryption
With #! this is easy. In the installation you can simply choose to use an encrypted LVM. (For those of you who missed that part on installation and would still like to use an encrypted partition withouth having to reinstall: use these instructions to get the job done.) For other data, e.g. data you store on transportable media you can use TrueCrypt - which is better than e.g. dmcrypt for portable media since it is portable, too. You can put a folder with TrueCrypt for every OS out there on to the unencrypted part of your drive and thus make sure you can access the files everywhere you go.
This is how it is done:
Making TrueCrypt Portable
•
• Download yourself some TC copy.
•
• Extract the tar.gz
•
• Execute the setup-file
•
• When prompted choose "Extract .tar Package File"
•
• go to /tmp
•
• copy the tar.gz and move it where you want to extract/store it
•
• extract it
•
• once it's unpacked go to "usr"->"bin" grab "truecrypt"-binary
•
• copy it onto your stick
•
• give it a test-run
There is really not much more in that tarball than the binary. Just execute it and you're ready for some crypto.
I don't recommend using TrueCrypt's hidden container, though. Watch this vid to find out why. If you don't yet know how to use TrueCrypt check out this guide. [TrueCrypt's standard encryption is AES-256. This encryption is really good but there are ways to attack it and you don't know how advanced certain people already got at this. So when prompted during the creation of a TrueCrypt container use: AES-Twofish-Serpent and as hash-algorithm use SHA-512. If you're not using the drive for serious video-editing or such you won't notice a difference in performance. Only the encryption process when creating the drive takes a little longer. But we get an extra scoop of security for that... ]
Hardware Encryption
There are three different types of hardware encrypted devices available, which are generally called: SED (Self Encrypting Devices)
- Flash-Drives (Kingston etc.)
- SSD-Drives (Samsung etc.)
- HD-Drives (WD, Hitachi, Toshiba etc.)
They all use AES encryption. The key is generated within the device's microprocessor and thus no crucial data - neither password nor key are written to the host system. AES is secure - and thus using these devices can give some extra protection.
But before you think that all you need to do is to get yourself one of these devices and you're safe - I have to warn you: You're not.
So let's get to the reasons behind that.
Attacks on Full-Disk-Encryption
Below we will have a look at a debian specific attack using a vulnerability common with encrypted LVMs.
But you need to be aware that all disk-encryption is generally vulnerable - be it software- or hardware-based. I won't go into details how each of them work exactly - but I will try to at least provide you with a short explanation.
For software-based disk-encryption there are these known attacks:
- DMA-Attacks (DMA/HDMI-Ports are used to connect to a running, locked machine to unlock it)
- Cold-Boot-Attacks (Keys are extracted from RAM after a cold reboot)
- Freezing of RAM (RAM is frozen and inserted into the attacker's machine to extratct the key)
- Evil-Maid-Attacks (Different methods to boot up a trojanized OS or some kind of software-keylogger)
For hardware-based disk-encryption there are similar attacks:
- DMA-Attacks (same as with SW-based encryption)
- Replug-Attacks (Drive's data cable is disconnected and connected to attacker's machine via SATA-hotplugging)
- Reboot-Attacks (Drive's data cable is disconnected and connected to attacker's machine after enforced reboot. Then the bios-password is circumvented through the repeated pressing of the F2- and enter-key. After the bios integrated SED-password has been disabled the data-cable is plugged into the attacker's machine. This only works on some machines.)
- Networked-Evil-Maid-Attacks (Attacker steals the actual SED and replaces it with another containing a tojanized OS. On bootup victim enters it's password which is subsequently send to the attacker via network/local attacker hot-spot. Different method: Replacing a laptop with a similar model [at e.g. airport/hotel etc.] and the attacker's phone# printed on the bottom of the machine. Victim boots up enters "wrong" password which is send to the attacker via network. Victim discovers that his laptop has been misplaced, calls attacker who now copies the content and gives the "misplaced" laptop back to the owner.)
A full explanation of all these attacks been be found in this presentation. (Unfortunately it has not yet been translated into English.) An English explanation of an evil-maid-attack against TrueCrypt encrypted drives can be found here
Attacks on encrypted Containers
There are also attacks against encrypted containers. They pretty much work like cold-boot-attacks, without the booting part.
An attacker can dump the container's password if the computer is either running or is in hibernation mode - either having the container open and even when the container has been opened during that session - using temporary and hibernation files.
Debian's encrypted LVM pwned
This type of "full" disk encryption can also be fooled by an attack that could be classified as a custom and extended evil-maid-attack. Don't believe me? Read this!
The problem basically is that although most of the filesystem and your personal data are indeed encrypted - your boot partition and GRUB aren't. And this allows an attacker with physical access to your box to bring you into real trouble.
To avoid this do the following:Micah Lee wrote:
If you don’t want to reinstall your operating system, you can format your USB stick, copy /boot/* to it, and install grub to it. In order to install grub to it, you’ll need to unmount /boot, remount it as your USB device, modify /etc/fstab, comment out the line that mounts /boot, and then run grub-install /dev/sdb (or wherever your USB stick is). You should then be able to boot from your USB stick.
An important thing to remember when doing this is that a lot of Ubuntu updates rewrite your initrd.img, most commonly kernel upgrades. Make sure your USB stick is plugged in and mounted as /boot when doing these updates. It’s also a good idea to make regular backups of the files on this USB stick, and burn them to CDs or keep them on the internet. If you ever lose or break your USB stick, you’ll need these backups to boot your computer.
One computer I tried setting this defense up on couldn’t boot from USB devices. I solved this pretty simply by making a grub boot CD that chainloaded to my USB device. If you google “Making a GRUB bootable CD-ROM,” you’ll find instructions on how to do that. Here’s what the menu.1st file on that CD looks like:
default 0
timeout 2
title Boot from USB (hd1)
root (hd1)
chainloader +1
I can now boot to this CD with my USB stick in, and the CD will then boot from the USB stick, which will then boot the closely watched initrd.img to load Ubuntu. A little annoying maybe, but it works.
(Big thanks to Micah Lee!)
Note: Apparently there is an issue with installing GRUB onto USB with waldorf/wheezy. As soon as I know how to get that fixed I will update this section.
Solutions
You might think that mixing soft- and hardware-based encryption will solve these issues. Well, no. They don't. An attacker can simply chain different methods and so we are back at square one. Of course this makes it harder for an attacker to reach his goals - but he/she will not be stopped by it. So the only method that basically remains is to regard full-disk-encryption as a first layer of protection only.
Please don't assume that the scenarios described above are somewhat unrealistic. In the US there are about 5000 laptops being lost or stolen each week on airports alone. European statistics indicate that about 8% of all business-laptops are at least once either lost or stolen.
A similar risk is there if you leave the room/apartment with your machine locked - but running. So the first protection against these methods is to always power down the machine. Always.
The next thing to remind yourself off is: You cannot rely on full-disk-encryption. So you need to employ further layers of encryption. That means that you will have to encrypt folders containing sensitive files again using other methods such as tomb or TrueCrypt. That way - if an attacker manages to get hold of your password he/she will only have access to rather unimportant files. If you have sensitive or confidential data to protect full-disk encryption is not enough!
When using encrypted containers that contain sensitive data you should shutdown your computer after having used them to clear all temporary data stored on your machine that could be used by an attacker to extract passwords.
If you have to rely on data being encrypted and would be in danger if anyone would find the data you were encrypting you should consider only using a power-supply when using a laptop - as opposed to running on power and battery. That way if let's say, you live in a dictatorship or the mafia is out to get you - and they are coming to your home or wherever you are - all you need to do when you sense that something weird is going on is to pull the cable and hope that they still need at least 30 secs to get to your ram. This can help prevent the above mentioned attacks and thus keep your data safely hidden.
eCryptfs
If for some reason (like performance or not wanting to type in thousands of passwords on boot) you don't want to use an encrypted LVM you can use ecryptfs to encrypt files and folders after installation of the OS.
To find out about all the different features of ecryptfs and how to use them I would like to point you to bodhi.zazen's excellent ecryptfs-tutorial.
But there is one thing that is also important for later steps in this guide and is generally a good idea to do:
Encrypting swap using ecryptfs
Especially when using older machines with less ram than modern computers it can happen quite frequently that your machine will use swap for different tasks when there's not enough ram available to do the job. Apart from the lack of speed this is isn't very nice from a security standpoint: as the swap-partition is not located within your ram but on your harddrive - writing into this partion will leave traces of your activities on the harddrive itself. If your computer happens to use swap during your use of encryption tools it can happen that the passwords to the keys are written to swap and are thus extractable from there - which is something you really want to avoid.
You can do this very easily with the help of ecryptfs.
First you need to install it:
Code: Select all
$ sudo apt-get install ecryptfs-utils cryptsetup
Then we need to actually encrypt our swap using the following command:
Code: Select all
$ sudo ecryptfs-setup-swap
Your swap-partition will be unmounted, encrypted and mounted again.
To make sure that it worked run this command:
Code: Select all
$ sudo blkid | grep swap
The output lists your swap partion and should contain "cryptswap".
To avoid error messages on boot you will need to edit your /etc/fstab to fit your new setup:
Code: Select all
$ sudo geany /etc/fstab
Copy the content of that file into another file and save it. You will want to use it as back-up in case something gets screwed up.
Now make sure to find the entry of the above listed encrypted swap partition. If you found it go ahead and delete the other swap-entry relating to the unencrypted swap-partition. Save and reboot to check that everything is working as it should be.
Tomb
Another great crypto-tool is Tomb provided by the dyne-crew.
Tomb uses LUKS AES/SHA-256 and can thus be consider secure. But Tomb isn't just a possible replacement for tools like TrueCrypt.
It has some really neat and easy to use features:
1) Separation of encrypted file and key
2) Mounting files and folders in predefined places using bind-hooks
3) Hiding keys in picture-files using steganography
The documentation on Tomb I was able to find, frankly, seems to be scattered all over the place.
After I played around with it a bit I also came up with some tricks that I did not see being mentioned in any documentation.
And because I like to have everything in one place I wrote a short manual myself:
Installation:
First you will need to import dyne's keys and add them to your gpg-keylist:
Code: Select all
$ sudo gpg --fetch-keys
http://apt.dyne.org/software.pubNow verify the key-fingerprint.
Code: Select all
$ sudo gpg --fingerprint software@dyne.org | grep fingerprint
The output of the above command should be:
Code: Select all
Key fingerprint = 8E1A A01C F209 587D 57063A36 E314 AFFA 8A7C 92F1
Now, after checking that you have the right key you can trust add it to apt:
Code: Select all
$ sudo gpg --armor --export software@dyne.org > dyne.gpg$ sudo apt-key add dyne.gpg
After you did this you want to add dyne's repos to your sources.list:
Code: Select all
$ sudo geany /etc/apt/sources.list
Add:
Code: Select all
deb
http://apt.dyne.org/debian dyne maindeb-src
http://apt.dyne.org/debian dyne main
To sync apt:
Code: Select all
$ sudo apt-get update
To install Tomb:
Code: Select all
$ sudo apt-get install tomb
Usage:
If you have your swap activated Tomb will urge you to turn it off or encrypt it. If you encrypt it and leave it on you will need to include --ignore-swap into your tomb-commands. To turn off swap for this session you can run
Code: Select all
$ swapoff -a
To disable it completely you can comment out the swap in /etc/fstab. So it won't be mounted on reboot. (Please be aware that disabling swap on older computers with not much ram isn't such a good idea. Once your ram is being used fully while having no swap-partition mounted processes and programs will crash.)
Tomb will create the crypto-file in the folder you are currently in - so if you want to create a tomb-file in your documents-folder make sure to
Code: Select all
$ cd /home/user/documents
Once you are in the right folder you can create a tomb-file with this command:
Code: Select all
$ tomb -s XX create FILE
XX is used to denote the size of the file in MB. So in order to create a file named "test" with the size of 10MB you would type this:
Code: Select all
$ tomb -s 10 create test