@@ -152,6 +152,35 @@ func CreateFlags(implementation Impl) {
152152 }
153153}
154154
155+ // HadSessions returns if the underlying channel has any sessions, regardless of their Active value.
156+ func HadSessions (implementation Impl ) bool {
157+ switch implementation .Category {
158+ case SimpleShellServerCategory :
159+ return simpleshell .GetServerInstance ().Channel ().HadSessions ()
160+ case SimpleShellClientCategory :
161+ return simpleshell .GetClientInstance ().Channel ().HadSessions ()
162+ case SSLShellServerCategory :
163+ return sslshell .GetInstance ().Channel ().HadSessions ()
164+ case HTTPServeFileCategory :
165+ return httpservefile .GetInstance ().Channel ().HadSessions ()
166+ case HTTPServeShellCategory :
167+ return httpserveshell .GetInstance ().Channel ().HadSessions ()
168+ case ExternalCategory :
169+ if implementation .Name != "" {
170+ return external .GetInstance (implementation .Name ).Channel ().HadSessions ()
171+ }
172+ case HTTPShellServerCategory :
173+ return httpshellserver .GetInstance ().Channel ().HadSessions ()
174+ case ShellTunnelCategory :
175+ return shelltunnel .GetInstance ().Channel ().HadSessions ()
176+ case InvalidCategory :
177+ default :
178+ }
179+ output .PrintFrameworkError ("Invalid C2 Server" )
180+
181+ return false
182+ }
183+
155184// HasSessions returns if the underlying channel has active sessions. This is useful for code that
156185// needs to validate if callbacks have occurred and is a helper wrapper around the channel package
157186// function of the same name.
0 commit comments