Skip to content

SMB mixins are spread across lib/msf/core/exploit/remote/smb/. The main one is Msf::Exploit::Remote::SMB::Client, which includes Tcp, NTLM, and Report.

MixinPurpose
Msf::Exploit::Remote::SMB::ClientBasic connection
...::Client::AuthenticatedAuthenticated operations
...::Client::PsexecPsExec-style operations
...::Client::PipeAuditor and othersPipe enumeration
...::Server / ShareAttacker-side SMB server
include Msf::Exploit::Remote::SMB::Client
include Msf::Exploit::Remote::SMB::Client::Authenticated
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report
OptionMeaning
SMBUser / SMBPass / SMBDomainAuthentication (some fall back to USERNAME/PASSWORD/DOMAIN)
SMBDirectWhether to use raw SMB on port 445
SMBNameNetBIOS name (for port 139)
SMB::ProtocolVersionSMB dialect
def run_host(ip)
connect
smb_login
# Shares, tree connections, etc.
report_service(host: ip, port: rport, name: 'smb', info: ...)
rescue Rex::Proto::SMB::Exceptions::Error, Rex::ConnectionError => e
vprint_error("#{ip}: #{e.message}")
ensure
disconnect
end

Existing examples: modules/auxiliary/scanner/smb/smb_version.rb, smb_enumshares.rb, smb_login.rb

Add the Authenticated mixin to work with files on shares and named pipes. AD CS and DCERPC modules may also use MsIcpr or a DCERPC mixin.

Use SMB::Server when clients are made to connect so the module can receive hashes or serve files.

  • Enforced signing or disabled SMBv1 can cause failures. Check advanced options with show advanced.
  • Do not put credentials in Git-tracked .rc files (the same rule as in the operations notes).