module PacketGen

PacketGen is a network packet generator and analyzor. @author Sylvain Daubert

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

rubocop:disable Metrics/ClassLength

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

rubocop:disable Metrics/ClassLength

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

This file is part of PacketGen See github.com/sdaubert/packetgen for more informations Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> This program is published under MIT license.

PacketGen is a network packet generator and analyzor.

@author Sylvain Daubert

Constants

VERSION

PacketGen version

Public Class Methods

capture(**kwargs) { |packet| ... } click to toggle source

Shortcut for {Packet.capture} Same arguments as {Capture#initialize} @see Capture#initialize @yieldparam [Packet] packet @return [Array<Packet>]

# File lib/packetgen.rb, line 69
def self.capture(**kwargs)
  Packet.capture(**kwargs) { |packet| yield packet if block_given? }
end
default_iface() click to toggle source

Get default network interface (ie. first non-loopback declared interface) @return [String]

# File lib/packetgen.rb, line 97
def self.default_iface
  return @default_iface if defined? @default_iface

  @default_iface = Interfacez.raw_interface_addresses.each do |iface|
    next unless iface.broadaddr
    next unless Interfacez.ipv4_address_of(iface.name)
    next unless Interfacez.ipv6_address_of(iface.name)

    break iface.name
  end
end
force_binary(str) click to toggle source

Force binary encoding for str @param [String] str @return [String] binary encoded string

# File lib/packetgen.rb, line 91
def self.force_binary(str)
  str.dup.force_encoding(Encoding::BINARY)
end
gen(protocol, options={}) click to toggle source

Shortcut for {Packet.gen} @param [String] protocol base protocol for packet @param [Hash] options specific options for protocol @return [Packet]

# File lib/packetgen.rb, line 52
def self.gen(protocol, options={})
  Packet.gen protocol, options
end
header(protocol, options={}) click to toggle source

Shortcut to get a header class @example builtin class

# same as PacketGen::Header::Dot11:Data.new(id: 0xfedc)
dot11 = PacketGen.header('Dot11::Data', id: 0xfedc)  #=> PacketGen::Header::Dot11:Data

@example plugin class

require 'packet-plugin-smb'
# same as PacketGen::Plugin::SMB::CloseRequest.new(fid: 0x1234)
smbclose = PacketGen.header('SMB::CloseRequest', fid: 0x1234)

@param [String] protocol protocol from which generate a header @param [Hash] options specific options for protocol @return [Header::Base]

# File lib/packetgen.rb, line 126
def self.header(protocol, options={})
  Header.get_header_class_by_name(protocol).new(options)
end
loopback_iface() click to toggle source

Get loopback network interface @return [String]

# File lib/packetgen.rb, line 111
def self.loopback_iface
  Interfacez.loopback
end
parse(binary_str, first_header: nil) click to toggle source

Shortcut for {Packet.parse} @param [String] binary_str @param [String] first_header First protocol header @return [Packet]

# File lib/packetgen.rb, line 60
def self.parse(binary_str, first_header: nil)
  Packet.parse binary_str, first_header: first_header
end
read(filename) click to toggle source

Shortcut for {Packet.read} @param [String] filename PcapNG file @return [Array<Packet>]

# File lib/packetgen.rb, line 76
def self.read(filename)
  Packet.read filename
end
write(filename, packets) click to toggle source

Shortcut for {Packet.write} @param [String] filename @param [Array<Packet>] packets packets to write @return [void]

# File lib/packetgen.rb, line 84
def self.write(filename, packets)
  Packet.write filename, packets
end