10.09.2016 Views

Hacking_and_Penetration_Testing_with_Low_Power_Devices

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

The SP parameter can be used to set the cyclic sleep period between 0 <strong>and</strong> 268 seconds<br />

in 10 millisecond increments. For coordinators, the SP value determines how<br />

long stored packets for indirect connections are retained. Packets are kept for a time<br />

equal to 2.5 times SP.<br />

The ST parameter establishes the inactivity time before a modem in a cyclic sleep<br />

mode goes to sleep. The permissible range for ST is 0 to 65.535 seconds in one millisecond<br />

increments. The ST parameter must be set to the same value on end devices<br />

<strong>and</strong> coordinators.<br />

For our purposes, a cyclic sleep mode seems most appropriate. Sleep mode 4 does not<br />

require the use of GPIO pins. If this mode is used <strong>and</strong> the drone has data to send, sleep can<br />

bedisabledbysettingSM tozero.The sleepmodecanbe resetafterthe dataare transferred.<br />

In most cases, the comm<strong>and</strong> console will initiate communications, so the sleep mode can<br />

be left at 4. Sleep mode 5 permits the SM parameter to be set to a consistent value.<br />

The following code snippet demonstrates how parameters such as SM, SP, <strong>and</strong><br />

ST can be read <strong>and</strong> set up programmatically. In addition, it shows how the sleep line<br />

can be toggled:<br />

import serial<br />

from xbee import XBee<br />

# read a value from an XBee modem<br />

def readXbeeParameter(xb, param):<br />

xb.send(’at’, frame_id¼’A’, comm<strong>and</strong>¼param)<br />

resp ¼ xb.wait_read_frame()<br />

return resp[’parameter’]<br />

# write a Xbee modem parameter<br />

def setXbeeParameter(xb, param, value):<br />

xb.send(’at’, frame_id¼’A’, comm<strong>and</strong>¼param, parameter¼value)<br />

# cause an Xbee modem configured for pin sleep to sleep\<br />

by asserting pin<br />

def xbeePinSleep():<br />

<strong>with</strong> open(’/sys/class/gpio/gpio69/value’, ’w’) as f:<br />

f.write(’1’)<br />

# wake up a Xbee modem from pin sleep by deasserting sleep pin<br />

def xbeePinAwake():<br />

<strong>with</strong> open(’/sys/class/gpio/gpio69/value’, ’w’) as f:<br />

f.write(’0’)<br />

ADDING SECURITY<br />

It is likely that many potential penetration testing targets are not using XBee networking.<br />

For these organizations, the comm<strong>and</strong> <strong>and</strong> control traffic is out of b<strong>and</strong><br />

<strong>and</strong> likely to go undetected. Even in cases when the client uses XBee, traffic using

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

Saved successfully!

Ooh no, something went wrong!