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


Recent Entries

Comments

Oldest comments listed first.

Posted by: Daenris on August 16, 2005 at 11:07 AM

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 :)


Posted by: GlucoPilot on August 16, 2005 at 4:01 PM

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.


Posted by: Daenris on August 16, 2005 at 4:16 PM

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.


Posted by: SillyRabbitPGH on August 17, 2005 at 3:47 AM

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.


Posted by: SillyRabbitPGH on August 17, 2005 at 3:49 AM

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.


Posted by: BBatchelder on August 17, 2005 at 11:23 AM

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


Posted by: EricK. on September 20, 2005 at 6:19 AM

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.


Leave a comment


Subscribe to MAKE!Subscribe to MAKE Magazine!

Subscribe today, save 42% and get web access to MAKE free. MAKE Digital Edition is available only to subscribers.

$34.95 / 1 year
(4 Quarterly Issues)

Subscribe now


Void your warranty, violate a user agreement, fry a circuit, blow a fuse, poke an eye out. Make: The risk-takers, the doers, the makers of things... Welcome to Make: Online!


CRAFT Maker Shed Maker Faire MAKE television
Holiday Gift Guides from MAKE
Gifts for Dads
Science and Chemistry
Gifts Under $20
More guides: Santa Claus Machines, Geek Toys for Grown Up Girls & Boys


Check out all of the episodes of Make: television

Alex Rider Dream Gadget Contest
Make: Science Room

Connect with MAKE

Be a MAKE fan on Facebook MAKE on Facebook
Visit our Facebook page and become a fan of MAKE!
MAKE on Twitter MAKE on Twitter
Follow our MAKE tweets!
MAKE Flickr Pool MAKE on Flickr
Join our MAKE Flickr Pool!
    make_tips on Twitter




    Maker SHED

    Advertise here with FM.

    Why advertise on MAKE?
    Read what folks are saying about us!

    Click here to advertise on MAKE!



    Subscribe to MAKE Magazine!

    Make: Online authors!

    Gareth BranwynGareth Branwyn
    Senior Editor


    Phillip TorronePhillip Torrone
    Senior Editor
    | AIM | Twitter


    Becky SternBecky Stern
    Associate Editor
    | AIM | Twitter


    Marc de VinckMarc de Vinck
    Contributing Writer
    | AIM | Twitter


    John ParkJohn Park
    Contributing Writer
    | Twitter


    Sean RaganSean Ragan
    Contributing Writer
    | Twitter


    Matt MetsMatt Mets
    Contributing Writer
    | AIM | Twitter


    Dale DoughertyDale Dougherty
    Editor & Publisher
    | Twitter


    Shawn ConnallyShawn Connally
    Managing Editor
    | Twitter


    Goli MohammadiGoli Mohammadi
    Associate Managing Editor

    Kip KayKip Kay
    Weekend Projects
    | AIM | Twitter


    Collin CunninghamCollin Cunningham
    Contributing Writer
    | AIM | Twitter

    Adam FlahertyAdam Flaherty
    Contributing Writer
    | AIM | Twitter



    More contributors: Mark Frauenfelder (Editor-in-Chief, MAKE magazine), Kipp Bradford (Technical Consultant/Writer), Chris Connors (Education), Diana Eng (Guest Author), Peter Horvath (Intern), Brian Jepson (O'Reilly Media), Robert Bruce Thompson (Science Room)

    Suggest a Site!

    Current Podcast

    itunesdl.gif Weekend Project: Beetlebot Simple robot from your parts bin that avoids obstacles. Thanks go to Jerome Demers for the original article in MAKE, Volume 12. To download the Beetlebot video, click here or subscribe in iTunes. Check out the complete Beetlebot article... More...

    Get the Make: Online sent via email
    Enter your email to receive Make: Online each day:



    MAKE Fascination video series brought to you by Dow

    Make: Education
    MAKE: en EspaƱol MAKE: Japan
    Important please read


    Subscribe to MAKE Magazine!

    Recent Posts from the Craft: Blog