@@ -77,32 +77,42 @@ func (serveShell *Server) CreateFlags() {
77
77
}
78
78
79
79
// load the provided file into memory. Generate the random filename.
80
- func (serveShell * Server ) Init (channel * channel.Channel ) bool {
81
- if channel .Shutdown == nil {
80
+ func (serveShell * Server ) Init (ch * channel.Channel ) bool {
81
+ if ch .Shutdown == nil {
82
82
// Initialize the shutdown atomic. This lets us not have to define it if the C2 is manually
83
83
// configured.
84
84
var shutdown atomic.Bool
85
85
shutdown .Store (false )
86
- channel .Shutdown = & shutdown
86
+ ch .Shutdown = & shutdown
87
87
}
88
- serveShell .channel = channel
88
+ serveShell .channel = ch
89
89
if len (serveShell .HTTPAddr ) == 0 {
90
90
output .PrintFrameworkError ("User must specify -httpServeFile.BindAddr" )
91
91
92
92
return false
93
93
}
94
- channel .HTTPAddr = serveShell .HTTPAddr
95
- channel .HTTPPort = serveShell .HTTPPort
94
+ ch .HTTPAddr = serveShell .HTTPAddr
95
+ ch .HTTPPort = serveShell .HTTPPort
96
96
97
- if ! httpservefile .GetInstance ().Init (channel ) {
97
+ if ! httpservefile .GetInstance ().Init (ch ) {
98
98
return false
99
99
}
100
100
101
+ // Initialize the shell server channels with variables from upstream
102
+ var shutdown atomic.Bool
103
+ shutdown .Store (false )
104
+ shellChannel := & channel.Channel {
105
+ IPAddr : ch .IPAddr ,
106
+ Port : ch .Port ,
107
+ IsClient : false ,
108
+ Shutdown : & shutdown ,
109
+ }
110
+ shellChannel .Shutdown = & shutdown
101
111
if serveShell .SSLShell {
102
- return sslshell .GetInstance ().Init (channel )
112
+ return sslshell .GetInstance ().Init (shellChannel )
103
113
}
104
114
105
- return simpleshell .GetServerInstance ().Init (channel )
115
+ return simpleshell .GetServerInstance ().Init (shellChannel )
106
116
}
107
117
108
118
// Shutdown triggers the shutdown for all running C2s.
@@ -154,7 +164,6 @@ func (serveShell *Server) Run(timeout int) {
154
164
go func () {
155
165
for {
156
166
if sslshell .GetInstance ().Channel ().Shutdown .Load () {
157
- sslshell .GetInstance ().Shutdown ()
158
167
wg .Done ()
159
168
160
169
break
@@ -167,7 +176,6 @@ func (serveShell *Server) Run(timeout int) {
167
176
go func () {
168
177
for {
169
178
if simpleshell .GetServerInstance ().Channel ().Shutdown .Load () {
170
- simpleshell .GetServerInstance ().Shutdown ()
171
179
wg .Done ()
172
180
173
181
break
0 commit comments