2013-01-27

Hard time upgrading to Fedora 18

Hard time upgrading to Fedora 18

Upgrade to new version of Fedora (Fedora 18) was this time harder than french kissing an Anaconda. Both recommended methods of installing (USB from ISO) / upgrading (FedUp) failed for me.

Using FedUp is nightmare. It required in my case 3GB for download just to copy it to install directory (another 3GB). Even when I was able to empty that much space in the system partition it asked for another 2GB of empty space for the upgrade. After cleaning up the unnecessary stuff it still crashed in infinite loop asking for password for my encrypted drive (probably bug 896010).

Then I decided just delete the system partition and just make fresh install of it. Booting from the ISO image using USB / HDD grub2 loopback was quite ok. Problem is I was not able to pass through disk partitioning. I have got quite unusual partition table with multiboot to 3+ systems. All partitions are encrypted - truecrypt NTFS, LUKS + ext3, LUKS + swap, LUKS + LVM - probably some of that crypto stuff is freaking Anaconda do death. (bugs 890881 and/or 862948 )

My workaround to upgrade Fedora 17 to Fedora 18 with all the encryption was this:

  • boot from ISO CD / USB
  • use cryptsetup luksOpen for the system partition
  • format /dev/mapper/luks-root with mkfs -t ext4 to clean it
  • Clone the minimal filesystem on the ISO to your new system partition. The image of the minimal FC18 filesystem is as device mapped somewhere in /dev/mapper/*. Pipe "dump" command to "restore" to clone the whole filesystem. Someting like:
    dump -0u /dev/mapper/iso-min-something | (cd /mnt/root; restore -rf -)
  • mount the luks-root to /mnt/root directory and use yum --installroot=/mnt/root to install updated kernel
  • copy vmlinuz and initrd files to /boot partition
  • copy old fedora 17 record from /boot/grub2/grub.cfg to new one and update with the new fc18 version of kernel
  • change the UUID of the root partition in the grub record. Use "ls -l /dev/disk/by-uuid/" and "ls -l /dev/mapper/" to determine the UUID of the partition on the LUKS encrypted volume.
  • reboot
  • just for the case reinstall grub2 package "yum reinstall grub2"
  • yum -y update

2012-05-23

Forensics Tools for AD


Joachim Metz and Csaba Barta have written excellent tools for the forensics analysis and offline security assessment of the Windows Active directory.

  • Joachim Mertz

    has written a lot of libraries to handle various file formats with a forensic analysis in mind libesedb and his other projects on SourceForge and Google Code
  • Csaba Barta

    is using the export of the ds database from libesedb and is doing excellent work in parsing the data and be able to perform offline queries and exports of data with his framework ntdsxtract. Here is the excellent white paper about NTDS.DIT

2011-12-17

LUKS + LVM + Backups

Using LVM for storing data is easy, cool and sexy - especially if you come to point you need to resize the partitions as the projects grow. And what about backups? I keep dd bit copy of my drive for the case something bad happens with the master drive. When I wanted to restore just some bits from the drive I came to issues how to mount it because of duplicities. This is how I solved.


Just to check we are fighting in similar dojo:

  • /dev/sda9 - partition marked with type 8e (LVM)

  • partition is encrypted with LUKS

  • LVM contains volume group vgdata

  • vgdata contains several logical volumes

  • whole disk sda cloned to sdb (external usb drive) using dd if=/dev/sda of=/dev/sdb. Side effect is that all UUIDs are same




Boot rescue CD, disconnect the backup drive, change UUIDs on the master drive to avoid duplicities. Of course you can do change UUIDs on the backup drive on different machine for example:

#mount luks device
cryptsetup luksOpen /dev/sdb9 luks-backup
#Change UUIDs on the master drive (disconnect the backup drive)
pvchange -u /dev/mapper/luks-backup
vgchange -u vgdata




Boot back to primary system - rest can be done online as UUIDs of the physical volumes and vggroups are different now.

pvs
WARNING: Duplicate VG name vgdata: zCyBsK-5oAX-fk1T-ZtKu-bJsq-V32U-jefWxT (created here) takes precedence over bM4h3v-C22d-yKLg-k21k-vhaq-VyN4-zxOVtN
WARNING: Duplicate VG name vgdata: Existing zCyBsK-5oAX-fk1T-ZtKu-bJsq-V32U-jefWxT (created here) takes precedence over bM4h3v-C22d-yKLg-k21k-vhaq-VyN4-zxOVtN
PV VG Fmt Attr PSize PFree
/dev/mapper/luks-1c37deed-13d9-4364-bbda-944a4ae42618 vgdata lvm2 a-- 316.70g 136.70g
/dev/mapper/luks-backup vgdata lvm2 a-- 316.70g 91.70g

#This will not work - need to use the UUID
vgrename vgdata vgdata-bak
WARNING: Duplicate VG name vgdata: zCyBsK-5oAX-fk1T-ZtKu-bJsq-V32U-jefWxT (created here) takes precedence over bM4h3v-C22d-yKLg-k21k-vhaq-VyN4-zxOVtN
Found more than one VG called vgdata. Please supply VG uuid.

#Rename the volume group for the backup
vgrename zCyBsK-5oAX-fk1T-ZtKu-bJsq-V32U-jefWxT vgdata-bak

#Make the volume active
lvchange -a y /dev/vgdata-bak/lvdat1

#Mount
mkdir /mnt/bak
mount /dev/vgdata-bak/lvdat1 /mnt/bak



2011-10-03

Fedora 16 Alpha - issues with encrypted drives

Here is the list of issues I was facing when upgrading from Fedora 15 to Fedora 16 Alpha.
First of all - have your backup ready for everything you have on the disk. Having bit backup of whole disk saved my ass really.

I do have multiple encrypted systems installed on my machine:

/dev/sda1 50GB Truecrypt - Windows
/dev/sda2 3GB Unencrypted - Grub boot partition
/dev/sda3 16GB LUKS - Backtrack5
/dev/sda4 Extended
/dev/sda5 16GB LUKS - Fedora root
/dev/sda6 16GB LUKS - home
/dev/sda7 4GB LUKS - swap
....


Issue #1 - LUKS device of the other system


I asked installator to format and install to sda5. Anaconda installator formatted sda5, but actually mounted luks device on sda3 as the /mnt/sysimage and tried to install there (this is the Backtrack partition on my computer) - and it failed. Changing the partition type to something insane didn' help. I had to delete partition sda3 from the partition table and return it after the installation.

Issue #2 - LUKS device with ext3


I do have "home" partition encrypted for quite some long time. It was with ext3 filesystem when I started, but installator failed with error. The anaconda installer assumes during the installation that the filesystem on LUKS encrypted disk needs to be ext4 and fails if it is ext3.

I wanted to migrate already for a while to ext4. So I didn't investigated much, why is anaconda throwing an error. I just flushed home to secondary disk, recreated luks device, formated with ext4 and restored the data from backup using conventional weapons.

Issue #3 - Truecrypt vs Grub2



After installation of Fedora 16 and realcrypt from rpmfusion I have found I am unable to mount the windows partition encrypted with TrueCrypt. After investigation it turns out that Fedora 16 Alpha is using grub2 as boot loader, which is the source of the issues.

Both truecrypt and grub2 use not only MBR to store boot loader, but these in fact use much more sectors to store the necessary information (64 sectors?). With grub it was enough to have backup of the MBR (1 sector of size 512 bytes) to boot the Truecrypt bootloader doing chainloading of the truecrypt MBR. Rest of Truecrypt remained untouched on the disk. With grub2 the truecrypt boot loader and volume header is overwritten completely.

I used to boot the truecrypt boot loader from the MBR saved directly after Truecrypt installation with:

dd if=/dev/sda of=/boot/win/truecrypt.mbr

#Old Grub configuration
title Windows XP
root (hd0,1)
chainloader (hd0,1)/win/truecrypt.mbr

#New Grub2 configuration form grub2-menulst2cfg
menuentry 'Windows XP' {
set root='(hd0,2)'; set legacy_hdbias='0'
chainloader '(hd0,2)/win/truecrypt.mbr'
}



Unfortunately this doesn't work anymore with grub2. Truecrypt boot loader reports this error:

TrueCrypt Boot Loader
Loader damaged! Use Rescue Disk: Repair Options > Restore Truecrypt Boot Loader


Trying to mount it from linux using realcrypt will fail as well:

# realcrypt --text --filesystem=none -m system -k "" --protect-hidden=no /dev/sda1
Enter password for /dev/sda1:
Incorrect keyfile(s) and/or password or not a RealCrypt volume.

Note that pre-boot authentication passwords need to be typed in the pre-boot environment where non-US keyboard layouts are not available. Therefore, pre-boot authentication passwords must always be typed using the standard US keyboard layout (otherwise, the password will be typed incorrectly in most cases). However, note that you do NOT need a real US keyboard; you just need to change the keyboard layout in your operating system.


You can boot from Truecrypt Rescue CD ISO image. The trick is to use the memdisk from the syslinux package:

yum install syslinux
cp /usr/share/syslinux/memdisk /boot/memdisk

cat /etc/grub.d/20_windows_truecryptiso
#!/bin/sh

echo "Adding entry for Windows/Truecrypt ISO" >&2

cat << EOF
menuentry 'WindowsXP/Truecrypt ISO' {
set root='(hd0,2)'; set legacy_hdbias='0'
linux16 /memdisk iso raw
initrd16 /win/tcrescue2011.iso
}
EOF


To regenerate the grub configuration:

grub2-mkconfig -o /boot/grub2/grub.cfg



I tried to restore the Truecrypt Boot Loader and it (as expected) obviously breaks grub2. So you have to reinstall grub2, which breaks the Truecrypt loader - chicken and egg problem right?:

# grub2-install /dev/sda
Installation finished. No error reported.





Only compromise between these two bootloaders, which I have found on the internet is to setup the grub2, boot from the truecrypt rescue cd iso using memdisk in grub2 and have only the key+data structure restored on the disk. This apparently doesn't overwrite grub2. Press F8 from when booted from the truecrypt rescue CD and choose option 3:




Not restoring the key+data will as a result mean that the disk can't be booted even from rescue CD and it won't be possible to mount it from linux. The error will not be obvious for the first sight as only the "Incorrect Password" is reported despite the fact you are sure the password is right:



Testing the configuration with qemu:

sync ; echo 3 > /proc/sys/vm/drop_caches ; qemu -hda /dev/sda

2011-08-24

Recovery of disk with badblocks


There are some specifics recovering the disk with badblocks.
Let's say there is badblock on sector 2550302 of /dev/sda.

This should fail because this is the bad sector:
# dd if=/dev/sda of=/dev/null bs=512 count=1 skip=2550302

This should be OK because this is the sector before:
# dd if=/dev/sda of=/dev/null bs=512 count=1 skip=2550301

But actually even this fails:
# dd if=/dev/sda of=/dev/null bs=512 count=1 skip=2550298

Reason is that the block of the block device /dev/sda is not 512 but actually (most probably) 4k:
# blockdev --getbsz /dev/sda
4096


This can cause you to loose some more data from the forensic image, than really necessary. Setting the block size on active device will most probably fail. Solution is to use O_DIRECT flag when opening the device - or rather to use tools which are capable of using direct mode.

This should really work:

# dd if=/dev/sda of=/dev/null bs=512 count=1 skip=2550301 iflag=direct
# dd if=/dev/sda of=/dev/null bs=512 count=1 skip=2550303 iflag=direct
# dc3dd if=/dev/sda of=/dev/null bs=512 count=1 skip=2550301 iflag=direct
# dc3dd if=/dev/sda of=/dev/null bs=512 count=1 skip=2550303 iflag=direct
# ddrescue -d ....

2011-07-28

Xrandr script for Gnome 3 - Fn+F4

As I am running gnome 3 and quite common in dualhead mode I was missing some easy way how to cycle between the Randr video modes.

So here is the result: xrandr_cycle


xrandr_cycle ... cycle between the display modes using the xrandr
Syntax: xrandr_cycle [--install|--help|-r]
xrandr_cycle ... cycle modes in forward order
xrandr_cycle -r ... cycle modes in reverse order
xrandr_cycle --help ... print this help
xrandr_cycle --install ... install ctrl-alt-3 and ctrl-alt-4 shortcuts


xrandr_cycle --install
By default it will install as metacity shortcut
Mod4-P (* Fn-F3) ... cycle modes in primary direction
ctrl-alt-4 (* Win-4) ... cycle modes in primary direction
ctrl-alt-3 (* Win-3) ... cycle modes in reverse direction


2011-04-22

Fedora 15 Snippets

These steps are inspired by
http://www.mjmwired.net/resources/mjm-fedora-f15.html


#-------------Download from nearest mirror
yum -y install yum-plugin-fastestmirror


#-------------Other repositories
#Rpmfusion for FC15 not stable at the time of FC15 release - needed to use rawhide originally
#rpm -Uhv http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-rawhide.noarch.rpm
#rpm -Uhv http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-rawhide.noarch.rpm

sudo rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
sudo rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm


#----------------- Citrix -----------------------
#http://webmail.scatterpated.net:10080/index.php?name=News&file=article&sid=5
yum -y install openmotif
#http://www.citrix.com/English/SS/downloads/details.asp?downloadID=3323&productID=-1#top
rpm -Uhv ICAClient-11.100-1.i386.rpm


#------------------Adobe ---------------------
rpm -Uhv http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm

#Reader + flash
yum -y install AdobeReader_enu flash-plugin


#----------------- Java -------------------------
#wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=35674
#http://www.oracle.com/technetwork/java/javase/downloads/index.html
http://download.oracle.com/otn-pub/java/jdk/6u25-b06/jdk-6u25-linux-i586-rpm.bin
#http://download.oracle.com/otn-pub/java/jdk/6u25-b06/jre-6u25-linux-i586-rpm.bin
#

sh jre-6u25-linux-i586-rpm.bin
sh jdk-6u25-linux-i586-rpm.bin
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/default/bin/java 20000
/usr/sbin/alternatives --install /usr/bin/keytool keytool /usr/java/default/bin/keytool 20000

sudo /usr/sbin/alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/default/lib/i386/libnpjp2.so 20000

sudo /usr/sbin/alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/default/jre/lib/i386/libnpjp2.so 30000

#Pulse audio plugin for java
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/ext/pulse-java.jar /usr/java/default/jre/lib/ext/
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386/libpulse-java.so /usr/java/default/jre/lib/i386/
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/ext/pulse-java.jar /usr/java/jre*/lib/ext/
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386/libpulse-java.so /usr/java/jre*/lib/i386/

mv /usr/java/default/jre/lib/i386/libjsoundalsa.so /usr/java/default/jre/lib/i386/libjsoundalsa.so.bak
mv /usr/java/jre*/lib/i386/libjsoundalsa.so /usr/java/jre*/lib/i386/libjsoundalsa.so.bak

/usr/sbin/alternatives --config java
/usr/sbin/alternatives --config libjavaplugin.so



#----------------- Font MS Core Fonts -------------------------
wget http://www.mjmwired.net/resources/files/msttcore-fonts-2.0-3.spec
rpmbuild -ba msttcore-fonts-2.0-3.spec
rpm -Uhv msttcore-fonts-2.0-3.noarch.rpm



#----------------- Font Google Webfonts -------------------------
cd /tmp
wget http://joemaller.com.nyud.net/googlewebfonts.tgz
tar xzvf googlewebfonts.tgz
cd googlefontdirectory
mkdir /usr/share/fonts/googlefontdirectory/
find ./ -type f -name *.ttf |xargs -i cp '{}' /usr/share/fonts/googlefontdirectory/
/usr/bin/fc-cache -f /usr/share/fonts/googlefontdirectory/


#----------------- Skype -------------------------
wget http://www.skype.com/go/getskype-linux-beta-fc10
rpm -Uhv skype-2.1.0.81-fc10.i586.rpm


#----------------- Additional packages -------------------------
#Gnome
yum -y install gconf-editor dconf-editor gnome-tweak-tool

#Photo
yum -y install gqview gthumb

#Audio
yum -y install audacity-freeworld xmms xmms-mp3 xmms* xmms2*

#Video
yum -y install mplayer xine vlc xine-lib-extras-freeworld kino transcode ffmpeg ffmpeg-devel
yum -y install gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg

#CD/DVD Burning
yum -y install k3b k3b-extras-freeworld

#Wine
yum -y install wine
yum -y install stardict.i686 stardict-dic-cs_CZ.noarch stardict-dic-en.noarch
yum -y install alacarte #gnome menu editor
yum -y install dia-*

#GPS
yum -y install gpsbabel viking gpscorrelate

#internet
yum -y install galeon psi
yum -y install firefox thunderbird
yum -y install lftp ncftp ftp tftp tftp-server dhcping ethtool wol net-tools tor polipo iptraf
cntlm wireshark-gnome wireshark-devel tcpdump
yum -y install tftp-server xinetd dhcp httpd php php-mysql php-cli php-pgsql php-ldap ppp kismet
umit


#kernel
yum -y install dkms
yum -y install kernel-headers-`uname -r` kernel-devel-`uname -r`

#RPM dev
yum -y install rpm-build rpmlint rpmdevtools expect rpm-sign

#----------------- Crypto ------------------------
yum -y install keepassx realcrypt john

#------------------ File tools ---------------------
yum -y install cabextract p7zip p7zip-plugins unrar unace

#devel
yum -y install qmake rpm-build rpm-sign

#----------------- Forensics ------------------------
yum -y install sharutils #uuencode uudecode
yum -y install sleuthkit
yum -y install squashfs-tools ufdtools ocfs2-tools nfs4-acl-tools
yum -y install guestfish libguestfs-*

sudo rpm -Uhv http://www.cert.org/forensics/tools/fedora/cert/14/i386/cert-forensics-tools-release-14.noarch.rpm
yum install CERT-Forensics-Tools

#----------------- Networking ------------------------
#Servers
chkconfig --level 12345 xinetd off
chkconfig --level 12345 dhcpd off
chkconfig --level 12345 avahi-daemon off
chkconfig --level 12345 tor off
chkconfig --level 12345 polipo off

# Wake on lan
cat >> /etc/rc.local <<EOF
ethtool -s eth0 wol g > /dev/null 2>&1
ethtool -s eth1 wol g > /dev/null 2>&1
EOF

#-------------------- Gnome 3 Hints -------------------------------
yum -y install gnome-shell-extension* gnome-shell-theme*

#gsettings list-recursively org.gnome.shell
#opt-out extensions I do not like
gsettings set org.gnome.shell disabled-extensions "['alternate-tab@gnome-shell-extensions.gnome.org', 'righthotcorner@fpmurphy.com', 'noripple@fpmurphy.com',

#I fail to keep track what the date is :)
gsettings set org.gnome.shell.clock show-date true

#still I like to see 3 buttons when there is vasted 1280x20 space not good for anything else
gconftool-2 -s /desktop/gnome/shell/windows/button_layout --type str ":minimize,maximize,close"

#It was wery annoying to me to not be able to move spell checker window away to see what is bellow
gconftool-2 -s /desktop/gnome/shell/windows/attach_modal_dialogs --type bool "false"

#Nautilus
gsettings set org.gnome.nautilus.desktop home-icon-visible true
gsettings set org.gnome.desktop.background show-desktop-icons true
gsettings set org.gnome.shell.calendar show-weekdate true

#Icons
gsettings set org.gnome.desktop.interface menus-have-icons true
gsettings set org.gnome.desktop.interface menus-have-tearoff true

#Notebook lid
# I preffer to not shutdown notebook on lid close, rather I preffer to controll manually
#http://fedora.rasmil.dk/blog/?p=208
#setting ::= nothing|blank|suspend|hibernate|shutdown

#gsettings list-recursively org.gnome.settings-daemon.plugins.power
gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action blank
gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action blank

#Favourite keyboard shortcuts
#Run Terminal on Win+t
gconftool-2 -s /apps/metacity/global_keybindings/run_command_terminal --type string 't'

#Show Desktop on Win+d
gconftool-2 -s /apps/metacity/global_keybindings/show_desktop --type string 'd'

#Show window menu on Alt+space
gconftool-2 -s /apps/metacity/window_keybindings/activate_window_menu --type string 'space'

#Run Firefox on Win+f
gconftool-2 -s /apps/metacity/global_keybindings/run_command_1 --type string 'f'
gconftool-2 -s /apps/metacity/keybinding_commands/command_1 --type=string 'firefox'

#Lock the screen on Win+l
gconftool-2 -s /apps/metacity/global_keybindings/run_command_2 --type=string 'l'
gconftool-2 -s /apps/metacity/keybinding_commands/command_2 --type=string 'gnome-screensaver-command -l'

#I preffer dark background in the terminal - set the dark background in vi
echo ":set background=dark" >> ~/.vimrc


2011-04-13

Run Elluminate Live Webcasts under Fedora 14

I was up to listen some SANS webcasts when I found that my java installation on Fedora 14 is totally mute. Everything looked fine, but no sound. The root case was that SUN java I was using was supporting alsa, but not pulse audio. Solution was to use the library from openjdk and disable the alsa library.

#Pulse audio plugin for java
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/ext/pulse-java.jar /usr/java/default/jre/lib/ext/
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386/libpulse-java.so /usr/java/default/jre/lib/i386/
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386/libpulse-java.so /usr/java/jre1.6.0_22/lib/i386/
cp /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/ext/pulse-java.jar /usr/java/jre1.6.0_22/lib/ext/

mv /usr/java/default/jre/lib/i386/libjsoundalsa.so /usr/java/default/jre/lib/i386/libjsoundalsa.so.bak



Sources:
http://www.linuxquestions.org/questions/linux-newbie-8/elluminate-live-on-linux-641328/
http://ubuntuforums.org/showthread.php?p=10659231

2011-03-25

Data Sanitization

I found some interesting materials to the topic of data sanitization:

Magnetic Media - (Peter Gutmann - oldies but interesting):
- note the old drives, low density, MFM/LCC - able to recover complements by osciloscipe reading
- read epilogue - 35-vodoo overwriting scheme not necessary for modern drives, radom data would do the trick

Semiconductors (Peter Gutmann - SRAM, DRAM,EEPROM, FLASH ...)

And recommended tools :D by Peter:

Data remanence
- Feasibility of recovery

Microscopy of HDD data
- micro imaging would take at least weeks on todays high density high volume drives

-------------

DoD 5220.22-M NISPOM
8-306. Maintenance - Clearing and Sanitization Matrix
d. Overwrite all addressable locations with a character, its complement, then a random character and verify. THIS METHOD IS NOT APPROVED FOR SANITIZING MEDIA THAT CONTAINS TOP SECRET INFORMATION.

AR380-19

Degausser for HDD - maybe we could use one for broken drives:
http://www.mediaduplicationsystems.com/Degausser_Hard_Drive_Degaussers_s/103.htm
http://www.datalinksales.com/detail/Model%201100.html/1100%20degauss%20wand

Additional topics:
HPA and DCO protected areas on ATA drives

-------------
My personal conclusions:
Working drives:
- even one verified zero overwrite the drive should be good enough for "For Internal Use" data.
- actually this is what "ATA Secure Erase" does
- even one random data overwrite the drive should be good enough for pretty much everything
- I find it highly non-economical to invest so much money and effort to read overwritten data
- DoD 5220.22-M with 3 overwrites - to be on safe side from audit


Broken drives:
- if suffering from badblocks "ATA Enhanced Secure Erase" still might help - although no fancy logs or reports of results
- hammer and drill is your friend :) for completely non-working discs
- I was surprised that HDD degaussers are quite affordable

2011-03-02

Using java keytool to import private key into JKS java keystore

I got question how to import the private key to JKS keystore.
According to some resources it is not possible with standard tools.

Answer is to use the -importkeystore option of java keytool. Keytool allows conversion between the different keystore types which are currently known to your java virtual machine.
For example you can import key+certificate from PKCS12 format (extensions .p12 or .pfx in Windows world).

keytool -importkeystore -srckeystore server.p12 -srcstoretype pkcs12 -destkeystore server.jks -deststoretype jks


If you have key and certificate in PEM format you can easily convert it to pkcs12 with openssl
#Join key, certificate and certs of certification authority to one file
cat server_key.pem server_cert.pem server_cacert.pem > server.pem
#Convert to PKCS12
openssl pkcs12 -export -out server.p12 -in server.pem



Relevant links:
http://download.oracle.com/javase/1.3/docs/tooldocs/win32/keytool.html
http://www.herongyang.com/crypto/Key_Formats_PKCS8_PKCS12_4.html
http://mindprod.com/jgloss/keytoolexe.html#EXPORTING
http://www.agentbob.info/agentbob/79-AB.html