diff --git a/tools/convert_31.rb b/tools/convert_31.rb deleted file mode 100755 index a35c6e3174..0000000000 --- a/tools/convert_31.rb +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env ruby -# -# $Id$ -# $Revision$ -# - -path = ARGV.shift || exit -data = File.read(path) -outp = "" - -endc = 0 -data.each_line do |line| - if(line =~ /^\s*module\s+[A-Z]/) - endc += 1 - next - end - - if(line =~ /^(\s*)include (.*)/) - spaces = $1 - inc = $2 - if (inc !~ /Msf/) - line = "#{spaces}include Msf::#{inc.strip}\n" - end - end - - if(line =~ /^(\s*)class ([^\<]+)\s*<\s*(.*)/) - prefix = "" - spaces = $1 - parent = $3 - - if(parent !~ /^Msf/) - prefix = "Msf::" - end - line = "#{spaces}class Metasploit3 < #{prefix}#{parent.strip}\n" - end - - outp += line -end - - - -endc.downto(1) do |idx| - i = outp.rindex("end") - outp[i, 4] = "" if i -end - -outp.rstrip! -outp << "\n" - -fd = File.open(path, "wb") -fd.write(outp) -fd.close diff --git a/tools/dev/resplat.rb b/tools/dev/resplat.rb deleted file mode 100755 index 8f3ade8c9c..0000000000 --- a/tools/dev/resplat.rb +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: binary -*- - -# Replace comment splat with something shorter and -# more sensible. -# -# Usage: -# metasploit-framework$ ./tools/dev/resplat.rb [path] -# -# Some cargo-culting of tools/dev/retab.rb - -require 'fileutils' -require 'find' - -dir = ARGV[0] || "." - -raise ArgumentError, "Need a filename or directory" unless (dir and File.readable? dir) - -def is_ruby?(fname) - return true if fname =~ /\.rb$/ -end - -def resplat(line) - if line =~ /This file is part of the Metasploit Framework/ -# This module requires Metasploit: http://metasploit.com/download - elsif line =~ /# redistribution and commercial restrictions\./ - return "# Current source: https://github.com/rapid7/metasploit-framework\n" - else - return nil - end -end - -Find.find(dir) do |infile| - next if infile =~ /\.git[\x5c\x2f]/ - next unless File.file? infile - next unless is_ruby? infile - outfile = infile - - data = File.open(infile, "rb") {|f| f.read f.stat.size} - fixed = [] - data.each_line do |line| - case line - when /^[\s]*#( ##)? This file is part of the Metasploit Framework and may be subject to/, /^[\s]*# redistribution and commercial restrictions\. Please see the Metasploit/, /^[\s]*# web site for more information on licensing and terms of use\./, /^[\s]*#[\s]{1,3}http:\/\/metasploit.com\/(framework\/)?/, /^# Framework web site for more information on licensing and terms of use./ - new_line = resplat(line) - fixed << new_line if new_line - else - fixed << line - end - end - - fh = File.open(outfile, "wb") - fh.write fixed.join - fh.close - puts "Resplatted #{fh.path}" -end diff --git a/tools/dev/retab.rb b/tools/dev/retab.rb deleted file mode 100755 index 45323edc20..0000000000 --- a/tools/dev/retab.rb +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: binary -*- - -# Replace leading tabs with 2-width spaces. -# I'm sure there's a sed/awk/perl oneliner that's -# a million times better but this is more readable for me. -# -# Usage: -# metasploit-framework$ ./tools/dev/retab.rb [path] -# -# If local backups are desired, prepend with "MSF_RETAB_BACKUPS" set, -# like so: -# metasploit-framework$ MSF_RETAB_BACKUPS=1 ./tools/dev/retab.rb [path] - -require 'fileutils' -require 'find' - -dir = ARGV[0] || "." -keep_backups = !!(ENV['MSF_RETAB_BACKUPS'] || ENV['MSF_RETAB_BACKUP']) -puts "Keeping .notab backups" if keep_backups - -raise ArgumentError, "Need a filename or directory" unless (dir and File.readable? dir) - -def is_ruby?(fname) - return true if fname =~ /\.rb$/ - file_util = "" - begin - file_util = %x{which file}.to_s.chomp - rescue Errno::ENOENT - end - if File.executable? file_util - file_fingerprint = %x{#{file_util} #{fname}} - !!(file_fingerprint =~ /Ruby script/) - end -end - -Find.find(dir) do |infile| - next if infile =~ /\.git[\x5c\x2f]/ - next unless File.file? infile - next unless is_ruby? infile - outfile = infile - - if keep_backups - backup = "#{infile}.notab" - FileUtils.cp infile, backup - end - - data = File.open(infile, "rb") {|f| f.read f.stat.size} - fixed = [] - data.each_line do |line| - fixed << line - next unless line =~ /^\x09/ - index = [] - i = 0 - line.each_char do |char| - break unless char =~ /[\x20\x09]/ - index << i if char == "\x09" - i += 1 - end - index.reverse.each do |idx| - line[idx] = " " - end - fixed[-1] = line - end - - fh = File.open(outfile, "wb") - fh.write fixed.join - fh.close - puts "Retabbed #{fh.path}" -end diff --git a/tools/dev/set_binary_encoding.rb b/tools/dev/set_binary_encoding.rb deleted file mode 100644 index 059f4165f4..0000000000 --- a/tools/dev/set_binary_encoding.rb +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: binary -*- - -str = '# -*- coding: binary -*-' - -fname = ARGV.shift || exit -data = '' -done = nil -fd = ::File.open(fname, "rb") -fd.each_line do |line| - if line =~ /^#.*coding:.*/ - done = true - end - - if not done - unless line =~ /^#\!.*env ruby/ - data << str + "\n" - done = true - end - end - - data << line -end -fd.close - -fd = ::File.open(fname, "wb") -fd.write(data) -fd.close diff --git a/tools/import_webscarab.rb b/tools/import_webscarab.rb deleted file mode 100755 index f68a949c5d..0000000000 --- a/tools/import_webscarab.rb +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env ruby -# -# $Id$ -# $Revision$ -# - -# Script which allows to import OWASP WebScarab sessions -# (http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project) -# into the metasploit/WMAP database. -# By spinbad - -require 'resolv' -require 'sqlite3' - -puts "--- WMAP WebScarab Session Importer ---------------------------------------------" -puts - -if ARGV.length < 2 - $stderr.puts("Usage: #{File.basename($0)} wescarabdirectory sqlite3database [target] [startrequest]") - $stderr.puts - $stderr.puts("webscarabdirectory\tThe directory where you stored the webscarab session") - $stderr.puts("sqlite3database\t\tThe name of the database file") - $stderr.puts("target\t\t\tThe target (host or domain) you want to add to the database") - $stderr.puts("startrequest\tThe request to start with...") - $stderr.puts - $stderr.puts("Examples:") - $stderr.puts("#{File.basename($0)} /tmp/savedsession example.db") - $stderr.puts("#{File.basename($0)} /tmp/savedsession example.db www.example.com") - $stderr.puts("#{File.basename($0)} /tmp/savedsession example.db example.com") - $stderr.puts("#{File.basename($0)} /tmp/savedsession example.db www.example.com 21") - exit -end - -ws_directory = ARGV.shift -db_file = ARGV.shift -target = ARGV.shift || nil -start_id = ARGV.shift.to_i || 1 - -# check if we have what we need... -if File.exists?(ws_directory+ File::SEPARATOR) == false then - $stderr.puts("ERROR: Can't find webscarab directory #{ws_directory}.") - exit -end - -if File.file?(db_file) == false then - $stderr.puts("ERROR: Can't find sqlite3 database file #{db_file}.") - exit -end - -# Prepare the database -puts("Opening database file: #{db_file}") -database = SQLite3::Database.new(db_file) - -# Prepare the insert statement... -insert_statement = database.prepare("INSERT INTO requests(host,port,ssl,meth,path,headers,query,body,respcode,resphead,response,created)" + - " VALUES(:host,:port,:ssl,:meth,:path,:headers,:query,:body,:respcode,:resphead,:response,:created)"); - -# target hash -> Resolving dns names is soooo slow, I don't know why. So we use the -# following hash as a "micro hosts", so we don't have to call getaddress each time... -target_ips = {} - -# Try to open the conversationlog file -File.open("#{ws_directory+File::SEPARATOR}conversationlog", "rb") do |log| - - # regulare expressions to extract the stuff that we really need - # i know that the url stuff can be handeled in one request but - # i am toooo lazy... - regex_conversation = /^### Conversation : (\d+)/ - regex_datetime = /^WHEN: (\d+)/ - regex_method = /^METHOD: (\S+)/ - regex_status = /^STATUS: (\d\d\d)/ - regex_url = /^URL: (http|https)?:\/\/(\S+):(\d+)\/([^\?]*)\?*(\S*)/ - - while line = log.gets - if line =~ regex_conversation then - conversation_id = regex_conversation.match(line)[1] - next if conversation_id.to_i < start_id - - # we don't care about scripts, commets - while (line =~ regex_datetime) == nil - line = log.gets - end - - # Add a dot to the timestring so we can convert it more easily - date_time = regex_datetime.match(line)[1] - date_time = Time.at(date_time.insert(-4, '.').to_f) - - method = regex_method.match(log.gets)[1] - - # we don't care about COOKIES - while (line =~ regex_status) == nil - line = log.gets - end - status = regex_status.match(line)[1] - - url_matcher = regex_url.match(log.gets) - - puts "Processing (#{conversation_id}): #{url_matcher[0]}" - - ssl = url_matcher[1] == "https" - host_name = url_matcher[2] - port = url_matcher[3] - path = url_matcher[4].chomp - query = url_matcher[5] - - if host_name.match("#{target}$").nil? == true then - puts("Not the selected target, skipping...") - next - end - - if(target_ips.has_key?(host_name)) then - host = target_ips[host_name] - else - ip = Resolv.getaddress(host_name) - target_ips[host_name] = ip - host = ip - end - - # set the parameters in the insert query - insert_statement.bind_param("host", host) - insert_statement.bind_param("port", port) - insert_statement.bind_param("ssl", ssl) - insert_statement.bind_param("meth", method) - insert_statement.bind_param("path", path) - insert_statement.bind_param("query", query) - insert_statement.bind_param("respcode", status) - insert_statement.bind_param("created", date_time) - insert_statement.bind_param("respcode", status) - - #Open the files with the requests and the responses... - request_filename = "#{ws_directory+File::SEPARATOR}conversations#{File::SEPARATOR+conversation_id}-request" - puts("Reading #{request_filename}") - request_file = File.open(request_filename, "rb") - - # Analyse the request - request_header = "" - request_file.gets # we don't need the return code... - while(request_line = request_file.gets) do - request_header += request_line - break if request_line == "\r\n" - end - - - request_body = "" - while(request_line = request_file.gets) do - request_body += request_line - end - - insert_statement.bind_param("headers", request_header) - insert_statement.bind_param("body", request_body) - - request_file.close() - - response_filename = "#{ws_directory+File::SEPARATOR}conversations#{File::SEPARATOR+conversation_id}-response" - puts("Reading #{response_filename}") - response_file = File.open("#{ws_directory+File::SEPARATOR}conversations#{File::SEPARATOR+conversation_id}-response", "rb") - - # scip the first line - response_file.gets - - # Analyse the response - response_header = "" - while(response_line = response_file.gets) do - response_header += response_line - break if response_line == "\r\n" - end - - response_body = response_file.read - - insert_statement.bind_param("resphead", response_header) - insert_statement.bind_param("response", response_body) - - response_file.close() - - insert_statement.execute() - end - end -end diff --git a/tools/module_changelog.rb b/tools/module_changelog.rb deleted file mode 100755 index fb2df57b85..0000000000 --- a/tools/module_changelog.rb +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env ruby -# -# $Id$ -# -# This script generates module changelogs -# -# $Revision$ -# - -msfbase = __FILE__ -while File.symlink?(msfbase) - msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase)) -end - -$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib'))) -require 'msfenv' - -$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB'] - -require 'rex' -require 'msf/ui' -require 'msf/base' - - -def usage - $stderr.puts "#{$0} [dst rev]" - exit(0) -end - -src_rev = ARGV.shift || usage() -dst_rev = ARGV.shift || "HEAD" - -$stderr.puts "[*] Extracting changes from Subversion..." -data = `svn diff -r #{src_rev}:#{dst_rev} --summarize https://www.metasploit.com/svn/framework3/trunk/modules/` - -# Always disable the database (we never need it just to list module -# information). -framework_opts = { 'DisableDatabase' => true } - -# Initialize the simplified framework instance. -framework = Msf::Simple::Framework.create(framework_opts) - - -madd = [] -mdel = [] -mmod = [] - -data.each_line do |line| - - action, mname = line.strip.split(/\s+/, 2) - mname = mname.gsub(/^.*modules\//, '').gsub('exploits', 'exploit').gsub(/\.rb$/, '') - case action - when /^A/ - # Added a new module - m = framework.modules.create(mname) - if m - madd << "\"#{m.name}\":http://www.metasploit.com/modules/#{mname}" - end - when /^D/ - # Deleted a module - mdel << mname - when /^M/ - # Modified a module - # Added a new module - m = framework.modules.create(mname) - if m - mmod << "\"#{m.name}\":http://www.metasploit.com/modules/#{mname}" - end - end - -end - - -$stdout.puts "h2. New Modules\n\n" -madd.each { |x| $stdout.puts x } -$stdout.puts "\nh2. Modified Modules\n\n" -mmod.each { |x| $stdout.puts x } -$stdout.puts "\nh2. Removed Modules\n\n" -mdel.each { |x| $stdout.puts "* modules/#{x}" } -