Welcome to In Depth Defense. In Depth Defense LLC is a privately owned Information Security Consulting company owned and operated by Mark Baggett. In Depth Defense specializes in Penetration Testing and Incident Response. At this time In Depth Defense is not accepting any new client work, but we are happy to speak to you and point you to other resources in the community.

Mark Baggett has been active in Information Security for 18+ years. I've served in a variety of roles from software developer to CISO. You can find archives of older blog entries below and read my newer posts on http://www.pauldotcom.com, http://isc.sans.edu and http://pen-testing.sans.org

Tuesday, May 12, 2015

Awesome Keyboard Tricks - Clevo/Sager Backlight control from Powershell

I'm back on Windows.   After 8 years on a Macintosh I just couldn't go another day with ONLY 16GB of RAM.   I priced it out and for the cost of a top of the line MacBook I could get a tricked out PC with 32GB of ram and 2.5 TB or hard drive space (1.5 of it being SSD).   So I made the switch.  To get a top performing laptop I ended up buying a gaming machine from xoticpc.com.   The model is Sager NP9752 (Clevo P750ZM).    I have to say I like it quite a bit.    One of the features I was curious about was the "Programmable backlit keyboard".   With it you can set your keyboard backlight to various colors and light movement patterns.    Now, when I hear "programmable" I think APIs.   I was a little disappointed to find out there weren't any documented APIs that I could use to control the keyboard.    Your only choice is to use their built in tool to configure the lights on the keyboard.   That stinks.  I want to be able to change key colors automatically from the command line and from within my own programs.  So through a little code analysis and examination of open source Linux versions of drivers I was able to put together the following Powershell Script.


Updated link:  https://github.com/MarkBaggett/MarkBaggett/blob/master/set-kbled.ps1

After downloading and storing the script on your local hard drive you import the module into Powershell like this:

C:\PS>import-module .\set-kbled.ps1

Then you can run various options and set your keyboard lights:

C:\PS>SET-KBLED -LeftColor RED -CenterColor WHITE -RightColor Blue

Or turn the lights off


Or turn the lights back on:


Or try some of the various blinking patterns:

C:\PS>SET-KBLED -Pattern Blink

Now I can have my keyboard lights react to specific events on my event log.  I can set my laptop so that the keyboard turns BLOOD RED when I launch Metasploit or it Blinks frantically if a virus is detected.   I can have it turn blue when I play some easy listening music.  The possibilities are endless.   Do you have a Sager or Clevo compatible laptop?   Try it.  Make sure your Powershell Window is running as an administrator, import the module and try some of the commands above.   GET-HELP SET-KBLED -Full for a complete list of options.   How you enjoy it.   Now on to some real work.


No comments: