-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use the BinData choice type to alternate between DirectoryaccessMask and FileAccessMask so we can use the appropriate one MS-2655
- Loading branch information
David Maloney
authored and
David Maloney
committed
Aug 10, 2017
1 parent
f9d16b3
commit 08c9e58
Showing
6 changed files
with
119 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/ruby | ||
|
||
# This example script is used for testing directory listing functionality | ||
# It will attempt to connect to a specific share and then list all files in a | ||
# specified directory.. | ||
# Example usage: ruby list_directory.rb 192.168.172.138 msfadmin msfadmin TEST_SHARE subdir1 | ||
# This will try to connect to \\192.168.172.138\TEST_SHARE with the msfadmin:msfadmin credentials, | ||
# and then list the contents of the directory 'subdir1' | ||
|
||
require 'bundler/setup' | ||
require 'ruby_smb' | ||
|
||
address = ARGV[0] | ||
username = ARGV[1] | ||
password = ARGV[2] | ||
share = ARGV[3] | ||
dir = ARGV[4] | ||
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!" | ||
rescue Exception => e | ||
puts "Failed to connect to #{path}: #{e.message}" | ||
end | ||
|
||
files = tree.list(directory: dir) | ||
|
||
require 'pry' | ||
binding.pry | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters