diff --git a/client/command/kill/kill.go b/client/command/kill/kill.go index 250a104e95..700836de68 100644 --- a/client/command/kill/kill.go +++ b/client/command/kill/kill.go @@ -26,6 +26,7 @@ import ( "github.com/spf13/cobra" "github.com/bishopfox/sliver/client/console" + "github.com/bishopfox/sliver/client/core" "github.com/bishopfox/sliver/protobuf/clientpb" "github.com/bishopfox/sliver/protobuf/commonpb" "github.com/bishopfox/sliver/protobuf/sliverpb" @@ -74,6 +75,16 @@ func KillSession(session *clientpb.Session, cmd *cobra.Command, con *console.Sli timeout, _ := cmd.Flags().GetInt64("timeout") force, _ := cmd.Flags().GetBool("force") + // remove any active socks proxies + socks := core.SocksProxies.List() + if len(socks) != 0 { + for _, p := range socks { + if p.SessionID == session.ID { + core.SocksProxies.Remove(p.ID) + } + } + } + _, err := con.Rpc.Kill(context.Background(), &sliverpb.KillReq{ Request: &commonpb.Request{ SessionID: session.ID, diff --git a/client/command/sessions/close.go b/client/command/sessions/close.go index 3968a1c11f..6d1784f568 100644 --- a/client/command/sessions/close.go +++ b/client/command/sessions/close.go @@ -22,6 +22,7 @@ import ( "context" "github.com/bishopfox/sliver/client/console" + "github.com/bishopfox/sliver/client/core" "github.com/bishopfox/sliver/protobuf/sliverpb" "github.com/spf13/cobra" ) @@ -35,6 +36,16 @@ func CloseSessionCmd(cmd *cobra.Command, con *console.SliverClient, args []strin return } + // remove any active socks proxies + socks := core.SocksProxies.List() + if len(socks) != 0 { + for _, p := range socks { + if p.SessionID == session.ID { + core.SocksProxies.Remove(p.ID) + } + } + } + // Close the session _, err := con.Rpc.CloseSession(context.Background(), &sliverpb.CloseSession{ Request: con.ActiveTarget.Request(cmd),