ruby_smb 0.0.12 → 0.0.13
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
- checksums.yaml.gz.sig +1 -2
- data/lib/ruby_smb/client/authentication.rb +1 -1
- data/lib/ruby_smb/client/echo.rb +36 -0
- data/lib/ruby_smb/client/tree_connect.rb +1 -1
- data/lib/ruby_smb/client.rb +17 -0
- data/lib/ruby_smb/dispatcher/socket.rb +21 -14
- data/lib/ruby_smb/error.rb +3 -0
- data/lib/ruby_smb/field/ea_info_array.rb +58 -0
- data/lib/ruby_smb/field/extended_attribute_flag.rb +10 -0
- data/lib/ruby_smb/field/file_full_ea_info.rb +15 -0
- data/lib/ruby_smb/field/security_descriptor.rb +42 -0
- data/lib/ruby_smb/field/smb_fea.rb +14 -0
- data/lib/ruby_smb/field/smb_fea_list.rb +13 -0
- data/lib/ruby_smb/field/utime.rb +54 -0
- data/lib/ruby_smb/field.rb +7 -0
- data/lib/ruby_smb/generic_packet.rb +8 -4
- data/lib/ruby_smb/impersonation_levels.rb +22 -0
- data/lib/ruby_smb/smb1/bit_field/create_options.rb +38 -0
- data/lib/ruby_smb/smb1/bit_field/file_access_mask.rb +1 -1
- data/lib/ruby_smb/smb1/bit_field/open2_access_mode.rb +42 -0
- data/lib/ruby_smb/smb1/bit_field/open2_flags.rb +18 -0
- data/lib/ruby_smb/smb1/bit_field/open2_open_mode.rb +17 -0
- data/lib/ruby_smb/smb1/bit_field/share_access.rb +20 -0
- data/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes.rb +35 -0
- data/lib/ruby_smb/smb1/bit_field/smb_file_attributes.rb +26 -0
- data/lib/ruby_smb/smb1/bit_field/smb_nmpipe_status.rb +19 -0
- data/lib/ruby_smb/smb1/bit_field/trans2_flags.rb +15 -0
- data/lib/ruby_smb/smb1/bit_field.rb +9 -0
- data/lib/ruby_smb/smb1/commands.rb +10 -6
- data/lib/ruby_smb/smb1/create_actions.rb +22 -0
- data/lib/ruby_smb/smb1/dispositions.rb +36 -0
- data/lib/ruby_smb/smb1/oplock_levels.rb +19 -0
- data/lib/ruby_smb/smb1/packet/echo_request.rb +30 -0
- data/lib/ruby_smb/smb1/packet/echo_response.rb +31 -0
- data/lib/ruby_smb/smb1/packet/empty_packet.rb +14 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/create_request.rb +85 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/create_response.rb +61 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/request.rb +47 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/response.rb +44 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/subcommands.rb +11 -0
- data/lib/ruby_smb/smb1/packet/nt_trans.rb +16 -0
- data/lib/ruby_smb/smb1/packet/trans2/data_block.rb +32 -0
- data/lib/ruby_smb/smb1/packet/trans2/open2_request.rb +60 -0
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +65 -0
- data/lib/ruby_smb/smb1/packet/trans2/request.rb +52 -0
- data/lib/ruby_smb/smb1/packet/trans2/request_secondary.rb +39 -0
- data/lib/ruby_smb/smb1/packet/trans2/response.rb +48 -0
- data/lib/ruby_smb/smb1/packet/trans2/subcommands.rb +12 -0
- data/lib/ruby_smb/smb1/packet/trans2.rb +18 -0
- data/lib/ruby_smb/smb1/packet.rb +5 -1
- data/lib/ruby_smb/smb1.rb +3 -0
- data/lib/ruby_smb/smb2/bit_field/{share_capabailities.rb → share_capabilities.rb} +0 -0
- data/lib/ruby_smb/smb2/bit_field/{smb2_capabailities.rb → smb2_capabilities.rb} +0 -0
- data/lib/ruby_smb/smb2/bit_field.rb +2 -2
- data/lib/ruby_smb/smb2/packet/echo_request.rb +21 -0
- data/lib/ruby_smb/smb2/packet/echo_response.rb +22 -0
- data/lib/ruby_smb/smb2/packet.rb +2 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/ruby_smb.gemspec +2 -0
- data/spec/lib/ruby_smb/client_spec.rb +46 -0
- data/spec/lib/ruby_smb/field/ea_info_array_spec.rb +51 -0
- data/spec/lib/ruby_smb/field/extended_attribute_flag_spec.rb +16 -0
- data/spec/lib/ruby_smb/field/file_full_ea_info_spec.rb +35 -0
- data/spec/lib/ruby_smb/field/security_descriptor.rb +194 -0
- data/spec/lib/ruby_smb/field/smb_fea_list_spec.rb +38 -0
- data/spec/lib/ruby_smb/field/smb_fea_spec.rb +27 -0
- data/spec/lib/ruby_smb/field/utime_spec.rb +59 -0
- data/spec/lib/ruby_smb/smb1/bit_field/create_options_spec.rb +181 -0
- data/spec/lib/ruby_smb/smb1/bit_field/open2_access_mode_spec.rb +81 -0
- data/spec/lib/ruby_smb/smb1/bit_field/open2_flags_spec.rb +62 -0
- data/spec/lib/ruby_smb/smb1/bit_field/open2_open_mode_spec.rb +27 -0
- data/spec/lib/ruby_smb/smb1/bit_field/share_access_spec.rb +38 -0
- data/spec/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes_spec.rb +144 -0
- data/spec/lib/ruby_smb/smb1/bit_field/smb_file_attributes_spec.rb +113 -0
- data/spec/lib/ruby_smb/smb1/bit_field/smb_nmpipe_status_spec.rb +53 -0
- data/spec/lib/ruby_smb/smb1/bit_field/trans2_flags_spec.rb +28 -0
- data/spec/lib/ruby_smb/smb1/packet/echo_request_spec.rb +44 -0
- data/spec/lib/ruby_smb/smb1/packet/echo_response_spec.rb +44 -0
- data/spec/lib/ruby_smb/smb1/packet/error_packet_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/create_request_spec.rb +194 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/create_response_spec.rb +124 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/request_spec.rb +91 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/response_spec.rb +75 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_request_spec.rb +112 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_response_spec.rb +107 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_secondary_spec.rb +77 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_spec.rb +98 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/response_spec.rb +88 -0
- data/spec/lib/ruby_smb/smb2/packet/echo_request_spec.rb +30 -0
- data/spec/lib/ruby_smb/smb2/packet/echo_response_spec.rb +30 -0
- data/spec/lib/ruby_smb/smb2/packet/negotiate_request_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb2/packet/negotiate_response_spec.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +104 -7
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/smb1/packet/error_packet.rb +0 -14
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module BitField
|
|
4
|
+
# The Flags bit-field for SMB1 File Attributes as defined in
|
|
5
|
+
# [2.2.1.2.4 SMB_FILE_ATTRIBUTES](https://msdn.microsoft.com/en-us/library/ee441551.aspx)
|
|
6
|
+
class SmbFileAttributes < BinData::Record
|
|
7
|
+
endian :little
|
|
8
|
+
bit2 :reserved, label: 'Reserved Space'
|
|
9
|
+
bit1 :archive, label: 'Archive'
|
|
10
|
+
bit1 :directory, label: 'Directory'
|
|
11
|
+
bit1 :volume, label: 'Volume Label'
|
|
12
|
+
bit1 :system, label: 'System File'
|
|
13
|
+
bit1 :hidden, label: 'Hidden File'
|
|
14
|
+
bit1 :read_only, label: 'Read Only'
|
|
15
|
+
# Byte boundary
|
|
16
|
+
bit2 :reserved2, label: 'Reserved Space'
|
|
17
|
+
bit1 :search_archive, label: 'Search for Archive Files'
|
|
18
|
+
bit1 :search_directory, label: 'Search for Directories'
|
|
19
|
+
bit1 :reserved3, label: 'Reserved Space'
|
|
20
|
+
bit1 :search_system, label: 'Search for System Files'
|
|
21
|
+
bit1 :search_hidden, label: 'Search for Hidden Files'
|
|
22
|
+
bit1 :search_read_only, label: 'Search for Read Only Files'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module BitField
|
|
4
|
+
# The SMB Named Pipe Status data type as defined in
|
|
5
|
+
# [2.2.1.3 Named Pipe Status (SMB_NMPIPE_STATUS)](https://msdn.microsoft.com/en-us/library/ee878732.aspx)
|
|
6
|
+
class SmbNmpipeStatus < BinData::Record
|
|
7
|
+
endian :little
|
|
8
|
+
bit8 :icount, label: 'Number of Instances'
|
|
9
|
+
# byte boundary
|
|
10
|
+
bit1 :nonblocking, label: 'NonBlocking'
|
|
11
|
+
bit1 :endpoint, label: 'Endpoint'
|
|
12
|
+
bit3 :reserved2, label: 'Reserved'
|
|
13
|
+
bit1 :nmpipe_type, label: 'Named Pipe Type'
|
|
14
|
+
bit1 :reserved, label: 'Reserved Space'
|
|
15
|
+
bit1 :read_mode, label: 'Read Mode'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module BitField
|
|
4
|
+
# The Flags bit-field for a Trans2 Request Packet
|
|
5
|
+
# [2.2.4.46.1 Request](https://msdn.microsoft.com/en-us/library/ee442192.aspx)
|
|
6
|
+
class Trans2Flags < BinData::Record
|
|
7
|
+
endian :little
|
|
8
|
+
bit6 :reserved, label: 'Reserved Space', initial_value: 0
|
|
9
|
+
bit1 :no_response, label: 'Do Not reply', initial_value: 0
|
|
10
|
+
bit1 :disconnect, label: 'Disconnect Tree', initial_value: 0
|
|
11
|
+
bit8 :reserved2, label: 'Reserved Space', initial_value: 0
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -9,6 +9,15 @@ module RubySMB
|
|
|
9
9
|
require 'ruby_smb/smb1/bit_field/optional_support'
|
|
10
10
|
require 'ruby_smb/smb1/bit_field/directory_access_mask'
|
|
11
11
|
require 'ruby_smb/smb1/bit_field/file_access_mask'
|
|
12
|
+
require 'ruby_smb/smb1/bit_field/trans2_flags'
|
|
13
|
+
require 'ruby_smb/smb1/bit_field/open2_flags'
|
|
14
|
+
require 'ruby_smb/smb1/bit_field/open2_access_mode'
|
|
15
|
+
require 'ruby_smb/smb1/bit_field/open2_open_mode'
|
|
16
|
+
require 'ruby_smb/smb1/bit_field/smb_file_attributes'
|
|
17
|
+
require 'ruby_smb/smb1/bit_field/smb_ext_file_attributes'
|
|
18
|
+
require 'ruby_smb/smb1/bit_field/smb_nmpipe_status'
|
|
19
|
+
require 'ruby_smb/smb1/bit_field/share_access'
|
|
20
|
+
require 'ruby_smb/smb1/bit_field/create_options'
|
|
12
21
|
end
|
|
13
22
|
end
|
|
14
23
|
end
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
module RubySMB
|
|
2
2
|
module SMB1
|
|
3
3
|
module Commands
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
SMB_COM_ECHO = 0x2B
|
|
5
|
+
SMB_COM_TRANSACTION2 = 0x32
|
|
6
|
+
SMB_COM_TRANSACTION2_SECONDARY = 0x33
|
|
7
|
+
SMB_COM_TREE_DISCONNECT = 0x71
|
|
8
|
+
SMB_COM_NEGOTIATE = 0x72
|
|
9
|
+
SMB_COM_SESSION_SETUP = 0x73
|
|
10
|
+
SMB_COM_LOGOFF = 0x74
|
|
11
|
+
SMB_COM_TREE_CONNECT = 0x75
|
|
12
|
+
SMB_COM_NT_TRANSACT = 0xA0
|
|
13
|
+
SMB_COM_NO_ANDX_COMMAND = 0xFF
|
|
10
14
|
end
|
|
11
15
|
end
|
|
12
16
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
# This module holds the Create Actions used in NT_TRANSACT_CREATE and
|
|
4
|
+
# SMB_COM_NT_CREATE_ANDX responses. The definitions for these values can be found at
|
|
5
|
+
# [2.2.7.1.2 Response](https://msdn.microsoft.com/en-us/library/ee441961.aspx)
|
|
6
|
+
module CreateActions
|
|
7
|
+
|
|
8
|
+
# An existing file was deleted and a new file was created in its place.
|
|
9
|
+
FILE_SUPERSEDED = 0x00000000
|
|
10
|
+
|
|
11
|
+
# An existing file was opened.
|
|
12
|
+
FILE_OPENED = 0x00000001
|
|
13
|
+
|
|
14
|
+
# A new file was created.
|
|
15
|
+
FILE_CREATED = 0x00000002
|
|
16
|
+
|
|
17
|
+
# An existing file was overwritten.
|
|
18
|
+
FILE_OVERWRITEN = 0x00000003
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
# This module holds the Create Dispositions used in NT_TRANSACT_CREATE and
|
|
4
|
+
# SMB_COM_NT_CREATE_ANDX requests. The definitions for these values can be found at
|
|
5
|
+
# [2.2.4.64.1 Request](https://msdn.microsoft.com/en-us/library/ee442175.aspx)
|
|
6
|
+
module Dispositions
|
|
7
|
+
|
|
8
|
+
# If the file already exists, it SHOULD be superseded (overwritten).
|
|
9
|
+
# If it does not already exist, it SHOULD be created.
|
|
10
|
+
FILE_SUPERSEDE = 0x00000000
|
|
11
|
+
|
|
12
|
+
# If the file already exists, it SHOULD be opened rather than creating a new file.
|
|
13
|
+
# If the file does not already exist, the operation MUST fail.
|
|
14
|
+
FILE_OPEN = 0x00000001
|
|
15
|
+
|
|
16
|
+
# If the file already exists, the operation MUST fail.
|
|
17
|
+
# If the file does not already exist, it SHOULD be created.
|
|
18
|
+
FILE_CREATE = 0x00000002
|
|
19
|
+
|
|
20
|
+
# If the file already exists, it SHOULD be opened.
|
|
21
|
+
# If the file does not already exist, it SHOULD be created.
|
|
22
|
+
FILE_OPEN_IF = 0x00000003
|
|
23
|
+
|
|
24
|
+
# If the file already exists, it SHOULD be opened and truncated.
|
|
25
|
+
# If the file does not already exist, the operation MUST fail.
|
|
26
|
+
# The client MUST open the file with at least GENERIC_WRITE access for the command to succeed.
|
|
27
|
+
FILE_OVERWRITE = 0x00000004
|
|
28
|
+
|
|
29
|
+
# If the file already exists, it SHOULD be opened and truncated.
|
|
30
|
+
# If the file does not already exist, it SHOULD be created.
|
|
31
|
+
# The client MUST open the file with at least GENERIC_WRITE access.
|
|
32
|
+
FILE_OVERWRITE_IF = 0x00000005
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
# This module holds the OPLock Levels used in NT_TRANSACT_CREATE and
|
|
4
|
+
# SMB_COM_NT_CREATE_ANDX responses. The definitions for these values can be found at
|
|
5
|
+
# [2.2.7.1.2 Response](https://msdn.microsoft.com/en-us/library/ee441961.aspx)
|
|
6
|
+
module CreateActions
|
|
7
|
+
|
|
8
|
+
# No OpLock Granted
|
|
9
|
+
NO_OPLOCK = 0x00
|
|
10
|
+
# Exclusive OpLock Granted
|
|
11
|
+
EXCLUSIVE_OPLOCK = 0x01
|
|
12
|
+
# Batch OpLock Granted
|
|
13
|
+
BATCH_OPLOCK = 0x02
|
|
14
|
+
# Level 2 OpLock Granted
|
|
15
|
+
LEVEL2_OPLOCK = 0x03
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
|
|
5
|
+
# This class represents an SMB1 Echo Request Packet as defined in
|
|
6
|
+
# [2.2.4.39.1 Request](https://msdn.microsoft.com/en-us/library/ee441746.aspx)
|
|
7
|
+
class EchoRequest < RubySMB::GenericPacket
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
|
11
|
+
uint16 :echo_count, label: 'Echo Count', initial_value: 1
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class DataBlock < RubySMB::SMB1::DataBlock
|
|
15
|
+
string :data, label: 'Data'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
smb_header :smb_header
|
|
19
|
+
parameter_block :parameter_block
|
|
20
|
+
data_block :data_block
|
|
21
|
+
|
|
22
|
+
def initialize_instance
|
|
23
|
+
super
|
|
24
|
+
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_ECHO
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
|
|
5
|
+
# This class represents an SMB1 Echo Request Packet as defined in
|
|
6
|
+
# [2.2.4.39.2 Response](https://msdn.microsoft.com/en-us/library/ee441626.aspx)
|
|
7
|
+
class EchoResponse < RubySMB::GenericPacket
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
|
11
|
+
uint16 :sequence_number, label: 'Sequence Number'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class DataBlock < RubySMB::SMB1::DataBlock
|
|
15
|
+
string :data, label: 'Data'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
smb_header :smb_header
|
|
19
|
+
parameter_block :parameter_block
|
|
20
|
+
data_block :data_block
|
|
21
|
+
|
|
22
|
+
def initialize_instance
|
|
23
|
+
super
|
|
24
|
+
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_ECHO
|
|
25
|
+
smb_header.flags.reply = 1
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
|
|
5
|
+
# This packet represent an SMB1 Response Packet when the parameter and
|
|
6
|
+
# data blocks will be empty.
|
|
7
|
+
class EmptyPacket < RubySMB::GenericPacket
|
|
8
|
+
smb_header :smb_header
|
|
9
|
+
parameter_block :parameter_block
|
|
10
|
+
data_block :data_block
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
module NtTrans
|
|
5
|
+
|
|
6
|
+
# Class representing a generic NT Transaction request packet as defined in
|
|
7
|
+
# [2.2.4.62.1 Request](https://msdn.microsoft.com/en-us/library/ee441534.aspx)
|
|
8
|
+
class CreateRequest < RubySMB::GenericPacket
|
|
9
|
+
|
|
10
|
+
class ParameterBlock < RubySMB::SMB1::Packet::NtTrans::Request::ParameterBlock
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Trans2Parameters < BinData::Record
|
|
14
|
+
endian :little
|
|
15
|
+
|
|
16
|
+
struct :flags do
|
|
17
|
+
bit4 :reserved
|
|
18
|
+
bit1 :open_target_dir, label: 'Open Parent Directory'
|
|
19
|
+
bit1 :request_opbatch, label: 'Request Batch OpLock'
|
|
20
|
+
bit1 :request_oplock, label: 'Request Exclusive OpLock'
|
|
21
|
+
bit1 :reserved2, label: 'Reserved Space'
|
|
22
|
+
# byte boundary
|
|
23
|
+
bit8 :reserved3, label: 'Reserved Space'
|
|
24
|
+
bit8 :reserved4, label: 'Reserved Space'
|
|
25
|
+
bit8 :reserved5, label: 'Reserved Space'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
uint32 :root_directory_fid, label: 'Root Directory FID'
|
|
29
|
+
file_access_mask :desired_access
|
|
30
|
+
uint64 :allocation_size, label: 'Allocation Size'
|
|
31
|
+
smb_ext_file_attributes :ext_file_attribute
|
|
32
|
+
share_access :share_access, label: 'Share Access'
|
|
33
|
+
uint32 :create_disposition, label: 'Create Disposition'
|
|
34
|
+
create_options :create_options
|
|
35
|
+
uint32 :security_descriptor_length, label: 'Security Descriptor Length', value: lambda { self.parent.trans2_data.security_descriptor.length }
|
|
36
|
+
uint32 :ea_length, label: 'Extended Attributes Length', value: lambda { self.parent.trans2_data.extended_attributes.length }
|
|
37
|
+
uint32 :impersonation_level, label: 'Impersonation Level'
|
|
38
|
+
|
|
39
|
+
struct :security_flags do
|
|
40
|
+
bit6 :reserved, label: 'Reserved Space'
|
|
41
|
+
bit1 :effective_only, label: 'Effective Only'
|
|
42
|
+
bit1 :context_tracking, label: 'Context Tracking'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
string :name, label: 'File Name'
|
|
46
|
+
|
|
47
|
+
# Returns the length of the Trans2Parameters struct
|
|
48
|
+
# in number of bytes
|
|
49
|
+
def length
|
|
50
|
+
self.do_num_bytes
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class Trans2Data < BinData::Record
|
|
55
|
+
security_descriptor :security_descriptor
|
|
56
|
+
file_full_ea_info :extended_attributes
|
|
57
|
+
|
|
58
|
+
# Returns the length of the Trans2Data struct
|
|
59
|
+
# in number of bytes
|
|
60
|
+
def length
|
|
61
|
+
self.do_num_bytes
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
|
66
|
+
string :pad1, length: lambda { pad1_length }
|
|
67
|
+
trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
|
68
|
+
string :pad2, length: lambda { pad2_length }
|
|
69
|
+
trans2_data :trans2_data, label: 'Trans2 Data'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
smb_header :smb_header
|
|
73
|
+
parameter_block :parameter_block
|
|
74
|
+
data_block :data_block
|
|
75
|
+
|
|
76
|
+
def initialize_instance
|
|
77
|
+
super
|
|
78
|
+
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
|
79
|
+
parameter_block.function = RubySMB::SMB1::Packet::NtTrans::Subcommands::CREATE
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
module NtTrans
|
|
5
|
+
|
|
6
|
+
# Class representing a NT Transaction Create response packet as defined in
|
|
7
|
+
# [2.2.7.1.2 Response](https://msdn.microsoft.com/en-us/library/ee441961.aspx)
|
|
8
|
+
class CreateResponse < RubySMB::GenericPacket
|
|
9
|
+
|
|
10
|
+
class ParameterBlock < RubySMB::SMB1::Packet::NtTrans::Response::ParameterBlock
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Trans2Parameters < BinData::Record
|
|
14
|
+
endian :little
|
|
15
|
+
|
|
16
|
+
uint8 :oplock_level, label: 'OpLock Level'
|
|
17
|
+
uint8 :reserved, label: 'Reserved Space'
|
|
18
|
+
uint16 :fid, label: 'File ID'
|
|
19
|
+
uint32 :create_action, label: 'Create Action'
|
|
20
|
+
uint32 :ea_error_offset, label: 'EA Error Offset'
|
|
21
|
+
file_time :creation_time, label: 'File Creation Time'
|
|
22
|
+
file_time :last_access_time, label: 'File Last Accessed Time'
|
|
23
|
+
file_time :last_write_time, label: 'File last Write Time'
|
|
24
|
+
file_time :last_change_time, label: 'File Last Changed Time'
|
|
25
|
+
smb_ext_file_attributes :ext_file_attributes, label: 'File Extended Attributes'
|
|
26
|
+
uint64 :allocation_size, label: 'Allocation Size'
|
|
27
|
+
uint64 :end_of_file, label: 'Offset to EOF'
|
|
28
|
+
uint16 :resource_type, label: 'Resource Type'
|
|
29
|
+
smb_nmpipe_status :nmpipe_status, label: 'Named Pipe Status'
|
|
30
|
+
uint8 :directory, label: 'Directory'
|
|
31
|
+
|
|
32
|
+
# Returns the length of the Trans2Parameters struct
|
|
33
|
+
# in number of bytes
|
|
34
|
+
def length
|
|
35
|
+
self.do_num_bytes
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
|
42
|
+
string :pad1, length: lambda { pad1_length }
|
|
43
|
+
trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
|
44
|
+
string :pad2, length: lambda { pad2_length }
|
|
45
|
+
string :trans2_data, label: 'Trans2 Data', length: 0
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
smb_header :smb_header
|
|
49
|
+
parameter_block :parameter_block
|
|
50
|
+
data_block :data_block
|
|
51
|
+
|
|
52
|
+
def initialize_instance
|
|
53
|
+
super
|
|
54
|
+
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
|
55
|
+
smb_header.flags.reply = 1
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
module NtTrans
|
|
5
|
+
|
|
6
|
+
# Class representing a generic NT Transaction request packet as defined in
|
|
7
|
+
# [2.2.4.62.1 Request](https://msdn.microsoft.com/en-us/library/ee441534.aspx)
|
|
8
|
+
class Request < RubySMB::GenericPacket
|
|
9
|
+
|
|
10
|
+
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
|
11
|
+
endian :little
|
|
12
|
+
uint8 :max_setup_count, label: 'Max Setup Count'
|
|
13
|
+
uint16 :reserved, label: 'Reserved Space'
|
|
14
|
+
uint32 :total_parameter_count, label: 'Total Parameter Count(bytes)'
|
|
15
|
+
uint32 :total_data_count, label: 'Total Data Count(bytes)'
|
|
16
|
+
uint32 :max_parameter_count, label: 'Max Parameter Count(bytes)'
|
|
17
|
+
uint32 :max_data_count, label: 'Max Data Count(bytes)'
|
|
18
|
+
uint32 :parameter_count, label: 'Parameter Count(bytes)', value: lambda {self.parent.data_block.trans2_parameters.length}
|
|
19
|
+
uint32 :parameter_offset, label: 'Parameter Offset', value: lambda {self.parent.data_block.trans2_parameters.abs_offset}
|
|
20
|
+
uint32 :data_count, label: 'Data Count(bytes)', value: lambda {self.parent.data_block.trans2_data.length}
|
|
21
|
+
uint32 :data_offset, label: 'Data Offset', value: lambda {self.parent.data_block.trans2_data.abs_offset}
|
|
22
|
+
uint8 :setup_count, label: 'Setup Count', value: lambda {setup.length}
|
|
23
|
+
uint16 :function, label: 'Function'
|
|
24
|
+
|
|
25
|
+
array :setup, type: :uint16, initial_length: 0
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
|
29
|
+
string :pad1, length: lambda { pad1_length }
|
|
30
|
+
string :trans2_parameters, label: 'Trans2 Parameters'
|
|
31
|
+
string :pad2, length: lambda { pad2_length }
|
|
32
|
+
string :trans2_data, label: 'Trans2 Data'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
smb_header :smb_header
|
|
36
|
+
parameter_block :parameter_block
|
|
37
|
+
data_block :data_block
|
|
38
|
+
|
|
39
|
+
def initialize_instance
|
|
40
|
+
super
|
|
41
|
+
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
module NtTrans
|
|
5
|
+
|
|
6
|
+
# Class representing a generic NT Transaction response packet as defined in
|
|
7
|
+
# [2.2.4.62.2 Response](https://msdn.microsoft.com/en-us/library/ee442112.aspx)
|
|
8
|
+
class Response < RubySMB::GenericPacket
|
|
9
|
+
|
|
10
|
+
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
|
11
|
+
endian :little
|
|
12
|
+
|
|
13
|
+
array :reserved, type: :uint8, length: 3
|
|
14
|
+
|
|
15
|
+
uint32 :total_parameter_count, label: 'Total Parameter Count(bytes)'
|
|
16
|
+
uint32 :total_data_count, label: 'Total Data Count(bytes)'
|
|
17
|
+
uint32 :parameter_count, label: 'Parameter Count(bytes)', value: lambda {self.parent.data_block.trans2_parameters.length}
|
|
18
|
+
uint32 :parameter_offset, label: 'Parameter Offset', value: lambda {self.parent.data_block.trans2_parameters.abs_offset}
|
|
19
|
+
uint32 :parameter_displacement, label: 'Parameter Displacement'
|
|
20
|
+
uint32 :data_count, label: 'Data Count(bytes)', value: lambda {self.parent.data_block.trans2_data.length}
|
|
21
|
+
uint32 :data_offset, label: 'Data Offset', value: lambda {self.parent.data_block.trans2_data.abs_offset}
|
|
22
|
+
uint32 :data_displacement, label: 'Data Displacement'
|
|
23
|
+
uint8 :setup_count, label: 'Setup Count', value: lambda {setup.length}
|
|
24
|
+
|
|
25
|
+
array :setup, type: :uint16, initial_length: 0
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class DataBlock < RubySMB::SMB1::Packet::NtTrans::Request::DataBlock
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
smb_header :smb_header
|
|
32
|
+
parameter_block :parameter_block
|
|
33
|
+
data_block :data_block
|
|
34
|
+
|
|
35
|
+
def initialize_instance
|
|
36
|
+
super
|
|
37
|
+
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
|
38
|
+
smb_header.flags.reply = 1
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
|
|
5
|
+
# Namespace for the NT Transaction sub-protocol documented in
|
|
6
|
+
# [2.2.4.62 SMB_COM_NT_TRANSACT (0xA0)](https://msdn.microsoft.com/en-us/library/ee441720.aspx)
|
|
7
|
+
module NtTrans
|
|
8
|
+
require 'ruby_smb/smb1/packet/nt_trans/subcommands'
|
|
9
|
+
require 'ruby_smb/smb1/packet/nt_trans/request'
|
|
10
|
+
require 'ruby_smb/smb1/packet/nt_trans/response'
|
|
11
|
+
require 'ruby_smb/smb1/packet/nt_trans/create_request'
|
|
12
|
+
require 'ruby_smb/smb1/packet/nt_trans/create_response'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
module Trans2
|
|
5
|
+
|
|
6
|
+
# Extends the {RubySMB::SMB1::DataBlock} to include padding methods
|
|
7
|
+
# that all Trans2 DataBlocks will need to handle proper byte alignment.
|
|
8
|
+
class DataBlock < RubySMB::SMB1::DataBlock
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
# Determines the correct length for the padding in front of
|
|
12
|
+
# #trans2_parameters. It should always force a 4-byte alignment.
|
|
13
|
+
def pad1_length
|
|
14
|
+
if self.respond_to?(:name)
|
|
15
|
+
offset = (name.abs_offset + 1) % 4
|
|
16
|
+
else
|
|
17
|
+
offset = (byte_count.abs_offset + 2) % 4
|
|
18
|
+
end
|
|
19
|
+
(4 - offset) % 4
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Determines the correct length for the padding in front of
|
|
23
|
+
# #trans2_data. It should always force a 4-byte alignment.
|
|
24
|
+
def pad2_length
|
|
25
|
+
offset = (trans2_parameters.abs_offset + trans2_parameters.length) % 4
|
|
26
|
+
(4 - offset) % 4
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module RubySMB
|
|
2
|
+
module SMB1
|
|
3
|
+
module Packet
|
|
4
|
+
module Trans2
|
|
5
|
+
|
|
6
|
+
# A Trans2 OPEN2 Request Packet as defined in
|
|
7
|
+
# [2.2.6.1.1 Request](https://msdn.microsoft.com/en-us/library/ee441733.aspx)
|
|
8
|
+
class Open2Request < RubySMB::GenericPacket
|
|
9
|
+
|
|
10
|
+
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Trans2Parameters < BinData::Record
|
|
14
|
+
endian :little
|
|
15
|
+
open2_flags :flags, label: 'Flags'
|
|
16
|
+
open2_access_mode :access_mode, label: 'AccessMode'
|
|
17
|
+
uint16 :reserved, label: 'Reserved Space'
|
|
18
|
+
smb_file_attributes :file_attributes, label: 'File Attributes'
|
|
19
|
+
utime :creation_time, label: 'Creation Time'
|
|
20
|
+
open2_open_mode :open_mode, label: 'Open Mode'
|
|
21
|
+
uint32 :allocation_size, label: 'Allocation Size'
|
|
22
|
+
array :reserved2, initial_length: 5 do
|
|
23
|
+
uint16 value: 0x0000
|
|
24
|
+
end
|
|
25
|
+
stringz :filename, label: 'Filename'
|
|
26
|
+
|
|
27
|
+
# Returns the length of the Trans2Parameters struct
|
|
28
|
+
# in number of bytes
|
|
29
|
+
def length
|
|
30
|
+
self.do_num_bytes
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Trans2Data < BinData::Record
|
|
35
|
+
smb_fea_list :extended_attribute_list, label: 'Extended Attribute List'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
|
39
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
|
40
|
+
string :pad1, length: lambda { pad1_length }
|
|
41
|
+
trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
|
42
|
+
string :pad2, length: lambda { pad2_length }
|
|
43
|
+
trans2_data :trans2_data, label: 'Trans2 Data'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
smb_header :smb_header
|
|
47
|
+
parameter_block :parameter_block
|
|
48
|
+
data_block :data_block
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def initialize_instance
|
|
52
|
+
super
|
|
53
|
+
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
|
54
|
+
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::OPEN2
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|