Sha256: 0b8017868c68553a03179a42e4460e5e1c7e06c2fd035a8d400a42f63dd01e45

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'command_lion'
require 'packetgen'
require 'pry'

CommandLion::App.run do

  name "Pcapr"
  version "1.0.0"
  description "Pcaprub command-line application to capture network traffic."

  command :capture do
    description "Capture from a given network interface ( default: #{Pcap.lookupdev} )."
    type :string
    default Pcap.lookupdev

    action do
      capture = Pcap.open_live(argument, options[:snaplen].argument, options[:promisc].argument, options[:buffer].argument)
      loop do
        if packet = capture.next
          puts packet
        end
      end
    end
    
    option :snaplen do
      default 65535
      type :integer
      description "Amount of data for each frame that is actually captured."
    end

    option :promisc do
      type :bool
      default true
      description "Capture all traffic received rather than only the frames the controller is meant to receive."
    end

    option :buffer do
      type :integer
      default 1
      description "Read time out in milliseconds when capturing packets, and a value of 0 means no time out."
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
command_lion-1.0.4 examples/pcapr.rb
command_lion-1.0.3geff examples/pcapr.rb
command_lion-1.0.3 examples/pcapr.rb
command_lion-1.0.2 examples/pcapr.rb
command_lion-1.0.1 examples/pcapr.rb