Update the sessions functionality
The use_any_session_to_target
is almost a deprecated feature since it supports only the tunnel_peer
argument (currently the target's IP). Another problem is that the session's tunnel_peer
can be even a different address in some cases (reverse shell (using docker_priv_esc from the metasploitable3) from target:56788 to attacker:4444, now we create a new session with the first one and the link can be from attacker:4444 to attacker:4445 - needs to be tested). In such a case, we have to go through each session and check if it's bound to another session, therefore leading to the correct target.
What would also be nice to add is to allow the user to use the easy way to define his target sessions (same as now) or to define his session using the available parameters, or their combination:
use_any_session_to_target: <target_ip>
use_any_session:
target_ip: <target_ip>
via_exploit: <exploit_name>
type: <session_type>
To push the functionality even further, it would be nice if the user could filter using the time the session was created (optionally, we could use the information).