Skip to content

Commit 0af363d

Browse files
author
Brent Cook
committed
more cleanup
1 parent adf30c5 commit 0af363d

File tree

1 file changed

+27
-38
lines changed

1 file changed

+27
-38
lines changed

scripts/meterpreter/multi_console_command.rb

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,17 @@
2222
"-rc" => [ true,"Text file with list of commands, one per line."]
2323
)
2424

25-
#Setting Argument variables
2625
commands = nil
2726
script = []
28-
help = 0
29-
silence = 0
30-
31-
################## Function Declarations ##################
32-
# Function for running a list of commands stored in a array, returs string
33-
def list_con_exec(cmdlst, silence)
34-
print_status("Running Command List ...")
35-
cmdout = ""
36-
cmdlst.each do |cmd|
37-
next if cmd.strip.length < 1
38-
next if cmd[0,1] == "#"
39-
begin
40-
print_status "\tRunning command #{cmd}"
41-
if silence == 1
42-
@client.console.disable_output = true
43-
end
44-
45-
@client.console.run_single(cmd)
46-
47-
if silence == 1
48-
@client.console.disable_output = false
49-
end
50-
51-
rescue ::Exception => e
52-
print_status("Error Running Command #{cmd}: #{e.class} #{e}")
53-
end
54-
end
55-
cmdout
56-
end
57-
27+
help = false
28+
silence = false
5829

5930
def usage
6031
print_line("Console Multi Command Execution Meterpreter Script ")
6132
print_line(@@exec_opts.usage)
6233
raise Rex::Script::Completed
6334
end
64-
################## Main ##################
35+
6536
@@exec_opts.parse(args) { |opt, idx, val|
6637
case opt
6738

@@ -79,16 +50,34 @@ def usage
7950
end
8051

8152
when "-h"
82-
help = 1
53+
help = true
8354
when "-sl"
84-
silence = 1
55+
silence = true
8556
end
8657
}
8758

88-
if args.length == 0 or help == 1 or commands.nil?
59+
if args.length == 0 or help or commands.nil?
8960
usage
90-
else
91-
list_con_exec(commands, silence)
92-
raise Rex::Script::Completed
9361
end
9462

63+
print_status("Running Command List ...")
64+
65+
commands.each do |cmd|
66+
next if cmd.strip.length < 1
67+
next if cmd[0,1] == "#"
68+
begin
69+
print_status "\tRunning command #{cmd}"
70+
if silence
71+
@client.console.disable_output = true
72+
end
73+
74+
@client.console.run_single(cmd)
75+
76+
if silence
77+
@client.console.disable_output = false
78+
end
79+
80+
rescue ::Exception => e
81+
print_status("Error Running Command #{cmd}: #{e.class} #{e}")
82+
end
83+
end

0 commit comments

Comments
 (0)