Comments

Kali Linux on the X1 Carbon Grub-pc Encrypted LVM FINALLY!

So finally I have Kali linux 1.0.6. installed as the main OS on my Lenovo X1 Carbon, this was not a trivial matter to say the least.

First of all the installation routine fails trying to install grub-pc; this is due to the network configuration step of the routine creating a blank /etc/resolv.conf

So right after network configuration has completed inspect your /etc/resolv.conf and if it is blank as mine was:

1
echo "nameserver 8.8.8.8" >> /etc/resolv.conf

Ensuring this is done BEFORE it reaches the grub installation step; this will now complete as expected.

Next up post reboot the encrypted LVM fails to mount, citing it was unable to find kali-root

1
2
3
4
Loading, please wait...
    Volume group "kali" not found
    Skipping volume group kali
Unable to find LVM volume kali/root

Help is however at hand, boot back into the live distro forensics mode, and what follows is my somewhat condensed and modified procedure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
blkid /dev/sda5
/dev/sda5: UUID="XXXXXX" TYPE="crypto_luks"
cryptsetup /dev/sda5 luksOpen sda1_crypt
vgchange -ay kali
mkdir -p /mnt/root
mount /dev/mapper/kali-root /mnt/root
cd /mnt/root
mount -t proc proc proc
mount -t sysfs sys sys
mount -o bind /dev dev
mount /deva/sda1 boot
chroot /mnt/root
echo "sda1_crypt UUID=XXXXXX non luks" > /etc/crypttab
update-initramfs -u
exit
reboot

As for UEFI / EFI ? Don’t even get me started there nothing I have spent long evening hours looking into works for kali, not using the fedora shim nothing at this time; I’m very annoyed at this and will post again once I arrive to a resolution.

In the interim CaptTofu release some interesting material on leveraging Docker to test PXC deploys, he’s even go so far to produce some Ansible playbooks for the deployment process; I’ve been helping to work in some respect on the Ansible side and I can see a lot of potential in docker aswell as a lot of issues (it is a very young project it reminds me a lot of OpenStack hack in the diablo RC days), I encourage you to check this out.

Spanking the Scan Monkies

Hello 2014, do I have your attention?

Early warning This is a satirical blog post, with colourful language of which the sole intent is to troll automated scanners and script kiddies, those of a disposition nature should stop reading now.

Shortly after watching @chrisjohnriley’s Defcon 21 talk defense by numbers, I began thinking how I could implement so of the methods within nginx, taking them to another level by trolling and generally pissing off anyone scanning the server.

Some background on this nginx server does nothing but bounce old domains, and links to their appropriate place on this blog, so it’s out of the way not something you’d typically see attacked en mass.

(seriously I see one or two hits from search engines on the instance, except recently China Telecom must LOVE my blog, 500K requests in an hour … aww shucks guys I love you too)

So let us start with response codes, because 400 response codes are so last century right? I really can’t see why the 7xx-rfc isn’t already a standard.

So I opted for responding to automated scans of my nginx instance with the 793 response code; helpfully letting the scanner know that the Zombie Apocalypse has occured where the instance is located and that I care not of their scans as I’m either shambling along biting everyone within reach and incoherently moaning, or I’m too busy trying to not get my ass zombified.

Zombie apocolypse is serious business; they should appreciate my early warning!

Providing this sorely needed public service is this small nginx server block after my main server block handling all valid requests.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
    listen 80 default_server;

    server_tokens off;
    autoindex off;
    root /var/www/rickroll;
    index index.html;
    add_header X-Never-gonna-give-you-up "";
    add_header X-Never-gonna-let-you-down "";
    add_header X-Never-gonna-run-around-and-desert-you "";
    add_header X-Never-gonna-make-you-cry "";
    add_header X-Never-gonna-say-goodbye "";
    add_header X-Never-gonna-tell-a-lie-and-hurt-you "";

    return 793; #zombie apocolypse 
}

if only those scanners could fully appreciate the midi tones of Rick Astley melodic symphony soothing them to sleep in the wake of the end of all things via Zombie Apocolypse … alas we wonder do calculators dream?

Yup no hostnames were being sent as part of the request, so China telecom doesn’t love my blog afterall … well screw you guys! I thought we had something but you were just a fake …

but wait there’s more just as the sweet verses dictate; we’re never going to give you up, so if you’re making so many requests in such a short time you must want to stay connected to me for as long as possible, it’s ok I’ve got you covered.

1
2
iptables -A INPUT -p tcp --dport 80 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 80 --state NEW -m recent --update --seconds NN --hitcount N -j TARPIT

Forever together … into the tarpit … shhhh … only dreams now …

And for those not snuggling with us down in the tarpit, sorry but you’ll just need to prove you really want to be in there; sticky cuddles …

YMMV etc this isn’t a fully tested configuration, it’s not ment to do anything but troll all the automated scanners out there hammering the instance.

Comments

Two Factor SSH Authentication - Pubkey Yubikey

OpenSSH >= 6.2 supports “multi factor authentication” which is to say you can require multiple forms of identification to complete authentication for the SSH connection.

A real world comparrison would be I suppose providing more than one form of identification to open a bank account.

OpenSSH 6.2 introduces the AuthenticationMethods setting; this combined with pam_yubico can be used to require that the connections provides both the SSH public key and the yubikey O.T.P (One time password).

OpenSSH 6.2 is included Fedora 19 and for a while now OpenSSH has supported the Match Group (I covered the use of such for chrooting users easily).

So we’re going to combined this combination such that we attain the following:

  1. SSH Connections will require pubkey authentication
  2. SSH Connections will also require yubikey authentication
  3. The above will be applied to specified users via the Match Group clause

To be clear if the connection does not provide a valid public key for the user; it will never reach the yubikey prompt stage; also if the provided yubikey OTP is invalid authentication will also fail.

Install the pam_yubico package: sudo yum -y install pam_yubico

At the end of your /etc/ssh/sshd_config add the following:

1
2
3
Match Group mfagroup
    AuthenticationMethods pubkey,keyboard-interactive
    

You will also need to set ChallengeResponseAuthentication yes in your sshd_config file.

The above is the bare minimum you can add any additions you wish; and restart sshd.

Create the file /etc/pam.d/yubi-auth with the content

1
auth sufficient pam_yubico.so id=your_yubicloud_id key=your_yubicloud_api_key authfile=/etc/ssh/yubikey_mappings url=https://api.yubico.com/wsapi/2.0/verify?id=%d&otp=%s debug

Note: I am specifying the URL as the default will use http and not https despite what the documentation might say.

Create the file: /etc/ssh/yubikey_mappings with the content:

1
username:yubikey_identity

You can get your yubikey identity from demo.yubico.com

Edit /etc/pam.d/sshd so that the first lines read:

1
2
#%PAM-1.0
auth       include     yubi-auth

And finally create a user in your group, in this case we’re using the mfagroup.

useradd -g mfagroup -s /bin/bash username and install their public ssh key in /home/username/.ssh/authorized_keys, ensuring proper permissions.

All being well when you try to login with the user you should see the following:

1
2
Authenticated with partial success.
Yubikey for `username': 

And you have sucessfully setup two factor ssh authentication with public keys.

Comments

SELinux on Amazon AMI Linux

This took a little digging into; in order to get SELinux to function on Amazon AMI Linux you must carry out the following steps.

yum -y install policycoreutils selinux-policy-targeted

Now edit /etc/grub.conf and ensure your kernel line looks something like the following:

1
2
3
4
title Amazon Linux 2013.XX (3.XX.XX-XX.XX.amzn1.x86_64)
root (hd0)
kernel /boot/vmlinuz-3.XX.XX-XX.XX.amzn1.x86_64 root=LABEL=/ console=hvc0 selinux=1 security=selinux enforcing=1 LANG=en_US.UTF-8 KEYTABLE=us
initrd /boot/initramfs-3.XX.XX-XX.XX.amzn1.x86_64.img

Note the addition of “selinux=1 security=selinux enforcing=1”

Now: touch /.autorelabel

And: /sbin/new-kernel-pkg --package kernel --mkinitrd --make-default --dracut --depmod --install 3.XX.XX-XX.XX.amzn1.x86_64 || exit $?

Replacing the XX portions with your running kernel or you can use substitute in the uname -r output; this one liner script was obtained from: rpm -q --scripts kernel and is required to rebuild the initrd image such that the selinux settings can take effect.

Alternatively if there are updates outstanding a yum -y update will acheive the same thing (selinux settings should persist); after all of this you can now reboot and wait.

This will take a while to start back up as an selinux relabel is running (this is what the touch /.autorelabel achieves.

All being well selinux should now be running enforcing in targeted mode; if not check your /etc/selinux/config file.

Comments

Percona Live UK 2013

Percona Live London 2013 drew to a close yesterday, following some truely great talks.

I myself presented a talk on security which it appears was very well received, and I am hopeful this talk will make it into the line up for percona live 2014.

My talk was well received and there was a lot of great Q&A both during and after the session … though I did run 15 minutes over sorry Tim I’ll have to buy you a beer by way of appology at the next confernece.

Ryan H also gave a great talk on backups, I’ll update this blog post with a link to the slides once tey become available.

I’ve posted some photos of the event aswell.

More to come.