Metasploit mailing list archives
Re: Catching exploit exceptions in rc script
From: Joshua Smith <lazydj98 () gmail com>
Date: Tue, 26 Jun 2012 11:51:14 -0500
If your sole intent is to ensure the rc script continues, just don't rescue it at all. The rc script will continue regardless of the outcome of the run_single. You also may want -j and possibly -q for quiet and have your output/logging come from your post mod. -Josh On Jun 26, 2012, at 10:46 AM, birchfresh wrote:
Hello there. I'm using msfconsole (newest git) to run a rc script that's essentially something like: <ruby> run_single("use windows/smb/psexec") # [...] old_sessions = framework.sessions.keys.clone run_single("exploit -z") rescue nil # script stops here after exception! new_session = (old_sessions - framework.sessions.keys).first do_something_with(new_session) if new_session </ruby> My problem is that if the exploit raises an exception, the script refuses continue until I press ^C. Shouldn't "rescue nil" catch the exception? I tried to work around it by running the exploit as a background job (exploit -z -j) and waiting for framework.jobs.length to be decremented, but it's no good: If there's an exception, the job hangs around forever. For context, I'm doing the following to a number of hosts, one by one: Pivoted login with the psexec module, run a post module to gather some data, kill the session, move on to the next host. Is there a better way to open a session (and get its number) than to run_single("exploit -z") and poke around in framework.sessions.keys for newcomers? Or, as a last resort: Is there a way to tell if the exploit at framework.jobs[id] is dead? _______________________________________________ https://mail.metasploit.com/mailman/listinfo/framework
_______________________________________________ https://mail.metasploit.com/mailman/listinfo/framework
Current thread:
- Catching exploit exceptions in rc script birchfresh (Jun 26)
- Re: Catching exploit exceptions in rc script Joshua Smith (Jun 26)
- Message not available
- Re: Catching exploit exceptions in rc script birchfresh (Jun 26)
- Re: Catching exploit exceptions in rc script Joshua Smith (Jun 26)
- Message not available
- Message not available
- Message not available
- Re: Catching exploit exceptions in rc script birchfresh (Jun 26)
- Message not available