Posts Tagged ‘Tools’

How I stay safe from viruses and spyware for free

Monday, August 11th, 2008

Being connected to the internet has – according to various news sources – got more and more dangerous over the years.

A metric that is commonly quoted is the average time it takes for an unprotected PC to become infected by viruses / spyware after it has been connected to the internet.

In 2004 the time was apparently 20 minutes. By 2005 the time had reduced to 12 minutes. Now in 2008 there are articles saying it is 4 minutes.

Whether these stories are true, or just a scare tactics by the anti-virus industry to sell more products is another matter. Whatever the real situation viruses and spyware are real threats and you should make sure you are protected. Becoming infected could lead to personal details being stolen for identity theft purposes, or your bandwidth being stolen for use in botnets.

I use both Windows XP and Internet Explorer and I’ve never had a virus or any spyware on my computer (or at least none that I know of!). Maybe I’m just lucky or maybe it is because I use a variety of tools to stay safe. You can get everything you need to stay safe for free so there is little excuse not to be protected. Here are the tools and techniques I use.

Keep Windows up to date with the latest patches

New patches for Windows are usually released on a monthly basis. Many of these patches stop ‘bad guys’ from taking advantages of newly discovered vulnerabilities in the operating system. Windows can download and install these for you automatically. You should make sure that you computer is configured to do this.

Go to Control Panel -> Security Center.

Make sure that Automatic Updates is turned on. For the easiest updating go into the Automatic Updates settings page and make sure that it is set to download and install them automatically.

Windows Automatic Updates

Use a firewall

A firewall stops unauthorised connections from coming into your computer. At the very least you should ensure that the default Windows firewall is enabled. As with the Automatic Updates you can check the firewall status from the Windows Security Center (in the Control Panel).

However the Windows firewall only stops unauthorised incoming connections. It won’t stop unauthorised outgoing connections. If you want to do this you should use a more sophisticated firewall such as the free version of the ZoneAlarm firewall. There are several different versions available from their website but the free one will do the job.

ZoneAlarm firewall

You should be warned however that it may well complicate your PC usage as every time a new program tries to access the internet it will ask you if you want to authorise that program. There have also been problems in the past where ZoneAlarm users have lost their internet connections. You will however be more secure if you use ZoneAlarm and if you have problems you can always uninstall it and go back to the default Windows firewall.

You can test how effective you firewall is at stopping incoming connections by using the ShieldsUP! online port scanner. Use their ‘All Service Ports’ scan to see if any of your ports are accessible from outside your computer.

Install a spyware blocker

Some programs will actively search and remove spyware and viruses. Spyware Blaster does something more simple. It sets kill bits for all the spyware programs it knows about so they can’t run.

There is a free version of Spyware Blaster available. You should install it and then run it on a regular basis to download and enable the new spyware updates.

SpywareBlaster

Get an anti-virus application

You should make sure you have an up-to-date anti-virus tool on your computer. Many require you to pay a yearly subscription. avast! antivirus is a commercial tool for business use, but it is free for home use. You can find and download the Home Edition from their official website.

avast! will automatically keep itself up to date if your computer connects to the internet. It will protect you from viruses, spyware and rootkits.

Use a variety of other tools

As well as using a good regular suite of protective tools (firewall, anti-virus, automatic updates) I also on an occasional basis scan my computer using other tools. Not all anti-malware tools find all problems so it is good to use different tools once in a while.

Here are a few that I’d recommend you try:

Ad-Aware – get the free version of this tool to scan for spyware.
Spybot – Search & Destroy – another anti-spyware tool which is worth running once in a while.
Windows Defender – free anti-malware program from Microsoft.

As well as using these application there are a number of online scanners that you can use too:

ZoneAlarm Online Spyware Scanner
Symantec Security Check – virus and security scanner
F-Secure online scanner

Stay safe!

FTP uploading a directory of files using perl

Monday, February 18th, 2008

Here is a simple script to upload the files which are in a particular directory. I use something similar to automate the file uploading for my tube walking blog.

Whenever I take photos for the blog I put them into a directory with the current date as the directory name. So I have a structure like this:

c:\website\080115\
c:\website\080203\
c:\website\080205\
c:\website\080218\

I want the images in these directories to be uploaded to a new directory on the FTP server where the FTP server directory is named with the date e.g. ‘080218′.

The script is run with a command such as:

perl imageupload.pl c:\website\080218\

The script will then:

  1. Extract the date part of the directory – ‘080218′.
  2. Connect to the FTP server.
  3. Create a directory called ‘080218′ on the FTP server.
  4. Get a list of all the local files in the directory that you passed in as the argument.
  5. Upload each of these files to the FTP server.

Here’s the script. You’ll need to modify the FTP server address, username and password if you want to use it.

use File::Basename;
use Net::FTP;

my $directory = $ARGV[0];

my @parts = split(/\\/, $directory);

# get leaf directory name from whole path
my $length = $parts;
my $dateDir = $parts[$length-1];

$ftp = Net::FTP->new("ftp.yourwebsite.com", Debug => 1)
    or die "Cannot connect to hostname: $@";

$ftp->login("username", "password")
    or die "Cannot login ", $ftp->message;

$ftp->cwd("/website/data")
    or die "Cannot change working directory ", $ftp->message;

# create 'date named' directory on FTP server
$ftp->mkdir($dateDir);
$ftp->cwd($dateDir);

# set binary mode which is needed for image upload
$ftp->binary();

opendir(DIR, "$directory");
my @files = readdir(DIR);

foreach my $file (@files)
    {
    if (not -d $file)
        {
        # make sure the names are lower case on the server
        $file = lc($file);
        # upload the file
        $ftp->put("$directory\\$file");
        }
    }

$ftp->quit();

The script is simple, but it can easily be integrated into a more complex set of scripts to help you manage your web site.

Backup / restore of last modified and created file time attributes on Windows

Saturday, January 12th, 2008

Last month I found that I needed to be able to backup and restore the last modified and created file times of a load of files in Windows XP. This is probably a bit of an obscure thing to need to do so naturally I couldn’t find any existing tools to do it.

I’ve therefore made a Perl script to allow this to be done. Just so you are clear, this isn’t backing up the files, it is backing up the last modified and created file time attributes.

This allows changes to be made to the files whilst keeping these attributes intact. In theory Perl’s utime function should allow me to change these attributes. However on my Windows XP machine it just didn’t work. I’ve therefore used the rather excellent nircmd tool to handle the file attribute modifications. You’ll need to download it and modify backupLastModified.pl to point to it.

Usage is simple:

perl backupLastModified.pl c:\yourdir -backup
perl backupLastModified.pl c:\yourdir -restore

Make sure you do a test of this script before you use it for real. It has only ever been tested on one machine.

  1. Download backupLastModified.zip
  2. View backupLastModified.pl

This script will create a file ‘backuplist.txt’ in the directory that you pass in as the first argument. If you run -backup multiple times then any new files will be appended to the backuplist.txt. The stored last modified / created times of any existing files will be preserved.