Categories
Computers Windows

Mail filter for Microsoft Exchange

I don't understand why people still open unknown attachments but apparently they do since the viruses with attachements with extension of .exe, .scr, .pif etc still flourish. A number of years ago and in the aftermath of such an virus attack I wrote this mail filter, implemented as an SMTP event sink for Microsoft Exchange Server 2003. I recently added support for recoding WAV file attachments to WMA based on my implementation of a WAV to WMA console utility.

Being able to transcode WAV files is particularily handy when used with a system that sends voice recordings in a poorly compressed format. An example of such an application is Avaya's voice mail server solution. A 45 second sound clip can thus be taken down from 750kB to 30kB which means that they can then easily and cost effectively be downloaded directly to smartphones capable of playing WMA files.

Installation

There is no installer included so you will have to do the installation manually. First you need to download and install the Microsoft Platform SDK. The only reason you need the Platform SDK is that you need the script SmtpReg.vbs from the include directory. Once you have the script you should copy it to some directory which is in your path. After that, do the following:

  • Copy the filter DLL to a suitable location on your Exchange server. It does not have to be in the same folder as Exchange itself.
  • Register the filter DLL by typing 'regsvr32 MailFilter.dll' from within the same folder.
  • Type 'smtpreg.vbs /add 1 OnArrival FilterSink MailFilter.Sink “rcpt to=*”'

The filter will be triggered by the first incoming email and write default settings to the registry (HKLM\Software\Bergek\MailFilter). Run the registry editor (regedit.exe) to make any changes you may want.

Note: As always, be careful when changing the registry as mistakes can, at worst, render the computer unbootable.

  • DropExtensions [SZ] Semicolon-separated list of attachment entries that will make the mail be dropped
  • ReencodeBitrate [DWORD] The minimum bitrate to be used to encode the sound files (only used if ReencodeWav is set)
  • ReencodeCodec [SZ] The preferred codec to be used to encode the sound files (only used if ReencodeWav is set)
  • ReencodeWav [DWORD] If true, reencodes WAV attachments using a voice encoder profile to save space
  • Syslog [DWORD] If true, log entries will be sent to a syslog client
  • SyslogAddress [SZ] The address to send syslog entries to (only used if Syslog is set)
  • SyslogPort [DWORD] The port to send syslog entries to (defaults to 514 and only used if Syslog is set)
  • WriteLog [DWORD] If true, writes log entries to a log file located in the same folder as the filter binary

Note that the log file is turned on by default which could grow big depending on the amount of email received by your system. To stop logging to a file, just change the value of WriteLog to zero. Also note that e-mail with at least one attachment with the extension .pif, .scr or .exe will be dropped entirely. To avoid dropping e-mail due to attachment extensions, just change the DropExtensions registry value to an empty string.

By writing 'rcpt to=*' when installing the event sink above the filter will receive all incoming SMTP mail traffic. If the filter should only be used for specific e-mail addresses they can be specified instead of the asterisk. It is also possible to use the format 'mail from=…' to filter only e-mail from a specific address. Multiple items can be separated by semi-colon.

Troubleshooting

Please verify directly after installation that your mail system is still operating as it should. Although this filter has proven very stable on my system it has not been tested on more than one system. If you do run into problems then just uninstall the filter and restart the IIS service (the first two points in the uninstallation instruction below).

Uninstallation

  • Remove the filter from the list of SMTP event sinks by typing 'smtpreg.vbs /remove 1 OnArrival FilterSink'
  • Restart the IIS SMTP service by running 'iisreset.exe'
  • Unregister the filter DLL by running 'regsvr32 /u MailFilter.dll'
  • Remove the filter DLL and the registry settings under HKLM\Software\Bergek\MailFilter

License

This application is provided as-is and free of charge as long as it is not included in any commercial offering. If you like it I would appreciate if you would link to my web site (http://www.spotwise.com).

Known issues

  • The file name for the attached sound file will change after the transcoding
  • Depending on the format of the e-mail received the filter may remove text encodings above 7 bit ASCII.

Attachments

Categories
Computers Music Windows

wav2wma – freeware console utility

VoiceWMA.gif

I provide this Windows console utility that transcodes from WAV files to WMA files. By default it uses the voice codec from Windows Media Audio 9 with a very low bitrate to encode voice content but it is possible to use any other Windows Media Audio codec and with a higher bitrate.

When I tried it after having done the last changes it even turned out to be possible to use mp3 files as input which was not even intentional but might be interesting to know. Do remember, however, that you would in that case be transcoding between two potential lossy formats which is normally not a good thing.

Usage: wav2wma -s source -t target [-c codec] [-b bitrate]
       wav2wma -l

Options
   -s source   Source WAV file
   -t target   Target WMA file
   -c codec    Preferred codec
   -b bitrate  Minimal bitrate [bps]
   -l          List all codecs on the system
   -?          Produces this help

License

This application is provided free of charge for personal use. If you like it I would appreciate if you would link to my web site (http://www.spotwise.com).

Attachments

Categories
Computers Gadgets

TomTom bluetooth issues on Qtek 9000

Users of the TomTom navigation solution may experience problem when trying to connect their PDAs to a non-supported bluetooth GPS receiver. At least I had huge problems when trying to get TomTom 5.21 on a Qtek 9000 (a.k.a. HTC Universal or the Jasjar) to connect to my Bluei GPS receiver. I had no issues in bonding the GPS receiver with the PDA but no matter how I tried I couldn't get TomTom to use the serial port provided by the bluetooth stack.

The problem is not that TomTom can't use the GPS. The problem is that TomTom is unable to list the Bluetooth serial port which means that the user is unable to select it. After much trials this is how I managed to do it.

First bind the GPS receiver to the PDA and add a serial port to it. I selected COM4 but you can use whatever port is available to you.

Then the GPS control panel applet must be enabled. The applet provides access to control the serial intermediate driver in Windows Mobile 5 which, for some reason, has been disabled by HTC.

Use any registry editor (I recommend PHM Registry Editor) on the PDA to set the value 0 (zero) to the key Hide in HKLM\ControlPanel\GPS Settings. If the GPS applet does not appear under Settings -> System, then restart your PDA to make the change take effect.

In the GPS applet you will find three tabs. The first tab ('Program') is the serial port which applications on your PDA will connect to in order to get GPS data. I selected COM8 but you can use another port as long as it is available. Under the second tab ('Hardware') you identify the serial port which the GPS is connected to; in other words the serial port selected in the bluetooth manager. The Bluei GPS receiver uses 4800 baud but your GPS receiver may differ so check your documentation. Finally, you will want to check the box under the third tab ('Access').

Once this is done, the serial port selected under the first tab ('Program') showed up in TomTom. The next problem was that TomTom seemed unable to open the serial port by itself. Other GPS applications, however, were able to use the bluetooth GPS and while they were running TomTom could also use the port. So, at this stage I had a clumsy workaround.

To avoid having to run multiple applications I then went back to the GPS applet and disabled the intermediate serial port support by unchecking the box on the third tab and instead changing the serial port setting in the Bluetooth manager to use the same port I had previously set for applications (COM8 in my case).

So much trouble just because the TomTom developers apparently can't enumerate serial ports properly.

Categories
Computers Photography Windows

Image resizer freeware

resizer_drag.jpg

Every now and then I find myself in the situation where I want to resize images to a defined size. To speed up the workflow I have created this simple application that supports drag-and-drop resizing. Just drag an image file onto the application icon and the image will be resized according to the settings.

The application requires .NET Framework 2.0. There is no installer. Just put the executable file wherever you want.

If the application is launched by itself it present the setting dialog, shown below.

resizer_gui.gif

The bounding box is the largest possible image that will be the result of the operation. If the “crop to box” option is set, the source image will be cropped to leave an image of the exact size of the bounding box. If, on the other hand, the “fit within box” option is selected the image will be made as large as possible with retained aspect ratio and still fit within the bounding box. The bounding box can be of any size and the cropping, if required, will be done from the centre.

A watermark text can be added to the finished image by enabling the watermark option and typing a suitable string in the edit box. The font or position of the watermark text can not be changed.

Images can be saved to the same folder as the source image or to a defined target folder and will be given a suffix of “_resized”. The application will add extra numbers at the end to avoid overwriting existing files. If required, the metadata associated with the source image can be copied over to the resulting image.

To avoid having to keep the application on the desktop or somewhere else where it is readily available you can do the following:

  • Put the application (resizer.exe) anywhere you want on your hard drive
  • Right-click on any image file and select “Open with…” followed by “Choose program…”
  • Make sure the “Always use the selected program…” checkbox is unchecked and browse for the application file
  • Press OK

Windows will remember the application you selected for the jpeg files and will include the Resizer application on the “Open with…” submenu. The next time you want to resize a file you just have to pick the Resizer option from the “Open with…” submenu.

The resizing is done using bicubic with the highest quality setting. If I get around to it I will implement support for “unsharp mask”.

License

This application is provided free of charge for personal use. If you like it I would appreciate if you would link to my web site (http://www.spotwise.com).

Uninstallation

Just remove the EXE file and all registry settings under HKCU\Software\Bergek\Resizer.

If you added the application as a short cut under the right-click context menu you can remove the application in the registry under the key HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ FileExts \ .jpg \ OpenWithList. As always, be careful when editing the registry.

Attachments

Categories
Computers Windows

IIS authentication freeware

Authenticator is an add-on filter to the Microsoft IIS web server that provides basic authentication against Microsoft Access, Microsoft SQL Server and MySQL Server data sources. This means that the standard client authentication dialogs can be used for authentication without requiring user licenses for accounts in Active Directory in Windows.

The filter has been tested successfully on:

  • Windows XP Professional
  • Windows 2000 Professional
  • Windows 2000 Server
  • Windows Server 2003

License

This application is provided free of charge for personal use. If you like it I would appreciate if you would link to my web site (http://www.spotwise.com).

Installation

Add the database as a data source as a System DSN in the Data Sources (ODBC) applet in the Control Panel. Database templates are provided for Microsoft Access, Microsoft SQL Server and MySQL Server. Choose the one that suits your purposes the best and add suitable user accounts to the database (check below).

Install the filter on a web site in the IIS snap in and set the security settings on a virtual directory below the web site to disallow unauthenticated access and instead use basic authentication. Although the filter requires the username/password to be sent in clear text it is be possible to use it in conjunction with SSL to encrypt the data over the network. Set the RequireSSL registry value to true if you want to prevent cleartext passwords to be sent over the network. Also, set the realm; the text will be shown in the authentication dialog if supported by the client operating system.

When first loaded by IIS, the code will write default registry settings. Start regedit and make changes under HKLM \ Software \ Bergek \ Authenticator.

Note: As always, be careful when changing the registry as mistakes can, at worst, render the computer unbootable.

  • ConnectionString [SZ] – The connection string used to connect to the data source. In its simplest form it is just “DSN=Authenticator” (with Authenticator configured as the data source name in the control panel), although it can be formatted in various ways. The data source must be added as a System DSN since the user which will access it will most likely be the IUSR_{computer} account.
  • SqlStyle [DWORD] – Controls the SQL style used to query the ODBC data source. Possible values are 0:Microsoft SQL Server, 1:Microsoft Access and 2:MySQL Server. By default MySQL Server syntax is used.
  • RequireSSL [DWORD] – If set, the filter will return HTTP 401 Access denied if a request is made using non-encrypted HTTP. The HTTP 401 response is sent before the client has sent the user credentials which means that they will not be transmitted in cleartext form on the network.
  • MappedLogin [SZ] – A valid user name on the computer. Accesses against the virtual directory will be mapped against this user which must exist and be allowed to access the resource in the web application. The user name should be provided in the form {domain}\{login} but it can be {login} only if the default domain is set in the IIS snap in. If your computer is not in a domain you should write the account as {computer}\{login}
  • MappedPassword [SZ] – The password for the user account selected above. When the filter is first accessed this password will be encrypted and the encrypted version will replace whatever you type here.
  • LogSuccesses [DWORD] – If set to true (non-zero), authentication successes are written to the database.
  • LogFailures [DWORD] – If set to true (non-zero), authentication failures are written to the database.

After having changed the registry settings access requests to the protected web application folder will be matched against the database and IIS will use the mapped user account for all access.

Database settings

Two things must be added to the database in order for a user to be allowed access. First of all a user account must be created in the 'users' table:

  • Login: The login name of the user
  • Password: The password (in clear text) for the login account
  • Enabled: Must be set to true (1)
  • Expires: If set to false (0) the account does not expire
  • Expiration: Determines the expiration time for the account. Only used if Expires is set to true (1)
  • Administrator: Not currently used

In addition to the account itself site, directory permissions must be set for the user. This is done in the 'permissions' table:

  • UserID: The ID of the user in the 'users' table
  • SitePrefix: The IIS instance metapath for the site. For the first site on the system this is typically /LM/W3SVC/1
  • PathPrefix: The URL path prefix for which the user should be granted access (e.g. /secret)

The PathPrefix can be used to allow access only to certain areas of the web site. To give access to the entire site the PathPrefix should be set to a single slash ('/').

Troubleshooting

Error in the ISAPI filter are most frequently related to the connection between the filter DLL and the database. Please make sure that the latest versions of relevant ODBC drivers are installed on your computer and check the database connection in the Data Sources (ODBC) applet in the Control Panel. Errors are logged to the system event log. Incorrect account information for the mapped account is not shown by the filter but might be logged by the web server or by the system itself.

Errors could also be the result of the account running the web server not having sufficient permission to update the relevant registry keys under HKLM\Software\Bergek\Authenticator.

Uninstallation

Remove the ISAPI filter from the IIS snap-in. Restart IIS and then remove the DLL, database ODBC DSN and the registry key HKLM \ Software \ Bergek \ Authenticator.

If you are unable to remove the DLL file, please make sure that the filter has been removed from within the IIS snapin and that the event viewer is not running.

Attachments

Categories
Computers Gadgets

First impressions of Lacie Rugged All-Terrain

lacie_rugged.jpg

After hearing about friends having their computers stolen and losing precious data I finally got around and purchased a new external backup disk, settling on a Lacie Rugged All-Terrain 80GB. DVD backups worked fine until last year when I purchased a Canon EOS 20D and decided to shoot in raw format. Now, instead of having a few GB of data per year to backup I find myself with some 50GB.

I have tried a large number of bus powered USB drives but none of them seemed to work without extra power via a second USB cable. I was happy to notice that the Lacie Rugged All-Terrain 80GB could do with just the power supplied from the USB port on my Shuttle SN95G5v3. It is worth noticing that I also have a Lacie Mobile hard drive from late 2004 which does require extra power when connecting it to the same Shuttle PC. It seems, thus, that this rugged drive requires less power than the older drive but it is uncertain whether newer drives of the Porsche designed series require as much power.

On the negative side I was a little surprised to note the flimsy orange protection around the edges. Contrary to what I thought after having seen images on the Internet, the protective cover is just slipped over the drive. It would feel more solid if Lacie were to at least glue it together.

As would be expected, the drive is quite silent and the sound is barely noticeable. When making an initial backup of 50GB of data I saw a sustained throughput of 12 MB/s.

In short, this external USB drive does what it says. But I would like it better if the orange protector was attached more firmly to the drive itself.

Categories
Computers Linux Windows

Linux screen resolution issues in Virtual PC

Virtual PC is great for setting up testbeds but the support for Linux is less than optimal. When installing standard Linux distributions under Virtual PC it may be impossible to set the resolution to anything higher than 800×600 or even to get any image at all.

Edit the sections for Monitor, Device and Screen in the file /etc/X11/xorg.conf to look like this:

Section "Monitor"
    Identifier  "Monitor0"     VendorName  "Monitor Vendor"     ModelName    "General Laptop Display Panel 1280x768"     HorizSync    31.5 - 90.0     VertRefresh  59.0 - 75.0     Option     "dpms" EndSection
Section "Device"
    Identifier  "Videocard0"
    Driver      "vesa"
    VendorName  "Videocard vendor"
    BoardName   "VESA driver (generic)"
    VideoRam    8192
EndSection
Section "Screen"
    Identifier "Screen0"
    Device     "Videocard0"
    Monitor    "Monitor0"
    DefaultDepth     16
    SubSection "Display"
        Viewport   0 0
        Depth     16
        Modes    "1280x768" "1024x768" "800x600" "640x480"
    EndSubSection
EndSection

The above works for Fedora Core 5 under Virtual PC 5.3.582.27. If you are unable to get any image then boot from the rescue CD and use 'nano' or 'vi' to edit the file.

Categories
Computers Windows

UsbAutorun

UsbAutorun is an application that enables autostarting of applications upon insertion of USB memory cards in Windows. Autostarting of applications when inserting new media is generally used for CDs and triggered by a file called autorun.inf in the root of the disk. This function is not supported for USB memories in the base OS although Windows XP sp2 introduced some support for it.

This application is provided as-is and is free for any use provided that it is not resold or included in any commercial offering.

Installation

To install this application:

  1. Extract the application (UsbAutorun.exe) to your disk.
    Open a command promt window and change directory to where the application was extracted
  2. Type usbautorun /install
  3. Type usbautorun /password {password} (with a password of sufficiently high entropy)
  4. Type usbautorun

Usage

As long as the application is running it will react on device insertions and use the autorun.inf file in the root of the USB memory to start any application indicated in the file. The autorun.inf file needs to have a new segment named UsbAutoRun which gives details on what to do when the USB memory is inserted. It also provides a password which must match the password configured in the computer itself. If the passwords don't match, the application will silently disregard the insertion of the USB memory. Below is an example of an autorun.inf file.

[AutoRun]
UseAutoPlay=1
ShellExecute=HelloWorld.vbs
icon=setup.ico

[UsbAutoRun]
ShellExecute=HelloWorld.vbs
Password=pwd

Running usbautorun /install writes data to the registry at HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Run to make the application autostart when the current user is logged on. After it is installed the application must not be moved as the path is written to the registry. For more information on command line parameters, type usbautorun -? at the command promt.


Note: Is is highly recommended to use a password as the ability to run an application on the computer just by inserting a USB memory card otherwise may be misused as a way to spread viruses.

Attachments

Categories
Computers Gadgets

Misbehaving Netgear WGPS606

To avoid having to run cables I have used a Netgear WGPS606 to wirelessly connect computers on my desktop with my broadband connection. When checking the log files on my Linux box I noticed that the Netgear unit was causing my log to fill up with DHCPDISCOVER/DHCPOFFER:

Jun 20 23:21:21 xxx dhcpd: DHCPDISCOVER from <mac>(WGPS606) via eth0
Jun 20 23:21:21 xxx dhcpd: DHCPOFFER on 10.1.1.191 to <mac>(WGPS606) via eth0
Jun 20 23:21:41 xxx dhcpd: DHCPDISCOVER from <mac> (WGPS606) via eth0
Jun 20 23:21:41 xxx dhcpd: DHCPOFFER on 10.1.1.191 to <mac> (WGPS606) via eth0
Jun 20 23:22:01 xxx dhcpd: DHCPDISCOVER from <mac> (WGPS606) via eth0
Jun 20 23:22:01 xxx dhcpd: DHCPOFFER on 10.1.1.191 to <mac> (WGPS606) via eth0

It is all very strange since the MAC address for which the DHCP discover is sent is the wireless NIC. But the wireless NIC has a static IP address and should not need to request a DHCP address in the first place. Furthemore, the DHCP server is on the LAN side of the Netgear box.

Netgear support has been unable to assist so in the end I had to blacklist the WGSP606 using the following few lines in dhcpd.conf:

host wgps606 {
        hardware ethernet <mac>;
        ignore booting;
        ignore bootp;
}

Apart from this the WGPS606 has been doing a great job for now almost a year.

Categories
Computers Windows

How to save a Real audio stream using only freeware

On more than one occassion I have found myself with a need to save a Real audio stream from a web site. Each time I have had to browse through multiple web sites to find a working solution. This is how I managed to do it last time around.

  1. Download and install FlashGet (http://www.flashget.com/index_en.htm)
  2. Copy audio stream URL (ending with .ram) from the web browser
  3. Create a new download in FlashGet using the URL taken from the previous step
  4. Run the download job to get the Real audio file
  5. Download and install Switch (http://www.nch.com.au/switch/)
  6. Use Switch to convert the Real audio file to the desired format

If required, use an application such as Mp3splt (http://mp3splt.sourceforge.net) to split the file into manageable parts.

All of the above applications are free to download and use.

css.php