Sha256: 34fb0831447e89b175e8b0676f64c2ee69da134c0f239943266e1ad39f0946fd

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

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]
path     = "\\\\#{address}\\IPC$"

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

client = RubySMB::Client.new(dispatcher, smb1: false, smb2: true, 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_smb-0.0.21 examples/net_share_enum_all.rb
ruby_smb-0.0.20 examples/net_share_enum_all.rb
ruby_smb-0.0.19 examples/net_share_enum_all.rb