Sha256: d8c398cd0b281cc64861375a3cbc9536b859ca4a9085994e8d5b7b375af4e5f2

Contents?: true

Size: 1.04 KB

Versions: 47

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/ruby

# This example script is used for testing NetShareEnumAll functionality
# It will attempt to connect to a host and enumerate shares.
# Example usage: ruby net_share_enum_all.rb 192.168.172.138 msfadmin msfadmin
# This will try to connect to \\192.168.172.138 with the msfadmin:msfadmin credentials

require 'bundler/setup'
require 'ruby_smb'

address      = ARGV[0]
username     = ARGV[1]
password     = ARGV[2]
smb_versions = ARGV[3]&.split(',') || ['1','2','3']

path     = "\\\\#{address}\\IPC$"

sock = TCPSocket.new address, 445
dispatcher = RubySMB::Dispatcher::Socket.new(sock, read_timeout: 60)

client = RubySMB::Client.new(dispatcher, smb1: smb_versions.include?('1'), smb2: smb_versions.include?('2'), smb3: smb_versions.include?('3'), username: username, password: password)
protocol = client.negotiate
status = client.authenticate

puts "#{protocol} : #{status}"

begin
  shares = client.net_share_enum_all(address)
  puts shares
rescue => e
  puts "failed to enum shares: #{e.message}, #{e.backtrace_locations}"
end

client.disconnect!

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
ruby_smb-3.3.12 examples/net_share_enum_all.rb
ruby_smb-3.3.11 examples/net_share_enum_all.rb
ruby_smb-3.3.10 examples/net_share_enum_all.rb
ruby_smb-3.3.9 examples/net_share_enum_all.rb
ruby_smb-3.3.7 examples/net_share_enum_all.rb
ruby_smb-3.3.6 examples/net_share_enum_all.rb
ruby_smb-3.3.5 examples/net_share_enum_all.rb
ruby_smb-3.3.4 examples/net_share_enum_all.rb
ruby_smb-3.3.3 examples/net_share_enum_all.rb
ruby_smb-3.3.2 examples/net_share_enum_all.rb
ruby_smb-3.3.1 examples/net_share_enum_all.rb
ruby_smb-3.3.0 examples/net_share_enum_all.rb
ruby_smb-3.2.8 examples/net_share_enum_all.rb
ruby_smb-3.2.7 examples/net_share_enum_all.rb
ruby_smb-3.2.6 examples/net_share_enum_all.rb
ruby_smb-3.2.5 examples/net_share_enum_all.rb
ruby_smb-3.2.4 examples/net_share_enum_all.rb
ruby_smb-3.2.3 examples/net_share_enum_all.rb
ruby_smb-3.2.2 examples/net_share_enum_all.rb
ruby_smb-3.2.1 examples/net_share_enum_all.rb