Sha256: 7dfbf60463230ab9df4de8872bf3b2e1beaa699829c24130ed03023c2c559b9a
Contents?: true
Size: 962 Bytes
Versions: 9
Compression:
Stored size: 962 Bytes
Contents
#!/usr/bin/ruby # This example script is used for testing TreeConnect functionality # It will attempt to connect to a specific share and then disconnect. # Example usage: ruby tree_connect.rb 192.168.172.138 msfadmin msfadmin TEST_SHARE # This will try to connect to \\192.168.172.138\TEST_SHARE with the msfadmin:msfadmin credentials require 'bundler/setup' require 'ruby_smb' address = ARGV[0] username = ARGV[1] password = ARGV[2] share = ARGV[3] path = "\\\\#{address}\\#{share}" sock = TCPSocket.new address, 445 dispatcher = RubySMB::Dispatcher::Socket.new(sock) client = RubySMB::Client.new(dispatcher, smb1: true, smb2: true, username: username, password: password) protocol = client.negotiate status = client.authenticate puts "#{protocol} : #{status}" begin tree = client.tree_connect(path) puts "Connected to #{path} successfully!" tree.disconnect! rescue Exception => e puts "Failed to connect to #{path}: #{e.message}" end
Version data entries
9 entries across 9 versions & 1 rubygems