Package killerbee :: Module kbutils
[hide private]
[frames] | no frames]

Module kbutils

source code

Classes [hide private]
  KBCapabilities
Class to store and report on the capabilities of a specific KillerBee device.
  findFromList
Custom matching function for pyUSB 1.x.
  findFromListAndBusDevId
Custom matching function for pyUSB 1.x.
  KBException
Base class for all KillerBee specific exceptions.
  KBInterfaceError
Custom exception for KillerBee having issues communicating with an interface, such as opening a port, syncing with the firmware, etc.
Functions [hide private]
 
devlist_usb_v1x(vendor=None, product=None)
Private function.
source code
 
devlist_usb_v0x(vendor=None, product=None)
Private function.
source code
 
isIpAddr(ip)
Return True if the given string is a valid IPv4 or IPv6 address.
source code
List
devlist(vendor=None, product=None, gps=None, include=None)
Return device information for all present devices, filtering if requested by vendor and/or product IDs on USB devices, and running device fingerprint functions on serial devices.
source code
 
get_serial_devs(seriallist) source code
 
isSerialDeviceString(s) source code
 
get_serial_ports(include=None)
Private function.
source code
Tuple
isgoodfetccspi(serialdev)
Determine if a given serial device is running the GoodFET firmware with the CCSPI application.
source code
Boolean
iszigduino(serialdev)
Determine if a given serial device is running the GoodFET firmware with the atmel_radio application.
source code
Boolean
isfreakduino(serialdev)
Determine if a given serial device is a Freakduino attached with the right sketch loaded.
source code
 
search_usb(device)
Takes either None, specifying that any USB device in the global vendor and product lists are acceptable, or takes a string that identifies a device in the format <BusNumber>:<DeviceNumber>, and returns the pyUSB objects for bus and device that correspond to the identifier string.
source code
 
search_usb_bus_v0x(bus, busNum, devNum)
Helper function for USB enumeration in pyUSB 0.x enviroments.
source code
String
hexdump(src, length=16)
Creates a tcpdump-style hex dump string output.
source code
String
randbytes(size)
Returns a random string of size bytes.
source code
String
randmac(length=8)
Returns a random MAC address using a list valid OUI's from ZigBee device manufacturers.
source code
 
makeFCS(data)
Do a CRC-CCITT Kermit 16bit on the data given Implemented using pseudocode from: June 1986, Kermit Protocol Manual See also: http://regregex.bbcmicro.net/crc-catalogue.htm#crc.cat.kermit
source code
Variables [hide private]
  USBVER = 1
  RZ_USB_VEND_ID = 1003
  RZ_USB_PROD_ID = 8458
  ZN_USB_VEND_ID = 1240
  ZN_USB_PROD_ID = 14
  FTDI_X_USB_VEND_ID = 1027
  FTDI_X_USB_PROD_ID = 24597
  usbVendorList = [1003, 1240]
  usbProductList = [8458, 14]
  gps_devstring = None
  __package__ = 'killerbee'
Function Details [hide private]

devlist_usb_v1x(vendor=None, product=None)

source code 

Private function. Do not call from tools/scripts/etc.

devlist_usb_v0x(vendor=None, product=None)

source code 

Private function. Do not call from tools/scripts/etc.

devlist(vendor=None, product=None, gps=None, include=None)

source code 

Return device information for all present devices, filtering if requested by vendor and/or product IDs on USB devices, and running device fingerprint functions on serial devices.

Parameters:
  • gps (String) - Optional serial device identifier for an attached GPS unit. If provided, or if global variable has previously been set, KillerBee skips that device in device enumeration process.
  • include (List of Strings) - Optional list of device handles to be appended to the normally found devices. This is useful for providing IP addresses for remote scanners.
Returns: List
List of device information present. For USB devices, get [busdir:devfilename, productString, serialNumber] For serial devices, get [serialFileName, deviceDescription, ""]

get_serial_ports(include=None)

source code 

Private function. Do not call from tools/scripts/etc. This should return a list of device paths for serial devices that we are interested in, aka USB serial devices using FTDI chips such as the TelosB, ApiMote, etc. This should handle returning a list of devices regardless of the *nix it is running on. Support for more *nix and winnt needed.

Parameters:
  • include (List of Strings, or None) - A list of device strings, of which any which appear to be serial device handles will be added to the set of serial ports returned by the normal search. This may be useful if we're not including some oddly named serial port which you have a KillerBee device on. Optional.

isgoodfetccspi(serialdev)

source code 

Determine if a given serial device is running the GoodFET firmware with the CCSPI application. This should either be a TelosB/Tmote Sky GOODFET or an Api-Mote design.

Parameters:
  • serialdev (String) - Path to a serial device, ex /dev/ttyUSB0.
Returns: Tuple
Tuple with the fist element==True if it is some goodfetccspi device. The second element is the subtype, and is 0 for telosb devices and 1 for apimote devices.

iszigduino(serialdev)

source code 

Determine if a given serial device is running the GoodFET firmware with the atmel_radio application. This should be a Zigduino (only tested on hardware r1 currently).

Parameters:
  • serialdev (String) - Path to a serial device, ex /dev/ttyUSB0.
Returns: Boolean
Boolean with the fist element==True if it is a goodfet atmel128 device.

isfreakduino(serialdev)

source code 

Determine if a given serial device is a Freakduino attached with the right sketch loaded.

Parameters:
  • serialdev (String) - Path to a serial device, ex /dev/ttyUSB0.
Returns: Boolean

hexdump(src, length=16)

source code 

Creates a tcpdump-style hex dump string output.

Parameters:
  • src (String) - Input string to convert to hexdump output.
  • length (Int) - Optional length of data for a single row of output, def=16
Returns: String

randbytes(size)

source code 

Returns a random string of size bytes. Not cryptographically safe.

Parameters:
  • size (Int) - Length of random data to return.
Returns: String

randmac(length=8)

source code 

Returns a random MAC address using a list valid OUI's from ZigBee device manufacturers. Data is returned in air-format byte order (LSB first).

Parameters:
  • length (String) - Optional length of MAC address, def=8. Minimum address return length is 3 bytes for the valid OUI.
Returns: String
A randomized MAC address in a little-endian byte string.

makeFCS(data)

source code 

Do a CRC-CCITT Kermit 16bit on the data given Implemented using pseudocode from: June 1986, Kermit Protocol Manual See also: http://regregex.bbcmicro.net/crc-catalogue.htm#crc.cat.kermit

Returns:
a CRC that is the FCS for the frame, as two hex bytes in little-endian order.