Projects STRLCPY CatSniffer Commits 610f4755
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    firmware/pycatsniffer/README.md
    skipped 23 lines
    24 24  ==========
    25 25  Run pycatsniffer
    26 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").
     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 +Default mode starts with Bluetooth Low Energy configuration.
     30 +For BLE, the advertising channel (`37`, `38` or `39`) must be selected, the deafult is `37`.
     31 + 
     32 +The capture device can be configured to follow a data connection between a specific Bluetooth Low Energy Master (Initiator) and Slave device. Type `-a` in the options menu and write the address of the Initiator (Master) device next. If this option is not setted, the capture device will start to follow the first data connection that appears on the selected advertising channel.
    28 33   
    29 34  To get this default behaviour, just run the command:
    30 35  `python pycatsniffer.py`
    31 36   
    32  -To see further information, run the help command:
    33  -`python pycatsniffer.py -h`
     37 +The following options will be available
    34 38   
    35  -To run in headless mode and pipe using /tmp/ccsniffpiper
    36  -`sudo python pycatsniffer.py -d -f /tmp/ccsniffpiper`
     39 +Commands:
     40 + * `c: Print current RF Channel`
     41 + * `n: Trigger new pcap header before the next frame`
     42 + * `h,?: Print this message`
     43 + * `[37,39]: Change RF channel`
     44 + * `s: Start/stop the packet capture`
     45 + * `q: Quit`
    37 46   
     47 +In this mode the output of captured packets will only be displayed on the terminal.
     48 + 
     49 +You can start packet capture by pressing the `s` key followed by the `Enter` key.
     50 +To stop, press the `s` key again followed by the `Enter` key again.
     51 + 
     52 +To run in normal mode and pipe using `/tmp/ccsniffpiper` type `sudo python pycatsniffer.py -f /tmp/ccsniffpiper` in the terminal
     53 + 
     54 +Start the packet capture by pressing the `s` key and then the `Enter` key in the terminal where pycatsniffer is running.
     55 +In headless mode use `sudo python pycatsniffer.py -d -f /tmp/ccsniffpiper`
     56 + 
     57 +To see further information, run the help command:
     58 +`python pycatsniffer.py -h`
    38 59   
    39 60  Run Wireshark
    40 61  -------------
    41 62  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`.
    42 63   
    43 64  To setup Wireshark correctly, perform the following steps:
    44  - * Go to Capture -> options -> Manage Interfaces -> New (under Pipes) -> type `/tmp/ccsniffpiper` and save.
    45  - * The pipe will then appear as an interface. Start a capture on it.
    46 65   
     66 +* Start Wireshark using sudo wireshark (linux)
     67 +* Add new pipe interface: Capture -> Options -> Manage Interfaces -> Pipes-> click on + to add new pipe -> type `/tmp/ccsniffpiper` and apply.
     68 +Note - The capture interface will not be saved.
     69 +* Click the start button to start a capture.
     70 +* The pipe will then appear as an interface.
    47 71   
    48 72  General packet format
    49 73  ======================================
    50  -This is just * **[documentation](https://software-dl.ti.com/lprf/packet_sniffer_2/docs/user_guide/html/sniffer_fw/firmware/command_interface.html)** of the packet format from the TI firmware on CatSniffer.
     74 +This is just **[documentation](https://software-dl.ti.com/lprf/packet_sniffer_2/docs/user_guide/html/sniffer_fw/firmware/command_interface.html)** of the packet format from the TI firmware on CatSniffer.
    51 75   
    52 76  The UART packet format is shown in the table below.
    53 77   
    skipped 9 lines
    63 87   
    64 88   * Check that the sniffer is sniffing in the correct channel.
    65 89   * Check that you have opened the named pipe that is being piped to.
    66  - *In particular, I would recommend reading the "Run Wireshark" section carefully.*
     90 + * In particular, I would recommend reading the "Run Wireshark" section carefully.*
    67 91   
    68 92   
  • ■ ■ ■ ■ ■ ■
    firmware/pycatsniffer/pingcatsniffer.py
    1  -import serial
    2  -import time
    3  -import sys
    4  - 
    5  -ser = serial.Serial()
    6  -ser.port = '/dev/ttyACM0'
    7  -ser.baudrate = 921600
    8  -ser.bytesize = serial.EIGHTBITS
    9  -ser.parity = serial.PARITY_NONE
    10  -ser.stopbits = serial.STOPBITS_ONE
    11  -ser.timeout = 1
    12  - 
    13  -ping = bytearray([0x40, 0x53, 0x40, 0x00, 0x00, 0x40, 0x40, 0x45])
    14  - 
    15  -time.sleep(1)
    16  -ser.open()
    17  - 
    18  -ser.write(cmd)
    19  - 
    20  -while(ser.in_waiting == 0):
    21  - pass
    22  -
    23  -time.sleep(0.01)
    24  -
    25  -if ser.in_waiting > 0:
    26  - msg = ser.read(ser.in_waiting)
    27  - print (msg.hex())
    28  -
    29  -ser.flush()
    30  -time.sleep(2)
    31  - 
    32  -ser.close()
    33  - 
    34  - 
  • ■ ■ ■ ■ ■
    firmware/pycatsniffer/pycatsniffer.py
    skipped 37 lines
    38 38   In interactive mode, the user can also input commands from stdin.
    39 39  """
    40 40   
     41 +# CC1352P1
     42 + 
    41 43  import serial
    42 44  import argparse
    43 45  import binascii
    skipped 18 lines
    62 64   'log_level': 'INFO',
    63 65   'log_file': 'ccsniffpiper.log',
    64 66   'channel': 37,
    65  - 'initiator_address':0x000000000000,
     67 + 'initiator_address':'000000000000',
    66 68   'port':'/dev/ttyACM0'
    67 69  }
    68 70   
    skipped 409 lines
    478 480   in_group.add_argument(
    479 481   '-a',
    480 482   '--address',
    481  - type=int,
     483 + type=str,
    482 484   action='store',
    483  - #choices=list(range(37, 40)),
    484 485   default=defaults['initiator_address'],
    485 486   help='Connect to Initiator Address. \
    486 487   (Default: %s)' % (defaults['initiator_address'], ))
    skipped 138 lines
    625 626   handlers.append(HexdumpHandler(args.hex_file))
    626 627   if args.pcap_file is not False:
    627 628   handlers.append(PcapDumpHandler(args.pcap_file))
     629 + if args.address != '000000000000':
     630 + print('Initiator: %s\n' % args.address)
     631 + address_bytes = bytearray.fromhex(args.address)
     632 + address_bytes.reverse()
     633 + initiator[5:11] = address_bytes
     634 + #adjust FCS
     635 + total = 0
     636 + for i in range(len(address_bytes)):
     637 + total += address_bytes[i]
     638 + initiator[11] = (total + 0x76) & 0xff
     639 +
    628 640   
    629 641   if args.headless is False:
    630 642   h = io.StringIO()
    631  - h.write('Commands:\n')
     643 + h.write('HELL Commands:\n')
     644 + #h.write('Initiator: %s\n' % defaults['initiator_address'])
    632 645   h.write('c: Print current RF Channel\n')
    633 646   h.write('n: Trigger new pcap header before the next frame\n')
    634 647   h.write('h,?: Print this message\n')
    skipped 78 lines
    713 726   snifferDev.stop()
    714 727   dump_stats()
    715 728   sys.exit(0)
     729 + 
Please wait...
Page is in error, reload to recover