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.
Adding it
Section titled “Adding it”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 endendUsing include causes an explicit failure.
Behavior
Section titled “Behavior”- When
AutoCheckis true (the default), runcheck. Vulnerable/Appears→ Continue; callreport_vulnif needed.Detected→ Warn, then continue.Safeand similar results → Fail. SetForceExploit trueto proceed anyway.
Options
Section titled “Options”| Option | Meaning |
|---|---|
AutoCheck | Whether to run check automatically |
ForceExploit | Run despite the check result |
set AutoCheck falseset ForceExploit trueWriting cautions
Section titled “Writing cautions”- Return a
CheckCodefromcheckrather than usingfail_with. - Avoid overly destructive checks; do not prove
Vulnerablethrough a denial of service. - Use
check_hostin scanners.
Related: Entry Methods

