CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/tools/smb_file_server.rb
Views: 11705
1
#!/usr/bin/env ruby
2
3
require 'pathname'
4
require 'ruby_smb'
5
6
# we just need *a* default encoding to handle the strings from the NTLM messages
7
Encoding.default_internal = 'UTF-8' if Encoding.default_internal.nil?
8
9
options = RubySMB::Server::Cli.parse(defaults: { share_path: '.', username: 'metasploit' }) do |options, parser|
10
parser.banner = <<~EOS
11
Usage: #{File.basename(__FILE__)} [options]
12
13
Start a read-only SMB file server.
14
15
Options:
16
EOS
17
18
parser.on("--share-path SHARE_PATH", "The path to share (default: #{options[:share_path]})") do |path|
19
options[:share_path] = path
20
end
21
end
22
23
server = RubySMB::Server::Cli.build(options)
24
server.add_share(RubySMB::Server::Share::Provider::Disk.new(options[:share_name], options[:share_path]))
25
26
RubySMB::Server::Cli.run(server)
27
28