Giter Site home page Giter Site logo

homewsn / whsniff Goto Github PK

View Code? Open in Web Editor NEW
129.0 16.0 31.0 41 KB

Whsniff is a command line utility that interfaces TI CC2531 USB dongle with Wireshark for capturing and displaying IEEE 802.15.4 traffic at 2.4 GHz.

License: GNU General Public License v2.0

Makefile 7.49% C 92.51%

whsniff's Introduction

Release Status Travis CI Build Status Coverity Scan Build Status

A packet converter for sniffing IEEE 802.15.4 wireless sensor networks

This repository is a part of the HomeWSN project.

Whsniff is a command line utility that interfaces TI CC2531 USB dongle with Wireshark for capturing and displaying IEEE 802.15.4 traffic at 2.4 GHz.

This utility only works on Linux (including OpenWrt). For Windows download and install the SmartRF Packet Sniffer from TI website.

Whsniff reads the packets from TI CC2531 USB dongle with sniffer_fw_cc2531 firmware, converts to the PCAP format and writes to the standard output(stdout).

Building (Linux)
  • Install libusb-1.0-0-dev:
$ sudo apt-get install libusb-1.0-0-dev
  • Download the latest release in tarball from github and untar it. Then build and install whsniff.
$ curl -L https://github.com/homewsn/whsniff/archive/v1.3.tar.gz | tar zx
$ cd whsniff-1.3
$ make
$ sudo make install
Building (macOS)
  • Install libusb via Homebrew (or your preferred package manager):
$ brew install libusb
  • Download the latest release in tarball from github and untar it. Then build and install whsniff.
$ curl -L https://github.com/homewsn/whsniff/archive/v1.3.tar.gz | tar zx
$ cd whsniff-1.3
$ make
$ sudo make install
Building (OpenWrt)
  • Install OpenWrt buildroot.
  • Add the following line to the feeds.conf.default in the OpenWrt buildroot:
src-git homewsn https://github.com/homewsn/homewsn.openwrt.packages.git
  • This feed should be included and enabled by default in the OpenWrt buildroot. To install all its package definitions, run:
$ ./scripts/feeds update homewsn
$ ./scripts/feeds install -a -p homewsn
  • The packages should now appear in menuconfig. You can find whsniff in the Network menu.
How to use (Locally)
  • Connect CC2531 USB dongle to your Linux or macOS computer.
  • Open a terminal session on the desktop where you have Wireshark installed and enter the following commands:
$ wireshark -k -i <( path/to/whsniff -c channel_number )
or
$ path/to/whsniff -c channel_number | wireshark -k -i -
or
$ mkfifo /tmp/pipes/whsniff
$ path/to/whsniff -c channel_number > /tmp/pipes/whsniff
  • You can also save the output to a file to analyze it later using Wireshark:
$ path/to/whsniff -c channel_number > filename.pcap
  • You can also let whsniff save the output to a file, whsniff will generate a file name that indicates sniffing start date/time
$ path/to/whsniff -c channel_number -f
  • You can also let whsniff save the output to a file, and automatically restart sniffing every hour (-h) or day (-d) so that a single file is not too huge
$ path/to/whsniff -c channel_number -f -h
$ path/to/whsniff -c channel_number -f -d
  • You can also keep the original FCS sent by the CC2531 through the -k option. The original FCS contains the RSSI and LQI. It can be interpreted by wireshark as a "TI CC24xx FCS format":
$ path/to/whsniff -k -c channel_number > /tmp/pipes/whsniff
  • If you see something like libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/006: Permission denied you can use udev

    1. Add below contents to /etc/udev/rules.d/54-cc2531.rules
    ATTR{idVendor}=="0451", ATTR{idProduct}=="16ae",MODE="660", GROUP="dialout"
    1. Reload udev rules
    sudo udevadm control --reload
    1. Add yourself to the group dialout, Log out and in again.
    sudo usermod -aG dialout $USER 
How to use (Remotely)
  • Connect CC2531 USB dongle to remote Linux PC or OpenWrt device, then start whsniff remotely with ssh from the desktop where you have Wireshark installed.
  • For Linux open a terminal session on the desktop and enter the following command:
$ ssh [email protected] "whsniff -c 18" | wireshark -k -i -

where 192.168.1.202 is an IP address of the computer where dongle is connected and 18 is a channel number.

  • For Windows install PuTTY with extension plink.exe from PuTTY Download Page, then open a command prompt window and enter the following command:
> "C:\Program Files\PuTTY\plink.exe" -batch -ssh -pw password [email protected] whsniff -c 18 | "C:\Program Files\Wireshark\wireshark.exe" -k -i -

where password is a root password, 192.168.1.202 is an IP address of the computer where dongle is connected and 18 is a channel number.

License

GNU GPL v 2.0

whsniff's People

Contributors

adriangranados avatar ffontaine avatar grafalex82 avatar homewsn avatar maltehillmann avatar philipphutterer avatar zhanglongqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whsniff's Issues

Starting Wireshark - no interface /dev/fd/63

Hello,

I followed the build guide for linux (I am using Ubuntu).

When I try to start the sniff with "sudo wireshark -k -i <( /usr/local/bin/whsniff -c 11 )" an error shows up:
The capture session could not be initiated on interface '/dev/fd/63' (No such device exists). Please check that you have the proper interface or pipe specified.

In the /dev/fd folder isnt a file or folder named 63.
I connected the CC2531 Dongle before I start wireshark with the command above. Also I reinstalled/-builded this while the dongle was connected.

I really hope you can help me.
Thanks in advance.

timestamp seems wrong

Hi,
Great project.
I do capturing for hours to catch an issue with your tool
When I read the pcap in wireshark the timestamp are going back and forth and seems not correct as it shows 4 hours of recording after 24h of actual recordings.
image
image
I can send you a sample privately if it helps
Thx

ERROR: No working device found.

I have followed the instructions to install Whsniff in a raspberry pi, and after connecting the CC2531 with sniffer firmware to one of the usb ports of the raspberry pi I get the error ERROR: No working device found. when I execute the command sudo whsniff -c 11

The firmware I flashed into the CC2531 is zboss_sniffer.hex and I am assuming this firmware is correct as I am able to sniff on a windows machine using the same CC2531.

Segfaults @ line 160

Been struggling with segfaults on line 160: https://github.com/homewsn/whsniff/blob/master/src/whsniff.c#L160

fwrite(&buf[sizeof(usb_data_header_type)], 1, usb_data_header->wpan_len - 2, stdout);

Occasionally a packet will be received where usb_data_header->wpan_len is equal to 1. This results in attempting to write -1 in length to fwrite. Have had this issue on multiple linux distros with multiple dongles. Took awhile to find this because oddly enough when I GDB debug + attach, this never happens so I had to figure it out from a core dump.

Presumably you have the -2 because there are suppose to be 2 bytes appended? Kinda tricky to debug this since TI doesn't provide the sniffer firmware? Also if its just a continuous data stream, how does one recover from this? There aren't really any sync bytes?

Wireshark Error

Hi,
I have the following issue. I installed whsniff tool on linux, but every time i try to execute the command "sudo whsniff -c ZIGBEE_CHANNEL_NUMBER | wireshark -k -i -" i get an error in wireshark.

Issue Zigbee Snifing

OS: ubuntu 19.10
Zigbee Stick/Sniffer --> CC2531

I hope your able to help me :), Thank you

Unable to make on Mac

Houston, we have a problem )

Unable to make make on MacOs 10.14.6 (18G1012)

When I just try to make, I receive error

Book:whsniff-1.1 istitch07$ make
mkdir -p obj
cc  -c src/whsniff.c -o obj/whsniff.o -I.
src/whsniff.c:19:10: fatal error: 'endian.h' file not found
#include <endian.h>                     /* htole16, htole32, le32toh */
         ^~~~~~~~~~
1 error generated.
make: *** [obj/whsniff.o] Error 1

When I change include path to #include <machine/endian.h>, I receive other error

Book:whsniff-1.1 istitch07$ make
cc  -c src/whsniff.c -o obj/whsniff.o -I.
src/whsniff.c:103:12: warning: implicit declaration of function 'le16toh' is invalid in C99 [-Wimplicit-function-declaration]
        usb_len = le16toh(usb_header->le_usb_len);
                  ^
src/whsniff.c:124:36: warning: implicit declaration of function 'le32toh' is invalid in C99 [-Wimplicit-function-declaration]
                timestamp_us = (timestamp_tick + le32toh(usb_data_header->le_timestamp)) / 32;
                                                 ^
src/whsniff.c:149:12: warning: implicit declaration of function 'htole16' is invalid in C99 [-Wimplicit-function-declaration]
                le_fcs = htole16(fcs);
                         ^
src/whsniff.c:235:2: warning: 'libusb_set_debug' is deprecated [-Wdeprecated-declarations]
        libusb_set_debug(NULL, 3);
        ^
/usr/local/include/libusb-1.0/libusb.h:1324:1: note: 'libusb_set_debug' has been explicitly marked deprecated here
LIBUSB_DEPRECATED_FOR(libusb_set_option)
^
/usr/local/include/libusb-1.0/libusb.h:89:49: note: expanded from macro 'LIBUSB_DEPRECATED_FOR'
#define LIBUSB_DEPRECATED_FOR(f) __attribute__((deprecated))
                                                ^
4 warnings generated.
cc  -o whsniff obj/whsniff.o  -lusb-1.0 -lrt
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [whsniff] Error 1

libusb installed:
libusb 1.0.23 is already installed and up-to-date

Can you help?

Issue on kali with CC2531

Attempting to use whsniff, it is stuck in the for loop looking for libusb_control_handle to return data. To preface, the hard-coded idProduct had to be changed to 0x16a8 for the CC2531 device. That enables it to find the hardware in the usb list.
However, I put in some debugging statements and the "get identity check" above returns a "-9" which is an error but the code doesn't error-check that result and continues down. Any way I can fix this?

Is CC2530 supported ?

Hello.
Is CC2530 supported or just CC2531 ?
I have no CC2531 so I tried to flash my CC2530 with sniffer_fw_cc2530.hex firmware extracted from "SmartRF_Packet_Sniffer_2.18.0" using a SmartRF04EB...

$ sudo ./cc-tool -e -w sniffer_fw_cc2530.hex 
  Programmer: SmartRF04EB
  Target: CC2530
  Erasing flash...
  Completed       
  Writing flash (2 KB)...
  Completed (0.16 s.)

But when I start whsniff it says me no device found...

$whsniff -c 25
ERROR: No working device found.

Add epoch offset

Feature Request: Save host machine's epoch time upon first packet capture and use this as an offset for future timestamps.


I noticed in wireshark my packets were dated in the 1970s. After looking through the code it looks like the packet timestamps are a pure counter upon start of capture. This makes merging data from multiple sources tricky if you don't have absolute timestamps. Granted, I know the timestamp's accuracy would be limited to the host machine but i'd certainly be a nice starting point. Perhaps an optional command line argument?

Unable to make on arm64 macOS

I'm still figuring out the switch from Intel macOS to arm64, but I can't figure out how to install this package. Homebrew installs now in /opt/homebrew and I've verified that libusb is installed. Whenever I run make it says ld: library not found for -lusb-1.0. I've tried changing the LIBPATH and INCLPATH but neither seem to work. Does anyone else know what I need to get this to work? Thanks for your time and help.

CC2531 0x16a8

Hello,

Thank you for this tool!

I purchased a SonOff CC2531, lsusb lists it as 0x16a8, but your code is apparently expecting 0x16ae. At line 257, there is:

if(t_desc.idVendor == 0x0451 && t_desc.idProduct == 0x16ae)

I tried my luck by changing it to:

if(t_desc.idVendor == 0x0451 && (t_desc.idProduct == 0x16ae || t_desc.idProduct == 0x16a8))

This compiles and runs, but I am not catching any packets.

I guess I will have to find a 0x16ae adapter tu use whsniff. The problem is you only know what you get after the purchase.

Is there anything that could be done to let whsniff support the 0x16a8 adapter?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.