Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nesting error and Crash When Debugging #65

Closed
gwillcox-r7 opened this issue Oct 12, 2022 · 3 comments · Fixed by ruby/debug#774
Closed

Nesting error and Crash When Debugging #65

gwillcox-r7 opened this issue Oct 12, 2022 · 3 comments · Fixed by ruby/debug#774

Comments

@gwillcox-r7
Copy link

Seem to keep getting this nesting error after I leave the debugger idle for too long:

["DEBUGGER Exception: /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:1108",
 #<NoMethodError: undefined method `nesting' for Msf::Module:Class>,
 ["(eval):1:in `check'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:914:in `eval'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:914:in `search_const'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:853:in `process_dap'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:1097:in `wait_next_action_'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:797:in `wait_next_action'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:310:in `suspend'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:344:in `block in step_tp'",
  "/home/gwillcox/git/metasploit-framework/modules/exploits/unix/http/pfsense_pfblockerng_webshell.rb:107:in `check'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/exploit/remote/auto_check.rb:44:in `with_prepended_auto_check'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/exploit/remote/auto_check.rb:26:in `exploit'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/exploit_driver.rb:228:in `job_run_proc'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/exploit_driver.rb:181:in `run'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/base/simple/exploit.rb:144:in `exploit_simple'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/base/simple/exploit.rb:171:in `exploit_simple'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/exploit.rb:45:in `exploit_single'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/exploit.rb:182:in `cmd_exploit'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in `run_command'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in `block in run_single'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `each'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `run_single'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/shell.rb:162:in `run'",
  "/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'",
  "/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'",
  "/home/gwillcox/git/metasploit-framework/msfconsole:23:in `<main>'"]]
[-] Exploit failed: NoMethodError undefined method `nesting' for Msf::Module:Class

Any reason this might be occurring?

@ko1
Copy link
Collaborator

ko1 commented Oct 13, 2022

Ah, I see. I will workaround into debug.gem but not sure it solves the issue.

If you can, could you try this patch?

diff --git a/lib/debug/thread_client.rb b/lib/debug/thread_client.rb
index 5f2d100..0a0cb00 100644
--- a/lib/debug/thread_client.rb
+++ b/lib/debug/thread_client.rb
@@ -568,7 +568,7 @@ module DEBUGGER__
         unless only_self
           s.ancestors.each{|c| break if c == Object; cs[c] = :ancestors}
           if b = current_frame&.binding
-            b.eval('Module.nesting').each{|c| cs[c] = :nesting unless cs.has_key? c}
+            b.eval('::Module.nesting').each{|c| cs[c] = :nesting unless cs.has_key? c}
           end
         end

@gwillcox-r7
Copy link
Author

gwillcox-r7 commented Oct 13, 2022

Edit: Was apparently working but then hit the issue again with the patch. Here is the stack trace:

["DEBUGGER Exception: /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:1108",
 #<NoMethodError: undefined method `nesting' for Msf::Module:Class>,
 ["(eval):1:in `block in run'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:914:in `eval'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:914:in `search_const'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:853:in `process_dap'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:1097:in `wait_next_action_'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:797:in `wait_next_action'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:310:in `suspend'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:344:in `block in step_tp'",
  "/home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc1_cert_finder.rb:388:in `block in run'",
  "/home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc1_cert_finder.rb:383:in `each'",
  "/home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc1_cert_finder.rb:383:in `run'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/base/simple/auxiliary.rb:178:in `job_run_proc'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/base/simple/auxiliary.rb:85:in `run_simple'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/base/simple/auxiliary.rb:96:in `run_simple'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/auxiliary.rb:82:in `block in cmd_run'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:62:in `block in each'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:151:in `<<'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:151:in `block (3 levels) in parse'",
  "/home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rex-socket-0.1.43/lib/rex/socket/range_walker.rb:234:in `each_host'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:146:in `block (2 levels) in parse'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:114:in `each'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:114:in `block in parse'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:61:in `each'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:61:in `each'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/core/rhosts_walker.rb:61:in `each'",
  "/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/auxiliary.rb:78:in `cmd_run'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in `run_command'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in `block in run_single'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `each'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `run_single'",
  "/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/shell.rb:162:in `run'",
  "/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'",
  "/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'",
  "/home/gwillcox/git/metasploit-framework/msfconsole:23:in `<main>'"]]
[-] Auxiliary failed: NoMethodError undefined method `nesting' for Msf::Module:Class
[-] Call stack:
[-]   (eval):1:in `block in run'
[-]   /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:914:in `eval'
[-]   /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:914:in `search_const'
[-]   /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/server_dap.rb:853:in `process_dap'
[-]   /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:1097:in `wait_next_action_'
[-]   /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:797:in `wait_next_action'
[-]   /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:310:in `suspend'
[-]   /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/debug-1.6.2/lib/debug/thread_client.rb:344:in `block in step_tp'
[-]   /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc1_cert_finder.rb:388:in `block in run'
[-]   /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc1_cert_finder.rb:383:in `each'
[-]   /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc1_cert_finder.rb:383:in `run'
[*] Auxiliary module execution completed

ko1 added a commit to ruby/debug that referenced this issue Oct 24, 2022
@ko1
Copy link
Collaborator

ko1 commented Oct 24, 2022

Thank you above PR will fix this issue.

ko1 added a commit to ruby/debug that referenced this issue Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants