Skip to content

Commit 871c30c

Browse files
committed
refactor stdapi and lanattacks to use filter_commands
1 parent e9c9c85 commit 871c30c

File tree

7 files changed

+7
-90
lines changed

7 files changed

+7
-90
lines changed

lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def commands
2929
"dhcp_load_options" => "Load DHCP optionis from a datastore",
3030
"dhcp_log" => "Log DHCP server activity"
3131
}
32-
3332
reqs = {
3433
"dhcp_start" => [ "lanattacks_start_dhcp" ],
3534
"dhcp_stop" => [ "lanattacks_stop_dhcp" ],
@@ -38,19 +37,7 @@ def commands
3837
"dhcp_load_options" => [ "lanattacks_set_dhcp_option" ],
3938
"dhcp_log" => [ "lanattacks_dhcp_log" ]
4039
}
41-
42-
all.delete_if do |cmd, desc|
43-
del = false
44-
reqs[cmd].each do |req|
45-
next if client.commands.include? req
46-
del = true
47-
break
48-
end
49-
50-
del
51-
end
52-
53-
all
40+
filter_commands(all, reqs)
5441
end
5542

5643
#

lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,13 @@ def commands
2727
"tftp_reset" => "Reset the TFTP server",
2828
"tftp_add_file" => "Add a file to the TFTP server"
2929
}
30-
3130
reqs = {
3231
"tftp_start" => [ "lanattacks_start_tftp" ],
3332
"tftp_stop" => [ "lanattacks_stop_tftp" ],
3433
"tftp_reset" => [ "lanattacks_reset_tftp" ],
3534
"tftp_add_file" => [ "lanattacks_add_tftp_file" ],
3635
}
37-
38-
all.delete_if do |cmd, desc|
39-
del = false
40-
reqs[cmd].each do |req|
41-
next if client.commands.include? req
42-
del = true
43-
break
44-
end
45-
46-
del
47-
end
48-
49-
all
36+
filter_commands(all, reqs)
5037
end
5138

5239
#

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,7 @@ def commands
102102
'show_mount' => ['stdapi_fs_mount_show'],
103103
}
104104

105-
all.delete_if do |cmd, desc|
106-
del = false
107-
reqs[cmd].each do |req|
108-
next if client.commands.include? req
109-
del = true
110-
break
111-
end
112-
113-
del
114-
end
115-
116-
all
105+
filter_commands(all, reqs)
117106
end
118107

119108
#

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,7 @@ def commands
108108
'resolve' => ['stdapi_net_resolve_host'],
109109
}
110110

111-
all.delete_if do |cmd, desc|
112-
del = false
113-
reqs[cmd].each do |req|
114-
next if client.commands.include? req
115-
del = true
116-
break
117-
end
118-
119-
del
120-
end
121-
122-
all
111+
filter_commands(all, reqs)
123112
end
124113

125114
#

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,7 @@ def commands
143143
"sysinfo" => [ "stdapi_sys_config_sysinfo" ],
144144
"localtime" => [ "stdapi_sys_config_localtime" ],
145145
}
146-
147-
all.delete_if do |cmd, desc|
148-
del = false
149-
reqs[cmd].each do |req|
150-
next if client.commands.include? req
151-
del = true
152-
break
153-
end
154-
155-
del
156-
end
157-
158-
all
146+
filter_commands(all, reqs)
159147
end
160148

161149
#

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,7 @@ def commands
4949
"stdapi_ui_enable_keyboard"
5050
]
5151
}
52-
53-
all.delete_if do |cmd, desc|
54-
del = false
55-
reqs[cmd].each do |req|
56-
next if client.commands.include? req
57-
del = true
58-
break
59-
end
60-
61-
del
62-
end
63-
64-
all
52+
filter_commands(all, reqs)
6553
end
6654

6755
#

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,7 @@ def commands
3434
"webcam_stream" => [ "webcam_start", "webcam_get_frame", "webcam_stop" ],
3535
"record_mic" => [ "webcam_audio_record" ]
3636
}
37-
38-
all.delete_if do |cmd, _desc|
39-
del = false
40-
reqs[cmd].each do |req|
41-
next if client.commands.include? req
42-
del = true
43-
break
44-
end
45-
del
46-
end
47-
48-
all
37+
filter_commands(all, reqs)
4938
end
5039

5140
#

0 commit comments

Comments
 (0)