Skip to content
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

SAP ConfigServlet OS command execution module #1740

Closed
wants to merge 6 commits into from

Conversation

andrewkabai
Copy link
Contributor

This module allows execution of operating system commands throug the
SAP ConfigServlet without any authentication.

The vulnerability was discovered by ERPScan's team, it was presented on Hacker Halted 2012 conference:
http://erpscan.com/wp-content/uploads/2012/11/Breaking-SAP-Portal-HackerHalted-2012.pdf

This module allows execution of operating system commands throug the
SAP ConfigServlet without any authentication.
class Metasploit3 < Msf::Auxiliary
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Scanner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this module isn't an scanner I would recommend to not use the Scanner mixin here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still better, I would recommend to switch to an exploit module :P sorry commented before full module review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used Scanner mixin because I had to execute OS commands on several machines in the same time and I was able to use RHOSTS for 'services -p 50000 -R' in this way. Could you recommend an other solution? Btw, it is ok to remove the Scanner mixin.

remove Scanner mixin because this module is not a scanner modul
switch from PATH to TARGETURI datastore;
use normalize_uri to build uri;
use query in send_request_cgi to to prepare query string (instead of
vars_get that escapes the necessary semicolons)
require 'msf/core'

class Metasploit3 < Msf::Auxiliary
Rank = ExcellentRanking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Rank field isn't needed on auxiliary modules

@jvazquez-r7
Copy link
Contributor

It's not msftidy compliant at this moment, msftidy warnings should be fixed:

$ tools/msftidy.rb modules/auxiliary/admin/sap/sap_configservlet_exec_noauth.rb 
sap_configservlet_exec_noauth.rb:39 - [WARNING] Spaces at EOL

'Andras Kabai' # Metasploit module
],
'License' => MSF_LICENSE,
'References' =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any CVE, OSVDB and/or BID reference for this vulnerability? just asking :) If there is would be nice to add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I know there is no more reference to this vulnerability yet.

@jvazquez-r7
Copy link
Contributor

Hi @andrewkabai , do you mind to share a pcap of the module working for verification? Since I dont find any free trial / edition of SAP java I guess it would be the easiest way to verify it and be able to proceed with merging :) Feel free to use email if would be better for you: juan.vazquez [at] metasploit.com

@andrewkabai
Copy link
Contributor Author

hi @jvazquez-r7 , sure, I don't mind, but I can access to the vulnerable environment on Monday. I will send the pcap via email.

@jvazquez-r7
Copy link
Contributor

Sounds good! thanks very much!

@andrewkabai
Copy link
Contributor Author

I sent the validation pcap via email!

@jvazquez-r7
Copy link
Contributor

Hi @andrewkabai

pcap verified and looks fine!, module is mainly ready to be merged! Thanks very much for your collaboration!

But I've just noticed you're using your mater branch to do the pull request. I'm going to need to ask you to do a new pull request, using a new branch on your repo, to avoid problems when merging into the rapid7 repository.

In order to do it fine just create new branch from your master branch. For example:

git checkout master
git checkout -b sap_portal_configservlet

Write the new module and then add the new module, in the new branch, to your local repository and push into your origin:

git add modules/auxiliary/admin/sap/sap_configservlet_exec_noauth.rb
git commit -m "Add module for SAP Portal cmd exec"
git push origin sap_portal_configservlet

Then proceed to do the pull request against the rapid7 repository, but using the new branch. I've just tried to provide sample commands. You can carefully review how to proceed with pull requests from the documentation available at the wiki: https://github.com/rapid7/metasploit-framework/wiki/Setting-Up-a-Metasploit-Development-Environment

Please dont hesitate on contact me if you've any doubt. In the meanwhile I'm going to close this pull request because it can not be merged.

Thanks very much!

juan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants