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

Posted by Phillip Torrone | Aug 16, 2005 10:01 AM
DIY Projects | Permalink | Comments (7)

Recent Entries

Comments

Oldest comments listed first.

  • 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: Daenris on August 16, 2005 at 11:07 AM

  • 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: GlucoPilot on August 16, 2005 at 4:01 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: Daenris on August 16, 2005 at 4:16 PM

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

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

    Posted by: BBatchelder on August 17, 2005 at 11:23 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.

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


Your comment will be posted in the background and may take a few minutes to appear on the site; you do not need to re-post.

Allowable html: a href,br/,p,b,strong,em,i,ol,ul,li,blockquote,pre

Name:

Comment:


Please enter the security code you see here

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

How-to videos for Makers and Crafers!


Void your warranty, violate a user agreement, fry a circuit, blow a fuse, poke an eye out... Welcome to the Make Blog!

Features and more @ MAKE!

MAKE @ The NYC Toy Fair 2008 - Covering DIY!
HOW TO - Build the arms of assistance.

MADE in Japan - Part I.
MADE in Japan - Part II.
MADE in Japan - Part III.

Make store - Blinky bug kit - Blink!
Make store - Loud Objects Noise Toy Kit

Makers - MAKE Flickr pool contest. Win cool stuff!
Makers - Join the MAKE Facebook page - Meet other makers.
MAKE on Twitter - Tweet! Tweet!
What you're reading in MAKE - Data!
Add MAKE to your RSS reader - Real simple.


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!


Phillip Torrone.Phillip Torrone
Senior Editor
Tel: 707-827-7311


Gareth BranwynGareth Branwyn
Robot Maker


Jonah Brucker-Cohen Jonah Brucker-Cohen
Researcher

Suggest a Site!

Natalie Zee DrieuNatalie Zee Drieu
Senior Editor
CRAFT


Becky Stern Becky Stern
Culture jammer


Collin CunninghamCollin Cunningham
Sound Maker


Marc de Vinck Marc de Vinck
CNC Maker

Current Podcast

itunes_p.jpg AHAB High Altitude Ballooning - Best of Weekend Projects mp4|mov|hd|3gp|3g2|itunes This week on Best of Weekend Projects, we look back at part two of the AHAB (High Altitude Balloon Adventure). In this epic Bre & Co. travel to Eastern Washington to launch a GPS and camera enabled balloon... More...

Get the Make blog sent via email

Enter your email to receive the Make blog each day:



WOW! Thanks to everyone involved with Maker Faire Austin: attendees, makers, exhibitors, sponsors, volunteers, and crew...it was AMAZING! Over 350 Makers and 20,000 attendees! Be sure to check out the photos @ Flickr, and our Maker Faire posts for all the action! Next year, scheduled Maker Faire's are: Bay Area: May 3rd & 4th, 2008 - San Mateo County Fairgrounds and Austin: Oct. 18th & 19th, 2008 - Travis County Expo Center!

Make Categories

www.flickr.com
photos in MAKE More photos in MAKE Flickr Pool
www.flickr.com
photos in Craft More photos in Craft Flickr Pool

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

Click here to advertise on MAKE!
Subscribe to MAKE Magazine!

Recent Projects

From the Instructables MAKE group


Important please read

Recent Posts from the Craft: Blog

Recent Posts from the Hackszine Blog