Metasploit-framework: `sessions -i <ID> -c <cmd>` returns data from previous commands

Created on 5 Feb 2018  路  2Comments  路  Source: rapid7/metasploit-framework

sessions -i <ID> -c <cmd> returns data from previous commands.

Tested with latest Metasploit from Github msf5 branch, which mettle updated to 0.3.7 (master branch uses 0.3.6).

Tested on Fedora 20, but I've noticed the issue intermittently on other OS too:

msf5 > use exploit/multi/handler 
msf5 exploit(multi/handler) > set lhost 172.16.191.244
lhost => 172.16.191.244
msf5 exploit(multi/handler) > set lport 1337
lport => 1337
msf5 exploit(multi/handler) > set payload cmd/unix/reverse_netcat
payload => cmd/unix/reverse_netcat
msf5 exploit(multi/handler) > run

[*] Started reverse TCP handler on 172.16.191.244:1337 
[*] Command shell session 1 opened (172.16.191.244:1337 -> 172.16.191.137:38546) at 2018-02-05 07:53:48 -0500

id
uid=1000(user) gid=1000(user) groups=1000(user),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
pwd
/home/user
^Z
Background session 1? [y/N]  y

msf5 exploit(multi/handler) > sessions

Active sessions
===============

  Id  Name  Type            Information  Connection
  --  ----  ----            -----------  ----------
  1         shell cmd/unix               172.16.191.244:1337 -> 172.16.191.137:38546 (172.16.191.137)

msf5 exploit(multi/handler) > sessions -i 1 -c "uname -a"
[*] Running 'uname -a' on shell session 1 (172.16.191.137)
uid=1000(user) gid=1000(user) groups=1000(user),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
/home/user
Linux localhost.localdomain 3.19.8-100.fc20.x86_64 #1 SMP Tue May 12 17:08:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Data from subsequent commands after the first instance are ok:

msf5 exploit(multi/handler) > sessions -i 1 -c "id"
[*] Running 'id' on shell session 1 (172.16.191.137)
uid=1000(user) gid=1000(user) groups=1000(user),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

msf5 exploit(multi/handler) > sessions -i 1 -c "id"
[*] Running 'id' on shell session 1 (172.16.191.137)
uid=1000(user) gid=1000(user) groups=1000(user),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Stale bug

Most helpful comment

Fixing this is one of the purposes of https://github.com/rapid7/metasploit-framework/pull/9356

All 2 comments

Fixing this is one of the purposes of https://github.com/rapid7/metasploit-framework/pull/9356

Hi!

This issue has been left open with no activity for a while now.

We get a lot of issues, so we currently close issues after 60 days of inactivity. It鈥檚 been at least 30 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kali64amd picture kali64amd  路  39Comments

akefallonitis picture akefallonitis  路  28Comments

TheBrokenWasp picture TheBrokenWasp  路  28Comments

nixawk picture nixawk  路  56Comments

esfomeado picture esfomeado  路  35Comments