Projects STRLCPY CatSniffer Commits 917433b8
🤬
  • ■ ■ ■ ■ ■ ■
    firmware/pycatsniffer/README.md
     1 +pycatsniffer
     2 +============
     3 + 
     4 +*Live Packet Sniffer to Wireshark bridge for IEEE 802.15.4 networks.*
     5 + 
     6 +NOTE WELL: at the moment **pycatsniffer** only supports packet capture of the following protocols:
     7 +Bluetooth Low Energy Adversiting Channels (does not support decryption of encrypted packets)
     8 + 
     9 +A Python module that uses a **CatSniffer** (TI CC1352 chip) to sniff packets and pipe them to (primarily) wireshark.
     10 + 
     11 +This tool is a mashup of three existing GitHub projects:
     12 + 
     13 + * **[ccsniffpiper](https://github.com/andrewdodd/ccsniffpiper)**: A python tool by Andrew Dodd, based on the two below, that pipes the captured frames to wireshark.
     14 + * **[sensniff](https://github.com/g-oikonomou/sensniff)**: A python tool by George Oikonomou to capture packets with the "sensniff" firmware for the TI CC2531 sniffer.
     15 + * **[ccsniffer](https://github.com/christianpanton/ccsniffer)**: A python module by Christian Panton to capture packets with the original TI firmware and print them to stdout.
     16 + 
     17 +This tool is intended to be an alternative to the Windows-based SmartRF Packet Sniffer 2 program using TI's default firmware on CC13XX chips (and combine it with Wireshark's live capture utility). **pycatsniffer** has been developed on Linux.
     18 + 
     19 +Requires: pyserial
     20 + 
     21 +**pycatsniffer** can run in interactive or headless mode. In interactive mode, the user can change the radio channel while running.
     22 + 
     23 +How to Use
     24 +==========
     25 +Run pycatsniffer
     26 +----------------
     27 +**pycatsniffer**'s main role it to read packets captured from the CatSniffer board and pipe the packets in PCAP format to a named pipe (by default "/tmp/ccsniffpiper").
     28 + 
     29 +To get this default behaviour, just run the command:
     30 +`python pycatsniffer.py`
     31 + 
     32 +To see further information, run the help command:
     33 +`python pycatsniffer.py -h`
     34 + 
     35 +To run in headless mode and pipe using /tmp/ccsniffpiper
     36 +`sudo python pycatsniffer.py -d -f /tmp/ccsniffpiper`
     37 + 
     38 + 
     39 + 
     40 +Run Wireshark
     41 +-------------
     42 +To receive the packets from **pycatsniffer** you need to use Wireshark to start a capture using a FIFO file as the 'interface'. By default, **pycatsniffer** will use `/tmp/ccsniffpiper`.
     43 + 
     44 +To setup Wireshark correctly, perform the following steps:
     45 + * Go to Capture -> options -> Manage Interfaces -> New (under Pipes) -> type `/tmp/ccsniffpiper` and save.
     46 + * The pipe will then appear as an interface. Start a capture on it.
     47 + 
     48 +Additional settings that might be important include:
     49 + * Open Wireshark's preferences and select 'TI CC24xx FCS format' under Protocols -> IEEE 802.15.4.
     50 + * Enable/disable the protocols you need.
     51 + 
     52 + 
     53 +TI's Packet Sniffer Payload Definition
     54 +======================================
     55 +This is just documentation of the packet format from the TI firmware on CatSniffer.
     56 + 
     57 +General packet format
     58 +The UART packet format is shown in the table below.
     59 + 
     60 + 0 1 2 3 4 5 6 7 -2 -1 EOF
     61 + |_______|_______|_______|_______|_______|_______|_______|>> ... |_______|_______|_______|
     62 + |Start of Frame |Packet Packet Length |Payload >> | FCS | End of Frame|
     63 + | |Info | | | | |
     64 + 2B 1B 2B 0-2049B 1B 2B
     65 +
     66 +FAQs
     67 +====
     68 +### I don't see anything appearing in Wireshark!
     69 + 
     70 + * Check that the sniffer is sniffing in the correct channel.
     71 + * Check that you have opened the named pipe that is being piped to.
     72 + *In particular, I would recommend reading the "Run Wireshark" section carefully.*
     73 + 
     74 + 
  • ■ ■ ■ ■ ■
    firmware/pycatsniffer/devpycatsniffer.py firmware/pycatsniffer/pycatsniffer.py
     1 +#!/usr/bin/env python
     2 +"""
     3 + pycatsniffer - a python module to connect to the CatSniffer
     4 + and pipe the sniffed packets to wireshark!
     5 + 
     6 + Copyright (c) 2023, Raul Vargas ([email protected])
     7 + 2013, Andrew Dodd ([email protected])
     8 +
     9 + 
     10 + This is essentially a mashup and extension of three existing sniffers:
     11 + 1. ccsniffpiper.py
     12 + ------------
     13 + Copyright (c) 2013, Andrew Dodd ([email protected])
     14 + 2. ccsniffer
     15 + ------------
     16 + Copyright (c) 2012, George Oikonomou ([email protected])
     17 + 3. sensniffer
     18 + -------------
     19 + Copyright (C) 2012 Christian Panton <[email protected]>
     20 + This program is free software; you can redistribute it and/or modify
     21 + it under the terms of the GNU General Public License as published by
     22 + the Free Software Foundation; either version 3 of the License, or
     23 + (at your option) any later version.
     24 + This program is distributed in the hope that it will be useful,
     25 + but WITHOUT ANY WARRANTY; without even the implied warranty of
     26 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     27 + GNU General Public License for more details.
     28 + You should have received a copy of the GNU General Public License
     29 + along with this program; if not, write to the Free Software Foundation,
     30 + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     31 +"""
     32 +"""
     33 + Functionality
     34 + -------------
     35 + Read IEEE802.15.4 frames from the default CC1352 sniffer firmware
     36 + and pipe them to wireshark via a FIFO/named pipe. At the same time, the
     37 + frames can be logged to a file for subsequent offline processing.
     38 + In interactive mode, the user can also input commands from stdin.
     39 +"""
     40 + 
    1 41  import serial
    2 42  import argparse
    3 43  import binascii
    skipped 18 lines
    22 62   'log_level': 'INFO',
    23 63   'log_file': 'ccsniffpiper.log',
    24 64   'channel': 37,
     65 + 'initiator_address':0x000000000000,
     66 + 'port':'/dev/ttyACM0'
    25 67  }
    26 68   
    27 69  logger = logging.getLogger(__name__)
    skipped 281 lines
    309 351   def startc(self):
    310 352   # start sniffing
    311 353   self.running = True
    312  - #self.dev.ctrl_transfer(CC2531.DIR_OUT, CC2531.SET_START)
    313 354  
    314 355   self.serial_port.write(letsgo)
    315 356  
    skipped 6 lines
    322 363   self.serial_port.write(stop)
    323 364   self.running = False
    324 365   self.thread.join()
    325  - #self.dev.ctrl_transfer(CC2531.DIR_OUT, CC2531.SET_STOP)
    326 366   
    327 367   def isRunning(self):
    328 368   return self.running
    skipped 27 lines
    356 396   # Do something with the substream
    357 397   #print(substream)
    358 398   
    359  - print ("SUBSRECV>> %s" % binascii.hexlify(substream))
     399 + print ("RECV>> %s" % binascii.hexlify(substream))
    360 400   
    361 401   if len(substream) >= 3:
    362 402   (sFrame, pInfo, pLength) = struct.unpack_from("<HBH", substream)
    skipped 68 lines
    431 471   '--channel',
    432 472   type=int,
    433 473   action='store',
    434  - choices=list(range(11, 27)),
     474 + choices=list(range(37, 40)),
    435 475   default=defaults['channel'],
    436  - help='Set the sniffer\'s CHANNEL. Valid range: 11-26. \
     476 + help='Set the sniffer\'s CHANNEL. Valid range: 37-39. \
    437 477   (Default: %s)' % (defaults['channel'], ))
     478 + in_group.add_argument(
     479 + '-a',
     480 + '--address',
     481 + type=int,
     482 + action='store',
     483 + #choices=list(range(37, 40)),
     484 + default=defaults['initiator_address'],
     485 + help='Connect to Initiator Address. \
     486 + (Default: %s)' % (defaults['initiator_address'], ))
    438 487   out_group = parser.add_argument_group('Output Options')
    439 488   out_group.add_argument(
    440 489   '-f',
    skipped 151 lines
    592 641   
    593 642   print(h)
    594 643   
    595  - snifferDev = CC1352('/dev/ttyACM0', handlerDispatcher, args.channel)
     644 + snifferDev = CC1352(defaults['port'], handlerDispatcher, args.channel)
    596 645   try:
    597 646   
    598 647   while 1:
    skipped 34 lines
    633 682   elif cmd == 's':
    634 683   if snifferDev.isRunning():
    635 684   snifferDev.stop()
     685 + print("stop")
    636 686   else:
    637 687   snifferDev.pingc()
    638 688   snifferDev.stopc()
    skipped 27 lines
Please wait...
Page is in error, reload to recover