2010-10-19 09:32:50 +02:00
|
|
|
#!/usr/bin/env ruby
|
2012-06-29 07:18:28 +02:00
|
|
|
# -*- coding: binary -*-
|
2010-10-19 09:32:50 +02:00
|
|
|
|
2011-10-23 14:04:41 +02:00
|
|
|
# $Id$
|
|
|
|
# $Revision$
|
|
|
|
|
2010-10-19 09:32:50 +02:00
|
|
|
msfbase = __FILE__
|
2012-10-04 00:06:38 +02:00
|
|
|
while File.symlink?(msfbase)
|
2010-10-19 09:32:50 +02:00
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
2012-10-01 19:30:29 +02:00
|
|
|
@args = ARGV.dup
|
2010-10-19 09:32:50 +02:00
|
|
|
|
2012-10-09 23:56:22 +02:00
|
|
|
# May be changed
|
2012-10-09 23:25:06 +02:00
|
|
|
@configdir = File.expand_path(File.join(File.dirname(msfbase), "data", "svn"))
|
|
|
|
|
2010-10-19 09:32:50 +02:00
|
|
|
Dir.chdir(File.dirname(msfbase))
|
|
|
|
|
|
|
|
$stderr.puts "[*]"
|
|
|
|
$stderr.puts "[*] Attempting to update the Metasploit Framework..."
|
|
|
|
$stderr.puts "[*]"
|
2010-10-19 10:22:44 +02:00
|
|
|
$stderr.puts ""
|
|
|
|
|
2011-10-10 23:20:56 +02:00
|
|
|
if not (Process.uid == 0 or File.stat(msfbase).owned?)
|
2011-10-10 23:10:50 +02: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 23:08:04 +02:00
|
|
|
end
|
|
|
|
|
2012-10-01 19:41:36 +02:00
|
|
|
@args.each_with_index do |arg,i|
|
2012-10-01 20:07:51 +02:00
|
|
|
case arg
|
|
|
|
when "wait"
|
2012-10-01 20:10:58 +02:00
|
|
|
@wait_index = i
|
2012-10-01 20:07:51 +02:00
|
|
|
when /--config-dir/
|
|
|
|
# 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.
|
|
|
|
# TODO: Test this spaces business. I don't buy it. -todb
|
2012-10-01 20:10:58 +02:00
|
|
|
@configdir_index = i
|
2012-10-01 19:41:36 +02:00
|
|
|
end
|
2011-06-27 22:30:44 +02:00
|
|
|
end
|
|
|
|
|
2012-10-01 20:10:58 +02:00
|
|
|
@args.delete_at @wait_index if @wait_index
|
2012-10-09 23:25:06 +02:00
|
|
|
@args.push("--config-dir=#{@configdir}") unless @configdir_index
|
2012-10-01 19:30:29 +02:00
|
|
|
@args.push("--non-interactive")
|
2011-06-27 22:30:44 +02:00
|
|
|
|
2011-09-15 17:31:08 +02: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
|
2012-10-01 19:30:29 +02:00
|
|
|
system("svn", "update", *@args)
|
2011-09-15 17:31:08 +02:00
|
|
|
end
|
2011-05-04 01:58:41 +02:00
|
|
|
|
2012-10-01 20:10:58 +02:00
|
|
|
if @wait_index
|
2010-10-19 10:22:44 +02:00
|
|
|
$stderr.puts ""
|
|
|
|
$stderr.puts "[*] Please hit enter to exit"
|
2011-09-15 17:31:08 +02:00
|
|
|
$stderr.puts ""
|
2010-10-19 10:22:44 +02:00
|
|
|
$stdin.readline
|
|
|
|
end
|