Class: PacketGen::Plugin::NetBIOS::Session

Inherits:
Header::Base
  • Object
show all
Defined in:
lib/packetgen/plugin/netbios/session.rb

Overview

NetBIOS Session Service messages.

Author:

  • Sylvain Daubert

Constant Summary collapse

TCP_PORT =

Port number for NetBIOS Session Service over TCP

139
TCP_PORT2 =

Port number for NetBIOS Session Service over TCP (mainly used yb SMB2)

445
TYPES =

Session packet types

{
  'message' => 0,
  'request' => 0x81,
  'positive_response' => 0x82,
  'negative_response' => 0x83,
  'retarget_response' => 0x84,
  'keep_alive' => 0x85,
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyString

Returns:

  • (String)


46
# File 'lib/packetgen/plugin/netbios/session.rb', line 46

define_field :body, PacketGen::Types::String

#lengthInteger

17-bit session packet length

Returns:

  • (Integer)


43
# File 'lib/packetgen/plugin/netbios/session.rb', line 43

define_field :length, PacketGen::Types::Int24

#typeInteger

8-bit session packet type

Returns:

  • (Integer)


39
# File 'lib/packetgen/plugin/netbios/session.rb', line 39

define_field :type, PacketGen::Types::Int8Enum, enum: TYPES

Class Method Details

.protocol_nameString

Give protocol name

Returns:

  • (String)


17
18
19
# File 'lib/packetgen/plugin/netbios/session.rb', line 17

def self.protocol_name
  'NetBIOS::Session'
end

Instance Method Details

#added_to_packet(packet) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

This method is used internally by PacketGen and should not be directly called

Since:

  • 2.7.0 Set TCP sport according to bindings, only if sport is 0. Needed by new bind API.



59
60
61
62
63
64
# File 'lib/packetgen/plugin/netbios/session.rb', line 59

def added_to_packet(packet)
  return unless packet.is? 'TCP'
  return unless packet.tcp.sport.zero?

  packet.tcp.sport = TCP_PORT
end

#calc_lengthInteger

Compute and set #length field

Returns:

  • (Integer)

    calculated length



50
51
52
# File 'lib/packetgen/plugin/netbios/session.rb', line 50

def calc_length
  PacketGen::Header::Base.calculate_and_set_length(self, header_in_size: false)
end