File tree Expand file tree Collapse file tree 7 files changed +28
-0
lines changed Expand file tree Collapse file tree 7 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ func (httpServer *Server) Channel() *channel.Channel {
105
105
106
106
// Shutdown the C2 server and cleanup all the sessions.
107
107
func (httpServer * Server ) Shutdown () bool {
108
+ // Account for non-running case
109
+ if httpServer .Channel () == nil {
110
+ return true
111
+ }
108
112
output .PrintFrameworkStatus ("Shutting down the HTTP Server" )
109
113
if len (httpServer .Channel ().Sessions ) > 0 {
110
114
for k := range httpServer .Channel ().Sessions {
Original file line number Diff line number Diff line change @@ -119,6 +119,10 @@ func (serveShell *Server) Init(ch *channel.Channel) bool {
119
119
120
120
// Shutdown triggers the shutdown for all running C2s.
121
121
func (serveShell * Server ) Shutdown () bool {
122
+ // Account for non-running case
123
+ if serveShell .Channel () == nil {
124
+ return true
125
+ }
122
126
// This is a bit confusing at first glance, but it solves the fact that this c2 doesn't directly
123
127
// keep track of sessions and we can't differentiate between a timeout "done" and a signal "done".
124
128
// What this means is that if a underlying shell server has sessions that we want to keep open for
Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ func (httpServer *Server) Channel() *channel.Channel {
131
131
132
132
// Shutdown the C2 server and cleanup all the sessions.
133
133
func (httpServer * Server ) Shutdown () bool {
134
+ // Account for non-running case
135
+ if httpServer .Channel () == nil {
136
+ return true
137
+ }
134
138
output .PrintFrameworkStatus ("Shutting down the HTTP Server" )
135
139
if len (httpServer .Channel ().Sessions ) > 0 {
136
140
for k := range httpServer .Channel ().Sessions {
Original file line number Diff line number Diff line change @@ -159,6 +159,10 @@ func (shellTunnel *Server) Init(channel *channel.Channel) bool {
159
159
}
160
160
161
161
func (shellTunnel * Server ) Shutdown () bool {
162
+ // Account for non-running case
163
+ if shellTunnel .Channel () == nil {
164
+ return true
165
+ }
162
166
output .PrintFrameworkStatus ("C2 received shutdown, killing server and client sockets for shell tunnel" )
163
167
if len (shellTunnel .Channel ().Sessions ) > 0 {
164
168
for k , session := range shellTunnel .Channel ().Sessions {
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ func (shellClient *Client) CreateFlags() {
31
31
}
32
32
33
33
func (shellClient * Client ) Shutdown () bool {
34
+ // Account for non-running case
35
+ if shellClient .Channel () == nil {
36
+ return true
37
+ }
34
38
ok := shellClient .Channel ().RemoveSessions ()
35
39
36
40
// we done here
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ func (shellServer *Server) Channel() *channel.Channel {
45
45
46
46
// Shutdown the C2 and cleanup any active connections.
47
47
func (shellServer * Server ) Shutdown () bool {
48
+ // Account for non-running case
49
+ if shellServer .Channel () == nil {
50
+ return true
51
+ }
48
52
output .PrintFrameworkStatus ("C2 received shutdown, killing server and client sockets for shell server" )
49
53
if len (shellServer .Channel ().Sessions ) > 0 {
50
54
for k , session := range shellServer .Channel ().Sessions {
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ func (shellServer *Server) CreateFlags() {
66
66
67
67
// Shutdown the C2 and close server and client connections when applicable.
68
68
func (shellServer * Server ) Shutdown () bool {
69
+ // Account for non-running case
70
+ if shellServer .Channel () == nil {
71
+ return true
72
+ }
69
73
output .PrintFrameworkStatus ("C2 received shutdown, killing server and client sockets for SSL shell server" )
70
74
if len (shellServer .channel .Sessions ) > 0 {
71
75
for k , session := range shellServer .channel .Sessions {
You can’t perform that action at this time.
0 commit comments