Browse Source

Remove fastlib

MSP-11368
MSP-11143

Remove fastlib as it slows down the code loading process.  From the
previous commit, the mean loading for
`METASPLOIT_FRAMEWORK_PROFILE=true msfconsole -q -x exit` was
27.9530±0.3485 seconds (N=10).  The mean after removal of fastlib
was 17.9820±0.6497 seconds (N=10).  This means an average 35.67%
reduction in boot time.
Luke Imhoff 5 years ago
parent
commit
b863978028
No account linked to committer's email address
60 changed files with 10 additions and 1178 deletions
  1. 0
    1
      .simplecov
  2. 0
    4
      LICENSE
  3. 0
    433
      lib/fastlib.rb
  4. 0
    1
      lib/msf/core/module_manager.rb
  5. 1
    3
      lib/msf/core/module_manager/loading.rb
  6. 5
    21
      lib/msf/core/module_manager/module_paths.rb
  7. 0
    1
      lib/msf/core/module_set.rb
  8. 0
    91
      lib/msf/core/modules/loader/archive.rb
  9. 4
    0
      lib/msf/core/modules/loader/directory.rb
  10. 0
    1
      msfbinscan
  11. 0
    1
      msfcli
  12. 0
    1
      msfd
  13. 0
    1
      msfelfscan
  14. 0
    1
      msfencode
  15. 0
    1
      msfmachscan
  16. 0
    1
      msfpayload
  17. 0
    1
      msfpescan
  18. 0
    1
      msfrop
  19. 0
    1
      msfrpc
  20. 0
    1
      msfrpcd
  21. 0
    1
      msfvenom
  22. 0
    234
      spec/lib/fastlib_spec.rb
  23. 0
    8
      spec/lib/msf/core/module_manager_spec.rb
  24. 0
    276
      spec/lib/msf/core/modules/loader/archive_spec.rb
  25. 0
    1
      spec/lib/rex/proto/pjl/client_spec.rb
  26. 0
    1
      spec/msfcli_spec.rb
  27. 0
    40
      spec/support/shared/examples/msf/module_manager/module_paths.rb
  28. 0
    14
      spec/support/shared/examples/msf/modules/loader_archive_read_module_content.rb
  29. 0
    1
      spec/tools/cpassword_decrypt_spec.rb
  30. 0
    1
      spec/tools/virustotal_spec.rb
  31. 0
    1
      test/tests/test_encoders.rb
  32. 0
    1
      tools/cpassword_decrypt.rb
  33. 0
    1
      tools/exe2vba.rb
  34. 0
    1
      tools/exe2vbs.rb
  35. 0
    1
      tools/find_badchars.rb
  36. 0
    1
      tools/halflm_second.rb
  37. 0
    1
      tools/hmac_sha1_crack.rb
  38. 0
    1
      tools/list_interfaces.rb
  39. 0
    1
      tools/lm2ntcrack.rb
  40. 0
    1
      tools/metasm_shell.rb
  41. 0
    1
      tools/module_author.rb
  42. 0
    1
      tools/module_changelog.rb
  43. 0
    1
      tools/module_count.rb
  44. 0
    1
      tools/module_disclodate.rb
  45. 0
    1
      tools/module_license.rb
  46. 0
    1
      tools/module_mixins.rb
  47. 0
    1
      tools/module_payloads.rb
  48. 0
    1
      tools/module_ports.rb
  49. 0
    1
      tools/module_rank.rb
  50. 0
    1
      tools/module_reference.rb
  51. 0
    1
      tools/module_targets.rb
  52. 0
    1
      tools/msf_irb_shell.rb
  53. 0
    1
      tools/nasm_shell.rb
  54. 0
    6
      tools/pack_fastlib.sh
  55. 0
    1
      tools/pattern_create.rb
  56. 0
    1
      tools/pattern_offset.rb
  57. 0
    1
      tools/payload_lengths.rb
  58. 0
    1
      tools/psexec.rb
  59. 0
    1
      tools/reg.rb
  60. 0
    1
      tools/virustotal.rb

+ 0
- 1
.simplecov View File

@@ -39,7 +39,6 @@ SimpleCov.configure do
39 39
 	# Other library groups
40 40
 	#
41 41
 
42
-	add_group 'Fastlib', 'lib/fastlib'
43 42
 	add_group 'Metasm', 'lib/metasm'
44 43
 	add_group 'PacketFu', 'lib/packetfu'
45 44
 	add_group 'Rex', 'lib/rex'

+ 0
- 4
LICENSE View File

@@ -87,10 +87,6 @@ Files: lib/bit-struct.rb lib/bit-struct/*
87 87
 Copyright: 2005-2009, Joel VanderWerf
88 88
 License: Ruby
89 89
 
90
-Files: lib/fastlib.rb
91
-Copyright: 2011, Rapid7, Inc.
92
-License: Ruby
93
-
94 90
 Files: lib/metasm.rb lib/metasm/* data/cpuinfo/*
95 91
 Copyright: 2006-2010 Yoann GUILLOT
96 92
 License: LGPL-2.1

+ 0
- 433
lib/fastlib.rb View File

@@ -1,433 +0,0 @@
1
-#!/usr/bin/env ruby
2
-# -*- coding: binary -*-
3
-
4
-#
5
-# FASTLIB is a mechanism for loading large sets of libraries in a way that is
6
-# faster and much more flexible than typical disk structures. FASTLIB includes
7
-# hooks that can be used for both compression and encoding of Ruby libraries.
8
-#
9
-
10
-#
11
-# This format was specifically created to improve the performance and
12
-# AV-resistance of the Metasploit Framework and Rex libraries.
13
-#
14
-
15
-
16
-#
17
-# This library is still in its early form; a large number of performance and
18
-# compatiblity improvements are not yet included. Do not depend on the FASTLIB
19
-# file format at this time.
20
-#
21
-
22
-require "find"
23
-
24
-
25
-#
26
-# Copyright (C) 2011 Rapid7. You can redistribute it and/or
27
-# modify it under the terms of the ruby license.
28
-#
29
-#
30
-# Roughly based on the rubyzip zip/ziprequire library:
31
-# 	>> Copyright (C) 2002 Thomas Sondergaard
32
-# 	>> rubyzip is free software; you can redistribute it and/or
33
-# 	>> modify it under the terms of the ruby license.
34
-
35
-
36
-#
37
-# The FastLib class implements the meat of the FASTLIB archive format
38
-#
39
-class FastLib
40
-
41
-  VERSION = "0.0.8"
42
-
43
-  FLAG_COMPRESS = 0x01
44
-  FLAG_ENCRYPT  = 0x02
45
-
46
-  @@cache = {}
47
-  @@has_zlib = false
48
-
49
-  #
50
-  # Load zlib support if possible
51
-  #
52
-  begin
53
-    require 'zlib'
54
-    @@has_zlib = true
55
-  rescue ::LoadError
56
-  end
57
-
58
-  #
59
-  # This method returns the version of the fastlib library
60
-  #
61
-  def self.version
62
-    VERSION
63
-  end
64
-
65
-  #
66
-  # This method loads content from a specific archive file by name. If the
67
-  # noprocess argument is set to true, the contents will not be expanded to
68
-  # include workarounds for things such as __FILE__. This is useful when
69
-  # loading raw binary data where these strings may occur
70
-  #
71
-  def self.load(lib, name, noprocess=false)
72
-    data = ""
73
-    load_cache(lib)
74
-
75
-    return unless ( @@cache[lib] and @@cache[lib][name] )
76
-
77
-
78
-    ::File.open(lib, "rb") do |fd|
79
-      fd.seek(
80
-        @@cache[lib][:fastlib_header][0] +
81
-        @@cache[lib][:fastlib_header][1] +
82
-        @@cache[lib][name][0]
83
-      )
84
-      data = fastlib_filter_decode( lib, fd.read(@@cache[lib][name][1] ))
85
-    end
86
-
87
-    # Return the contents in raw or processed form
88
-    noprocess ? data : post_process(lib, name, data)
89
-  end
90
-
91
-  #
92
-  # This method caches the file list and offsets within the archive
93
-  #
94
-  def self.load_cache(lib)
95
-    return if @@cache[lib]
96
-    @@cache[lib] = {}
97
-
98
-    return if not ::File.exists?(lib)
99
-
100
-    ::File.open(lib, 'rb') do |fd|
101
-      dict = {}
102
-      head = fd.read(4)
103
-      return if head != "FAST"
104
-      hlen = fd.read(4).unpack("N")[0]
105
-      flag = fd.read(4).unpack("N")[0]
106
-
107
-      @@cache[lib][:fastlib_header] = [12, hlen, fd.stat.mtime.utc.to_i ]
108
-      @@cache[lib][:fastlib_flags]  = flag
109
-
110
-      nlen, doff, dlen, tims = fd.read(16).unpack("N*")
111
-
112
-      while nlen > 0
113
-        name = fastlib_filter_decode( lib, fd.read(nlen) )
114
-        dict[name] = [doff, dlen, tims]
115
-
116
-        nlen, doff, dlen, tims = fd.read(16).unpack("N*")
117
-      end
118
-
119
-      @@cache[lib].merge!(dict)
120
-    end
121
-
122
-  end
123
-
124
-  #
125
-  # This method provides compression and encryption capabilities
126
-  # for the fastlib archive format.
127
-  #
128
-  def self.fastlib_filter_decode(lib, buff)
129
-
130
-    if (@@cache[lib][:fastlib_flags] & FLAG_ENCRYPT) != 0
131
-
132
-      @@cache[lib][:fastlib_decrypt] ||= ::Proc.new do |data|
133
-        stub = "decrypt_%.8x" % ( @@cache[lib][:fastlib_flags] & 0xfffffff0 )
134
-        FastLib.send(stub, data)
135
-      end
136
-
137
-      buff = @@cache[lib][:fastlib_decrypt].call( buff )
138
-    end
139
-
140
-    if (@@cache[lib][:fastlib_flags] & FLAG_COMPRESS) != 0
141
-      if not @@has_zlib
142
-        raise ::RuntimeError, "zlib is required to open this archive"
143
-      end
144
-
145
-      z = Zlib::Inflate.new
146
-      buff = z.inflate(buff)
147
-      buff << z.finish
148
-      z.close
149
-    end
150
-
151
-    buff
152
-  end
153
-
154
-  #
155
-  # This method provides compression and encryption capabilities
156
-  # for the fastlib archive format.
157
-  #
158
-  def self.fastlib_filter_encode(lib, buff)
159
-
160
-    if (@@cache[lib][:fastlib_flags] & FLAG_COMPRESS) != 0
161
-      if not @@has_zlib
162
-        raise ::RuntimeError, "zlib is required to open this archive"
163
-      end
164
-
165
-      z = Zlib::Deflate.new
166
-      buff = z.deflate(buff)
167
-      buff << z.finish
168
-      z.close
169
-    end
170
-
171
-    if (@@cache[lib][:fastlib_flags] & FLAG_ENCRYPT) != 0
172
-
173
-      @@cache[lib][:fastlib_encrypt] ||= ::Proc.new do |data|
174
-        stub = "encrypt_%.8x" % ( @@cache[lib][:fastlib_flags] & 0xfffffff0 )
175
-        FastLib.send(stub, data)
176
-      end
177
-
178
-      buff = @@cache[lib][:fastlib_encrypt].call( buff )
179
-    end
180
-
181
-    buff
182
-  end
183
-
184
-
185
-  # This method provides a way to create a FASTLIB archive programatically.
186
-  #
187
-  # @param [String] lib the output path for the archive
188
-  # @param [String] flag a string containing the hex values for the
189
-  #   flags ({FLAG_COMPRESS} and {FLAG_ENCRYPT}).
190
-  # @param [String] bdir the path to the base directory which will be
191
-  #   stripped from all paths included in the archive
192
-  # @param [Array<String>] dirs list of directories/files to pack into
193
-  #   the archive.  All dirs should be under bdir so that the paths are
194
-  #   stripped correctly.
195
-  # @return [void]
196
-  def self.dump(lib, flag, bdir, *dirs)
197
-    head = ""
198
-    data = ""
199
-    hidx = 0
200
-    didx = 0
201
-
202
-    bdir = bdir.gsub(/\/$/, '')
203
-    brex = /^#{Regexp.escape(bdir)}\//
204
-
205
-    @@cache[lib] = {
206
-      :fastlib_flags => flag.to_i(16)
207
-    }
208
-
209
-    dirs.each do |dir|
210
-      ::Find.find(dir) do |path|
211
-        next if not ::File.file?(path)
212
-        name = fastlib_filter_encode( lib, path.sub( brex, "" ) )
213
-
214
-        buff = ""
215
-        ::File.open(path, "rb") do |fd|
216
-          buff = fastlib_filter_encode(lib, fd.read(fd.stat.size))
217
-        end
218
-
219
-
220
-        head << [ name.length, didx, buff.length, ::File.stat(path).mtime.utc.to_i ].pack("NNNN")
221
-        head << name
222
-        hidx = hidx + 16 + name.length
223
-
224
-        data << buff
225
-        didx = didx + buff.length
226
-      end
227
-    end
228
-
229
-    head << [0,0,0].pack("NNN")
230
-
231
-    ::File.open(lib, "wb") do |fd|
232
-      fd.write("FAST")
233
-      fd.write( [ head.length, flag.to_i(16) ].pack("NN") )
234
-      fd.write( head )
235
-      fd.write( data )
236
-    end
237
-  end
238
-
239
-  #
240
-  # This archive provides a way to list the contents of an archive
241
-  # file, returning the names only in sorted order.
242
-  #
243
-  def self.list(lib)
244
-    load_cache(lib)
245
-    ( @@cache[lib] || {} ).keys.map{|x| x.to_s }.sort.select{ |x| @@cache[lib][x] }
246
-  end
247
-
248
-  #
249
-  # This method is called on the loaded is required to expand __FILE__
250
-  # and other inline dynamic constants to map to the correct location.
251
-  #
252
-  def self.post_process(lib, name, data)
253
-    data.gsub('__FILE__', "'#{ ::File.expand_path(::File.join(::File.dirname(lib), name)) }'")
254
-  end
255
-
256
-  #
257
-  # This is a stub crypto handler that performs a basic XOR
258
-  # operation against a fixed one byte key. The two usable IDs
259
-  # are 12345600 and 00000000
260
-  #
261
-  def self.encrypt_12345600(data)
262
-    encrypt_00000000(data)
263
-  end
264
-
265
-  def self.decrypt_12345600(data)
266
-    encrypt_00000000(data)
267
-  end
268
-
269
-  def self.encrypt_00000000(data)
270
-    data.unpack("C*").map{ |c| c ^ 0x90 }.pack("C*")
271
-  end
272
-
273
-  def self.decrypt_00000000(data)
274
-    encrypt_00000000(data)
275
-  end
276
-
277
-  #
278
-  # Expose the cache to callers
279
-  #
280
-  def self.cache
281
-    @@cache
282
-  end
283
-end
284
-
285
-
286
-#
287
-# Allow this library to be used as an executable to create and list
288
-# FASTLIB archives
289
-#
290
-if __FILE__ == $0
291
-  cmd = ARGV.shift
292
-  unless ["store", "list", "version"].include?(cmd)
293
-    $stderr.puts "Usage: #{$0} [dump|list|version] <arguments>"
294
-    exit(0)
295
-  end
296
-
297
-  case cmd
298
-  when "store"
299
-    dst = ARGV.shift
300
-    flg = ARGV.shift
301
-    dir = ARGV.shift
302
-    src = ARGV
303
-    unless dst and dir and src.length > 0
304
-      $stderr.puts "Usage: #{$0} store destination.fastlib flags base_dir src1 src2 ... src99"
305
-      exit(0)
306
-    end
307
-    FastLib.dump(dst, flg, dir, *src)
308
-
309
-  when "list"
310
-    src = ARGV.shift
311
-    unless src
312
-      $stderr.puts "Usage: #{$0} list"
313
-      exit(0)
314
-    end
315
-    $stdout.puts "Library: #{src}"
316
-    $stdout.puts "====================================================="
317
-    FastLib.list(src).each do |name|
318
-      fsize = FastLib.cache[src][name][1]
319
-      ftime = ::Time.at(FastLib.cache[src][name][2]).strftime("%Y-%m-%d %H:%M:%S")
320
-      $stdout.puts sprintf("%9d\t%20s\t%s\n", fsize, ftime, name)
321
-    end
322
-    $stdout.puts ""
323
-
324
-  when "version"
325
-    $stdout.puts "FastLib Version #{FastLib.version}"
326
-  end
327
-
328
-  exit(0)
329
-end
330
-
331
-#
332
-# FASTLIB archive format (subject to change without notice)
333
-#
334
-=begin
335
-
336
-  * All integers are 32-bit and in network byte order (big endian / BE)
337
-  * The file signature is 0x46415354 (big endian, use htonl() if necessary)
338
-  * The header is always 12 bytes into the archive (magic + header length)
339
-  * The data section is always 12 + header length into the archive
340
-  * The header entries always start with 'fastlib_header'
341
-  * The header entries always consist of 16 bytes + name length (no alignment)
342
-  * The header name data may be encoded, compressed, or transformed
343
-  * The data entries may be encoded, compressed, or transformed too
344
-
345
-
346
-  4 bytes: "FAST"
347
-  4 bytes: NBO header length
348
-  4 bytes: NBO flags (24-bit crypto ID, 8 bit modes)
349
-  [
350
-    4 bytes: name length (0 = End of Names)
351
-    4 bytes: data offset
352
-    4 bytes: data length
353
-    4 bytes: timestamp
354
-  ]
355
-  [ Raw Data ]
356
-
357
-=end
358
-
359
-
360
-module Kernel #:nodoc:all
361
-  alias :fastlib_original_require :require
362
-
363
-  #
364
-  # Store the CWD when were initially loaded
365
-  # required for resolving relative paths
366
-  #
367
-  @@fastlib_base_cwd = ::Dir.pwd
368
-
369
-  #
370
-  # This method hooks the original Kernel.require to support
371
-  # loading files within FASTLIB archives
372
-  #
373
-  def require(name)
374
-    fastlib_require(name) || fastlib_original_require(name)
375
-  end
376
-
377
-  #
378
-  # This method handles the loading of FASTLIB archives
379
-  #
380
-  def fastlib_require(name)
381
-    if name.respond_to? :to_path
382
-      name = name.to_path
383
-    end
384
-
385
-    name = name + ".rb" if not name =~ /\.rb$/
386
-    return false if fastlib_already_loaded?(name)
387
-    return false if fastlib_already_tried?(name)
388
-
389
-    # XXX Implement relative search paths within archives
390
-    $:.map{ |path|
391
-      (path =~ /^([A-Za-z]\:|\/)/ ) ? path : ::File.expand_path( ::File.join(@@fastlib_base_cwd, path) )
392
-    }.map{  |path| ::Dir["#{path}/*.fastlib"] }.flatten.uniq.each do |lib|
393
-      data = FastLib.load(lib, name)
394
-      next if not data
395
-      $" << name
396
-
397
-      Object.class_eval(data, lib + "::" + name)
398
-
399
-      return true
400
-    end
401
-
402
-    $fastlib_miss << name
403
-
404
-    false
405
-  end
406
-
407
-  #
408
-  # This method determines whether the specific file name
409
-  # has already been loaded ($LOADED_FEATURES aka $")
410
-  #
411
-  def fastlib_already_loaded?(name)
412
-    re = Regexp.new("^" + Regexp.escape(name) + "$")
413
-    $".detect { |e| e =~ re } != nil
414
-  end
415
-
416
-  #
417
-  # This method determines whether the specific file name
418
-  # has already been attempted with the included FASTLIB
419
-  # archives.
420
-  #
421
-  # TODO: Ensure that this only applies to known FASTLIB
422
-  #       archives and that newly included archives will
423
-  #       be searched appropriately.
424
-  #
425
-  def fastlib_already_tried?(name)
426
-    $fastlib_miss ||= []
427
-    $fastlib_miss.include?(name)
428
-  end
429
-end
430
-
431
-
432
-
433
-

+ 0
- 1
lib/msf/core/module_manager.rb View File

@@ -7,7 +7,6 @@ require 'pathname'
7 7
 #
8 8
 # Project
9 9
 #
10
-require 'fastlib'
11 10
 require 'msf/core'
12 11
 require 'msf/core/module_set'
13 12
 

+ 1
- 3
lib/msf/core/module_manager/loading.rb View File

@@ -7,7 +7,6 @@ require 'active_support/concern'
7 7
 #
8 8
 # Project
9 9
 #
10
-require 'msf/core/modules/loader/archive'
11 10
 require 'msf/core/modules/loader/directory'
12 11
 
13 12
 # Deals with loading modules for the {Msf::ModuleManager}
@@ -20,7 +19,6 @@ module Msf::ModuleManager::Loading
20 19
 
21 20
   # Classes that can be used to load modules.
22 21
   LOADER_CLASSES = [
23
-      Msf::Modules::Loader::Archive,
24 22
       Msf::Modules::Loader::Directory
25 23
   ]
26 24
 
@@ -103,7 +101,7 @@ module Msf::ModuleManager::Loading
103 101
 
104 102
   # Load all of the modules from the supplied directory or archive
105 103
   #
106
-  # @param [String] path Path to a directory or Fastlib archive
104
+  # @param [String] path Path to a directory
107 105
   # @param [Hash] options
108 106
   # @option options [Boolean] :force Whether the force loading the modules even if they are unchanged and already
109 107
   #   loaded.

+ 5
- 21
lib/msf/core/module_manager/module_paths.rb View File

@@ -24,30 +24,14 @@ module Msf::ModuleManager::ModulePaths
24 24
 
25 25
     # Make the path completely canonical
26 26
     pathname = Pathname.new(path_without_trailing_file_separator).expand_path
27
-    extension = pathname.extname
28 27
 
29
-    if extension == Msf::Modules::Loader::Archive::ARCHIVE_EXTENSION
30
-      unless pathname.exist?
31
-        raise ArgumentError, "The path supplied does not exist", caller
32
-      end
33
-
34
-      nested_paths << pathname.to_s
35
-    else
36
-      # Make sure the path is a valid directory
37
-      unless pathname.directory?
38
-        raise ArgumentError, "The path supplied is not a valid directory.", caller
39
-      end
40
-
41
-      nested_paths << pathname.to_s
42
-
43
-      # Identify any fastlib archives inside of this path
44
-      fastlib_glob = pathname.join('**', "*#{Msf::Modules::Loader::Archive::ARCHIVE_EXTENSION}")
45
-
46
-      Dir.glob(fastlib_glob).each do |fastlib_path|
47
-        nested_paths << fastlib_path
48
-      end
28
+    # Make sure the path is a valid directory
29
+    unless pathname.directory?
30
+      raise ArgumentError, "The path supplied is not a valid directory.", caller
49 31
     end
50 32
 
33
+    nested_paths << pathname.to_s
34
+
51 35
     # Update the module paths appropriately
52 36
     self.module_paths = (module_paths + nested_paths).flatten.uniq
53 37
 

+ 0
- 1
lib/msf/core/module_set.rb View File

@@ -1,6 +1,5 @@
1 1
 # -*- coding: binary -*-
2 2
 require 'msf/core'
3
-require 'fastlib'
4 3
 require 'pathname'
5 4
 
6 5
 #

+ 0
- 91
lib/msf/core/modules/loader/archive.rb View File

@@ -1,91 +0,0 @@
1
-# -*- coding: binary -*-
2
-require 'msf/core/modules/loader/base'
3
-
4
-# Concerns loading modules form fastlib archives
5
-class Msf::Modules::Loader::Archive < Msf::Modules::Loader::Base
6
-  #
7
-  # CONSTANTS
8
-  #
9
-
10
-  # The extension for Fastlib archives.
11
-  ARCHIVE_EXTENSION = '.fastlib'
12
-
13
-  # Returns true if the path is a Fastlib archive.
14
-  #
15
-  # @param (see Msf::Modules::Loader::Base#loadable?)
16
-  # @return [true] if path has the {ARCHIVE_EXTENSION} extname.
17
-  # @return [false] otherwise
18
-  def loadable?(path)
19
-    if File.extname(path) == ARCHIVE_EXTENSION
20
-      true
21
-    else
22
-      false
23
-    end
24
-  end
25
-
26
-  protected
27
-
28
-  # Yields the module_reference_name for each module file in the Fastlib archive at path.
29
-  #
30
-  # @param path [String] The path to the Fastlib archive file.
31
-  # @param opts [Hash] Additional options
32
-  # @yield (see Msf::Modules::Loader::Base#each_module_reference_name)
33
-  # @yieldparam (see Msf::Modules::Loader::Base#each_module_reference_name)
34
-  # @return (see Msf::Modules::Loader::Base#each_module_reference_name)
35
-  def each_module_reference_name(path, opts={})
36
-    whitelist = opts[:whitelist] || []
37
-    entries = ::FastLib.list(path)
38
-
39
-    entries.each do |entry|
40
-      if entry.include?('.svn/')
41
-        next
42
-      end
43
-
44
-      type = entry.split('/', 2)[0]
45
-      type = type.singularize
46
-
47
-      unless module_manager.type_enabled?(type)
48
-        next
49
-      end
50
-
51
-      if whitelist.empty?
52
-
53
-        if module_path?(entry)
54
-          # The module_reference_name doesn't have a file extension
55
-          module_reference_name = module_reference_name_from_path(entry)
56
-
57
-          yield path, type, module_reference_name
58
-        end
59
-      else
60
-        whitelist.each do |pattern|
61
-          if entry =~ pattern
62
-            yield path, type, module_reference_name
63
-          else
64
-            next
65
-          end
66
-        end
67
-      end
68
-    end
69
-  end
70
-
71
-  # Returns the path to the module inside the Fastlib archive.  The path to the archive is separated from the path to
72
-  # the file inside the archive by '::'.
73
-  #
74
-  # @param (see Msf::Modules::Loader::Base#module_path)
75
-  # @return [String] Path to module file inside the Fastlib archive.
76
-  def module_path(parent_path, type, module_reference_name)
77
-    file_path = typed_path(type, module_reference_name)
78
-    module_path = "#{parent_path}::#{file_path}"
79
-
80
-    module_path
81
-  end
82
-
83
-  # Loads the module content from the Fastlib archive.
84
-  #
85
-  # @return (see Msf::Modules::Loader::Base#read_module_content)
86
-  def read_module_content(path, type, module_reference_name)
87
-    file_path = typed_path(type, module_reference_name)
88
-
89
-    ::FastLib.load(path, file_path)
90
-  end
91
-end

+ 4
- 0
lib/msf/core/modules/loader/directory.rb View File

@@ -1,4 +1,8 @@
1 1
 # -*- coding: binary -*-
2
+
3
+require 'msf/core/modules/loader'
4
+require 'msf/core/modules/loader/base'
5
+
2 6
 # Concerns loading module from a directory
3 7
 class Msf::Modules::Loader::Directory < Msf::Modules::Loader::Base
4 8
   # Returns true if the path is a directory

+ 0
- 1
msfbinscan View File

@@ -11,7 +11,6 @@ while File.symlink?(msfbase)
11 11
 end
12 12
 
13 13
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
14
-require 'fastlib'
15 14
 require 'msfenv'
16 15
 
17 16
 

+ 0
- 1
msfcli View File

@@ -535,7 +535,6 @@ class Msfcli
535 535
     end
536 536
 
537 537
     $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
538
-    require 'fastlib'
539 538
     require 'msfenv'
540 539
     require 'msf/ui'
541 540
     require 'msf/base'

+ 0
- 1
msfd View File

@@ -17,7 +17,6 @@ while File.symlink?(msfbase)
17 17
 end
18 18
 
19 19
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
20
-require 'fastlib'
21 20
 require 'msfenv'
22 21
 
23 22
 

+ 0
- 1
msfelfscan View File

@@ -11,7 +11,6 @@ while File.symlink?(msfbase)
11 11
 end
12 12
 
13 13
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
14
-require 'fastlib'
15 14
 require 'msfenv'
16 15
 
17 16
 

+ 0
- 1
msfencode View File

@@ -11,7 +11,6 @@ while File.symlink?(msfbase)
11 11
 end
12 12
 
13 13
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
14
-require 'fastlib'
15 14
 require 'msfenv'
16 15
 
17 16
 

+ 0
- 1
msfmachscan View File

@@ -11,7 +11,6 @@ while File.symlink?(msfbase)
11 11
 end
12 12
 
13 13
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
14
-require 'fastlib'
15 14
 require 'msfenv'
16 15
 
17 16
 

+ 0
- 1
msfpayload View File

@@ -11,7 +11,6 @@ while File.symlink?(msfbase)
11 11
 end
12 12
 
13 13
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
14
-require 'fastlib'
15 14
 require 'msfenv'
16 15
 
17 16
 

+ 0
- 1
msfpescan View File

@@ -11,7 +11,6 @@ while File.symlink?(msfbase)
11 11
 end
12 12
 
13 13
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
14
-require 'fastlib'
15 14
 require 'msfenv'
16 15
 
17 16
 

+ 0
- 1
msfrop View File

@@ -14,7 +14,6 @@ while File.symlink?(msfbase)
14 14
 end
15 15
 
16 16
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
17
-require 'fastlib'
18 17
 require 'msfenv'
19 18
 
20 19
 

+ 0
- 1
msfrpc View File

@@ -15,7 +15,6 @@ while File.symlink?(msfbase)
15 15
 end
16 16
 
17 17
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
18
-require 'fastlib'
19 18
 require 'msfenv'
20 19
 
21 20
 

+ 0
- 1
msfrpcd View File

@@ -15,7 +15,6 @@ while File.symlink?(msfbase)
15 15
 end
16 16
 
17 17
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
18
-require 'fastlib'
19 18
 require 'msfenv'
20 19
 
21 20
 

+ 0
- 1
msfvenom View File

@@ -7,7 +7,6 @@ while File.symlink?(msfbase)
7 7
 end
8 8
 
9 9
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
10
-require 'fastlib'
11 10
 require 'msfenv'
12 11
 
13 12
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 234
spec/lib/fastlib_spec.rb View File

@@ -1,234 +0,0 @@
1
-# -*- coding:binary -*-
2
-require 'spec_helper'
3
-
4
-require 'msf/core'
5
-
6
-describe FastLib do
7
-  let(:archived_paths) do
8
-    [
9
-        File.join('auxiliary', 'scanner', 'portscan', 'xmas.rb'),
10
-        File.join('exploits', 'windows', 'smb', 'ms08_067_netapi.rb')
11
-    ]
12
-  end
13
-
14
-  let(:base_path) do
15
-    File.join(Msf::Config.install_root, 'modules')
16
-  end
17
-
18
-  let(:extension) do
19
-    '.fastlib'
20
-  end
21
-
22
-  let(:flag_compress) do
23
-    0x01
24
-  end
25
-
26
-  let(:flag_encrypt) do
27
-    0x02
28
-  end
29
-
30
-  let(:unarchived_paths) do
31
-    archived_paths.collect { |archived_path|
32
-      File.join(base_path, archived_path)
33
-    }
34
-  end
35
-
36
-  context 'CONSTANTS' do
37
-    context 'flags' do
38
-      it 'should have compression' do
39
-        described_class::FLAG_COMPRESS.should == flag_compress
40
-      end
41
-
42
-      it 'should have encryption' do
43
-        described_class::FLAG_ENCRYPT.should == flag_encrypt
44
-      end
45
-    end
46
-  end
47
-
48
-  context 'class methods' do
49
-    context 'dump' do
50
-      let(:flag_string) do
51
-        flags.to_s(16)
52
-      end
53
-
54
-      before(:each) do
55
-        FastLib.cache.clear
56
-      end
57
-
58
-      around(:each) do |example|
59
-        Dir.mktmpdir do |directory|
60
-          @destination_path = File.join(directory, "rspec#{extension}")
61
-
62
-          example.run
63
-        end
64
-      end
65
-
66
-      context 'without compression and without encryption' do
67
-        let(:flags) do
68
-          0x0
69
-        end
70
-
71
-        it 'should create an archive' do
72
-          File.exist?(@destination_path).should be_falsey
73
-
74
-          described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
75
-
76
-          File.exist?(@destination_path).should be_truthy
77
-        end
78
-
79
-        context 'cache' do
80
-          it 'should populate' do
81
-            FastLib.cache[@destination_path].should be_nil
82
-
83
-            described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
84
-
85
-            FastLib.cache[@destination_path].should be_a Hash
86
-          end
87
-
88
-          it 'should include flags' do
89
-            described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
90
-
91
-            FastLib.cache[@destination_path][:fastlib_flags].should == flags
92
-          end
93
-
94
-          skip "Fix https://www.pivotaltracker.com/story/show/38730815" do
95
-            it 'should include header' do
96
-              described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
97
-              header = FastLib.cache[@destination_path][:fastlib_header]
98
-              modification_time = File.mtime(@destination_path).utc.to_i
99
-
100
-              header.should be_a Array
101
-              # @todo figure out why 12 before header length
102
-              header[0].should == 12
103
-              # @todo figure out why header length is 0
104
-              header[1].should == 0
105
-              header[2].should == modification_time
106
-            end
107
-
108
-            it 'should include archived paths' do
109
-              described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
110
-              cache = FastLib.cache[@destination_path]
111
-
112
-              archived_path = File.join('exploits', 'windows', 'smb', 'ms08_067_netapi.rb')
113
-              unarchived_path = File.join(base_path, archived_path)
114
-
115
-              # make sure that the unarchived module exists and hasn't be deleted or renamed before expecting it to be
116
-              # in the archive.
117
-              File.exist?(unarchived_path).should be_truthy
118
-              cache[archived_path].should_not be_nil
119
-            end
120
-          end
121
-        end
122
-      end
123
-
124
-      context 'with compression and without encryption' do
125
-        let(:flags) do
126
-          flag_compress
127
-        end
128
-
129
-        it 'should create an archive' do
130
-          File.exist?(@destination_path).should be_falsey
131
-
132
-          described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
133
-
134
-          File.exist?(@destination_path).should be_truthy
135
-        end
136
-
137
-        it 'should be smaller than the uncompressed archive' do
138
-          uncompressed_path = "#{@destination_path}.uncompressed"
139
-          compressed_path = "#{@destination_path}.compressed"
140
-
141
-          File.exist?(uncompressed_path).should be_falsey
142
-          File.exist?(compressed_path).should be_falsey
143
-
144
-          described_class.dump(uncompressed_path, '', base_path, *unarchived_paths)
145
-          described_class.dump(compressed_path, flag_string, base_path, *unarchived_paths)
146
-
147
-          File.exist?(uncompressed_path).should be_truthy
148
-          File.exist?(compressed_path).should be_truthy
149
-
150
-          File.size(compressed_path).should < File.size(uncompressed_path)
151
-        end
152
-      end
153
-
154
-      context 'without compression and with encryption' do
155
-        let(:flags) do
156
-          flag_encrypt
157
-        end
158
-
159
-        it 'should create an archive' do
160
-          File.exist?(@destination_path).should be_falsey
161
-
162
-          described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
163
-
164
-          File.exist?(@destination_path).should be_truthy
165
-        end
166
-      end
167
-
168
-      context 'with compression and with encryption' do
169
-        let(:flags) do
170
-          flag_compress | flag_encrypt
171
-        end
172
-
173
-        it 'should create an archive' do
174
-          File.exist?(@destination_path).should be_falsey
175
-
176
-          described_class.dump(@destination_path, flag_string, base_path, *unarchived_paths)
177
-
178
-          File.exist?(@destination_path).should be_truthy
179
-        end
180
-      end
181
-    end
182
-
183
-    context 'list' do
184
-      around(:each) do |example|
185
-        Dir.mktmpdir do |directory|
186
-          @destination_path = File.join(directory, "rspec#{extension}")
187
-
188
-          FastLib.dump(@destination_path, FastLib::FLAG_COMPRESS.to_s, base_path, *unarchived_paths)
189
-
190
-          example.run
191
-        end
192
-      end
193
-
194
-      # ensure modules expected to be listed actually exist
195
-      it 'should use existent unarchived modules' do
196
-        unarchived_paths.each do |unarchived_path|
197
-          File.exist?(unarchived_path).should be_truthy
198
-        end
199
-      end
200
-
201
-      skip "Fix https://www.pivotaltracker.com/story/show/38730815" do
202
-        context 'with cached dump' do
203
-          it 'should have dump cached' do
204
-            FastLib.cache[@destination_path].should_not be_nil
205
-          end
206
-
207
-          it 'should list archived paths' do
208
-            paths = FastLib.list(@destination_path)
209
-
210
-            paths.length.should == archived_paths.length
211
-            paths.should == archived_paths
212
-          end
213
-        end
214
-      end
215
-
216
-      context 'without cached dump' do
217
-        before(:each) do
218
-          FastLib.cache.clear
219
-        end
220
-
221
-        it 'should not have dump cache' do
222
-          FastLib.cache[@destination_path].should be_nil
223
-        end
224
-
225
-        it 'should list archived paths' do
226
-          paths = FastLib.list(@destination_path)
227
-
228
-          paths.length.should == archived_paths.length
229
-          paths.should == archived_paths
230
-        end
231
-      end
232
-    end
233
-  end
234
-end

+ 0
- 8
spec/lib/msf/core/module_manager_spec.rb View File

@@ -19,14 +19,6 @@ require 'msf/core'
19 19
 describe Msf::ModuleManager do
20 20
   include_context 'Msf::Simple::Framework'
21 21
 
22
-  let(:archive_basename) do
23
-    [basename_prefix, archive_extension]
24
-  end
25
-
26
-  let(:archive_extension) do
27
-    '.fastlib'
28
-  end
29
-
30 22
   let(:basename_prefix) do
31 23
     'rspec'
32 24
   end

+ 0
- 276
spec/lib/msf/core/modules/loader/archive_spec.rb View File

@@ -1,276 +0,0 @@
1
-# -*- coding:binary -*-
2
-require 'spec_helper'
3
-
4
-require 'msf/core'
5
-
6
-describe Msf::Modules::Loader::Archive do
7
-  let(:archive_extension) do
8
-    '.fastlib'
9
-  end
10
-
11
-  context 'CONSTANTS' do
12
-    it 'should have extension' do
13
-      described_class::ARCHIVE_EXTENSION.should == archive_extension
14
-    end
15
-  end
16
-
17
-  context 'instance methods' do
18
-    let(:enabled_type) do
19
-      'exploit'
20
-    end
21
-
22
-    let(:enabled_type_directory) do
23
-      'exploits'
24
-    end
25
-
26
-    let(:framework) do
27
-      double('Framework')
28
-    end
29
-
30
-    let(:module_extension) do
31
-      '.rb'
32
-    end
33
-
34
-    let(:module_manager) do
35
-      # DO NOT mock module_manager to ensure that no protected methods are being called.
36
-      Msf::ModuleManager.new(framework, [enabled_type])
37
-    end
38
-
39
-    let(:module_reference_name) do
40
-      'module/reference/name'
41
-    end
42
-
43
-    subject do
44
-      described_class.new(module_manager)
45
-    end
46
-
47
-    context '#each_module_reference_name' do
48
-      let(:disabled_module_content) do
49
-        <<-EOS
50
-        class Metasploit3 < Msf::Auxiliary
51
-        end
52
-        EOS
53
-      end
54
-
55
-      let(:disabled_type) do
56
-        'auxiliary'
57
-      end
58
-
59
-      let(:disabled_type_directory) do
60
-        'auxiliary'
61
-      end
62
-
63
-      let(:enabled_module_content) do
64
-        <<-EOS
65
-        class Metasploit3 < Msf::Exploit::Remote
66
-        end
67
-        EOS
68
-      end
69
-
70
-      around(:each) do |example|
71
-        Dir.mktmpdir do |directory|
72
-          @base_path = directory
73
-
74
-          # make a .svn directory to be ignored
75
-          subversion_path = File.join(@base_path, '.svn')
76
-          FileUtils.mkdir_p subversion_path
77
-
78
-          # make a type directory that should be ignored because it's not enabled
79
-          disabled_type_path = File.join(@base_path, disabled_type_directory)
80
-          FileUtils.mkdir_p disabled_type_path
81
-
82
-          #
83
-          # create a valid module in the disabled type directory to make sure it's the enablement that's preventing the
84
-          # yield
85
-          #
86
-
87
-          disabled_module_path = File.join(disabled_type_path, "#{disabled_type}#{module_extension}")
88
-
89
-          File.open(disabled_module_path, 'wb') do |f|
90
-            f.write(disabled_module_content)
91
-          end
92
-
93
-          # make a type directory that should not be ignored because it is enabled
94
-          enabled_module_path = File.join(
95
-              @base_path,
96
-              enabled_type_directory,
97
-              "#{module_reference_name}#{module_extension}"
98
-          )
99
-          enabled_module_directory = File.dirname(enabled_module_path)
100
-          FileUtils.mkdir_p enabled_module_directory
101
-
102
-          File.open(enabled_module_path, 'wb') do |f|
103
-            f.write(enabled_module_content)
104
-          end
105
-
106
-          Dir.mktmpdir do |archive_directory|
107
-            @archive_path = File.join(archive_directory, "rspec#{archive_extension}")
108
-            FastLib.dump(@archive_path, FastLib::FLAG_COMPRESS.to_s(16), @base_path, @base_path)
109
-
110
-            # @todo Fix https://www.pivotaltracker.com/story/show/38730815 and the cache won't need to be cleared as a work-around
111
-            FastLib.cache.clear
112
-
113
-            example.run
114
-          end
115
-        end
116
-      end
117
-
118
-      # this checks that the around(:each) is working
119
-      it 'should have an existent FastLib' do
120
-        File.exist?(@archive_path).should be_truthy
121
-      end
122
-
123
-      it 'should ignore .svn directories' do
124
-        subject.send(:each_module_reference_name, @archive_path) do |parent_path, type, module_reference_name|
125
-          parent_path.should_not include('.svn')
126
-        end
127
-      end
128
-
129
-      it 'should ignore types that are not enabled' do
130
-        module_manager.type_enabled?(disabled_type).should be_falsey
131
-
132
-        subject.send(:each_module_reference_name, @archive_path) do |parent_path, type, module_reference_name|
133
-          type.should_not == disabled_type
134
-        end
135
-      end
136
-
137
-      it 'should yield (parent_path, type, module_reference_name) with parent_path equal to the archive path' do
138
-        subject.send(:each_module_reference_name, @archive_path) do |parent_path, type, module_reference_name|
139
-          parent_path.should == @archive_path
140
-        end
141
-      end
142
-
143
-      it 'should yield (parent_path, type, module_reference_name) with type equal to enabled type' do
144
-        module_manager.type_enabled?(enabled_type).should be_truthy
145
-
146
-        subject.send(:each_module_reference_name, @archive_path) do |parent_path, type, module_reference_name|
147
-          type.should == enabled_type
148
-        end
149
-      end
150
-
151
-      it 'should yield (path, type, module_reference_name) with module_reference_name without extension' do
152
-        subject.send(:each_module_reference_name, @archive_path) do |parent_path, type, module_reference_name|
153
-          module_reference_name.should_not match(/#{Regexp.escape(module_extension)}$/)
154
-          module_reference_name.should == module_reference_name
155
-        end
156
-      end
157
-
158
-      # ensure that the block is actually being run so that shoulds in the block aren't just being skipped
159
-      it 'should yield the correct number of tuples' do
160
-        actual_count = 0
161
-
162
-        subject.send(:each_module_reference_name, @archive_path) do |parent_path, type, module_reference_name|
163
-          actual_count += 1
164
-        end
165
-
166
-        actual_count.should == 1
167
-      end
168
-    end
169
-
170
-    context '#loadable?' do
171
-      it 'should return true if the path has ARCHIVE_EXTENSION as file extension' do
172
-        path = "path/to/archive#{archive_extension}"
173
-
174
-        File.extname(path).should == described_class::ARCHIVE_EXTENSION
175
-        subject.loadable?(path).should be_truthy
176
-      end
177
-
178
-      it 'should return false if the path contains ARCHIVE_EXTENSION, but it is not the file extension' do
179
-        path = "path/to/archive#{archive_extension}.bak"
180
-
181
-        path.should include(described_class::ARCHIVE_EXTENSION)
182
-        File.extname(path).should_not == described_class::ARCHIVE_EXTENSION
183
-        subject.loadable?(path).should be_falsey
184
-      end
185
-    end
186
-
187
-    context '#module_path' do
188
-      let(:parent_path) do
189
-        "path/to/archive#{archive_extension}"
190
-      end
191
-
192
-      let(:type) do
193
-        'exploit'
194
-      end
195
-
196
-      let(:type_directory) do
197
-        'exploits'
198
-      end
199
-
200
-      it 'should use typed_path to convert the type name to a type directory' do
201
-        subject.should_receive(:typed_path).with(type, module_reference_name)
202
-
203
-        subject.send(:module_path, parent_path, type, module_reference_name)
204
-      end
205
-
206
-      it "should separate the archive path from the entry path with '::'" do
207
-        module_path = subject.send(:module_path, parent_path, type, module_reference_name)
208
-
209
-        module_path.should == "#{parent_path}::#{type_directory}/#{module_reference_name}.rb"
210
-      end
211
-    end
212
-
213
-    context '#read_module_path' do
214
-      let(:module_reference_name) do
215
-        'windows/smb/ms08_067_netapi'
216
-      end
217
-
218
-      let(:type) do
219
-        enabled_type
220
-      end
221
-
222
-      let(:type_directory) do
223
-        enabled_type_directory
224
-      end
225
-
226
-      let(:archived_path) do
227
-        File.join(type_directory, "#{module_reference_name}#{module_extension}")
228
-      end
229
-
230
-      let(:base_path) do
231
-        File.join(Msf::Config.install_root, 'modules')
232
-      end
233
-
234
-      let(:flag_string) do
235
-        flags.to_s(16)
236
-      end
237
-
238
-      let(:flags) do
239
-        0x0
240
-      end
241
-
242
-      let(:unarchived_path) do
243
-        File.join(base_path, archived_path)
244
-      end
245
-
246
-      it 'should read modules that exist' do
247
-        File.exist?(unarchived_path).should be_truthy
248
-      end
249
-
250
-      around(:each) do |example|
251
-        Dir.mktmpdir do |directory|
252
-          @parent_path = File.join(directory, 'rspec.fastlib')
253
-
254
-          FastLib.dump(@parent_path, flag_string, base_path, unarchived_path)
255
-
256
-          # @todo Fix https://www.pivotaltracker.com/story/show/38730815 so cache from dump is correct
257
-          FastLib.cache.clear
258
-
259
-          example.run
260
-        end
261
-      end
262
-
263
-      context 'with uncompressed archive' do
264
-        it_should_behave_like 'Msf::Modules::Loader::Archive#read_module_content'
265
-      end
266
-
267
-      context 'with compressed archive' do
268
-        let(:flags) do
269
-          FastLib::FLAG_COMPRESS
270
-        end
271
-
272
-        it_should_behave_like 'Msf::Modules::Loader::Archive#read_module_content'
273
-      end
274
-    end
275
-  end
276
-end

+ 0
- 1
spec/lib/rex/proto/pjl/client_spec.rb View File

@@ -1,5 +1,4 @@
1 1
 require 'spec_helper'
2
-require 'fastlib'
3 2
 require 'msfenv'
4 3
 require 'msf/base'
5 4
 require 'rex/proto/pjl'

+ 0
- 1
spec/msfcli_spec.rb View File

@@ -2,7 +2,6 @@ require 'spec_helper'
2 2
 
3 3
 load Metasploit::Framework.root.join('msfcli').to_path
4 4
 
5
-require 'fastlib'
6 5
 require 'msfenv'
7 6
 require 'msf/ui'
8 7
 require 'msf/base'

+ 0
- 40
spec/support/shared/examples/msf/module_manager/module_paths.rb View File

@@ -14,33 +14,6 @@ shared_examples_for 'Msf::ModuleManager::ModulePaths' do
14 14
       end
15 15
     end
16 16
 
17
-    context 'with Fastlib archive' do
18
-      it 'should raise an ArgumentError unless the File exists' do
19
-        file = Tempfile.new(archive_basename)
20
-        # unlink will clear path, so copy it to a variable
21
-        path = file.path
22
-        file.unlink
23
-
24
-        File.exist?(path).should be_falsey
25
-
26
-        expect {
27
-          module_manager.add_module_path(path)
28
-        }.to raise_error(ArgumentError, "The path supplied does not exist")
29
-      end
30
-
31
-      it 'should add the path to #module_paths if the File exists' do
32
-        Tempfile.open(archive_basename) do |temporary_file|
33
-          path = temporary_file.path
34
-
35
-          File.exist?(path).should be_truthy
36
-
37
-          module_manager.add_module_path(path)
38
-
39
-          module_paths.should include(path)
40
-        end
41
-      end
42
-    end
43
-
44 17
     context 'with directory' do
45 18
       it 'should add path to #module_paths' do
46 19
         Dir.mktmpdir do |path|
@@ -49,19 +22,6 @@ shared_examples_for 'Msf::ModuleManager::ModulePaths' do
49 22
           module_paths.should include(path)
50 23
         end
51 24
       end
52
-
53
-      context 'containing Fastlib archives' do
54
-        it 'should add each Fastlib archive to #module_paths' do
55
-          Dir.mktmpdir do |directory|
56
-            Tempfile.open(archive_basename, directory) do |file|
57
-              module_manager.add_module_path(directory)
58
-
59
-              module_paths.should include(directory)
60
-              module_paths.should include(file.path)
61
-            end
62
-          end
63
-        end
64
-      end
65 25
     end
66 26
 
67 27
     context 'with other file' do

+ 0
- 14
spec/support/shared/examples/msf/modules/loader_archive_read_module_content.rb View File

@@ -1,14 +0,0 @@
1
-# -*- coding:binary -*-
2
-shared_examples_for 'Msf::Modules::Loader::Archive#read_module_content' do
3
-  it 'should be able to read the module content' do
4
-    archived_module_content = subject.send(:read_module_content, @parent_path, type, module_reference_name)
5
-    unarchived_module_content = ''
6
-
7
-    File.open(unarchived_path) do |f|
8
-      unarchived_module_content = f.read
9
-    end
10
-
11
-    unarchived_module_content.should_not be_empty
12
-    archived_module_content.should == unarchived_module_content
13
-  end
14
-end

+ 0
- 1
spec/tools/cpassword_decrypt_spec.rb View File

@@ -2,7 +2,6 @@ require 'spec_helper'
2 2
 
3 3
 load Metasploit::Framework.root.join('tools/cpassword_decrypt.rb').to_path
4 4
 
5
-require 'fastlib'
6 5
 require 'msfenv'
7 6
 require 'msf/base'
8 7
 

+ 0
- 1
spec/tools/virustotal_spec.rb View File

@@ -2,7 +2,6 @@ require 'spec_helper'
2 2
 
3 3
 load Metasploit::Framework.root.join('tools/virustotal.rb').to_path
4 4
 
5
-require 'fastlib'
6 5
 require 'msfenv'
7 6
 require 'msf/base'
8 7
 require 'digest/sha2'

+ 0
- 1
test/tests/test_encoders.rb View File

@@ -11,7 +11,6 @@ end
11 11
 
12 12
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
13 13
 
14
-require 'fastlib'
15 14
 require 'msfenv'
16 15
 require 'msf/base'
17 16
 

+ 0
- 1
tools/cpassword_decrypt.rb View File

@@ -38,7 +38,6 @@ while File.symlink?(msfbase)
38 38
 end
39 39
 
40 40
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
41
-require 'fastlib'
42 41
 require 'msfenv'
43 42
 require 'rex'
44 43
 

+ 0
- 1
tools/exe2vba.rb View File

@@ -14,7 +14,6 @@ while File.symlink?(msfbase)
14 14
 end
15 15
 
16 16
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
17
-require 'fastlib'
18 17
 require 'msfenv'
19 18
 
20 19
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/exe2vbs.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/find_badchars.rb View File

@@ -14,7 +14,6 @@ while File.symlink?(msfbase)
14 14
 end
15 15
 
16 16
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
17
-require 'fastlib'
18 17
 require 'msfenv'
19 18
 
20 19
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/halflm_second.rb View File

@@ -16,7 +16,6 @@ while File.symlink?(msfbase)
16 16
 end
17 17
 
18 18
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
19
-require 'fastlib'
20 19
 require 'msfenv'
21 20
 
22 21
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/hmac_sha1_crack.rb View File

@@ -16,7 +16,6 @@ while File.symlink?(msfbase)
16 16
 end
17 17
 
18 18
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
19
-require 'fastlib'
20 19
 require 'msfenv'
21 20
 
22 21
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/list_interfaces.rb View File

@@ -15,7 +15,6 @@ while File.symlink?(msfbase)
15 15
 end
16 16
 
17 17
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
18
-require 'fastlib'
19 18
 require 'msfenv'
20 19
 
21 20
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/lm2ntcrack.rb View File

@@ -14,7 +14,6 @@ while File.symlink?(msfbase)
14 14
 end
15 15
 
16 16
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
17
-require 'fastlib'
18 17
 require 'msfenv'
19 18
 
20 19
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/metasm_shell.rb View File

@@ -21,7 +21,6 @@ while File.symlink?(msfbase)
21 21
 end
22 22
 
23 23
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
24
-require 'fastlib'
25 24
 require 'msfenv'
26 25
 
27 26
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_author.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_changelog.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_count.rb View File

@@ -8,7 +8,6 @@ while File.symlink?(msfbase)
8 8
 end
9 9
 
10 10
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
11
-require 'fastlib'
12 11
 require 'msfenv'
13 12
 
14 13
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_disclodate.rb View File

@@ -12,7 +12,6 @@ while File.symlink?(msfbase)
12 12
 end
13 13
 
14 14
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
15
-require 'fastlib'
16 15
 require 'msfenv'
17 16
 
18 17
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_license.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_mixins.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_payloads.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_ports.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_rank.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_reference.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/module_targets.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/msf_irb_shell.rb View File

@@ -10,7 +10,6 @@ while File.symlink?(msfbase)
10 10
 end
11 11
 
12 12
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
13
-require 'fastlib'
14 13
 require 'msfenv'
15 14
 
16 15
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/nasm_shell.rb View File

@@ -15,7 +15,6 @@ while File.symlink?(msfbase)
15 15
 end
16 16
 
17 17
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
18
-require 'fastlib'
19 18
 require 'msfenv'
20 19
 
21 20
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 6
tools/pack_fastlib.sh View File

@@ -1,6 +0,0 @@
1
-#!/bin/sh
2
-
3
-mkdir fastlib-archived
4
-./lib/fastlib.rb store modules.fastlib 12345603 modules/ modules/*
5
-./lib/fastlib.rb store lib/metasploit.fastlib 12345603 lib lib/msf/ lib/rex*
6
-mv lib/msf lib/rex* modules/ fastlib-archived

+ 0
- 1
tools/pattern_create.rb View File

@@ -10,7 +10,6 @@ while File.symlink?(msfbase)
10 10
 end
11 11
 
12 12
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
13
-require 'fastlib'
14 13
 require 'msfenv'
15 14
 
16 15
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/pattern_offset.rb View File

@@ -8,7 +8,6 @@ while File.symlink?(msfbase)
8 8
 end
9 9
 
10 10
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
11
-require 'fastlib'
12 11
 require 'msfenv'
13 12
 
14 13
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/payload_lengths.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/psexec.rb View File

@@ -10,7 +10,6 @@ while File.symlink?(msfbase)
10 10
 end
11 11
 
12 12
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
13
-require 'fastlib'
14 13
 require 'msfenv'
15 14
 
16 15
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/reg.rb View File

@@ -13,7 +13,6 @@ while File.symlink?(msfbase)
13 13
 end
14 14
 
15 15
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
16
-require 'fastlib'
17 16
 require 'msfenv'
18 17
 
19 18
 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']

+ 0
- 1
tools/virustotal.rb View File

@@ -34,7 +34,6 @@ while File.symlink?(msfbase)
34 34
 end
35 35
 
36 36
 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
37
-require 'fastlib'
38 37
 require 'msfenv'
39 38
 require 'rex'
40 39
 require 'msf/core'

Loading…
Cancel
Save