HOW TO write a plugin for UsbWiSec

HOW TO write a plugin for UsbWiSec

 Users Pt Desktop Post Usbwisechowto Hardware
The USB Wireless Security Lock is an interesting piece of hardware, a little green button that you carry on your person, which allows your computer to lock itself when you walk away from it. It consists of the key fob, and a receiver that plugs in via usb. There are no drivers to install, as the device is seen as a simple USB Human Interface Device. The OEM software is nearly useless, but there’s a homemade replacement, called UsbWiSec – here’s the HOW TO…HOW TO by-

Bryan Batchelder
http://labs.patchadvisor.com/blogs/bryan

Scott Hanselman
http://www.computerzen.com

The OEM software is nearly useless, but I was able to write my own replacement, called UsbWiSec. This replacement software is available on SourceForge, and there is an MSDN article written by Scott Hanselman that describes its architecture.

The hardware is essentially a re-purposed cheap wireless mouse. If you want more information on the technical details of the hardware, you can read the MSDN article and my original article describing my journey in figuring out what makes it tick.

Extensibility
One of the goals of UsbWiSec is to be as easily extensible as possible. When I released my initial proof of concept, I was deluged by requests for various features. My next release included a plugin system. When Scott ported the code to .NET 2.0 for the MSDN article, he beefed up the plugin system, and wrote several new plugins.

The locking mechanism itself is simply a plugin, which you could disable if you were not interested in security, and for example just want your music to be paused when you step away from the workstation.

Plugins
By far, the best plugin (from an extensibility point of view) is the Batch File plugin. It simply executes locked.bat when the station should lock, and unlocked.bat when it should unlock. You can craft any script you desire. In fact, if .NET isn’t your language platform of choice, you can write a plugin in any language you want, and compile it into an executable, and call it from the batch files.

 Users Pt Desktop Post Usbwisechowto Folder

The batch files that are executed for lock and unlock events.

The preferred method of extending the app is writing a plugin. The major advantage to this approach is you can provide an integrated configuration screen. You also have access to the raw messages sent by the KeyFob, and the PresenceNotification events – in addition to being informed of lock and unlock events.

 Users Pt Desktop Post Usbwisechowto Ui

The main interface to UsbWiSec, you can see the plugins listed.

How to create a plugin for UsbWiSec

You will need:

* Visual Studio 2005 Beta 2
* UsbWiSec 2.0.1 installed

First, start a new project in Visual Studio 2005

 Users Pt Desktop Post Usbwisechowto Newproject

Add a reference to the UsbWirelessSecurity.Core.dll to your project

Create a new class, and name it accordingly for what your plugin does.

You will then:

* Add a using statement for the UsbWirelessSecurity namespace.
* Make your class sub-class PresencePluginBase
* Add an attribute that defines the name of the plugin, and an optional configurator type (which also means you would need to create a configurator, which is just a WinForm):
o [PresencePluginConfigurator(“My Plugin”, typeof(MyPluginConfigurator))]

* Override any of the following methods:
o HandleMessage(KeyFobMessage m)
o HandlePresenceNotification(PresenceNotificationEventArgs e)
o InitializePlugin(string pluginDirectory)
o WorkstationLocked()
o WorkstationUnlocked()

A barebones plugin looks like this:

using System;
using System.Collections.Generic;
using System.Text;
using UsbWirelessSecurity;
namespace SampleUsbWiSecPlugins
{
[PresencePluginConfigurator( “Sample Plugin”)]
public class MyPlugin : PresencePluginBase
{
public override void WorkstationLocked()
{
//do cool stuff here
}

public override void WorkstationUnlocked()
{
//do more cool stuff here
}
}
}

Then compile your plugin, copy the .dll to the program directory for the UsbWiSec app, and restart the UsbWiSec app. Your plugin will then appear in the app!

 Users Pt Desktop Post Usbwisechowto Uiwithplugin

For examples of more complex plugins, and how to create a plugin configurator, you can download the source code from SourceForge and examine it for yourself. When you have completed your plugin, let one of us know and we might include it into the core plugin set.

Bryan Batchelder
http://labs.patchadvisor.com/blogs/bryan

Scott Hanselman
http://www.computerzen.com

14 thoughts on “HOW TO write a plugin for UsbWiSec

  1. Daenris says:

    Okay, this software sounds pretty cool.

    However, my first thought about the USB security lock thing is how is it secure at all? I mean, can’t someone just unhook the USB receiver from the computer? I mean, sure it wouldn’t unlock the system, but it defeat s the purpose of the device. Or what if someone manages to unhook the think while you’re standing within 2 meters of your system without you noticing. Then you walk away and they have access to your computer.

    Of course, looking at this software I may consider buying one just for the variety of other things I could have it trigger based on proximity :)

  2. GlucoPilot says:

    Scott Hanselman here – Keep in mind that this USB KeyFob doesn’t KEEP the system locked, it doesn’t have to. If I walk away, it locks. If someone evil unlocks it, it doesn’t change anything, the system is still locked. Now, if they unlock it while you’re standing near it, and you haven’t set a screensaver to lock it anyway after 5 min of inactivity, then how is that any different whether you have the device or not? This is a serious convenience, and when combined with the Microsoft FingerPrint Reader, it’s really slick. Walk away, lock. Walk back, fingerprint unlock.

  3. Daenris says:

    I understand it doesn’t have to keep it locked. Thus my second hypothetical situation.

    Now, if they unlock it while you’re standing near it, and you haven’t set a screensaver to lock it anyway after 5 min of inactivity, then how is that any different whether you have the device or not?

    Because, if they’ve unlocked it, then you’ll walk away assuming your computer will lock. Now they walk in a minute or so after you’ve left and access your system.

    Sure. It’s a convenience. That’s about it. Although I reiterate, now with this alternative to the pure security related software that comes with it I’ll probably pick one up. I can think of some good uses for it in my in-the-works car system.

  4. SillyRabbitPGH says:

    OK, after reading the article concerning what type of hardware this device is, I was wondering if the software could be used with a cheap wireless mouse instead of the USB Security Lock. If so, you could just take the mouse with you to activate the program.

  5. SillyRabbitPGH says:

    OK, after reading the article concerning what type of hardware this device is, I was wondering if the software could be used with a cheap wireless mouse instead of the USB Security Lock. If so, you could just take the mouse with you to activate the program.

  6. BBatchelder says:

    I have adressed these questions in a post to my blog.

  7. EricK. says:

    Daenris:

    I know it’s been over a month since you asked your question, but here’s the answer:

    The USBWiSec lock does precisely the following:

    If the software loses contact with the keychain, it locks the workstation.

    It does this by calling the same routine that you do if you hit Ctrl-Alt-Delete and choose ‘Lock Workstation’. The computer is now locked and does NOT rely on the presence of the hardware or software to keep it LOCKED. It actually relies on the presence of the hardware to keep it from deciding to lock.

    So, if someone disconnects the hardware while you’re within 2 meters, the machine locks immediately, thinking you’d suddenly gone away.

    If someone steals your keychain and brings it back to the computer expecting for it to unlock, nothing happens. The software will automatically LOCK your PC for you, but will NOT automatically UNLOCK your PC. It’s not as convenient but it’s more secure this way.

    The keychain is a convenience. And it’s no less secure than if you personally remembered to lock your workstation every time you walked away from it.

    I can barely get out of my cublicle before my computer locks, so anyone who wanted to slide in and end-task the program before I got away would have to elbow me out of the way to do it. I’m pretty sure I’d notice.

Comments are closed.

Discuss this article with the rest of the community on our Discord server!
Tagged

current: @adafruit - previous: MAKE, popular science, hackaday, engadget, fallon, braincraft ... howtoons, 2600...

View more articles by Phillip Torrone

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK