-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
move external module template to an ERB, allowing for more templates to be added #8346
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Msf::Module::External | ||
def wait_status(mod) | ||
while mod.running | ||
m = mod.get_status | ||
if m | ||
case m['level'] | ||
when 'error' | ||
print_error m['message'] | ||
when 'warning' | ||
print_warning m['message'] | ||
when 'good' | ||
print_good m['message'] | ||
when 'info' | ||
print_status m['message'] | ||
when 'debug' | ||
vprint_status m['message'] | ||
else | ||
print_status m['message'] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'Name' => <%= meta[:name] %>, | ||
'Description' => <%= meta[:description] %>, | ||
'Author' => | ||
[ | ||
<%= meta[:authors] %> | ||
], | ||
'License' => MSF_LICENSE, |
48 changes: 48 additions & 0 deletions
48
lib/msf/core/modules/external/templates/remote_exploit_cmd_stager.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'msf/core/modules/external/bridge' | ||
require 'msf/core/module/external' | ||
|
||
class MetasploitModule < Msf::Exploit::Remote | ||
Rank = ExcellentRanking | ||
|
||
include Msf::Module::External | ||
include Msf::Exploit::CmdStager | ||
|
||
def initialize(info = {}) | ||
super(update_info(info, | ||
<%= common_metadata meta %> | ||
'References' => | ||
[ | ||
<%= meta[:references] %> | ||
], | ||
'DisclosureDate' => <%= meta[:date] %>, | ||
'Privileged' => <%= meta[:privileged] %>, | ||
'Platform' => [<%= meta[:platform] %>], | ||
'Payload' => | ||
{ | ||
'DisableNops' => true | ||
}, | ||
'Targets' => | ||
[ | ||
<%= meta[:targets] %> | ||
], | ||
'DefaultTarget' => 0, | ||
'DefaultOptions' => { 'WfsDelay' => <%= meta[:wfsdelay] %> } | ||
)) | ||
|
||
register_options([ | ||
<%= meta[:options] %> | ||
]) | ||
end | ||
|
||
def execute_command(cmd, opts) | ||
mod = Msf::Modules::External::Bridge.open(<%= meta[:path] %>) | ||
mod.run(datastore.merge(command: cmd)) | ||
wait_status(mod) | ||
true | ||
end | ||
|
||
def exploit | ||
print_status("Exploiting...") | ||
execute_cmdstager({:flavor => :<%= meta[:command_stager_flavor] %>}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,12 +34,16 @@ | |
{'type': 'edb', 'ref': '41162'}, | ||
{'type': 'url', 'ref': 'https://github.com/haraka/Haraka/pull/1606'}, | ||
], | ||
'type': 'remote_exploit.cmd_stager.wget', | ||
'type': 'remote_exploit_cmd_stager', | ||
'wfsdelay': 5, | ||
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. I think this should be changed in the template. 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. updated, thx |
||
'privileged': True, | ||
'targets': [ | ||
{'platform': 'linux', 'arch': 'x64'}, | ||
{'platform': 'linux', 'arch': 'x86'} | ||
], | ||
'payload': { | ||
'command_stager_flavor': 'wget' | ||
}, | ||
'options': { | ||
'email_to': {'type': 'string', 'description': 'Email to send to, must be accepted by the server', 'required': True, 'default': 'admin@localhost'}, | ||
'email_from': {'type': 'string', 'description': 'Address to send from', 'required': True, 'default': 'foo@example.com'}, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra debugging.