Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

get_application_list.rb 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ##
  2. # WARNING: Metasploit no longer maintains or accepts meterpreter scripts.
  3. # If you'd like to improve this script, please try to port it as a post
  4. # module instead. Thank you.
  5. ##
  6. # Meterpreter script for listing installed applications and their version.
  7. # Provided: carlos_perez[at]darkoperator[dot]com
  8. #Options and Option Parsing
  9. opts = Rex::Parser::Arguments.new(
  10. "-h" => [ false, "Help menu." ]
  11. )
  12. def app_list
  13. tbl = Rex::Text::Table.new(
  14. 'Header' => "Installed Applications",
  15. 'Indent' => 1,
  16. 'Columns' => [
  17. "Name",
  18. "Version"
  19. ])
  20. appkeys = ['HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
  21. 'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall' ]
  22. threadnum = 0
  23. a = []
  24. appkeys.each do |keyx86|
  25. soft_keys = registry_enumkeys(keyx86)
  26. if soft_keys
  27. soft_keys.each do |k|
  28. if threadnum < 10
  29. a.push(::Thread.new {
  30. begin
  31. dispnm = registry_getvaldata("#{keyx86}\\#{k}","DisplayName")
  32. dispversion = registry_getvaldata("#{keyx86}\\#{k}","DisplayVersion")
  33. if dispnm =~ /\S*/
  34. tbl << [dispnm,dispversion]
  35. end
  36. rescue
  37. end
  38. })
  39. threadnum += 1
  40. else
  41. sleep(0.05) and a.delete_if {|x| not x.alive?} while not a.empty?
  42. threadnum = 0
  43. end
  44. end
  45. end
  46. end
  47. print_line("\n" + tbl.to_s + "\n")
  48. end
  49. opts.parse(args) { |opt, idx, val|
  50. case opt
  51. when "-h"
  52. print_line "Meterpreter Script for extracting a list installed applications and their version."
  53. print_line(opts.usage)
  54. raise Rex::Script::Completed
  55. end
  56. }
  57. if client.platform == 'windows'
  58. app_list
  59. else
  60. print_error("This version of Meterpreter is not supported with this Script!")
  61. raise Rex::Script::Completed
  62. end