-
Notifications
You must be signed in to change notification settings - Fork 14.6k
MeterpreterOptions break-up and default extension loading removal #20012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
44617cb
a7f4da5
e44043b
dd23be9
e4bc2a6
70bafdf
c4ca4d6
5e3e975
da7ee9d
f18787e
ef6e59d
9e10d24
2fac43c
fa68bd8
d45193b
56fc33f
ee05f88
25e0538
8985cd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,32 +180,30 @@ def bootstrap(datastore = {}, handler = nil) | |
print_warning('Meterpreter start up operations have been aborted. Use the session at your own risk.') | ||
return nil | ||
end | ||
# Unhook the process prior to loading stdapi to reduce logging/inspection by any AV/PSP | ||
if datastore['AutoUnhookProcess'] == true | ||
console.run_single('load unhook') | ||
console.run_single('unhook_pe') | ||
end | ||
|
||
unless datastore['AutoLoadStdapi'] == false | ||
|
||
session.load_stdapi | ||
|
||
unless datastore['AutoSystemInfo'] == false | ||
session.load_session_info | ||
end | ||
|
||
# only load priv on native windows | ||
# TODO: abstract this too, to remove windows stuff | ||
if session.platform == 'windows' && [ARCH_X86, ARCH_X64].include?(session.arch) | ||
session.load_priv rescue nil | ||
end | ||
end | ||
|
||
extensions = datastore['AutoLoadExtensions']&.delete(' ').split(',') || [] | ||
|
||
# BEGIN: This should be removed on MSF 7 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can keep this around in MSF 7 still; maybe we could just change the default behaviors in the upcoming malleable profile config file setup that we're wanting to ship so that these aren't loaded by default, and they need to be opt-in. That way we're being less detected by default, rather than fighting against these older default values |
||
# Unhook the process prior to loading stdapi to reduce logging/inspection by any AV/PSP (by default unhook is first, see meterpreter_options/windows.rb) | ||
extensions.push('unhook') if datastore['AutoUnhookProcess'] && session.platform == 'windows' | ||
extensions.push('stdapi') if datastore['AutoLoadStdapi'] | ||
msutovsky-r7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extensions.push('priv') if datastore['AutoLoadStdapi'] && session.platform == 'windows' | ||
extensions.push('android') if session.platform == 'android' | ||
extensions = extensions.uniq | ||
# END | ||
original = console.disable_output | ||
console.disable_output = true | ||
# TODO: abstract this a little, perhaps a "post load" function that removes | ||
# platform-specific stuff? | ||
if session.platform == 'android' | ||
session.load_android | ||
extensions.each do |extension| | ||
begin | ||
console.run_single("load #{extension}") | ||
console.run_single('unhook_pe') if extension == 'unhook' | ||
session.load_session_info if extension == 'stdapi' && datastore['AutoSystemInfo'] | ||
rescue => e | ||
print_warning("Failed loading extension #{extension}") | ||
end | ||
end | ||
console.disable_output = original | ||
|
||
['InitialAutoRunScript', 'AutoRunScript'].each do |key| | ||
unless datastore[key].nil? || datastore[key].empty? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::Android | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'stdapi,android'] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::AppleIos | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'stdapi'] | ||
), | ||
OptString.new( | ||
'PayloadProcessCommandLine', | ||
[ false, 'The displayed command line that will be used by the payload', ''] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::Bsd | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'stdapi'] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::Java | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'stdapi'] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::Linux | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'stdapi'] | ||
), | ||
OptString.new( | ||
'PayloadProcessCommandLine', | ||
[ false, 'The displayed command line that will be used by the payload', ''] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::OSX | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, 'Automatically load extensions on bootstrap, comma separated.', 'stdapi'] | ||
), | ||
OptString.new( | ||
'PayloadProcessCommandLine', | ||
[ false, 'The displayed command line that will be used by the payload', ''] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::Php | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'stdapi'] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::Python | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'stdapi'] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'shellwords' | ||
|
||
module Msf | ||
module Sessions | ||
# | ||
# Defines common options across all Meterpreter implementations | ||
# | ||
module MeterpreterOptions::Windows | ||
include Msf::Sessions::MeterpreterOptions::Common | ||
def initialize(info = {}) | ||
super(info) | ||
|
||
register_advanced_options( | ||
[ | ||
OptString.new( | ||
'AutoLoadExtensions', | ||
[true, "Automatically load extensions on bootstrap, comma separated.", 'unhook,priv,stdapi'] | ||
), | ||
OptBool.new( | ||
'AutoUnhookProcess', | ||
[true, "Automatically load the unhook extension and unhook the process", false] | ||
), | ||
], | ||
self.class | ||
) | ||
end | ||
end | ||
end | ||
end |
Uh oh!
There was an error while loading. Please reload this page.