rapid7/metasploit-framework — pull request #4473 by FireFart (2014-12-28 23:39:26+00:00)
Title: log errors into framework.log

See #4122 for discussion on this one.

Basicially this PR is all about logging a stacktracke when a module fails dua to coding errors (undefined method xxx on nil and so on).

Test module:
```
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking

def initialize(info = {})
super(update_info(
info,
'Name' => 'XXXX',
'Description' => %q{
XXX
},
'Author' =>
[
'Christian Mehlmauer' # metasploit module
],
'License' => MSF_LICENSE,
'References' =>
[
['URL', 'https://www.google.com']
],
'Privileged' => false,
'Platform' => ['php'],
'Arch' => ARCH_PHP,
'Targets' => [['XXXX', {}]],
'DefaultTarget' => 0,
'DisclosureDate' => 'Dec 3 2014'))
end

def exploit
test = nil
test.asdf
end
end
```

Example output of exploit_driver.rb:
```
msf exploit(test) > run

[*] Started reverse handler on 10.0.0.5:4444
[-] Exploit failed: NoMethodError undefined method `asdf' for nil:NilClass
[-] Call stack:
[-] /Users/firefart/.msf4/modules/exploits/test.rb:37:in `exploit'
[-] /Users/firefart/Coding/metasploit-framework/lib/msf/core/exploit_driver.rb:205:in `job_run_proc'
[-] /Users/firefart/Coding/metasploit-framework/lib/msf/core/exploit_driver.rb:166:in `run'
[-] /Users/firefart/Coding/metasploit-framework/lib/msf/base/simple/exploit.rb:136:in `exploit_simple'
[-] /Users/firefart/Coding/metasploit-framework/lib/msf/base/simple/exploit.rb:171:in `exploit_simple'
[-] /Users/firefart/Coding/metasploit-framework/lib/msf/ui/console/command_dispatcher/exploit.rb:111:in `cmd_exploit'
[-] /Users/firefart/Coding/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:427:in `run_command'
[-] /Users/firefart/Coding/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:389:in `block in run_single'
[-] /Users/firefart/Coding/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:383:in `each'
[-] /Users/firefart/Coding/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:383:in `run_single'
[-] /Users/firefart/Coding/metasploit-framework/lib/rex/ui/text/shell.rb:200:in `run'
[-] /Users/firefart/Coding/metasploit-framework/lib/metasploit/framework/command/console.rb:30:in `start'
[-] /Users/firefart/Coding/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
[-] ./msfconsole:48:in `

'
```