From 9975d5a22044039d31448509db57f58f41738bc5 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Wed, 29 Feb 2012 01:34:29 -0600 Subject: [PATCH] Always clone modules before running them via the simplified wrappers. This prevents changes to the datastore or instance variables from being carried over into a second run --- lib/msf/base/simple/auxiliary.rb | 3 +++ lib/msf/base/simple/exploit.rb | 3 +++ lib/msf/base/simple/payload.rb | 3 +++ lib/msf/base/simple/post.rb | 3 +++ 4 files changed, 12 insertions(+) diff --git a/lib/msf/base/simple/auxiliary.rb b/lib/msf/base/simple/auxiliary.rb index 776210d4f0..dbaa6643da 100644 --- a/lib/msf/base/simple/auxiliary.rb +++ b/lib/msf/base/simple/auxiliary.rb @@ -42,6 +42,9 @@ module Auxiliary # def self.run_simple(mod, opts = {}) + # Clone the module to prevent changes to the original instance + mod = mod.replicant + # Import options from the OptionStr or Option hash. mod._import_extra_options(opts) diff --git a/lib/msf/base/simple/exploit.rb b/lib/msf/base/simple/exploit.rb index db70f24e7a..6cd132aacb 100644 --- a/lib/msf/base/simple/exploit.rb +++ b/lib/msf/base/simple/exploit.rb @@ -58,6 +58,9 @@ module Exploit # Trap and print errors here (makes them UI-independent) begin + # Clone the module to prevent changes to the original instance + exploit = exploit.replicant + # Import options from the OptionStr or Option hash. exploit._import_extra_options(opts) diff --git a/lib/msf/base/simple/payload.rb b/lib/msf/base/simple/payload.rb index b93c7af81b..c0968d464a 100644 --- a/lib/msf/base/simple/payload.rb +++ b/lib/msf/base/simple/payload.rb @@ -42,6 +42,9 @@ module Payload # def self.generate_simple(payload, opts) + # Clone the module to prevent changes to the original instance + payload = payload.replicant + # Import any options we may need payload._import_extra_options(opts) framework = payload.framework diff --git a/lib/msf/base/simple/post.rb b/lib/msf/base/simple/post.rb index 52a01166e5..83688d2b43 100644 --- a/lib/msf/base/simple/post.rb +++ b/lib/msf/base/simple/post.rb @@ -38,6 +38,9 @@ module Post # def self.run_simple(mod, opts = {}) + # Clone the module to prevent changes to the original instance + mod = mod.replicant + # Import options from the OptionStr or Option hash. mod._import_extra_options(opts)