@@ -715,27 +715,34 @@ def cmd_threads_tabs(str, words)
715
715
end
716
716
717
717
def cmd_load_help
718
- print_line "Usage: load <path > [var=val var=val ...]"
718
+ print_line "Usage: load <option > [var=val var=val ...]"
719
719
print_line
720
- print_line "Loads a plugin from the supplied path. If path is not absolute, first looks"
721
- print_line "in the user's plugin directory (#{ Msf ::Config . user_plugin_directory } ) then"
722
- print_line "in the framework root plugin directory (#{ Msf ::Config . plugin_directory } )."
720
+ print_line "Loads a plugin from the supplied path."
721
+ print_line "For a list of built-in plugins, do: load -l"
723
722
print_line "The optional var=val options are custom parameters that can be passed to plugins."
724
723
print_line
725
724
end
726
725
727
- #
728
- # Loads a plugin from the supplied path. If no absolute path is supplied,
729
- # the framework root plugin directory is used.
730
- #
731
- def cmd_load ( *args )
732
- if ( args . length == 0 )
733
- cmd_load_help
734
- return false
726
+ def list_plugins
727
+ plugin_directories = {
728
+ 'Framework' => Msf ::Config . plugin_directory ,
729
+ 'User' => Msf ::Config . user_plugin_directory
730
+ }
731
+
732
+ plugin_directories . each do |type , plugin_directory |
733
+ items = Dir . entries ( plugin_directory ) . keep_if { |n | n . match ( /^.+\. rb$/ ) }
734
+ next if items . empty?
735
+ print_status ( "Available #{ type } plugins:" )
736
+ items . each do |item |
737
+ print_line ( " * #{ item . split ( '.' ) . first } " )
738
+ end
739
+ print_line
735
740
end
741
+ end
742
+
743
+ def load_plugin ( args )
744
+ path = args [ 0 ]
736
745
737
- # Default to the supplied argument path.
738
- path = args . shift
739
746
opts = {
740
747
'LocalInput' => driver . input ,
741
748
'LocalOutput' => driver . output ,
@@ -759,7 +766,6 @@ def cmd_load(*args)
759
766
# If the following "path" doesn't exist it will be caught when we attempt to load
760
767
path = Msf ::Config . plugin_directory + File ::SEPARATOR + plugin_file_name
761
768
end
762
-
763
769
end
764
770
765
771
# Load that plugin!
@@ -773,6 +779,21 @@ def cmd_load(*args)
773
779
end
774
780
end
775
781
782
+ #
783
+ # Loads a plugin from the supplied path. If no absolute path is supplied,
784
+ # the framework root plugin directory is used.
785
+ #
786
+ def cmd_load ( *args )
787
+ case args [ 0 ]
788
+ when '-l'
789
+ list_plugins
790
+ when '-h' , nil , ''
791
+ cmd_load_help
792
+ else
793
+ load_plugin ( args )
794
+ end
795
+ end
796
+
776
797
#
777
798
# Tab completion for the load command
778
799
#
0 commit comments