Skip to content

AutoCheck

Msf::Exploit::Remote::AutoCheck automatically runs check before exploit or run. Use prepend, not include. Its implementation is lib/msf/core/exploit/remote/auto_check.rb.

class MetasploitModule < Msf::Exploit::Remote
prepend Msf::Exploit::Remote::AutoCheck
include Msf::Exploit::Remote::HttpClient
def check
CheckCode::Appears('service detected')
end
def exploit
# AutoCheck calls check first
end
end

Using include causes an explicit failure.

  1. When AutoCheck is true (the default), run check.
  2. Vulnerable / Appears → Continue; call report_vuln if needed.
  3. Detected → Warn, then continue.
  4. Safe and similar results → Fail. Set ForceExploit true to proceed anyway.
OptionMeaning
AutoCheckWhether to run check automatically
ForceExploitRun despite the check result
set AutoCheck false
set ForceExploit true
  • Return a CheckCode from check rather than using fail_with.
  • Avoid overly destructive checks; do not prove Vulnerable through a denial of service.
  • Use check_host in scanners.

Related: Entry Methods