Howto create a Virtualbox 4 image clone

VirtualBox 4 for multiple OS availability
If you are like me and do a lot of testing with Virtual Machines, then you will know that to keep having to create a new machine and installing a Debian netinstall each time is a complete p.i.t.a

Cloning vdi’s
No need for all that malarkey now. Just create a fresh VM, install a base Debian netinstall, or any other OS for the matter, i’ve got loads installed!

Once you have it all setup, shut down VirtualBox, open your terminal and issue a command like this:

vboxmanage clonevdi /home/rich/VirtualBoxVMs/Squeeze64/Squeeze64.vdi /home/rich/VirtualBoxVMs/Squeeze64b/Squeeze64b.vdi

As you can see, all my vdi’s are stored in /home/rich/VirtualBoxVms so just adapt the command to suite your needs.

The output will be like this (with a new uuid created for the harddisk):
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: cc76ae5a-719a-4833-b481-42f254f5fe2e

So, imagine you want to create a new Debian clone called “MyBigFatCopy”.

cd /directory/where/your/vdis/are/stored/
mkdir MyBigFatCopy

Now run the code from before:

vboxmanage clonevdi /home/you/VirtualBoxVMs/ORIGINAL/original.vdi /home/you/VirtualBoxVMs/MyBigFatCopy/mybigfatcopy.vdi

Adding your new clone to the VirtualBox list
Now open up VirtualBox4, choose “NEW” and create a VM called MyBigFatCopy

(**NOTE** It has to have “exactly” the same name as the directory you just created).

Instead of creating a new harddrive, just choose an “existing” vdi, yup, you’ve guessed, navigate to your newly cloned mybigfatcopy.vdi 🙂

Finish off, restart VirtualBox4, and fire up your new mybigfatclone.

If you are on a network (or want to run several VM’s at the same time), just make sure you change the hostname, and if it has a static IP address, change it to dhcp or a new static ip. Now you can fire up your clone alongside your original without any problems.

Happy Cloning! 😉

New Microsoft Windows rootkit so severe, Complete re-install necessary

Microsoft security just keeps getting worse
It has just been announced that a new Trojan Rootkit can embed itself so deep into the Windows operating system, that a complete format of all data and a fresh re-install is needed to get rid of it, as it hooks itself to to the hard disk port driver for protection and then hides in the machine’s boot sector.

From Microsoft Malware Protection:

The bootkit malware Trojan:Win32/Popureb.E has made some changes in its code compared to previous samples (specifically, Trojan:Win32/Popureb.B), and now it introduces a driver component to prevent the malicious MBR and other malicious data stored as disk sectors from being changed. The driver component protects the data in an unusual way – by hooking the DriverStartIo routine in a hard disk port driver (for example, atapi.sys).

Does your Windows computer feel sluggish today? You may just have the unremovable Popureb.E Trojan Rootkit offering up all your private data to the world!

Crunchbang Linux Right Mouse Click Gpg Encrypt/Decrypt scripts

Thunar Right-Click Menu Encryption/Decryption
This was a script inspired by machiner on the LxH Forum who showed me a cool Encrypt/Decrypt script a while ago.

Gpg and Password Protection
I decided to add a password dialogue box as well, which is launched in an xterm. I tried a Zenity diaogue box, but it caused a few problems with input and output, so my work colleague Eduardo stepped in and suggested doing it with an xterm pop-up instead. Edu is a far better coder than me.

Pgp/Gpg Key Creation
Obviously you need to have created pgp-keypair, I used Gpg (Gnu Privacy Guard) frontend, and you can find a Howto HERE You will also need “xterm” installed, but should come as default.

The Encrypt/Decrypt Scripts
You need to create two bash scripts in either /usr/local/bin or your home ~/bin, I chose the latter as I always backup my personal scripts. I called them RMCencrypt and RMCdecrypt. “RMC” means Right Mouse Click 🙂

ENCRYPT

#!/bin/bash
# Handy Encryption Action ##

encrypt ()
{
#PASSWD=`zenity –entry –title “Password” –text “Enter password”`
#if [ “z$PASSWD” != “z” ]; then
# gpg -ac –no-options –passphrase $PASSWD “$1” || \
# zenity –error –text “Decryption failed: $?”
#else
# zenity –error –text “No password: Aborted”
#fi
xterm -e “gpg -ac –no-options ${1+\”$@\”}; echo -n \”Press \”; read”
}

## End Handy Encryption Action ##

encrypt ${1+”$@”}

DECRYPT

#!/bin/bash
## Handy Decryption Action ##
decrypt ()
{
#PASSWD=`zenity –entry –title “Password” –text “Enter password”`
#if [ “z$PASSWD” != “z” ]; then
# gpg –no-options –passphrase $PASSWD “$1” || \
# zenity –error –text “Encryption failed: $?”
#else
# zenity –error –text “No password: Aborted”
#fi
xterm -e “gpg –no-options ${1+\”$@\”}; echo -n \”Press \”; read”
}
## End Handy Encryption Action ##

decrypt ${1+”$@”}

Now just place those two scripts in ~/bin and make them executable (chmod +x).

Next up, open Thunar file manager, click the “edit” then “Configure custom file actions..” and add both scripts with a name and icon of your choice. I chose RMCencrypt and RMCdecrypt like the scripts, which Thunar Actions manager adds an %n after to encrypt the selected file.

You will now be able to encrypt and decrypt any file at the click of a (right) mouse button.


Howto Change all instances of a word in a Mysql database

This how to refers to an Smf Forum database but can just as easily be applied to a WordPress, or any other Mysql database.

I recently re-opened my old forum which is 5 years old and has a lot of old posts, people have changed usernames, email addresses. The forum has had three domain names, so it stands to reason that there is a lot to tidy up. So I set about updating a few things today.

The basic mysql syntax (which can be launched from Phpmyadmin Sql Tab) is this:

UPDATE table SET field_name = REPLACE(field_name, ‘tony’, ‘TONY’)

For example, to change an old url link to a new one in the body of forum posts:

UPDATE smf_messages SET body = REPLACE(body, ‘myoldurl.com’, ‘mynewurl.com’)

Obviously, you just change the table, field and text to be replaced.