Skip to content

Commit c62beac

Browse files
committed
Revert rapid7#4473 - Log backtraces by default
1 parent 32746e0 commit c62beac

File tree

7 files changed

+21
-52
lines changed

7 files changed

+21
-52
lines changed

lib/msf/base/simple/auxiliary.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,17 @@ def self.job_run_proc(ctx)
151151
rescue ::Exception => e
152152
mod.error = e
153153
mod.print_error("Auxiliary failed: #{e.class} #{e}")
154-
elog("Auxiliary failed: #{e.class} #{e}", 'core', LEV_0)
155-
156-
if e.kind_of?(Msf::OptionValidateError)
157-
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
158-
else
154+
if(e.class.to_s != 'Msf::OptionValidateError')
159155
mod.print_error("Call stack:")
160156
e.backtrace.each do |line|
161157
break if line =~ /lib.msf.base.simple.auxiliary.rb/
162158
mod.print_error(" #{line}")
163159
end
164-
elog("Call stack:\n#{$@.join("\n")}", 'core', LEV_0)
165160
end
166161

162+
elog("Auxiliary failed: #{e.class} #{e}", 'core', LEV_0)
163+
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
164+
167165
mod.cleanup
168166

169167
return
@@ -184,3 +182,4 @@ def self.job_cleanup_proc(ctx)
184182

185183
end
186184
end
185+

lib/msf/base/simple/exploit.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,7 @@ def self.exploit_simple(oexploit, opts, &block)
147147
exploit.error = e
148148
exploit.print_error("Exploit failed: #{e}")
149149
elog("Exploit failed (#{exploit.refname}): #{e}", 'core', LEV_0)
150-
151-
if e.kind_of?(Msf::OptionValidateError)
152-
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
153-
else
154-
exploit.print_error("Call stack:")
155-
e.backtrace.each do |line|
156-
break if line =~ /lib.msf.base.simple.exploit.rb/
157-
exploit.print_error(" #{line}")
158-
end
159-
elog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_0)
160-
end
150+
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
161151
end
162152

163153
return driver.session if driver
@@ -209,3 +199,4 @@ def check_simple(opts)
209199

210200
end
211201
end
202+

lib/msf/base/simple/post.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,17 @@ def self.job_run_proc(ctx)
121121
rescue ::Exception => e
122122
mod.error = e
123123
mod.print_error("Post failed: #{e.class} #{e}")
124-
elog("Post failed: #{e.class} #{e}", 'core', LEV_0)
125-
126-
if e.kind_of?(Msf::OptionValidateError)
127-
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
128-
else
124+
if(e.class.to_s != 'Msf::OptionValidateError')
129125
mod.print_error("Call stack:")
130126
e.backtrace.each do |line|
131127
break if line =~ /lib.msf.base.simple.post.rb/
132128
mod.print_error(" #{line}")
133129
end
134-
elog("Call stack:\n#{$@.join("\n")}", 'core', LEV_0)
135130
end
136131

132+
elog("Post failed: #{e.class} #{e}", 'core', LEV_0)
133+
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
134+
137135
mod.cleanup
138136

139137
return
@@ -156,3 +154,4 @@ def self.job_cleanup_proc(ctx)
156154

157155
end
158156
end
157+

lib/msf/core/exploit_driver.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,14 @@ def job_run_proc(ctx)
271271
exploit.fail_reason = Msf::Exploit::Failure::Unknown
272272
end
273273

274-
elog("Exploit failed (#{exploit.refname}): #{msg}", 'core', LEV_0)
275-
276274
if exploit.fail_reason == Msf::Exploit::Failure::Unknown
277275
exploit.print_error("Exploit failed: #{msg}")
278-
exploit.print_error("Call stack:")
279-
e.backtrace.each do |line|
280-
break if line =~ /lib.msf.base.core.exploit_driver.rb/
281-
exploit.print_error(" #{line}")
282-
end
283-
elog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_0)
284276
else
285277
exploit.print_error("Exploit failed [#{exploit.fail_reason}]: #{msg}")
286-
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
287278
end
279+
280+
elog("Exploit failed (#{exploit.refname}): #{msg}", 'core', LEV_0)
281+
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
288282
end
289283

290284
# Record the error to various places
@@ -335,3 +329,4 @@ def job_cleanup_proc(ctx)
335329
end
336330

337331
end
332+

lib/msf/ui/console/command_dispatcher/auxiliary.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,12 @@ def cmd_run(*args)
120120
print_error("Auxiliary interrupted by the console user")
121121
rescue ::Exception => e
122122
print_error("Auxiliary failed: #{e.class} #{e}")
123-
elog("Auxiliary failed: #{e.class} #{e}", 'core', LEV_0)
124-
125-
if e.kind_of?(Msf::OptionValidateError)
126-
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
127-
else
123+
if(e.class.to_s != 'Msf::OptionValidateError')
128124
print_error("Call stack:")
129125
e.backtrace.each do |line|
130126
break if line =~ /lib.msf.base.simple/
131127
print_error(" #{line}")
132128
end
133-
elog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_0)
134129
end
135130

136131
return false
@@ -157,3 +152,4 @@ def cmd_run_help
157152
end
158153

159154
end end end end
155+

lib/msf/ui/console/command_dispatcher/exploit.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,12 @@ def cmd_exploit(*args)
121121
raise $!
122122
rescue ::Exception => e
123123
print_error("Exploit exception (#{mod.refname}): #{e.class} #{e}")
124-
125-
elog("Exploit exception (#{mod.refname}): #{e.class} #{e}", 'core', LEV_0)
126-
127-
if e.kind_of?(Msf::OptionValidateError)
128-
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
129-
else
124+
if(e.class.to_s != 'Msf::OptionValidateError')
130125
print_error("Call stack:")
131126
e.backtrace.each do |line|
132127
break if line =~ /lib.msf.base.simple/
133128
print_error(" #{line}")
134129
end
135-
elog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_0)
136130
end
137131
end
138132

lib/msf/ui/console/command_dispatcher/post.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,12 @@ def cmd_run(*args)
122122
print_error("Post interrupted by the console user")
123123
rescue ::Exception => e
124124
print_error("Post failed: #{e.class} #{e}")
125-
126-
elog("Post failed: #{e.class} #{e}", 'core', LEV_0)
127-
128-
if e.kind_of?(Msf::OptionValidateError)
129-
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
130-
else
125+
if (e.class.to_s != 'Msf::OptionValidateError')
131126
print_error("Call stack:")
132127
e.backtrace.each do |line|
133128
break if line =~ /lib.msf.base.simple/
134129
print_error(" #{line}")
135130
end
136-
elog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_0)
137131
end
138132

139133
return false
@@ -160,3 +154,4 @@ def cmd_run_help
160154
end
161155

162156
end end end end
157+

0 commit comments

Comments
 (0)