Posts Tagged Arduino
Adding the ARDX.ORG source code to your Arduino Example folder
Posted by grymoire in Hacking, Shell Scripting, Technology on October 16, 2011
I purchased the ARDX kit from Lady Ada, and I wanted to experiment with all of the source code from the ARDX web site. However typing in the link and copying the source code didn’t automatically add it as an example. Instead I had to re-save it as a sketch. So instead, I wrote a shell script called ARDX.sh
This does several things.
- It downloads all of the sketches.
- It creates a directory to store all of the sketches
- It creates a directory for each one of the sketches.
- It renames the source code into a *.pde file
- It moves the *.pde file into the proper sketch folder
- It removes all files created during the process. that are no longer needed.
To use the script, simply type
./ARDX.sh
# This creates a folder called "Ardx"
mv Ardx .../arduino-0022/examples/.
Here is the script. Note how I used the $debug variable. This let me select if I wanted to show the commands or execute the commands.
#!/bin/sh # Remove the '#' at the beginning of the next line to debug this script #debug=echo if [ ! -d Ardx ] then mkdir Ardx fi cd Ardx Examples="01 02 03 04 05 06 07 08 09 10 11 12A 13A" for i in $Examples do $debug wget -r http://ardx.org/CODE$i done $debug wget -r http://www.ardx.org/src/circ/CIRC12-code-ADAF.txt $debug wget -r http://www.ardx.org/src/circ/CIRC13-code-ADAF.txt # Now create a directory for each of the examples Examples="01 02 03 04 05 06 07 08 09 10 11" for i in $Examples do if [ ! -f ardx.org/src/circ/CIRC$i-code.txt ] then echo unable to find file ardx.org/src/circ/CIRC$i-code.txt else $debug mkdir CIRC$i $debug mv ardx.org/src/circ/CIRC$i-code.txt CIRC$i/CIRC$i.pde fi done # Now remove the old files in $debug mkdir CIRC12A $debug mv www.ardx.org/src/circ/CIRC12-code-ADAF.txt CIRC12A/CIRC12A.pde $debug mkdir CIRC13A $debug mv www.ardx.org/src/circ/CIRC13-code-ADAF.txt CIRC13A/CIRC13A.pde $debug /bin/rm -r ardx.org www.ardx.org
Restart your Arduino session, and when you look in examples, you will see a new folder called Ardx. Inside is a sketch for each of the examples.
The new attack vector – HID
After attending Black Hat 2010/DEFCON 18, the world-famous hacking convention, I will make a prediction of a large number of attacks using USB devices being discovered for the next few years.
USB drives can be dangerous. If you store sensitive information on one and lose it, you should assume the information will be seen. Hint: encrypt the data.
It’s also a great way for penetration experts to break into a computer system. Leave a USB drive in the parking lot, and install some malware (e.g. using Switchblade) that executes when the USB drive is plugged into the computer. Presto! And the malware is installed. This works because most computers are set up to automatically run the programs on a USB drive when one is plugged in. This is dangerous, and I suggest you disable this autorun feature. Even worse is the U3 USB drives, which can write into your computer’s registry, or into the filesystem, without asking. How convenient, especially for the evil-doer. Then again, you can also have a program called “Install” and it’s amazing how many smart people will click this just to see what is on the USB stick.
This autorun “feature” also works on network mapped drives, which is how the Conficker virus spreads. The best solution is to completely disable autorun, which is a tip from US-CERT to prevent viruses from spreading.
Problem solved, right? Not really. I predict that there will be a lot of new attacks on computer systems from a new threat – the keyboard. Or rather, a keyboard-like device. Or more accurately, a Human Interface Device.
Andrian Crenshaw, AKA IronGeek was given a Phantom Keystroker at Schmoocon 2010. This device acts looks like a USB stick, but acts as a keyboard. It randomly does annoying things like changing CAPSLOCK, moving the mouse, inserting garbage characters. In other words, it’s a great practical joke: it drives the victim crazy. Cool, but a hacker would like to be able to reprogram the device to do more sinister things. While looking into the possibility, Adrian learned about the Teensy device, which is a low-cost ($18) Arduino-like device that does exactly that. Adrian started exploring the possibilities with it to attack a computer and I learned about this on pauldotcom. Yes, you do need physical access to the device, but the Teensy is very small, and easy to hide.
Adrian was the first to look into this as far as I can tell. However, at Black Hat 2010/DEFCON 18, I saw several presentations all using the HID interface. Clearly the time has come. The talks were
- USB – HID, The Hacking Interface Design- Richard Rushing The slides are available here (PDF).
- Microsoft Powershell – It’s time to own – David Kennedy, Joshua Kelley
- Powershell…omfg – David Kennedy (ReL1K), Josh Kelley (WINFANG) See the video here and code here.
- Hacking with Hardware: Introducing the Universal RF Usb Keboard Emulation Device – URFUKED – Monta Elkins. See here for code and notes
- Programmable HID USB Keystroke Dongle: Using the Teensy as a Pen Testing Device – Adrian Crenshaw (Irongeek). See here for the code, slides, video, pictures, etc. And here for the DEFCON-18 talk.
Unlike a U3 USB drive, a HID (or Human Interface Device) does not require any driver. The HID is typically a keyboard, or a mouse. It could also be a joystick, a bar code scanner, a camera, a keypad, etc. For more information see the Apple docs and the HID usage Table (PDF). This means the device can type whatever it wants. In other words, the device acts like an evil secret keyboard, and the operating system allows it to do so. How nice.
Here are some of the things you can do with this technology:
- Make a device that once every 5 minutes, it moves the mouse one pixel to the left, and then move it one pixel to the right. If someone expects their computer to lock the screen automatically, the program will prevent it from happening.
- Run a batch or script file. And Microsoft, bless its heart, has added almost everything you need to PowerShell, which is standard on newer operating systems. Launch a power shell and change the configuration of the computer. It is limited to 140 characters a second, and the user might see a window pop up. Either wait for them to be out of the room, or misdirect them (drop hot coffee i their lap).
- Go to a remote website and download and install program.
- Hook up a wireless interface to it, like Monta did. Wait for the person to be distracted, and press a button, and run a program.
- Adrian hooked up a photodiode to his device. It waits until the lights turn off before it does anything. Evil likes the dark.
I predict that next year we will find out a lot about ways this technology can be used to compromise computers. There are several reasons for this:
- It’s cheap. The software is free, and as I said, the Teensy is $18.
- It’s small. Adrian put a device and a hub inside a transparent mouse. The device also had colored LEDs that would flash based on activity. A mouse with flashing LEDs – that’s a cool gift. It also attacked your computer. Many keyboards have built-in hubs. Put one of these inside a keyboard. There’s plenty of room.
- It can be reprogrammed to appear to be any device. Most businesses allow users to swap keyboards and mice. You need some heavy duty paranoid software to detect unusual and unexpected HID devices, which usually means rigid military-like systems.
- Since it can pretend to be any device, it is an excellent way to attack device drivers. After all, drivers don’t expect devices to suddenly claim to move a million pixels to the left. But a Teensy device can create events that do this. Every keyboard and mouse driver is now a possible entry (vector) into a computer.
- HID events can be sent to the computer even when the screen is locked, and the computer will respond. Richard Rushing showed someone at Microsoft some examples, and they were surprised. Expect a patch for this.
In other words, those that care about security must be careful of what USB devices they plug into a computer. Those clever USB toys you see may really be an evil device. And it’s hard for the computer to protect itself. We use HID-enabled devices all the time. We can’t just disable the: nothing would work.
Expect that many drivers for USB devices will be found to have security holes, because they never expect those devices to suddenly turn evil. Already people are finding ways to use this technology. The PS3-Groove uses a Teensy to jailbreak a Playstation PS3. The TI84 Calculator can also be used to jailbreak the PS3.
Adrian has a new paper on malicious USB devices.
I will update this site as I find out more.
Irongeek gave an update on pauldotcom.
And here’s a new example.
Update -
Another Teensy-like device, from AdaFruit
http://www.ladyada.net/wiki/products/atmega32u4breakout/index.html?s[]=teensy
Update July 14