Skip to content

Commit 7b52bcb

Browse files
committed
log errors into framework.log
1 parent 01daadc commit 7b52bcb

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

lib/msf/base/simple/auxiliary.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,19 @@ 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+
154156
if(e.class.to_s != 'Msf::OptionValidateError')
155157
mod.print_error("Call stack:")
156158
e.backtrace.each do |line|
157159
break if line =~ /lib.msf.base.simple.auxiliary.rb/
158160
mod.print_error(" #{line}")
159161
end
162+
elog("Call stack:\n#{$@.join("\n")}", 'core', LEV_0)
163+
else
164+
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
160165
end
161166

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

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

183185
end
184186
end
185-

lib/msf/base/simple/exploit.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,17 @@ 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-
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
150+
151+
if(e.class.to_s != 'Msf::OptionValidateError')
152+
mod.print_error("Call stack:")
153+
e.backtrace.each do |line|
154+
break if line =~ /lib.msf.base.simple.exploit.rb/
155+
mod.print_error(" #{line}")
156+
end
157+
elog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_0)
158+
else
159+
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
160+
end
151161
end
152162

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

200210
end
201211
end
202-

lib/msf/base/simple/post.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,19 @@ 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+
124126
if(e.class.to_s != 'Msf::OptionValidateError')
125127
mod.print_error("Call stack:")
126128
e.backtrace.each do |line|
127129
break if line =~ /lib.msf.base.simple.post.rb/
128130
mod.print_error(" #{line}")
129131
end
132+
elog("Call stack:\n#{$@.join("\n")}", 'core', LEV_0)
133+
else
134+
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
130135
end
131136

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

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

155157
end
156158
end
157-

0 commit comments

Comments
 (0)