Metasploit-framework: Error while running command kill: undefined method `datastore' for "Error while running command kill: undefined method `datastore' for "IK3ioQdrzz1eFJ6p4tCJ21":String":String

Created on 6 Dec 2019  路  3Comments  路  Source: rapid7/metasploit-framework

when i kill jobs will be error

image

bug confirmed msfconsole

Most helpful comment

Sorry to reopen this but I experience the same issue with socks4 and socks5 aux.
jobs -k will not kill them
kill will not kill them
jobs -K will kill them for some reason.

msf5 auxiliary(server/socks5) > version
Framework: 5.0.83-dev
Console  : 5.0.83-dev

I did apply the fix below to the file /usr/share/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb on line 216 but same result.

This fixed it for me, but I'm not sure if this is the best / correct approach.

msf5 auxiliary(server/socks4a) > edit lib/msf/ui/console/command_dispatcher/jobs.rb
[*] Reloading /root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb
msf5 auxiliary(server/socks4a) > jobs -k 0
[*] Stopping the following job(s): 0
[*] Stopping job 0

[*] Stopping the socks4a proxy server
msf5 auxiliary(server/socks4a) > jobs

Jobs
====

No active jobs.

msf5 auxiliary(server/socks4a) > git diff lib/msf/ui/console/command_dispatcher/jobs.rb
[*] exec: git diff lib/msf/ui/console/command_dispatcher/jobs.rb

diff --git a/lib/msf/ui/console/command_dispatcher/jobs.rb b/lib/msf/ui/console/command_dispatcher/jobs.rb
index 641cbe8e37..e67b6ce27c 100644
--- a/lib/msf/ui/console/command_dispatcher/jobs.rb
+++ b/lib/msf/ui/console/command_dispatcher/jobs.rb
@@ -213,7 +213,7 @@ module Msf
               job_list.map(&:to_s).each do |job|
                 if framework.jobs.key?(job)
                   next unless framework.jobs[job.to_s].ctx[1] # next if no payload context in the job
-                  payload_option = framework.jobs[job.to_s].ctx[1].datastore
+                  payload_option = framework.jobs[job.to_s].ctx[1]
                   persist_list.delete_if{|pjob|pjob['mod_options']['Options'] == payload_option}
                 end
               end
msf5 auxiliary(server/socks4a) > 

All 3 comments

Confirmed.

msf5 > use auxiliary/server/socks4a 
msf5 auxiliary(server/socks4a) > run
[*] Auxiliary module running as background job 0.

[*] Starting the socks4a proxy server
msf5 auxiliary(server/socks4a) > jobs

Jobs
====

  Id  Name                       Payload  Payload opts
  --  ----                       -------  ------------
  0   Auxiliary: server/socks4a           

msf5 auxiliary(server/socks4a) > kill 0
[*] Stopping the following job(s): 0
[-] Error while running command kill: undefined method `datastore' for "1q76aQkasafsIiO6febyDdAA":String

Call stack:
/root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb:216:in `block in cmd_jobs'
/root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb:213:in `each'
/root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb:213:in `cmd_jobs'
/root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb:302:in `cmd_kill'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
/root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:158:in `run'
/root/Desktop/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:49:in `<main>'
msf5 auxiliary(server/socks4a) > jobs

Jobs
====

  Id  Name                       Payload  Payload opts
  --  ----                       -------  ------------
  0   Auxiliary: server/socks4a           

msf5 auxiliary(server/socks4a) > jobs -k 0
[*] Stopping the following job(s): 0
[-] Error while running command jobs: undefined method `datastore' for "1q76aQkasafsIiO6febyDdAA":String

Call stack:
/root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb:216:in `block in cmd_jobs'
/root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb:213:in `each'
/root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb:213:in `cmd_jobs'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
/root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
/root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:158:in `run'
/root/Desktop/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:49:in `<main>'
msf5 auxiliary(server/socks4a) > 

This fixed it for me, but I'm not sure if this is the best / correct approach.

msf5 auxiliary(server/socks4a) > edit lib/msf/ui/console/command_dispatcher/jobs.rb
[*] Reloading /root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb
msf5 auxiliary(server/socks4a) > jobs -k 0
[*] Stopping the following job(s): 0
[*] Stopping job 0

[*] Stopping the socks4a proxy server
msf5 auxiliary(server/socks4a) > jobs

Jobs
====

No active jobs.

msf5 auxiliary(server/socks4a) > git diff lib/msf/ui/console/command_dispatcher/jobs.rb
[*] exec: git diff lib/msf/ui/console/command_dispatcher/jobs.rb

diff --git a/lib/msf/ui/console/command_dispatcher/jobs.rb b/lib/msf/ui/console/command_dispatcher/jobs.rb
index 641cbe8e37..e67b6ce27c 100644
--- a/lib/msf/ui/console/command_dispatcher/jobs.rb
+++ b/lib/msf/ui/console/command_dispatcher/jobs.rb
@@ -213,7 +213,7 @@ module Msf
               job_list.map(&:to_s).each do |job|
                 if framework.jobs.key?(job)
                   next unless framework.jobs[job.to_s].ctx[1] # next if no payload context in the job
-                  payload_option = framework.jobs[job.to_s].ctx[1].datastore
+                  payload_option = framework.jobs[job.to_s].ctx[1]
                   persist_list.delete_if{|pjob|pjob['mod_options']['Options'] == payload_option}
                 end
               end
msf5 auxiliary(server/socks4a) > 

Sorry to reopen this but I experience the same issue with socks4 and socks5 aux.
jobs -k will not kill them
kill will not kill them
jobs -K will kill them for some reason.

msf5 auxiliary(server/socks5) > version
Framework: 5.0.83-dev
Console  : 5.0.83-dev

I did apply the fix below to the file /usr/share/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb on line 216 but same result.

This fixed it for me, but I'm not sure if this is the best / correct approach.

msf5 auxiliary(server/socks4a) > edit lib/msf/ui/console/command_dispatcher/jobs.rb
[*] Reloading /root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/jobs.rb
msf5 auxiliary(server/socks4a) > jobs -k 0
[*] Stopping the following job(s): 0
[*] Stopping job 0

[*] Stopping the socks4a proxy server
msf5 auxiliary(server/socks4a) > jobs

Jobs
====

No active jobs.

msf5 auxiliary(server/socks4a) > git diff lib/msf/ui/console/command_dispatcher/jobs.rb
[*] exec: git diff lib/msf/ui/console/command_dispatcher/jobs.rb

diff --git a/lib/msf/ui/console/command_dispatcher/jobs.rb b/lib/msf/ui/console/command_dispatcher/jobs.rb
index 641cbe8e37..e67b6ce27c 100644
--- a/lib/msf/ui/console/command_dispatcher/jobs.rb
+++ b/lib/msf/ui/console/command_dispatcher/jobs.rb
@@ -213,7 +213,7 @@ module Msf
               job_list.map(&:to_s).each do |job|
                 if framework.jobs.key?(job)
                   next unless framework.jobs[job.to_s].ctx[1] # next if no payload context in the job
-                  payload_option = framework.jobs[job.to_s].ctx[1].datastore
+                  payload_option = framework.jobs[job.to_s].ctx[1]
                   persist_list.delete_if{|pjob|pjob['mod_options']['Options'] == payload_option}
                 end
               end
msf5 auxiliary(server/socks4a) > 
Was this page helpful?
0 / 5 - 0 ratings

Related issues

XSecr3t picture XSecr3t  路  3Comments

bugshere picture bugshere  路  3Comments

felipee07 picture felipee07  路  3Comments

handsomebeast picture handsomebeast  路  3Comments

0x27 picture 0x27  路  3Comments