packetgen-plugin-smb 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/lib/packetgen/plugin/gssapi.rb +3 -1
- data/lib/packetgen/plugin/llmnr.rb +58 -0
- data/lib/packetgen/plugin/netbios/session.rb +2 -1
- data/lib/packetgen/plugin/smb/blocks.rb +0 -2
- data/lib/packetgen/plugin/smb/negotiate/dialect.rb +32 -0
- data/lib/packetgen/plugin/smb/negotiate/request.rb +28 -0
- data/lib/packetgen/plugin/smb/negotiate/response.rb +23 -0
- data/lib/packetgen/plugin/smb/negotiate.rb +20 -0
- data/lib/packetgen/plugin/smb.rb +13 -1
- data/lib/packetgen/plugin/smb2/base.rb +2 -4
- data/lib/packetgen/plugin/smb2/guid.rb +2 -1
- data/lib/packetgen/plugin/smb2/negotiate/context.rb +16 -3
- data/lib/packetgen/plugin/smb2/negotiate/request.rb +11 -5
- data/lib/packetgen/plugin/smb2/negotiate/response.rb +14 -6
- data/lib/packetgen/plugin/smb2/session_setup/request.rb +4 -3
- data/lib/packetgen/plugin/smb2/session_setup/response.rb +4 -3
- data/lib/packetgen/plugin/smb2.rb +10 -1
- data/lib/packetgen/plugin/smb_version.rb +1 -1
- data/lib/packetgen-plugin-smb.rb +1 -0
- data/packetgen-plugin-smb.gemspec +4 -7
- metadata +15 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aaeb4b048754ed60fdb9f88a6d82dec247a993056617765e48e047d312d0962
|
4
|
+
data.tar.gz: 9c5da64aa7a58e9e7971554cdf435c08b085e2b63f81bacd9d36a19e9b610ac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e261d4a050ed4a8ed34a51d106bacc519279256bc95bb75e0998947c6365bf008f4f7e43103b9f86b9526efafd0ee18e5cdb1f9f260fe94e052b309555552b50
|
7
|
+
data.tar.gz: 1c1e0fa328e1272a45ab699168b8cc246df7bf4520f4e2a82d2378ff89706e308dfbd57f50ecd1567800e905959a2672bce3756d1e1d6a59c8838198ae4dde92
|
data/.rubocop.yml
CHANGED
@@ -75,7 +75,7 @@ module PacketGen::Plugin
|
|
75
75
|
content: [sequence_of(:mech_types, RASN1::Types::ObjectId, explicit: 0, class: :context),
|
76
76
|
bit_string(:req_flags, explicit: 1, class: :context, constructed: true, optional: true),
|
77
77
|
octet_string(:mech_token, explicit: 2, class: :context, constructed: true, optional: true),
|
78
|
-
|
78
|
+
any(:mech_list_mic, explicit: 3, class: :context, constructed: true, optional: true)]
|
79
79
|
end
|
80
80
|
|
81
81
|
# GSS API Negotiation Token Response
|
@@ -122,5 +122,7 @@ module PacketGen::Plugin
|
|
122
122
|
def sz
|
123
123
|
to_der.size
|
124
124
|
end
|
125
|
+
|
126
|
+
alias to_s to_der
|
125
127
|
end
|
126
128
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# This file is part of packetgen-plugin-smb.
|
2
|
+
# See https://github.com/sdaubert/packetgen-plugin-smb for more informations
|
3
|
+
# Copyright (C) 2018 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
|
+
# This program is published under MIT license.
|
5
|
+
|
6
|
+
# frozen_string_literal: true
|
7
|
+
|
8
|
+
module PacketGen::Plugin
|
9
|
+
# Link-Local Multicast Name Resolution (LLMNR) header ({https://tools.ietf.org/html/rfc4795 RFC 4795}).
|
10
|
+
# @author Sylvain Daubert
|
11
|
+
class LLMNR < PacketGen::Header::DNS
|
12
|
+
# UDP port number
|
13
|
+
UDP_PORT = 5355
|
14
|
+
# MAC address used with IPv4 multicast addresses
|
15
|
+
MAC_IPV4_MCAST = '01:00:5e:00:00:fc'
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
# @note This method is used internally by PacketGen and should not be
|
19
|
+
# directly called
|
20
|
+
def added_to_packet(packet)
|
21
|
+
packet.instance_eval <<-END_OF_DEFINITION
|
22
|
+
def llmnrize(**kwargs)
|
23
|
+
llmnr = headers.find { |hdr| hdr.is_a? PacketGen::Plugin::LLMNR }
|
24
|
+
llmnr.llmnrize(**kwargs)
|
25
|
+
end
|
26
|
+
END_OF_DEFINITION
|
27
|
+
end
|
28
|
+
|
29
|
+
# Fixup IP header according to RFC 4795:
|
30
|
+
# * optionally set destination address,
|
31
|
+
# * set TTL to 1 if destination is a mcast address,
|
32
|
+
# * set MAC destination address to {MAC_IPV4_MCAST} if destination address is a mcast one.
|
33
|
+
# This method may be called as:
|
34
|
+
# # first way
|
35
|
+
# pkt.llmnr.llmnrize
|
36
|
+
# # second way
|
37
|
+
# pkt.llmnrize
|
38
|
+
# @param [String,nil] dst destination address. May be a dotted IP
|
39
|
+
# address (by example '224.0.0.252').
|
40
|
+
# @return [void]
|
41
|
+
def llmnrize(dst: nil)
|
42
|
+
ip = ip_header(self)
|
43
|
+
ip.dst = dst unless dst.nil?
|
44
|
+
ip.ttl = 1 if ip[:dst].mcast?
|
45
|
+
|
46
|
+
# rubocop:disable Lint/HandleExceptions
|
47
|
+
begin
|
48
|
+
llh = ll_header(self)
|
49
|
+
llh.dst = MAC_IPV4_MCAST if ip[:dst].mcast?
|
50
|
+
rescue PacketGen::FormatError
|
51
|
+
end
|
52
|
+
# rubocop:enable Lint/HandleExceptions
|
53
|
+
end
|
54
|
+
end
|
55
|
+
PacketGen::Header.add_class LLMNR
|
56
|
+
PacketGen::Header::UDP.bind LLMNR, sport: LLMNR::UDP_PORT
|
57
|
+
PacketGen::Header::UDP.bind LLMNR, dport: LLMNR::UDP_PORT
|
58
|
+
end
|
@@ -59,6 +59,7 @@ module PacketGen::Plugin
|
|
59
59
|
def added_to_packet(packet)
|
60
60
|
return unless packet.is? 'TCP'
|
61
61
|
return unless packet.tcp.sport.zero?
|
62
|
+
|
62
63
|
packet.tcp.sport = TCP_PORT
|
63
64
|
end
|
64
65
|
end
|
@@ -67,5 +68,5 @@ module PacketGen::Plugin
|
|
67
68
|
PacketGen::Header::TCP.bind Session, sport: Session::TCP_PORT
|
68
69
|
PacketGen::Header::TCP.bind Session, dport: Session::TCP_PORT2
|
69
70
|
PacketGen::Header::TCP.bind Session, sport: Session::TCP_PORT2
|
70
|
-
|
71
|
+
end
|
71
72
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module PacketGen::Plugin
|
2
|
+
class SMB
|
3
|
+
module Negotiate
|
4
|
+
# A SMB_Dialect struct containing:
|
5
|
+
# * a 8-bit {#format} field, which should be set to 0x02,
|
6
|
+
# * a null-terminated string identifying a SMB dialect.
|
7
|
+
# @author Sylvain Daubert
|
8
|
+
class Dialect < PacketGen::Types::Fields
|
9
|
+
# @!attribute format
|
10
|
+
# 8-bit format. Should be +2+ to indicate a null-terminated string for
|
11
|
+
# {#dialect} field.
|
12
|
+
# @return [Integer]
|
13
|
+
define_field :format, PacketGen::Types::Int8, default: 2
|
14
|
+
# @!attribute dialect
|
15
|
+
# Null-terminated string identifying a SMB dialect.
|
16
|
+
# @return [String]
|
17
|
+
define_field :dialect,PacketGen::Types::CString
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
def to_human
|
21
|
+
self[:dialect].to_human
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Specialized {PacketGen::Types::Array} to embed {Dialect Dialects}.
|
26
|
+
# @author Sylvain Daubert
|
27
|
+
class ArrayOfDialect < PacketGen::Types::Array
|
28
|
+
set_of Dialect
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module PacketGen::Plugin
|
2
|
+
class SMB
|
3
|
+
module Negotiate
|
4
|
+
# SMB Negotiation Request header.
|
5
|
+
#
|
6
|
+
# See also {Blocks}, as {Negotiate::Request} is a specialization of {Blocks#words}
|
7
|
+
# and {Blocks#bytes}.
|
8
|
+
# @author Sylvain Daubert
|
9
|
+
class Request < PacketGen::Header::Base
|
10
|
+
# @!attribute word_count
|
11
|
+
# The size, in 2-byte words, of the SMB command parameters. It should
|
12
|
+
# be +0+ setup_count+.
|
13
|
+
# @return [Integer]
|
14
|
+
define_field :word_count, PacketGen::Types::Int8, default: 0
|
15
|
+
# @!attribute byte_count
|
16
|
+
# @return [Integer]
|
17
|
+
define_field :byte_count, PacketGen::Types::Int16le
|
18
|
+
# @!attribute dialects
|
19
|
+
# @return [ArrayOfDialect]
|
20
|
+
define_field :dialects, ArrayOfDialect
|
21
|
+
|
22
|
+
def self.protocol_name
|
23
|
+
'SMB::Negotiate::Request'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PacketGen::Plugin
|
2
|
+
class SMB
|
3
|
+
module Negotiate
|
4
|
+
# SMB Negotiation Response header.
|
5
|
+
#
|
6
|
+
# See also {Blocks}, as {Negotiate::Rersponse} is a specialization of {Blocks#words}
|
7
|
+
# and {Blocks#bytes}.
|
8
|
+
# @author Sylvain Daubert
|
9
|
+
class Response < Blocks
|
10
|
+
|
11
|
+
# Get index of the dialect selected by the server from the list presented in the request.
|
12
|
+
# @return [Integer]
|
13
|
+
def dialect_index
|
14
|
+
words.first.to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.protocol_name
|
18
|
+
'SMB::Negotiate::Response'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file is part of packetgen-plugin-smb.
|
2
|
+
# See https://github.com/sdaubert/packetgen-plugin-smb for more informations
|
3
|
+
# Copyright (C) 2018 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
|
+
# This program is published under MIT license.
|
5
|
+
|
6
|
+
# frozen_string_literal: true
|
7
|
+
|
8
|
+
module PacketGen::Plugin
|
9
|
+
class SMB
|
10
|
+
# Namespace for NEGOTIATE related classes
|
11
|
+
# @author Sylvain Daubert
|
12
|
+
module Negotiate; end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require_relative 'negotiate/dialect'
|
17
|
+
require_relative 'negotiate/request'
|
18
|
+
require_relative 'negotiate/response'
|
19
|
+
|
20
|
+
PacketGen::Plugin::SMB.bind_command 'negotiate'
|
data/lib/packetgen/plugin/smb.rb
CHANGED
@@ -171,6 +171,13 @@ module PacketGen::Plugin
|
|
171
171
|
self.bind kresponse, command: SMB::COMMANDS[command], flags: ->(v) { v.nil? ? 0 : (v & 0x80 == 0x80) }
|
172
172
|
end
|
173
173
|
|
174
|
+
# Check if this is really a SMB2 header. Check {#protocol} has value {MARKER}.
|
175
|
+
# @return [Boolean]
|
176
|
+
def parse?
|
177
|
+
protocol == MARKER
|
178
|
+
end
|
179
|
+
|
180
|
+
# @return [String]
|
174
181
|
def inspect
|
175
182
|
super do |attr|
|
176
183
|
case attr
|
@@ -196,8 +203,13 @@ end
|
|
196
203
|
|
197
204
|
require_relative 'smb/string'
|
198
205
|
require_relative 'smb/filetime'
|
206
|
+
require_relative 'smb/blocks'
|
199
207
|
require_relative 'smb/close'
|
200
208
|
require_relative 'smb/trans'
|
201
209
|
require_relative 'smb/nt_create_and_x'
|
210
|
+
require_relative 'smb/negotiate'
|
202
211
|
require_relative 'smb/browser'
|
203
|
-
|
212
|
+
|
213
|
+
# If unknown command, bind SMB blocks
|
214
|
+
PacketGen::Header.add_class PacketGen::Plugin::SMB::Blocks
|
215
|
+
PacketGen::Plugin::SMB.bind PacketGen::Plugin::SMB::Blocks
|
@@ -19,11 +19,9 @@ module PacketGen::Plugin
|
|
19
19
|
def self.define_smb2_pad_field(name)
|
20
20
|
prev_field = self.fields.last
|
21
21
|
lf = lambda do |hdr|
|
22
|
-
|
23
|
-
len = 0 if len == 8
|
24
|
-
len
|
22
|
+
(8 - (hdr.offset_of(prev_field) + hdr[prev_field].sz) % 8) % 8
|
25
23
|
end
|
26
|
-
define_field name, PacketGen::Types::String, default:
|
24
|
+
define_field name, PacketGen::Types::String, default: SMB2::MAX_PADDING,
|
27
25
|
builder: ->(h, t) { t.new(length_from: -> { lf[h] }) }
|
28
26
|
end
|
29
27
|
end
|
@@ -63,8 +63,16 @@ module PacketGen::Plugin
|
|
63
63
|
def to_human
|
64
64
|
human_type
|
65
65
|
end
|
66
|
+
|
67
|
+
# Set {#data_length} field
|
68
|
+
# @return [Integer]
|
69
|
+
def calc_length
|
70
|
+
self[:pad].read SMB2::MAX_PADDING
|
71
|
+
self.data_length = sz - self[:pad].sz - 8
|
72
|
+
end
|
66
73
|
end
|
67
74
|
|
75
|
+
# Specialized {Context} for PREAUTH_INTEGRITY_CAP type.
|
68
76
|
class PreauthIntegrityCap < Context
|
69
77
|
remove_field :data
|
70
78
|
# @!attribute hash_alg_count
|
@@ -87,6 +95,7 @@ module PacketGen::Plugin
|
|
87
95
|
update_field :pad, builder: ->(h, t) { t.new(length_from: -> { (8 - (h.offset_of(:salt) + h.salt_length) % 8) % 8 }) }
|
88
96
|
end
|
89
97
|
|
98
|
+
# Specialized {Context} for ENCRYPTION_CAP type.
|
90
99
|
class EncryptionCap < Context
|
91
100
|
remove_field :data
|
92
101
|
# @!attribute cipher_count
|
@@ -97,7 +106,7 @@ module PacketGen::Plugin
|
|
97
106
|
# Array of 16-bit integer IDs specifying the supported encryption
|
98
107
|
# algorithms
|
99
108
|
# @return [PacketGen::Types::ArrayOfInt16le]
|
100
|
-
define_field_before :pad, :ciphers, PacketGen::Types::ArrayOfInt16le, builder: ->(h, t) { t.new(counter: h[:
|
109
|
+
define_field_before :pad, :ciphers, PacketGen::Types::ArrayOfInt16le, builder: ->(h, t) { t.new(counter: h[:cipher_count]) }
|
101
110
|
update_field :pad, builder: ->(h, t) { t.new(length_from: -> { (8 - (h.offset_of(:cipher_count) + h[:cipher_count].sz) % 8) % 8 }) }
|
102
111
|
end
|
103
112
|
|
@@ -109,9 +118,13 @@ module PacketGen::Plugin
|
|
109
118
|
private
|
110
119
|
|
111
120
|
def real_type(ctx)
|
112
|
-
name = Context::TYPES.key(ctx.type)
|
121
|
+
name = Context::TYPES.key(ctx.type).to_s
|
113
122
|
klassname = name.downcase.capitalize.gsub(/_(\w)/) { $1.upcase }
|
114
|
-
|
123
|
+
if !klassname.empty? && Negotiate.const_defined?(klassname)
|
124
|
+
Negotiate.const_get(klassname)
|
125
|
+
else
|
126
|
+
ctx.class
|
127
|
+
end
|
115
128
|
end
|
116
129
|
end
|
117
130
|
end
|
@@ -48,7 +48,7 @@ module PacketGen::Plugin
|
|
48
48
|
SECURITY_MODES = {
|
49
49
|
'signing_enabled' => 1,
|
50
50
|
'signing required' => 2
|
51
|
-
}
|
51
|
+
}.freeze
|
52
52
|
|
53
53
|
# @!attribute structure_size
|
54
54
|
# 16-bit negotiate request structure size. Should be 36.
|
@@ -146,7 +146,7 @@ module PacketGen::Plugin
|
|
146
146
|
str << PacketGen::Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''),
|
147
147
|
attr, value]
|
148
148
|
when :dialects
|
149
|
-
list = self.dialects.map { |v|
|
149
|
+
list = self.dialects.map { |v| '%#x' % v.to_i }.join(',')
|
150
150
|
str = PacketGen::Inspect.shift_level
|
151
151
|
str << PacketGen::Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''),
|
152
152
|
attr, list]
|
@@ -154,11 +154,17 @@ module PacketGen::Plugin
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
# Calculate and set {#context_offset}
|
158
|
-
# lengths in {Context contexts}.
|
157
|
+
# Calculate and set {#context_offset} and {#pad} fields.
|
158
|
+
# Also calculate lengths in {Context contexts}.
|
159
159
|
# @return [Integer]
|
160
160
|
def calc_length
|
161
|
-
self.
|
161
|
+
self[:pad].read SMB2::MAX_PADDING
|
162
|
+
|
163
|
+
self.context_offset = 0
|
164
|
+
unless context_list.empty?
|
165
|
+
self.context_offset = SMB2::HEADER_SIZE + offset_of(:context_list)
|
166
|
+
end
|
167
|
+
context_list.each { |ctx| ctx.calc_length if ctx.respond_to? :calc_length }
|
162
168
|
end
|
163
169
|
end
|
164
170
|
end
|
@@ -140,10 +140,11 @@ module PacketGen::Plugin
|
|
140
140
|
define_field :context_offset, PacketGen::Types::Int32le
|
141
141
|
# @!attribute buffer
|
142
142
|
# @return [GSSAPI]
|
143
|
-
define_field :buffer, GSSAPI, token: :init
|
143
|
+
define_field :buffer, GSSAPI, token: :init, optional: ->(h) { h.buffer_offset > 0 }
|
144
144
|
# @!attribute pad
|
145
145
|
# Optional padding between the end of the {#buffer} field and the first negotiate
|
146
|
-
# context in {#context_list} so that the first negotiate context is 8-byte aligned
|
146
|
+
# context in {#context_list} so that the first negotiate context is 8-byte aligned
|
147
|
+
# with start of SMB2 header.
|
147
148
|
# @return [String]
|
148
149
|
define_smb2_pad_field :pad
|
149
150
|
# @!attribute context_list
|
@@ -176,13 +177,20 @@ module PacketGen::Plugin
|
|
176
177
|
end
|
177
178
|
end
|
178
179
|
|
179
|
-
# Calculate and set {#context_offset}, {#buffer_offset}
|
180
|
+
# Calculate and set {#context_offset}, {#buffer_offset}, {#buffer_length} and
|
181
|
+
# {#pad} fields.
|
180
182
|
# Also calculate lengths in {Context contexts}.
|
181
183
|
# @return [void]
|
182
184
|
def calc_length
|
183
|
-
self.
|
184
|
-
|
185
|
-
self.
|
185
|
+
self[:pad].read SMB2::MAX_PADDING
|
186
|
+
|
187
|
+
self.buffer_offset = SMB2::HEADER_SIZE + offset_of(:buffer)
|
188
|
+
self.buffer_length = self[:buffer].sz
|
189
|
+
|
190
|
+
self.context_offset = 0
|
191
|
+
unless context_list.empty?
|
192
|
+
self.context_offset = SMB2::HEADER_SIZE + offset_of(:context_list)
|
193
|
+
end
|
186
194
|
context_list.each { |ctx| ctx.calc_length if ctx.respond_to? :calc_length }
|
187
195
|
end
|
188
196
|
end
|
@@ -79,12 +79,13 @@ module PacketGen::Plugin
|
|
79
79
|
define_field :prev_session_id, PacketGen::Types::Int64le
|
80
80
|
# @!attribute buffer
|
81
81
|
# @return [GSSAPI]
|
82
|
-
define_field :buffer, GSSAPI, token: :response
|
82
|
+
define_field :buffer, GSSAPI, token: :response, optional: ->(h) { h.buffer_offset > 0 }
|
83
83
|
|
84
|
-
# Calculate and set {#buffer_length}
|
84
|
+
# Calculate and set {#buffer_length} and {#buffer_offset} fields.
|
85
85
|
# @return [void]
|
86
86
|
def calc_length
|
87
|
-
self.
|
87
|
+
self.buffer_offset = SMB2.new.sz + offset_of(:buffer)
|
88
|
+
self.buffer_length = self[:buffer].sz
|
88
89
|
end
|
89
90
|
|
90
91
|
# Protocol name
|
@@ -50,12 +50,13 @@ module PacketGen::Plugin
|
|
50
50
|
define_field :buffer_length, PacketGen::Types::Int16le
|
51
51
|
# @!attribute buffer
|
52
52
|
# @return [GSSAPI]
|
53
|
-
define_field :buffer, GSSAPI, token: :response
|
53
|
+
define_field :buffer, GSSAPI, token: :response, optional: ->(h) { h.buffer_offset > 0 }
|
54
54
|
|
55
|
-
# Calculate and set {#buffer_length}
|
55
|
+
# Calculate and set {#buffer_length} and {#buffer_offset} fields.
|
56
56
|
# @return [void]
|
57
57
|
def calc_length
|
58
|
-
self.
|
58
|
+
self.buffer_offset = SMB2.new.sz + offset_of(:buffer)
|
59
|
+
self.buffer_length = self[:buffer].sz
|
59
60
|
end
|
60
61
|
|
61
62
|
# Protocol name
|
@@ -38,6 +38,9 @@ module PacketGen::Plugin
|
|
38
38
|
# SMB2 header size
|
39
39
|
HEADER_SIZE = 64
|
40
40
|
|
41
|
+
# SMB2 pad field at its maximum length
|
42
|
+
MAX_PADDING = [0].pack('q').freeze
|
43
|
+
|
41
44
|
# @!attribute protocol
|
42
45
|
# This field must contain {MARKER SMB2 marker}
|
43
46
|
# @return [String]
|
@@ -145,7 +148,7 @@ module PacketGen::Plugin
|
|
145
148
|
PacketGen::Header.add_class krequest
|
146
149
|
self.bind krequest, command: SMB2::COMMANDS[command], flags: ->(v) { v.nil? ? 0 : (v & 1).zero? }
|
147
150
|
PacketGen::Header.add_class kresponse
|
148
|
-
self.bind kresponse, command: SMB2::COMMANDS[command], flags: ->(v) { v.nil? ?
|
151
|
+
self.bind kresponse, command: SMB2::COMMANDS[command], flags: ->(v) { v.nil? ? 1 : (v & 1 == 1) }
|
149
152
|
end
|
150
153
|
|
151
154
|
# Invert {#flags_response?}
|
@@ -154,6 +157,12 @@ module PacketGen::Plugin
|
|
154
157
|
self.flags_response = !flags_response?
|
155
158
|
end
|
156
159
|
|
160
|
+
# Check if this is really a SMB2 header. Check {#protocol} has value {MARKER}.
|
161
|
+
# @return [Boolean]
|
162
|
+
def parse?
|
163
|
+
protocol == MARKER
|
164
|
+
end
|
165
|
+
|
157
166
|
# @return [String]
|
158
167
|
def inspect
|
159
168
|
super do |attr|
|
data/lib/packetgen-plugin-smb.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path('
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'packetgen/plugin/smb_version'
|
4
4
|
|
@@ -8,8 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Sylvain Daubert']
|
9
9
|
spec.email = ['sylvain.daubert@laposte.net']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
11
|
+
spec.summary = 'SMB plugin for packetgen.'
|
13
12
|
spec.homepage = 'https://github.com/sdaubert/packetgen-plugin-smb'
|
14
13
|
|
15
14
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -19,14 +18,12 @@ Gem::Specification.new do |spec|
|
|
19
18
|
|
20
19
|
spec.required_ruby_version = '>= 2.3.0'
|
21
20
|
|
22
|
-
spec.add_dependency 'packetgen', '~>3.0'
|
23
|
-
spec.add_dependency 'rasn1', '~>0.6', '>= 0.6.
|
21
|
+
spec.add_dependency 'packetgen', '~>3.0', '>= 3.0.2'
|
22
|
+
spec.add_dependency 'rasn1', '~>0.6', '>= 0.6.8'
|
24
23
|
|
25
24
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
26
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
26
|
spec.add_development_dependency 'rspec', '~> 3.7'
|
28
27
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
29
28
|
spec.add_development_dependency 'yard', '~> 0.9'
|
30
|
-
|
31
|
-
|
32
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packetgen-plugin-smb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Daubert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: packetgen
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.2
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.2
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rasn1
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +39,7 @@ dependencies:
|
|
33
39
|
version: '0.6'
|
34
40
|
- - ">="
|
35
41
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.6.
|
42
|
+
version: 0.6.8
|
37
43
|
type: :runtime
|
38
44
|
prerelease: false
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +49,7 @@ dependencies:
|
|
43
49
|
version: '0.6'
|
44
50
|
- - ">="
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.6.
|
52
|
+
version: 0.6.8
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: bundler
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +136,7 @@ files:
|
|
130
136
|
- Rakefile
|
131
137
|
- lib/packetgen-plugin-smb.rb
|
132
138
|
- lib/packetgen/plugin/gssapi.rb
|
139
|
+
- lib/packetgen/plugin/llmnr.rb
|
133
140
|
- lib/packetgen/plugin/netbios.rb
|
134
141
|
- lib/packetgen/plugin/netbios/datagram.rb
|
135
142
|
- lib/packetgen/plugin/netbios/name.rb
|
@@ -144,6 +151,10 @@ files:
|
|
144
151
|
- lib/packetgen/plugin/smb/close/request.rb
|
145
152
|
- lib/packetgen/plugin/smb/close/response.rb
|
146
153
|
- lib/packetgen/plugin/smb/filetime.rb
|
154
|
+
- lib/packetgen/plugin/smb/negotiate.rb
|
155
|
+
- lib/packetgen/plugin/smb/negotiate/dialect.rb
|
156
|
+
- lib/packetgen/plugin/smb/negotiate/request.rb
|
157
|
+
- lib/packetgen/plugin/smb/negotiate/response.rb
|
147
158
|
- lib/packetgen/plugin/smb/nt_create_and_x.rb
|
148
159
|
- lib/packetgen/plugin/smb/ntcreateandx/request.rb
|
149
160
|
- lib/packetgen/plugin/smb/ntcreateandx/response.rb
|