Skip to content

Commit

Permalink
Merge pull request #1705 from BishopFox/autoremove_socks_proxies
Browse files Browse the repository at this point in the history
autoremove socks proxies
  • Loading branch information
rkervella authored Jun 3, 2024
2 parents 05408ef + 6790cd1 commit 6f4a150
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/command/kill/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions client/command/sessions/close.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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),
Expand Down

0 comments on commit 6f4a150

Please sign in to comment.