Linux post Module for enumerating startup of configured services

git-svn-id: file:///home/svn/framework3/trunk@12807 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Carlos Perez 2011-06-01 22:51:50 +00:00
parent 849600d31e
commit e030fb0a1e
1 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,82 @@
# $Id: enum_packages.rb 12796 2011-06-01 11:52:36Z darkoperator $
##
##
# ## This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
require 'rex'
require 'msf/core/post/common'
require 'msf/core/post/file'
require 'msf/core/post/linux/system'
class Metasploit3 < Msf::Post
include Msf::Post::Common
include Msf::Post::File
include Msf::Post::System
def initialize(info={})
super( update_info( info,
'Name' => 'Linux Gather Configured Services',
'Description' => %q{ Post Module to enumerate Services on a Linux System},
'License' => MSF_LICENSE,
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
'Version' => '$Revision: 12796 $',
'Platform' => [ 'linux' ],
'SessionTypes' => [ 'shell' ]
))
register_options(
[
OptBool.new('VERBOSE', [false, 'Show list of Packages.', false]),
], self.class)
end
# Run Method for when run command is issued
def run
distro = linux_ver
store_loot("linux.version", "text/plain", session, "Distro: #{distro[:distro]}, Version: #{distro[:version]}, Kernel: #{distro[:kernel]}", "linux_info.txt", "Linux Version")
# Print the info
print_good("Info:")
print_good("\t#{distro[:version]}")
print_good("\t#{distro[:kernel]}")
installed_pkg = get_services(distro[:distro])
pkg_loot = store_loot("linux.services", "text/plain", session, installed_pkg, "configured_services.txt", "Linux Configured Services")
print_status("Service list saved to loot file: #{pkg_loot}")
if datastore['VERBOSE']
print_good("Services:")
# Print the Packages
installed_pkg.each_line do |p|
print_good("\t#{p.chomp}")
end
end
end
def get_services(distro)
services_installed = ""
if distro =~ /fedora|redhat|suse|mandrake/
services_installed = cmd_exec("/sbin/chkconfig --list")
elsif distro =~ /slackware/
services_installed << "\nEnabled:\n*************************\n"
services_installed << cmd_exec("ls -F /etc/rc.d | /bin/grep \'*$\'")
services_installed << "\n\nDisabled:\n*************************\n"
services_installed << cmd_exec("ls -F /etc/rc.d | /bin/grep \'[a-z0-9A-z]$\'")
elsif distro =~ /ubuntu|debian/
services_installed = cmd_exec("/usr/bin/service --status-all")
elsif distro =~ /gentoo/
services_installed = cmd_exec("/bin/rc-status --all")
else
print_error("Could not determine the Linux Distribution to get list of configured services")
end
return services_installed
end
end