@@ -26,6 +26,7 @@ def initialize(info = {})
26
26
[
27
27
OptString . new ( 'SERVICE_NAME' , [ false , 'The service name' , nil ] ) ,
28
28
OptString . new ( 'SERVICE_DISPLAY_NAME' , [ false , 'The service display name' , nil ] ) ,
29
+ OptString . new ( 'SERVICE_DESCRIPTION' , [ false , "Service description to to be used on target for pretty listing" , nil ] )
29
30
] , self . class )
30
31
end
31
32
@@ -39,6 +40,10 @@ def display_name
39
40
@display_name ||= rand_text_alpha ( 16 )
40
41
end
41
42
43
+ def service_description
44
+ @service_description ||= datastore [ 'SERVICE_DESCRIPTION' ]
45
+ end
46
+
42
47
# Retrives output from the executed command
43
48
#
44
49
# @param smbshare [String] The SMBshare to connect to. Usually C$
@@ -164,6 +169,25 @@ def close_service_handle(svc_handle)
164
169
svc_status
165
170
end
166
171
172
+ def change_service_description ( svc_handle , service_description )
173
+ svc_status = nil
174
+ stubdata =
175
+ svc_handle +
176
+ NDR . long ( 1 ) + # dwInfoLevel = SERVICE_CONFIG_DESCRIPTION
177
+ NDR . long ( 1 ) + # lpInfo -> *SERVICE_DESCRIPTION
178
+ NDR . long ( 0x0200 ) + # SERVICE_DESCRIPTION struct
179
+ NDR . long ( 0x04000200 ) +
180
+ NDR . wstring ( service_description )
181
+ begin
182
+ response = dcerpc . call ( 0x25 , stubdata ) # ChangeServiceConfig2
183
+ svc_status = response . unpack ( 'V' ) . first
184
+ rescue Rex ::Proto ::DCERPC ::Exceptions ::Fault => e
185
+ print_error ( "#{ peer } - Error changing service description : #{ e } " )
186
+ end
187
+
188
+ svc_status
189
+ end
190
+
167
191
# Executes a single windows command.
168
192
#
169
193
# If you want to retrieve the output of your command you'll have to
@@ -176,7 +200,7 @@ def close_service_handle(svc_handle)
176
200
# @param command [String] Should be a valid windows command
177
201
# @param disconnect [Boolean] Disconnect afterwards
178
202
# @return [Boolean] Whether everything went well
179
- def psexec ( command , disconnect = true , servicedescription = nil )
203
+ def psexec ( command , disconnect = true )
180
204
simple . connect ( "\\ \\ #{ datastore [ 'RHOST' ] } \\ IPC$" )
181
205
handle = dcerpc_handle ( '367abb81-9844-35f1-ad32-98f038001003' , '2.0' , 'ncacn_np' , [ "\\ svcctl" ] )
182
206
vprint_status ( "#{ peer } - Binding to #{ handle } ..." )
@@ -214,18 +238,7 @@ def psexec(command, disconnect=true, servicedescription=nil)
214
238
215
239
if service_description
216
240
vprint_status ( "#{ peer } - Changing service description..." )
217
- stubdata =
218
- svc_handle +
219
- NDR . long ( 1 ) + # dwInfoLevel = SERVICE_CONFIG_DESCRIPTION
220
- NDR . long ( 1 ) + # lpInfo -> *SERVICE_DESCRIPTION
221
- NDR . long ( 0x0200 ) + # SERVICE_DESCRIPTION struct
222
- NDR . long ( 0x04000200 ) +
223
- NDR . wstring ( service_description )
224
- begin
225
- response = dcerpc . call ( 0x25 , stubdata ) # ChangeServiceConfig2
226
- rescue Rex ::Proto ::DCERPC ::Exceptions ::Fault => e
227
- print_error ( "#{ peer } - Error changing service description : #{ e } " )
228
- end
241
+ change_service_description ( svc_handle , service_description )
229
242
end
230
243
231
244
vprint_status ( "#{ peer } - Starting the service..." )
0 commit comments