packetz

Version, currently master branch1 version
  • master branchlatestDec 22, 2017

github.com/picatz/packetz

🦈 Packet capturing library built with LibPcap

25 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  packetz:
    github: picatz/packetz
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.23.1
License
MIT
Author
Kent Gruber <kgruber1@emich.edu>

Dependencies

This version declares no dependencies.

README

# 🦈  Packetz

Packet capturing library built with [LibPcap](https://github.com/the-tcpdump-group/libpcap).

## Installation

Add this to your application's `shard.yml`:

```yaml
dependencies:
  packetz:
    github: picatz/packetz
```

## Basic Usage

```crystal
require "packetz"

# start packet capture on default interface
Packetz.capture do |packet|
  puts packet.hexdump
end
```

#### Craft your Capture

```crystal
# create capture handler
cap = Packetz.capture

# stop the capture with ctl+C
Signal::INT.trap do
  puts "Stopping!"
  cap.stop!
  exit
end

# setup the handler
cap.snapshot_length  = 33333
cap.promiscuous_mode = true
cap.monitor_mode     = true

# start capturing
cap.start!

# do something with each packet and its pcap header
cap.each do |packet, pcap_header|
  # something
end
```

#### Network Interfaces

```crystal
# get default interface to capture on
Packetz.interfaces.default
```

```crystal
# get all possible interfaces
Packetz.interfaces.all do |interface|
  puts interface
end
```

## Contributors

- [picat](https://github.com/picatz) Kent 'picat' Gruber - creator, maintainer
- [maiha](https://github.com/maiha) maiha - `pcap.cr`
- [puppetpies](https://github.com/puppetpies) Brian Hood - `libpcap.cr`