Forensic disk recovery

If someone gave you a Sandisk Cruzer 8GB micro USB stick*, which had their entire life of work stored on it. This stick couldn’t be directory listed under Windows 7 only Windows XP.. nothing could be copied off nor copied on to it.

What would you do ?

Well here’s what I did to recover the files.

first of all I tried all the normal windows based solutions:

Chkdsk
Recovery software GetDataBack – (Which has served me well in the past)

No joy! Nothing! Nada! – USB just disconnects when you try anything.

So I turn to Unix for the answer, the USB stick could be mounted and read, it just crashed out when trying to copy the files/directories from the device, saving about 10% of the data.. I’m assuming its a hardware failure of the device.

This is when I turn to open source forensic software – Ubuntu Rescue Remix

Here’s how I used it :

I created a bootable image of the Ubuntu Rescue Disk ‘to a different USB stick’, following the instructions at Pendrivelinux.com

Booted that, then used the following commands :

Create ‘hdd1’ directory in the ‘mnt’ folder
sudo mkdir /mnt/hdd1

Mount your machines hard drive to the folder ‘/mnt/hhd1’
sudo mount /dev/sda1 /mnt/hdd1

Check the ‘mount’ command to see what the USB device your trying to recover is called, in my case its mounted as ‘/dev/sdc1’
sudo mount

Use that information to constuct the following command; ddrescue-retry to read upto 3 times-USB device-name of image to write-name of log to write
sudo ddrescue -r 3 /dev/sdc1 /mnt/hdd1/recovery-image /mnt/hdd1/recovery-log

Create a new directory on your hard drive to store all the recovered files.
sudo mkdir /mnt/hdd1/recovery

Run ‘foremost’ which is some forensic software created by the US Air force; foremost-image name-output directory
sudo foremost -i /mnt/hdd1/recovery-image -o /mnt/hdd1/recovery

This will extract files ‘Without filenames’ to the output directory, slight issue, but lucky to get anything back at all.

* Other USB sticks are available..

Selenium, what a great tool

Whilst trying to write some code which would rollover Blackboard courses automatically, year in year out.

We where looking for an answer to using a ‘value’ or piece of ‘text’ which was next to a checkbox rather than the ‘id’ (which is the usual way Selenium handles checkboxes), as the ‘id’ in our case was being dynamically generated so it couldn’t be relied upon being the same number, as it depended how many checkboxes where on that particular screen.

Here’s how we solved it :

selenium.click(”//input[@value='users']“);

where ‘users’ is the value from within the code, rather than ‘Users’ which is just some text after the checkbox, which display next to it, so not really that connected, actual code from within Blackboard (yuck) follows :

<input type='checkbox' name='area' id="area_14" value="users"> <label for="area_14"><font class="fnt0"><b>Users</b></font>

* Note, this only seems to work with Selenium using Firefox 3 as the browser rather than IE.

Glassfish v2.1.1 site redirect

Simple to do, hard to locate the information on how to.
Hopefully you’ll find this a lot easier..

Navigate to :

Configuration, HTTP Service, Virtual Servers, server

Scroll to bottom of page :
Add Property

Name :
redirect_1

Value :
from=/{name of webapp to redirect} url={URL to redirect traffic to}

(dont include the ‘{‘ ‘}’ brackets)

It should look something like this :
from=/mywebapp url=http://www.google.co.uk

Click ‘Save’ button.

Done!

Alfresco community 4.0 installation on Glassfish 3.1

PLEASE NOTE:

The following worked only on Alfresco 3.4d – We tried to get it to work on version 4.0 but it will not.
We have now resorted to using the Tomcat Bundled version of 3.4d as our server is 32bit linux.

Follow the below instructions if you still want, but be it on your own head 🙂

1. Get alfresco war files for deployment in existing application servers package file  alfresco-community-4.0.a.zip from https://process.alfresco.com/ccdl/?file=release/community/build-3755/alfresco-community-4.0.a.zip

2. MySql setting

mysql>create database alfresco;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’%’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’localhost’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

3. Create alfresco documents and index folder

mkdir /usr/local/alfresco

4.Unpack alfresco-community-4.0.a.zip

unzip alfresco-community-4.0.a.zip

5. Configure Alfresco before deploying to glassfish

5.1 alfresco-global.properties

Since alfresco 3.3, all the settings now based on alfresco-global.properties. This file can be found from the alfresco package file alfresco-community-4.0.a.zip. Copy this file from the unzip location to  glassfish lib folder.

cd /alfresco-community-4.0.a/extensions/extension

cp alfresco-global.properties /usr/local/glassfish/domains/domain1/lib/classes/alfresco-global.properties

if Glassfish is installed at /usr/local/glassfish.

5.2 Modify alfresco-global.properties so alfresco can find database and index folder created before

Set alfresco folder
dir.root = /usr/local/alfresco

Set dababase username and password

db.username=YOUR_ALFRESCO_USERNAME
db.password=YOUR_ALFRESCO_PASSWORD
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco

6. You need a ‘glassfish-web.xml’ for “useMyFaces” for alfresco. *ONLY needed if your using Glassfish 3.1 * – If using Glassfish 3.0 or below Skip to step 7/7.1 as that needs ‘sun-web.xml’.

7. sun-web.xml:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE sun-web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN”  “http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd”&gt;
<sun-web-app>
<class-loader delegate=”false”/>
<property name=”useMyFaces” value=”true”/>
</sun-web-app>

You can also get this file from http://blogs.sun.com/mandy/resource/sun-web.xml

7.1 Add sun-web.xml to alfresco.war

Go to the unpacked directory created from alfresco-community-4.0.a.zip, create a new directory named WEB-INF and put sun-web.xml on it.

cd /alfresco-community-4.0.a/

mkdir /WEB-INF/

cp /temp/sun-web.xml /WEB-INF/sun-web.xml

jar -uvf alfresco.war WEB-INF/*.xml

The alfresco.war should be edited.

8.  Increase glassfish memory heap setting
Log in as administrator of glassfish from http://glassfishHost:4848/
Application Server->JVM Settings->JVM Options
Change -Xmx256m to -Xmx512m or more.

9.  Deploy the new war file to glassfish.
Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy alfresco.war.
After a few minutes, alfreso can be visited by hppp://glassfishHost:8080/alfresco

10.  Deploy share

Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy share.war from the unzip package.

There is a bug in share.war, so you will get the “No ‘login’ page type configured – but page auth required it.”  error message if go to  http://glassfishHost:8080/share.

Solution is download the latest spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar from alfresco SVN

wget http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/3rd-party/src/spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar

cp spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar /usr/local/glassfish/domains/domain1/applications/j2ee-modules/share/WEB-INF/lib/

Restart glassfish, go to http://Glassfishhost:8080/share

Should work!

You can also add the spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar to the share.war and deploy it.

Jinitiator working on Windows 7

We need ‘Jinitiator 1.3.1.13’ to use a core application. The applications in-house team havent managed to get it working with JRE, which is the replacement to Jinit. They insist that you must use Jinitiator 1.3.1.13 & windows XP! Joy! We also know that Jinit is no longer supported by Oracle & refuses to work with Windows 7.

So how do you get around this ?

Install Jinitiator as normal, if your having problems actually getting it to install, just use the Win7 ‘compatibility mode’ to get it to stay on your machine instead of it annoyingly uninstalling itself at the end of a failed install process.

Now

Replace the ‘jvm.dll’ in jinitiator directory (C:\Program Files (x86)\Oracle\JInitiator 1.3.1.13\bin\hotspot\) with this file jvm.dll.

Restart IE* and try again, Windows 7 should reduce your colour scheme and your app should now work.

See post repaint blog post on how to fix the repaint screen issues, if they are happening to you.

*Note, I would never normally recommend Internet Explorer, it’s just that this process doesn’t work for me using Chrome or Firefox, my preferred browsers.

.jar file associations and Windows 7

Has your .jar associations ever been hijacked ?

Mine too, after spending far too long following suggestions of people on forums of how to get it back, using your command prompt ‘assoc’ & ‘ftype’ commands and manually editing your regedit etc…

Forget it, grab yourself this handy util ‘jarfix

Jarfix has existed since 2002, so can be trusted to correct the .jar association & put back the following -jar flag, so when you launch a .jar file it runs correctly. On typing ‘ftype jarfile’ in your Command Prompt you should see the following.

jarfile=”C:\Program Files (x86)\Java\jre6\bin\javaw.exe” -jar “%1” %*

Alfresco community 3.2 installation on glassfish

1 Get alfresco war files for deployment in existing application servers package file  alfresco-community-war-3.2r2.tar.gz from http://wiki.alfresco.com/wiki/Community_Edition_file_list_32r2

2. MySql setting

mysql>create database alfresco;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’%’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’localhost’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

3. Create alfresco libray folder on glassfish

mkdir /usr/lcoal/glassfish/domains/domain1/lib/classes/alfresco

4.Unpacke alfresco-community-war-3.2r2.tar.gz

tar vzxf alfresco-community-war-3.2r2.tar.gz

5. From the directory in which you unpacked the Alfresco bundle, copy the entire contents of the extensions directory to the glassfish domain library /usr/lcoal/glassfish/domains/domain1/lib/classes/alfresco

cp -rf extensions/*  /usr/lcoal/glassfish/domains/domain1/lib/classes/alfresco

6. Create alfresco documents and index folder

mkdir /usr/local/alfresco

7. Modify alfresco config files for glassfish (/usr/local/glassfish/domains/domain1/lib/classes/alfresco/extension)so alfresco can find database and index folder created before

two files should be edited

custom-repository.properties

custom-hibernate-dialog.properties

cd /usr/local/glassfish/domains/domain1/lib/classes/alfresco/extension
vi custom-repository.properties

Set alfresco folder
dir.root = /usr/local/alfresco

Set dababase username and password

db.username=YOUR_ALFRESCO_USERNAME
db.password=YOUR_ALFRESCO_PASSWORD

Comment out the lines for derby and uncomment the lines for MySQL

#db.driver=org.apache.derby.jdbc.EmbeddedDriver
#db.url=jdbc:derby:data/derby_data/alfrescocreate=true


db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco

In custom-hibernate-dialog.properties, comment out the line for Derby and uncomment the line for MySQL

8 The Alfresco war file has a WEB-INF/web.xml deployment descriptor that doesn’t comply with the DTD, you need to replace this file and add a Glassfish specific deployment descriptor that will allow Alfresco to use MyFaces instead of JSF.

Get these two files from http://blogs.sun.com/mandy/resource/web.xml, http://blogs.sun.com/mandy/resource/sun-web.xml

Change to the unpacked directory created from alfresco-community-war-3.2r2.tar.gz, create a new directory named WEB-INF and copy the above two files into it. Now update the alfresco.war file using the Java jar command

jar -uvf alfresco.war WEB-INF/*.xml

The alfresco.war should be edited.

9 Increase glassfish memory heap setting
Log in as administrator of glassfish from http://glassfishHost:4848/
Application Server->JVM Settings->JVM Options
Change -Xmx256m to -Xmx512m or more.

10 Deploy the new war file to glassfish.
Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy alfresco.war.
After a few minutes, alfreso can be visited by hppp://glassfishHost:8080/alfresco

Useful links:
http://blogs.sun.com/mandy/entry/alfresco_on_glassfish_revisited

Sendmail did not send mail instantly but queued it

Sendmail did not send mail instantly but just queued it.

Testing sendmail by

#mail test@host.com

System didn’t show any error but just queued the mail

#mailq

Showing that the mail message has been put into the queue.

Queue message  “host map: lookup (domain): deferred”

#/sendmail -q

Can force server sent mail successfully. It means the DNS setting should be correct.

Check sendmail configuration files

#/etc/mail/sendmail.cf

DeliveryMode is not  “deferred”

O DeliveryMode=background

#/etc/hosts

#/etc/resolv.cf

#/etc/nsswitch.conf

Both files have the same setting as another server which can send mail instantly.

Try to stop and restart sendmail

#/etc/init.d/sendmail stop

#/etc/init.d/sendmail start

Problem solved.