Tagged: coding

Hakology Day 82: Digistump … rickroll all the things.

Well merry crimbo, I hope you had a great day whatever you spent it doing. So i’ve been really busy the last few weeks but I’m starting to have a little more free time now … and thought I’d take this chance to start writing up a little code and project for the digistump.

What is a digistump?

A digistump is a small USB development board that emulates a HID (Human interface device (Usually a keyboard or mouse but there are other variants)). The digistump allows the user to flash up to 6k of code to the device which when plugged in to a computer after programming will execute the code on the device as if it were a keyboard and/or mouse.

Why would I use one?

Its very handy for automating small tasks such as downloading a file and running an install or just editing settings on the pc that remain consistent across operating systems. eg. You could use the digistump to run a command in the command window or run a specific application with certain options automatically. All you need to do is plug the device in after programming and it will start executing the pre-programmed keypresses.

What operating systems does it support?
The digistump is cross-platform this doesnt mean one script works for all operating systems. This means the device is capable of running and executing code on Win/Linux/Mac but due to difference across the various operating systems scripts would need to be customised for each. The digistump has no way of reading data or accepting any feedback from the PC it just blindly presses keys. Your scripts will rely heavily on intelligent timing. Some commands will execute and finish on modern PCs faster than they would on older hardware, this has to be taken in to consideration when writing code.

Where can I get one?
The digistump is available from Digistump.com you can also find them available on ebay and similar sites. I bought mine from ebay for £1.50 each which is a tiny amount when compared to similar devices.

The install procedure is pretty straight forward, download arduino IDE, install drivers and add digistump examples and templates. Which is all detailed on this page here … Getting started with the digistump
The setup is relatively straight forward.

So why am I reading all of this?

Well b/c the digistump is a relatively new product there’s not a lot of reference material on the internet so I started developing a small framework to make it easy to deploy and develop code very quickly. I’ve been busy working on my first little project for the device and right of passage to rick roll any windows 7 users. Although this project is a harmless bit of fun it’s helping me to develop a lot of standardised functions for running applications, opening web pages creating and saving files.

Rickroll notes …
I spent the first few nights tearing my hair out with this device. Here are some of the issues I encountered and how I mitigated them or formed some workarounds.

The first major issue I had was the backslash. The digistump by default outputs US scancodes, as I live in the UK this was an issue. So after much googling and head scratching I figured out that the scancode for the backslash on a UK keyboard was 0x64 yet the digistump was sending 0x31 the US scancode for the backslash.

Whilst I couldn’t figure out where the digistump library resided on the PC I wrote a small function to swap out the 0x31 for 0x64 which seems to have remedied my backslash issues. This is not the correct way to do things.

Eventually I found the library location last night (c:\Users\Username\arduino15\… ). I’m still yet to look through the code and figure out a conversion table for 101(UK en-gb 32) keyboards. Given a little more time I’ll get this fixed and not have to use any functions for string processing.

Another related problem was the saving of files using the %USERPROFILE% environment variable. Full filenames containing this variable were not being parsed properly ie. the environment variable was being read as %USERPROFILE% and not the actual users name. To mitigate this I broke the file string down in to sections and type each part of the save file string in separately. ie. C:\ [ENTER] Users\ [ENTER] %USERPROFILE%\ [ENTER] etc which allowed me to use the %USERPROFILE% variable when saving files.

I’m not going to upload all the code yet as its still messy and I have some functions that need more calling parameters adding so if I released the code now it’ll probably change before the final release and I want everything nice and polished before I release everything.

A great big shout to advancednewbie who’s been working on a special script for the digistump (More on that very soon.) his research and project helped me greatly in trying to figure out the key mappings for most default buttons and some of the UK differences. Given some more time im sure we’ll have this working seamlessly between countries and keyboard layouts.

Even though these issues don’t directly relate to the rickroll project I thought I’d include them just in case anyone else is having similar issues.

Download digispark digistump stumpyroll source code

Hakology – Ubercrypt – Python multi-layer AES encryption.

In this video we’ll be looking at a script I wrote a few months ago to facilitate multilayer aes encryption (cryptographic strengthening) using multiple keys and ivs combined into one monster key. Allows users to encrypt share and decrypt data using the command line. Demo is for linux but this may work if you can install the python crypto library on windows.

Full source code …

sudo apt-get install git python python-crypto
git clone …
python crypto.py -g 4096
python crypto.py -e “Hack the planet”
python crypto.py -d ENC-23-32-54-232

have fun hacking !