2010-10-19 07:32:50 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2011-10-23 12:04:41 +00:00
|
|
|
# $Id$
|
|
|
|
# $Revision$
|
|
|
|
|
2010-10-19 07:32:50 +00:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
Dir.chdir(File.dirname(msfbase))
|
|
|
|
|
|
|
|
$stderr.puts "[*]"
|
|
|
|
$stderr.puts "[*] Attempting to update the Metasploit Framework..."
|
|
|
|
$stderr.puts "[*]"
|
2010-10-19 08:22:44 +00:00
|
|
|
$stderr.puts ""
|
|
|
|
|
2011-10-10 21:20:56 +00:00
|
|
|
if not (Process.uid == 0 or File.stat(msfbase).owned?)
|
2011-10-10 21:10:50 +00:00
|
|
|
$stderr.puts "[-] ERROR: User running msfupdate does not own the metasploit install"
|
|
|
|
$stderr.puts "Please run msfupdate as the same user who installed metasploit."
|
2011-10-10 21:08:04 +00:00
|
|
|
end
|
|
|
|
|
2011-05-03 23:58:41 +00:00
|
|
|
wait = (ARGV.shift.to_s == "wait")
|
2010-10-19 08:22:44 +00:00
|
|
|
|
2011-06-27 20:30:44 +00:00
|
|
|
have_configdir = false
|
|
|
|
ARGV.each do |arg|
|
|
|
|
next unless arg =~ /--config-dir/
|
|
|
|
have_configdir = true
|
|
|
|
end
|
|
|
|
|
|
|
|
unless have_configdir
|
|
|
|
configdir = File.join(File.dirname(msfbase), "data", "svn")
|
|
|
|
# Spaces in the directory should be fine since this whole thing is passed
|
|
|
|
# as a single argument via the multi-arg syntax for system() below.
|
|
|
|
ARGV.push("--config-dir=#{configdir}")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-09-15 15:31:08 +00:00
|
|
|
res = system("svn", "cleanup")
|
|
|
|
if res.nil?
|
|
|
|
$stderr.puts "[-] ERROR: Failed to run svn"
|
|
|
|
$stderr.puts ""
|
|
|
|
$stderr.puts "[-] If you used a binary installer, make sure you run the symlink in"
|
|
|
|
$stderr.puts "[-] /usr/local/bin instead of running this file directly (e.g.: ./msfupdate)"
|
|
|
|
$stderr.puts "[-] to ensure a proper environment."
|
|
|
|
else
|
|
|
|
# Cleanup worked, go ahead and update
|
|
|
|
system("svn", "update", *ARGV)
|
|
|
|
end
|
2011-05-03 23:58:41 +00:00
|
|
|
|
|
|
|
if wait
|
2010-10-19 08:22:44 +00:00
|
|
|
$stderr.puts ""
|
|
|
|
$stderr.puts "[*] Please hit enter to exit"
|
2011-09-15 15:31:08 +00:00
|
|
|
$stderr.puts ""
|
2010-10-19 08:22:44 +00:00
|
|
|
$stdin.readline
|
|
|
|
end
|