Sha256: 21d6d96c916f22f12fb32c34ad4b3a8a2818f41c66ac37e794de429c00027990

Contents?: true

Size: 778 Bytes

Versions: 13

Compression:

Stored size: 778 Bytes

Contents

#!/usr/bin/env ruby

#Jacob Hammack
#Jacob.Hammack@hammackj.com
#An Example for connecting to a Windows Share.

require 'rubygems'
require 'rex'

host = ARGV[0]
username = ARGV[1]
password = ARGV[2]
#hostname is interesting, new windows require the actual hostname of the box 
#to connect so this may not work on 7
hostname = "*SMBSERVER" 
domain = ""

begin
	sock = Rex::Socket::Tcp.create('PeerHost' => host, 'PeerPort' => 139)
	smb = Rex::Proto::SMB::SimpleClient.new(sock)

	puts "[*] Logging in to #{host}"
	smb.login(hostname, username, password, domain)
	smb.connect("Admin$")
		
	if smb.client.auth_user
		puts "[*] Connected to Admin$"
	else
		puts "[!] Unable to Connect to Admin$"
	end
	
	sock.close
rescue Exception => e
	puts "#{e.message}\n#{e.backtrace}\n\n"
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
rex-2.0.13 examples/smb_example.rb
rex-2.0.12 examples/smb_example.rb
rex-2.0.11 examples/smb_example.rb
rex-2.0.10 examples/smb_example.rb
rex-2.0.9 examples/smb_example.rb
rex-2.0.8 examples/smb_example.rb
rex-2.0.7 examples/smb_example.rb
rex-2.0.5 examples/smb_example.rb
rex-2.0.4 examples/smb_example.rb
dstruct-0.0.1 examples/smb_example.rb
rex-2.0.3 examples/smb_example.rb
librex-0.0.999 examples/smb_example.rb
rex-2.0.2 examples/smb_example.rb