10.09.2016 Views

Hacking_and_Penetration_Testing_with_Low_Power_Devices

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

168 CHAPTER 7 Building an army of devices<br />

<strong>and</strong> you should be rewarded <strong>with</strong> a log-in prompt on the drone. When using a USB<br />

XBee adapter, the port will likely be /dev/ttyUSB0.<br />

This same technique can be used to control multiple drones one at a time. In order<br />

to switch from one drone to another, the DL address on the comm<strong>and</strong> console XBee<br />

modem must be set to match the MY address of the target drone. The steps to change<br />

drones are as follows: First, type “+++” into the terminal program <strong>and</strong> do not press<br />

enter. The modem will respond <strong>with</strong> “OK” after about a second. Second, change the<br />

DL value to match the drone MY address by typing “ATDLnnnn,” where nnnn is the<br />

drone MY address, <strong>and</strong> press enter. Third, write the results to the modem by typing<br />

“ATWR” <strong>and</strong> pressing enter. Finally, exit comm<strong>and</strong> mode by typing “ATCN” <strong>and</strong><br />

pressing enter. All of these comm<strong>and</strong>s must be entered before the time-out value set<br />

on the modem is reached <strong>and</strong> it automatically exits comm<strong>and</strong> mode.<br />

The TTY method has a couple of advantages over using Python. First of all, no<br />

programming is required. Once the XBee modems are configured <strong>and</strong> TTY services<br />

are running on the drones, penetration testing may commence. Secondly, interactive<br />

programs can be run using this method. Finally, if the comm<strong>and</strong> console is connected<br />

to a drone <strong>and</strong> it goes out of range, it will still be connected when back in range.<br />

While this method is simpler than the Python method to be described next, it is<br />

not recommended for any penetration tests <strong>with</strong> more than just a h<strong>and</strong>ful of drones.<br />

Even then, I would be inclined to use Python. Running interactive programs is nice,<br />

but keep in mind that the maximum connection speed is 250 kbps. Noise on the wireless<br />

connection can also be an issue. A big limitation is that communication is only<br />

possible <strong>with</strong> one drone at a time. When running in API mode, the comm<strong>and</strong> console<br />

can talk to multiple drones <strong>and</strong> noise is less of a problem because data are transmitted<br />

in packets <strong>with</strong> checksums.<br />

REMOTE CONTROL via PYTHON<br />

Using API mode is the most desirable situation. There are a number of options on<br />

how to accomplish this. If you have an excess amount of free time, you can write<br />

your own XBee communication program in the language of your choice. There is<br />

a Java XBee-API library available from https://code.google.com/p/xbee-api/. A<br />

Python XBee <strong>and</strong> ZigBee module is also available at https://code.google.com/p/<br />

python-xbee/.<br />

Given Python’s popularity <strong>with</strong> penetration testers, it seems like the logical choice<br />

for our purposes. The current version of the Python XBee module is 2.1.0 as of this<br />

writing. Despite its name, the XBee module works <strong>with</strong> ZigBee modems as well.<br />

The XBee module is very easy to use. The following code snippet demonstrates<br />

how to send packets using this module. One thing to keep in mind when operating the<br />

XBee modems in API mode is that the maximum packet size is 100 bytes:<br />

import serial<br />

from xbee import XBee

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!