Parse SVN information and warns folks with out of date installations
git-svn-id: file:///home/svn/framework3/trunk@7415 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a87fc61a63
commit
5581f5a73b
|
@ -1,4 +1,5 @@
|
|||
require 'msf/core'
|
||||
require 'msf/util'
|
||||
|
||||
module Msf
|
||||
|
||||
|
@ -13,11 +14,18 @@ class Framework
|
|||
#
|
||||
# Versioning information
|
||||
#
|
||||
|
||||
Major = 3
|
||||
Minor = 3
|
||||
Release = "-beta"
|
||||
Release = "-rc1"
|
||||
Version = "#{Major}.#{Minor}#{Release}"
|
||||
Revision = "$Revision$"
|
||||
|
||||
# Repository information
|
||||
RepoRevision = ::Msf::Util::SVN.revision
|
||||
RepoUpdated = ::Msf::Util::SVN.updated
|
||||
RepoUpdatedDays = ::Msf::Util::SVN.days_since_update
|
||||
RepoUpdatedDaysNote = ::Msf::Util::SVN.last_updated_friendly
|
||||
RepoRoot = ::Msf::Util::SVN.root
|
||||
|
||||
# API Version
|
||||
APIMajor = 1
|
||||
|
@ -158,3 +166,4 @@ protected
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -172,19 +172,32 @@ class Core
|
|||
#
|
||||
def cmd_banner(*args)
|
||||
banner = Banner.to_s + "\n\n"
|
||||
banner << " =[ msf v#{Msf::Framework::Version} [core:#{Msf::Framework::VersionCore} api:#{Msf::Framework::VersionAPI}]\n"
|
||||
banner << " =[ metasploit v#{Msf::Framework::Version} [core:#{Msf::Framework::VersionCore} api:#{Msf::Framework::VersionAPI}]\n"
|
||||
banner << "+ -- --=[ "
|
||||
banner << "#{framework.stats.num_exploits} exploits - "
|
||||
banner << "#{framework.stats.num_payloads} payloads\n"
|
||||
banner << "#{framework.stats.num_exploits} exploits - #{framework.stats.num_auxiliary} auxiliary\n"
|
||||
banner << "+ -- --=[ "
|
||||
banner << "#{framework.stats.num_encoders} encoders - "
|
||||
banner << "#{framework.stats.num_nops} nops\n"
|
||||
banner << " =[ "
|
||||
banner << "#{framework.stats.num_auxiliary} aux\n"
|
||||
|
||||
oldwarn = nil
|
||||
banner << "#{framework.stats.num_payloads} payloads - #{framework.stats.num_encoders} encoders - #{framework.stats.num_nops} nops\n"
|
||||
if ( ::Msf::Framework::RepoRevision > 0)
|
||||
banner << " =[ svn r#{::Msf::Framework::RepoRevision} updated #{::Msf::Framework::RepoUpdatedDaysNote}\n"
|
||||
if(::Msf::Framework::RepoUpdatedDays > 7)
|
||||
oldwarn = []
|
||||
oldwarn << "Warning: This copy of the Metasploit Framework was last updated #{::Msf::Framework::RepoUpdatedDays}."
|
||||
oldwarn << " We recommend that you update the framework at least every other day."
|
||||
oldwarn << " For information on updating your copy of Metasploit, please see:"
|
||||
oldwarn << " http://dev.metasploit.com/redmine/projects/framework/wiki/Updating"
|
||||
oldwarn << ""
|
||||
end
|
||||
end
|
||||
banner << "\n"
|
||||
|
||||
# Display the banner
|
||||
print(banner)
|
||||
|
||||
if(oldwarn)
|
||||
oldwarn.map{|line| print_line(line) }
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -1908,3 +1921,4 @@ protected
|
|||
end
|
||||
|
||||
end end end end
|
||||
|
||||
|
|
|
@ -20,3 +20,6 @@ end
|
|||
|
||||
# Executable generation and encoding
|
||||
require 'msf/util/exe'
|
||||
|
||||
# Parse SVN entries
|
||||
require 'msf/util/svn'
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
###
|
||||
#
|
||||
# framework-util-svn
|
||||
# --------------
|
||||
#
|
||||
# The class provides methods for parsing the SVN information in the framework directory
|
||||
#
|
||||
###
|
||||
|
||||
require 'date'
|
||||
|
||||
module Msf
|
||||
module Util
|
||||
class SVN
|
||||
|
||||
def self.load_root
|
||||
info = {}
|
||||
path = ::File.join(::File.dirname(__FILE__), "..", "..", "..", ".svn", "entries")
|
||||
if !::File.exists?(path)
|
||||
return info
|
||||
end
|
||||
ents = []
|
||||
File.open(path, "rb") do |fd|
|
||||
ents = fd.read(::File.size(path)).split("\x0c")
|
||||
end
|
||||
ents[0].split("\n").each do |line|
|
||||
line.strip!
|
||||
next if line.empty?
|
||||
case line
|
||||
when /framework3/
|
||||
info[:root] = line
|
||||
when /^\d+$/
|
||||
info[:revision] = line.to_i
|
||||
when /^\d{4}-\d.*T/
|
||||
info[:updated] = line
|
||||
end
|
||||
break if (info[:root] and info[:revision] and info[:updated])
|
||||
end
|
||||
info
|
||||
end
|
||||
|
||||
def self.revision
|
||||
info = load_root
|
||||
info[:revision]
|
||||
end
|
||||
|
||||
def self.updated
|
||||
info = load_root
|
||||
info[:updated]
|
||||
end
|
||||
|
||||
def self.root
|
||||
info = load_root
|
||||
info[:root]
|
||||
end
|
||||
|
||||
def self.days_since_update
|
||||
info = load_root
|
||||
svnt = info[:updated]
|
||||
if(not svnt)
|
||||
return
|
||||
end
|
||||
diff = (Date.parse(Time.now.to_s) - Date.parse(svnt)).to_f
|
||||
end
|
||||
|
||||
def self.last_updated_friendly
|
||||
diff = self.days_since_update
|
||||
case diff
|
||||
when nil
|
||||
"at a unknown date"
|
||||
when -2.0 .. 1.0
|
||||
"today"
|
||||
when 1.0 .. 2.0
|
||||
"yesterday"
|
||||
else
|
||||
"#{diff.to_i} days ago"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue