ruby_smb 3.1.0 → 3.1.3

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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/examples/file_server.rb +6 -61
  4. data/examples/virtual_file_server.rb +91 -0
  5. data/lib/ruby_smb/client/negotiation.rb +7 -7
  6. data/lib/ruby_smb/client.rb +2 -2
  7. data/lib/ruby_smb/fscc/file_information/file_access_information.rb +15 -0
  8. data/lib/ruby_smb/fscc/file_information/file_alignment_information.rb +45 -0
  9. data/lib/ruby_smb/fscc/file_information/file_all_information.rb +23 -0
  10. data/lib/ruby_smb/fscc/file_information/file_basic_information.rb +20 -0
  11. data/lib/ruby_smb/fscc/file_information/file_both_directory_information.rb +3 -3
  12. data/lib/ruby_smb/fscc/file_information/file_directory_information.rb +3 -3
  13. data/lib/ruby_smb/fscc/file_information/file_ea_information.rb +1 -0
  14. data/lib/ruby_smb/fscc/file_information/file_full_directory_information.rb +3 -3
  15. data/lib/ruby_smb/fscc/file_information/file_id_both_directory_information.rb +3 -3
  16. data/lib/ruby_smb/fscc/file_information/file_id_full_directory_information.rb +3 -3
  17. data/lib/ruby_smb/fscc/file_information/file_internal_information.rb +15 -0
  18. data/lib/ruby_smb/fscc/file_information/file_mode_information.rb +29 -0
  19. data/lib/ruby_smb/fscc/file_information/file_name_information.rb +16 -0
  20. data/lib/ruby_smb/fscc/file_information/file_names_information.rb +1 -1
  21. data/lib/ruby_smb/fscc/file_information/file_normalized_name_information.rb +16 -0
  22. data/lib/ruby_smb/fscc/file_information/file_position_information.rb +15 -0
  23. data/lib/ruby_smb/fscc/file_information/file_rename_information.rb +1 -1
  24. data/lib/ruby_smb/fscc/file_information/file_standard_information.rb +20 -0
  25. data/lib/ruby_smb/fscc/file_information/file_stream_information.rb +3 -0
  26. data/lib/ruby_smb/fscc/file_information.rb +41 -8
  27. data/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information.rb +1 -0
  28. data/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information.rb +1 -0
  29. data/lib/ruby_smb/fscc/file_system_information.rb +4 -0
  30. data/lib/ruby_smb/gss/provider/ntlm.rb +20 -3
  31. data/lib/ruby_smb/gss/provider.rb +10 -1
  32. data/lib/ruby_smb/ntlm/client.rb +74 -0
  33. data/lib/ruby_smb/ntlm.rb +1 -0
  34. data/lib/ruby_smb/server/cli.rb +121 -0
  35. data/lib/ruby_smb/server/server_client/session_setup.rb +4 -2
  36. data/lib/ruby_smb/server/server_client.rb +9 -1
  37. data/lib/ruby_smb/server/session.rb +5 -1
  38. data/lib/ruby_smb/server/share/provider/disk/processor/close.rb +9 -5
  39. data/lib/ruby_smb/server/share/provider/disk/processor/create.rb +2 -2
  40. data/lib/ruby_smb/server/share/provider/disk/processor/query.rb +2 -2
  41. data/lib/ruby_smb/server/share/provider/disk/processor/read.rb +15 -14
  42. data/lib/ruby_smb/server/share/provider/disk/processor.rb +76 -12
  43. data/lib/ruby_smb/server/share/provider/disk.rb +8 -2
  44. data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb +85 -0
  45. data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.rb +196 -0
  46. data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat.rb +175 -0
  47. data/lib/ruby_smb/server/share/provider/virtual_disk.rb +116 -0
  48. data/lib/ruby_smb/server/share/provider.rb +1 -0
  49. data/lib/ruby_smb/server.rb +14 -3
  50. data/lib/ruby_smb/smb2/tree.rb +1 -0
  51. data/lib/ruby_smb/version.rb +1 -1
  52. data/spec/lib/ruby_smb/client_spec.rb +11 -2
  53. data/spec/lib/ruby_smb/fscc/file_information/file_access_information_spec.rb +21 -0
  54. data/spec/lib/ruby_smb/fscc/file_information/file_alignment_information_spec.rb +21 -0
  55. data/spec/lib/ruby_smb/fscc/file_information/file_all_information_spec.rb +61 -0
  56. data/spec/lib/ruby_smb/fscc/file_information/file_basic_information_spec.rb +41 -0
  57. data/spec/lib/ruby_smb/fscc/file_information/file_both_directory_information_spec.rb +59 -10
  58. data/spec/lib/ruby_smb/fscc/file_information/file_directory_information_spec.rb +30 -12
  59. data/spec/lib/ruby_smb/fscc/file_information/file_ea_information_spec.rb +21 -0
  60. data/spec/lib/ruby_smb/fscc/file_information/file_full_directory_information_spec.rb +30 -12
  61. data/spec/lib/ruby_smb/fscc/file_information/file_id_both_directory_information_spec.rb +63 -10
  62. data/spec/lib/ruby_smb/fscc/file_information/file_id_full_directory_information_spec.rb +30 -12
  63. data/spec/lib/ruby_smb/fscc/file_information/file_internal_information_spec.rb +21 -0
  64. data/spec/lib/ruby_smb/fscc/file_information/file_mode_information_spec.rb +21 -0
  65. data/spec/lib/ruby_smb/fscc/file_information/file_name_information_spec.rb +44 -0
  66. data/spec/lib/ruby_smb/fscc/file_information/file_names_information_spec.rb +30 -12
  67. data/spec/lib/ruby_smb/fscc/file_information/file_network_open_information_spec.rb +51 -0
  68. data/spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb +44 -0
  69. data/spec/lib/ruby_smb/fscc/file_information/file_position_information_spec.rb +21 -0
  70. data/spec/lib/ruby_smb/fscc/file_information/file_rename_information_spec.rb +1 -1
  71. data/spec/lib/ruby_smb/fscc/file_information/file_standard_information_spec.rb +41 -0
  72. data/spec/lib/ruby_smb/fscc/file_information/file_stream_information_spec.rb +51 -0
  73. data/spec/lib/ruby_smb/fscc/file_information_spec.rb +14 -0
  74. data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information_spec.rb +46 -0
  75. data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information_spec.rb +51 -0
  76. data/spec/lib/ruby_smb/fscc/file_system_information_spec.rb +14 -0
  77. data/spec/lib/ruby_smb/ntlm/client/session_spec.rb +114 -0
  78. data/spec/lib/ruby_smb/ntlm/client_spec.rb +36 -0
  79. data/spec/lib/ruby_smb/server/server_client_spec.rb +15 -0
  80. data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname_spec.rb +581 -0
  81. data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat_spec.rb +207 -0
  82. data/spec/lib/ruby_smb/server/share/provider/virtual_disk_spec.rb +122 -0
  83. data.tar.gz.sig +2 -2
  84. metadata +63 -2
  85. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 582c72fe6559ee4c40aa9e33f77c6644669848ae3452c11095f31fb0b0fce387
4
- data.tar.gz: 2791bfa79cb55e6ec6689782a747860287278bc42c38d6ecd03a66396efba200
3
+ metadata.gz: 0b10829db92d5746b069916440f0e91ca006c370053fdc02621ed75723efbf40
4
+ data.tar.gz: aeeeb396277c47b16ff977e33344ab08da275a0632d6a9a220aac7e733e91311
5
5
  SHA512:
6
- metadata.gz: ae54e45927264996fbaed098e38f38d179c0750aa4d82073910364bdc3cb2719c8ec89c9f432554ef44a752b9aef3e4f945b73357b4694c7faa52f7025582efc
7
- data.tar.gz: 0cf5036c07e48a2cb6a40bdb63e0ec18f0f20d7110af4938f3fc4067e77d99e084ac5cba0f255980b1b971f93985793cce8211f4496e9ffd6be0bc00ab5e2dd7
6
+ metadata.gz: 7269f0664dd840a83d39d5d1b3a953f87d050bcffbea0b9993685ef1ec91c9047a9117d88ee305d2c467555b475a7c15e82f0f8bfa1b98d077ea00fd401de200
7
+ data.tar.gz: a5997a65e48cd66585896c55cd8a01fbbee4a8b04280a15ecacdd79501fdd42caf772ac712a32228ea6c1991a6db27c9657d8829ca412691df0834e392c45284
checksums.yaml.gz.sig CHANGED
Binary file
@@ -3,74 +3,19 @@
3
3
  require 'bundler/setup'
4
4
  require 'optparse'
5
5
  require 'ruby_smb'
6
- require 'ruby_smb/gss/provider/ntlm'
7
6
 
8
7
  # we just need *a* default encoding to handle the strings from the NTLM messages
9
8
  Encoding.default_internal = 'UTF-8' if Encoding.default_internal.nil?
10
9
 
11
- options = {
12
- allow_anonymous: true,
13
- domain: nil,
14
- username: 'RubySMB',
15
- password: 'password',
16
- share_name: 'home',
17
- share_path: '.',
18
- smbv1: true,
19
- smbv2: true,
20
- smbv3: true
21
- }
22
- OptionParser.new do |opts|
23
- opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
24
- opts.on("--path PATH", "The path to share (default: #{options[:share_path]})") do |path|
10
+ options = RubySMB::Server::Cli.parse(defaults: { share_path: '.' }) do |options, parser|
11
+ parser.banner = "Usage: #{File.basename(__FILE__)} [options]"
12
+
13
+ parser.on("--share-path SHARE_PATH", "The path to share (default: #{options[:share_path]})") do |path|
25
14
  options[:share_path] = path
26
15
  end
27
- opts.on("--share SHARE", "The share name (default: #{options[:share_name]})") do |share|
28
- options[:share_name] = share
29
- end
30
- opts.on("--[no-]anonymous", "Allow anonymous access (default: #{options[:allow_anonymous]})") do |allow_anonymous|
31
- options[:allow_anonymous] = allow_anonymous
32
- end
33
- opts.on("--[no-]smbv1", "Enable or disable SMBv1 (default: #{options[:smbv1] ? 'Enabled' : 'Disabled'})") do |smbv1|
34
- options[:smbv1] = smbv1
35
- end
36
- opts.on("--[no-]smbv2", "Enable or disable SMBv2 (default: #{options[:smbv2] ? 'Enabled' : 'Disabled'})") do |smbv2|
37
- options[:smbv2] = smbv2
38
- end
39
- opts.on("--[no-]smbv3", "Enable or disable SMBv3 (default: #{options[:smbv3] ? 'Enabled' : 'Disabled'})") do |smbv3|
40
- options[:smbv3] = smbv3
41
- end
42
- opts.on("--username USERNAME", "The account's username (default: #{options[:username]})") do |username|
43
- if username.include?('\\')
44
- options[:domain], options[:username] = username.split('\\', 2)
45
- else
46
- options[:username] = username
47
- end
48
- end
49
- opts.on("--password PASSWORD", "The account's password (default: #{options[:password]})") do |password|
50
- options[:password] = password
51
- end
52
- end.parse!
53
-
54
- ntlm_provider = RubySMB::Gss::Provider::NTLM.new(allow_anonymous: options[:allow_anonymous])
55
- ntlm_provider.put_account(options[:username], options[:password], domain: options[:domain]) # password can also be an NTLM hash
56
-
57
- server = RubySMB::Server.new(
58
- gss_provider: ntlm_provider,
59
- logger: :stdout
60
- )
61
- server.dialects.select! { |dialect| RubySMB::Dialect[dialect].family != RubySMB::Dialect::FAMILY_SMB1 } unless options[:smbv1]
62
- server.dialects.select! { |dialect| RubySMB::Dialect[dialect].family != RubySMB::Dialect::FAMILY_SMB2 } unless options[:smbv2]
63
- server.dialects.select! { |dialect| RubySMB::Dialect[dialect].family != RubySMB::Dialect::FAMILY_SMB3 } unless options[:smbv3]
64
-
65
- if server.dialects.empty?
66
- puts "at least one version must be enabled"
67
- exit false
68
16
  end
69
17
 
18
+ server = RubySMB::Server::Cli.build(options)
70
19
  server.add_share(RubySMB::Server::Share::Provider::Disk.new(options[:share_name], options[:share_path]))
71
- puts "server is running"
72
- server.run do
73
- puts "received connection"
74
- true
75
- end
76
20
 
21
+ RubySMB::Server::Cli.run(server)
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'optparse'
5
+ require 'ruby_smb'
6
+
7
+ # we just need *a* default encoding to handle the strings from the NTLM messages
8
+ Encoding.default_internal = 'UTF-8' if Encoding.default_internal.nil?
9
+
10
+ # see: https://en.wikipedia.org/wiki/Magic_8-ball#Possible_answers
11
+ MAGIC_8_BALL_ANSWERS = [
12
+ 'It is certain.',
13
+ 'It is decidedly so.',
14
+ 'Without a doubt.',
15
+ 'Yes definitely.',
16
+ 'You may rely on it.',
17
+ 'As I see it, yes.',
18
+ 'Most likely.',
19
+ 'Outlook good.',
20
+ 'Yes.',
21
+ 'Signs point to yes.',
22
+ 'Reply hazy, try again.',
23
+ 'Ask again later.',
24
+ 'Better not tell you now.',
25
+ 'Cannot predict now.',
26
+ 'Concentrate and ask again.',
27
+ 'Don\'t count on it.',
28
+ 'My reply is no.',
29
+ 'My sources say no.',
30
+ 'Outlook not so good.',
31
+ 'Very doubtful'
32
+ ]
33
+
34
+ options = RubySMB::Server::Cli.parse do |options, parser|
35
+ parser.banner = "Usage: #{File.basename(__FILE__)} [options]"
36
+
37
+ parser.on("--virtual-content CONTENT", "The virtual share contents") do |virtual_content|
38
+ options[:virtual_content] = virtual_content
39
+ end
40
+
41
+ parser.on("--virtual-name NAME", "The virtual share file name") do |virtual_name|
42
+ options[:virtual_name] = virtual_name
43
+ end
44
+
45
+ parser.on("--virtual-type TYPE", "The virtual share type") do |virtual_type|
46
+ options[:virtual_type] = virtual_type
47
+ end
48
+ end
49
+
50
+ server = RubySMB::Server::Cli.build(options)
51
+ virtual_disk = RubySMB::Server::Share::Provider::VirtualDisk.new(options[:share_name])
52
+
53
+ # greeting is a static text file
54
+ virtual_disk.add_static_file('greeting', 'Hello World!')
55
+
56
+ # self is this example file, it's read when it's added and its #stat object is copied over
57
+ virtual_disk.add_static_file('self/static', File.open(__FILE__))
58
+
59
+ # self is this example file, it's mapped in using a real Pathname object
60
+ virtual_disk.add_mapped_file('self/mapped', Pathname.new(File.expand_path(__FILE__)))
61
+
62
+ # magic_8_ball is a dynamic file that is generated each time it is open
63
+ virtual_disk.add_dynamic_file('magic_8_ball') do
64
+ MAGIC_8_BALL_ANSWERS.sample
65
+ end
66
+
67
+ if options[:virtual_content] && options[:virtual_name] && options[:virtual_type]
68
+ case options[:virtual_type].downcase
69
+ when 'static'
70
+ # for static, content is left as is
71
+ virtual_disk.add_static_file(options[:virtual_name], options[:virtual_content])
72
+ when 'mapped'
73
+ # for mapped, content is a file path
74
+ virtual_disk.add_mapped_file(options[:virtual_name], Pathname.new(File.expand_path(options[:virtual_content])))
75
+ when 'dynamic'
76
+ # for dynamic, content is a file path
77
+ virtual_disk.add_dynamic_file(options[:virtual_name]) do
78
+ File.read(options[:virtual_content])
79
+ end
80
+ else
81
+ puts "virtual type: #{options[:virtual_type]}, must be one of static, mapped, or dynamic"
82
+ exit false
83
+ end
84
+ elsif options[:virtual_content] || options[:virtual_name] || options[:virtual_type]
85
+ puts 'the --virtual-* flags are only used when all are specified'
86
+ exit false
87
+ end
88
+
89
+ server.add_share(virtual_disk)
90
+
91
+ RubySMB::Server::Cli.run(server)
@@ -5,7 +5,7 @@ module RubySMB
5
5
  module Negotiation
6
6
  # Handles the entire SMB Multi-Protocol Negotiation from the
7
7
  # Client to the Server. It sets state on the client appropriate
8
- # to the protocol and capabilites negotiated during the exchange.
8
+ # to the protocol and capabilities negotiated during the exchange.
9
9
  # It also keeps track of the negotiated dialect.
10
10
  #
11
11
  # @return [void]
@@ -23,13 +23,13 @@ module RubySMB
23
23
  update_preauth_hash(response_packet)
24
24
  end
25
25
 
26
- # If the response contains the SMB2 wildcard revision number dialect;
27
- # it indicates that the server implements SMB 2.1 or future dialect
28
- # revisions and expects the client to send a subsequent SMB2 Negotiate
29
- # request to negotiate the actual SMB 2 Protocol revision to be used.
30
- # The wildcard revision number is sent only in response to a
26
+ # If the response contains an SMB2 dialect and the request was SMB1;
27
+ # it indicates that the server supports SMB2 and wants to upgrade the
28
+ # connection. The server expects the client to send a subsequent SMB2
29
+ # Negotiate request to negotiate the actual SMB 2 Protocol revision to
30
+ # be used. The wildcard revision number is sent only in response to a
31
31
  # multi-protocol negotiate request with the "SMB 2.???" dialect string.
32
- if @dialect == '0x02ff'
32
+ if request_packet.packet_smb_version == 'SMB1' && RubySMB::Dialect[@dialect]&.order == RubySMB::Dialect::ORDER_SMB2
33
33
  self.smb2_message_id += 1
34
34
  version = negotiate
35
35
  end
@@ -332,7 +332,7 @@ module RubySMB
332
332
  # session setup response is received
333
333
  @session_encrypt_data = always_encrypt
334
334
 
335
- @ntlm_client = Net::NTLM::Client.new(
335
+ @ntlm_client = RubySMB::NTLM::Client.new(
336
336
  @username,
337
337
  @password,
338
338
  workstation: @local_workstation,
@@ -404,7 +404,7 @@ module RubySMB
404
404
  @password = pass.encode('utf-8') || ''.encode('utf-8')
405
405
  @username = user.encode('utf-8') || ''.encode('utf-8')
406
406
 
407
- @ntlm_client = Net::NTLM::Client.new(
407
+ @ntlm_client = RubySMB::NTLM::Client.new(
408
408
  @username,
409
409
  @password,
410
410
  workstation: @local_workstation,
@@ -0,0 +1,15 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileAccessInformation Class as defined in
5
+ # [2.4.1 FileAccessInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/01cf43d2-deb3-40d3-a39b-9e68693d7c90)
6
+ class FileAccessInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_ACCESS_INFORMATION
8
+
9
+ endian :little
10
+
11
+ uint32 :access_flags, label: 'Access Flags'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,45 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileAlignmentInformation Class as defined in
5
+ # [2.4.3 FileAlignmentInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/9b0b9971-85aa-4651-8438-f1c4298bcb0d)
6
+ class FileAlignmentInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_ALIGNMENT_INFORMATION
8
+
9
+ # If this value is specified, there are no alignment requirements for the device.
10
+ FILE_BYTE_ALIGNMENT = 0x00000000 # 0
11
+
12
+ # If this value is specified, data MUST be aligned on a 2-byte boundary.
13
+ FILE_WORD_ALIGNMENT = 0x00000001 # 1
14
+
15
+ # If this value is specified, data MUST be aligned on a 4-byte boundary.
16
+ FILE_LONG_ALIGNMENT = 0x00000003 # 3
17
+
18
+ # If this value is specified, data MUST be aligned on an 8-byte boundary.
19
+ FILE_QUAD_ALIGNMENT = 0x00000007 # 7
20
+
21
+ # If this value is specified, data MUST be aligned on a 16-byte boundary.
22
+ FILE_OCTA_ALIGNMENT = 0X0000000F # 15
23
+
24
+ # If this value is specified, data MUST be aligned on a 32-byte boundary.
25
+ FILE_32_BYTE_ALIGNMENT = 0X0000001F # 31
26
+
27
+ # If this value is specified, data MUST be aligned on a 64-byte boundary.
28
+ FILE_64_BYTE_ALIGNMENT = 0X0000003F # 63
29
+
30
+ # If this value is specified, data MUST be aligned on a 128-byte boundary.
31
+ FILE_128_BYTE_ALIGNMENT = 0X0000007F # 127
32
+
33
+ # If this value is specified, data MUST be aligned on a 256-byte boundary.
34
+ FILE_256_BYTE_ALIGNMENT = 0X000000FF # 255
35
+
36
+ # If this value is specified, data MUST be aligned on a 512-byte boundary.
37
+ FILE_512_BYTE_ALIGNMENT = 0X000001FF # 511
38
+
39
+ endian :little
40
+
41
+ uint32 :alignment_requirement, label: 'Alignment Requirement', initial_value: FILE_BYTE_ALIGNMENT
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileAllInformation Class as defined in
5
+ # [2.4.2 FileAllInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/95f3056a-ebc1-4f5d-b938-3f68a44677a6)
6
+ class FileAllInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_ALL_INFORMATION
8
+
9
+ endian :little
10
+
11
+ file_basic_information :basic_information, label: 'Basic Information'
12
+ file_standard_information :standard_information, label: 'Standard Information'
13
+ file_internal_information :internal_information, label: 'Internal Information'
14
+ file_ea_information :ea_information, label: 'EA Information'
15
+ file_access_information :access_information, label: 'Access Information'
16
+ file_position_information :position_information, label: 'Position Information'
17
+ file_mode_information :mode_information, label: 'Mode Information'
18
+ file_alignment_information :alignment_information, label: 'Alignment Information'
19
+ file_name_information :name_information, label: 'Name Information'
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileBasicInformation Class as defined in
5
+ # [2.4.7 FileBasicInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/16023025-8a78-492f-8b96-c873b042ac50)
6
+ class FileBasicInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_BASIC_INFORMATION
8
+
9
+ endian :little
10
+
11
+ file_time :create_time, label: 'Create Time'
12
+ file_time :last_access, label: 'Last Accessed Time'
13
+ file_time :last_write, label: 'Last Write Time'
14
+ file_time :last_change, label: 'Last Modified Time'
15
+ file_attributes :file_attributes, label: 'File Attributes'
16
+ string :reserved, label: 'Reserved', length: 4
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,7 +2,7 @@ module RubySMB
2
2
  module Fscc
3
3
  module FileInformation
4
4
  # The FileBothDirectoryInformation Class as defined in
5
- # [2.4.8 FileBothDirectoryInformation](https://msdn.microsoft.com/en-us/library/cc232095.aspx)
5
+ # [2.4.8 FileBothDirectoryInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/270df317-9ba5-4ccb-ba00-8d22be139bc5)
6
6
  class FileBothDirectoryInformation < BinData::Record
7
7
  CLASS_LEVEL = FileInformation::FILE_BOTH_DIRECTORY_INFORMATION
8
8
 
@@ -14,8 +14,8 @@ module RubySMB
14
14
  file_time :last_access, label: 'Last Accessed Time'
15
15
  file_time :last_write, label: 'Last Write Time'
16
16
  file_time :last_change, label: 'Last Modified Time'
17
- uint64 :end_of_file, label: 'End of File'
18
- uint64 :allocation_size, label: 'Allocated Size'
17
+ int64 :end_of_file, label: 'End of File'
18
+ int64 :allocation_size, label: 'Allocated Size'
19
19
  file_attributes :file_attributes, label: 'File Attributes'
20
20
  uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
21
21
  uint32 :ea_size, label: 'Extended Attributes Size'
@@ -2,7 +2,7 @@ module RubySMB
2
2
  module Fscc
3
3
  module FileInformation
4
4
  # The FileDirectoryInformation Class as defined in
5
- # [2.4.10 FileDirectoryInformation](https://msdn.microsoft.com/en-us/library/cc232097.aspx)
5
+ # [2.4.10 FileDirectoryInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/b38bf518-9057-4c88-9ddd-5e2d3976a64b)
6
6
  class FileDirectoryInformation < BinData::Record
7
7
  CLASS_LEVEL = FileInformation::FILE_DIRECTORY_INFORMATION
8
8
 
@@ -14,8 +14,8 @@ module RubySMB
14
14
  file_time :last_access, label: 'Last Accessed Time'
15
15
  file_time :last_write, label: 'Last Write Time'
16
16
  file_time :last_change, label: 'Last Modified Time'
17
- uint64 :end_of_file, label: 'End of File'
18
- uint64 :allocation_size, label: 'Allocated Size'
17
+ int64 :end_of_file, label: 'End of File'
18
+ int64 :allocation_size, label: 'Allocated Size'
19
19
  file_attributes :file_attributes, label: 'File Attributes'
20
20
  uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
21
21
  string16 :file_name, label: 'File Name', read_length: -> { file_name_length }
@@ -7,6 +7,7 @@ module RubySMB
7
7
  CLASS_LEVEL = FileInformation::FILE_EA_INFORMATION
8
8
 
9
9
  endian :little
10
+
10
11
  uint32 :ea_size, label: 'Extended Attributes Size'
11
12
  end
12
13
  end
@@ -2,7 +2,7 @@ module RubySMB
2
2
  module Fscc
3
3
  module FileInformation
4
4
  # The FileFullDirectoryInformation Class as defined in
5
- # [2.4.14 FileFullDirectoryInformation](https://msdn.microsoft.com/en-us/library/cc232068.aspx)
5
+ # [2.4.14 FileFullDirectoryInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/e8d926d1-3a22-4654-be9c-58317a85540b)
6
6
  class FileFullDirectoryInformation < BinData::Record
7
7
  CLASS_LEVEL = FileInformation::FILE_FULL_DIRECTORY_INFORMATION
8
8
 
@@ -14,8 +14,8 @@ module RubySMB
14
14
  file_time :last_access, label: 'Last Accessed Time'
15
15
  file_time :last_write, label: 'Last Write Time'
16
16
  file_time :last_change, label: 'Last Modified Time'
17
- uint64 :end_of_file, label: 'End of File'
18
- uint64 :allocation_size, label: 'Allocated Size'
17
+ int64 :end_of_file, label: 'End of File'
18
+ int64 :allocation_size, label: 'Allocated Size'
19
19
  file_attributes :file_attributes, label: 'File Attributes'
20
20
  uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
21
21
  uint32 :ea_size, label: 'Extended Attributes Size'
@@ -14,8 +14,8 @@ module RubySMB
14
14
  file_time :last_access, label: 'Last Accessed Time'
15
15
  file_time :last_write, label: 'Last Write Time'
16
16
  file_time :last_change, label: 'Last Modified Time'
17
- uint64 :end_of_file, label: 'End of File'
18
- uint64 :allocation_size, label: 'Allocated Size'
17
+ int64 :end_of_file, label: 'End of File'
18
+ int64 :allocation_size, label: 'Allocated Size'
19
19
  file_attributes :file_attributes, label: 'File Attributes'
20
20
  uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
21
21
  uint32 :ea_size, label: 'Extended Attributes Size'
@@ -23,7 +23,7 @@ module RubySMB
23
23
  uint8 :reserved, label: 'Reserved Space'
24
24
  string16 :short_name, label: 'File Short Name', length: 24
25
25
  uint16 :reserved2, label: 'Reserved Space'
26
- uint64 :file_id, label: 'File Id'
26
+ uint64 :file_id, label: 'File ID'
27
27
  string16 :file_name, label: 'File Name', read_length: -> { file_name_length }
28
28
  end
29
29
  end
@@ -2,7 +2,7 @@ module RubySMB
2
2
  module Fscc
3
3
  module FileInformation
4
4
  # The FileIdDirectoryInformation Class as defined in
5
- # [2.4.18 FileIdFullDirectoryInformation](https://msdn.microsoft.com/en-us/library/cc232071.aspx)
5
+ # [2.4.18 FileIdFullDirectoryInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/ab8e7558-899c-4be1-a7c5-3a9ae8ab76a0)
6
6
  class FileIdFullDirectoryInformation < BinData::Record
7
7
  CLASS_LEVEL = FileInformation::FILE_ID_FULL_DIRECTORY_INFORMATION
8
8
 
@@ -14,8 +14,8 @@ module RubySMB
14
14
  file_time :last_access, label: 'Last Accessed Time'
15
15
  file_time :last_write, label: 'Last Write Time'
16
16
  file_time :last_change, label: 'Last Modified Time'
17
- uint64 :end_of_file, label: 'End of File'
18
- uint64 :allocation_size, label: 'Allocated Size'
17
+ int64 :end_of_file, label: 'End of File'
18
+ int64 :allocation_size, label: 'Allocated Size'
19
19
  file_attributes :file_attributes, label: 'File Attributes'
20
20
  uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
21
21
  uint32 :ea_size, label: 'Extended Attributes Size'
@@ -0,0 +1,15 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileInternalInformation Class as defined in
5
+ # [2.4.22 FileInternalInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/7d796611-2fa5-41ac-8178-b6fea3a017b3)
6
+ class FileInternalInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_INTERNAL_INFORMATION
8
+
9
+ endian :little
10
+
11
+ uint64 :file_id, label: 'File ID'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileModeInformation Class as defined in
5
+ # [2.4.26 FileModeInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/52df7798-8330-474b-ac31-9afe8075640c)
6
+ class FileModeInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_MODE_INFORMATION
8
+
9
+ endian :little
10
+
11
+ struct :flags do
12
+ bit2 :reserved
13
+ bit1 :file_synchronous_io_nonalert, label: 'File Synchronous IO Nonalert'
14
+ bit1 :file_synchronous_io_alert, label: 'File Synchronous IO Alert'
15
+ bit1 :file_no_intermediate_buffering, label: 'File No Intermediate Buffering'
16
+ bit1 :file_sequential_only, label: 'File Sequential Only'
17
+ bit1 :file_write_through, label: 'File Write Through'
18
+ bit1 :reserved2
19
+ # byte boundary
20
+ bit3 :reserved3
21
+ bit1 :file_delete_on_close, label: 'File Delete On Close'
22
+ bit4 :reserved4
23
+ # byte boundary
24
+ bit16 :reserved5
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileNameInformation Class as defined in
5
+ # [2.4.27 FileNameInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/cb30e415-54c5-4483-a346-822ea90e1e89)
6
+ class FileNameInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_NAME_INFORMATION
8
+
9
+ endian :little
10
+
11
+ uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
12
+ string16 :file_name, label: 'File Name', read_length: -> { file_name_length }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,7 +2,7 @@ module RubySMB
2
2
  module Fscc
3
3
  module FileInformation
4
4
  # The FileNamesInformation Class as defined in
5
- # [2.4.26 FileNamesInformation](https://msdn.microsoft.com/en-us/library/cc232077.aspx)
5
+ # [2.4.28 FileNamesInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/a289f7a8-83d2-4927-8c88-b2d328dde5a5)
6
6
  class FileNamesInformation < BinData::Record
7
7
  CLASS_LEVEL = FileInformation::FILE_NAMES_INFORMATION
8
8
 
@@ -0,0 +1,16 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileNormalizedNameInformation Class as defined in
5
+ # [2.4.30 FileNormalizedNameInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/20bcadba-808c-4880-b757-4af93e41edf6)
6
+ class FileNormalizedNameInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_NORMALIZED_NAME_INFORMATION
8
+
9
+ endian :little
10
+
11
+ uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
12
+ string16 :file_name, label: 'File Name', read_length: -> { file_name_length }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FilePositionInformation Class as defined in
5
+ # [2.4.35 FilePositionInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/e3ce4a39-327e-495c-99b6-6b61606b6f16)
6
+ class FilePositionInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_POSITION_INFORMATION
8
+
9
+ endian :little
10
+
11
+ int64 :current_byte_offset, label: 'Current Byte Offset'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -4,7 +4,7 @@ module RubySMB
4
4
  # The FileRenameInformation Class as defined in
5
5
  # [2.4.34.2 FileRenameInformation](https://msdn.microsoft.com/en-us/library/cc704597.aspx)
6
6
  class FileRenameInformation < BinData::Record
7
- CLASS_LEVEL = FileInformation::FILE_ID_FULL_DIRECTORY_INFORMATION
7
+ CLASS_LEVEL = FileInformation::FILE_RENAME_INFORMATION
8
8
 
9
9
  endian :little
10
10
 
@@ -0,0 +1,20 @@
1
+ module RubySMB
2
+ module Fscc
3
+ module FileInformation
4
+ # The FileStandardInformation Class as defined in
5
+ # [2.4.41 FileStandardInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/5afa7f66-619c-48f3-955f-68c4ece704ae)
6
+ class FileStandardInformation < BinData::Record
7
+ CLASS_LEVEL = FileInformation::FILE_STANDARD_INFORMATION
8
+
9
+ endian :little
10
+
11
+ int64 :allocation_size, label: 'Allocation Size'
12
+ int64 :end_of_file, label: 'End of File'
13
+ uint32 :number_of_links, label: 'Number of Links'
14
+ int8 :delete_pending, label: 'Delete Pending'
15
+ int8 :directory, label: 'Directory'
16
+ string :reserved, label: 'Reserved', length: 2
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,7 +4,10 @@ module RubySMB
4
4
  # The FileStreamInformation
5
5
  # [2.4.43 FileStreamInformation](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/f8762be6-3ab9-411e-a7d6-5cc68f70c78d)
6
6
  class FileStreamInformation < BinData::Record
7
+ CLASS_LEVEL = Fscc::FileInformation::FILE_STREAM_INFORMATION
8
+
7
9
  endian :little
10
+
8
11
  uint32 :next_entry_offset, label: 'Next Entry Offset'
9
12
  uint32 :stream_name_length, label: 'Stream Name Length', initial_value: -> { stream_name.do_num_bytes }
10
13
  int64 :stream_size, label: 'Stream Size'