Path: blob/master/documentation/modules/exploit/multi/misc/osgi_console_exec.md
26054 views
Vulnerable Application
Description
This module takes advantage of OSGi consoles exposed by some Java-based middleware servers.
The OSGi console is a telnet-based server that can be used for remote debugging and dynamic loading/removal of Java bundles running on an OSGi based server.
Test setup
Linux environment
Follow these steps to run the vulnerable application on a Linux host:
Create a test environment directory
mkdir testenv && cd testenvDownload the setup script
wget https://gist.githubusercontent.com/QKaiser/66c8a618eef2a7801c0bbb1aa43d724a/raw/e098f6ea31717311bd6ce5b3be94744dddfc2388/setup.shSet appropriate permission
chmod +x setup.shExecute setup script
./setup.shLaunch the vulnerable application with this command so it listens on port TCP/5555
java -jar org.eclipse.osgi.jar -console 5555Verify that the server is running, you should be prompted with
osgi>telnet localhost 5555From the telnet console, enable the second second server. This one listens on port 2019 by default. Set the IP to an address linked to an external interface if attacker machine is on another host.
telnetd --ip=127.0.0.1 start
Windows environment
Follow these steps to run the vulnerable application on a Windows host:
Download the Eclipse Equinox SDK from https://www.eclipse.org/downloads/download.php?file=/equinox/drops/R-Oxygen.2-201711300510/equinox-SDK-Oxygen.2.zip&r=1
Create a test directory. Let's name it
osgi_testfor clarity.Create a directory named
configurationinosgi_testCreate a file named
config.iniin yourconfigurationdirectory. The file should contain the following lines only:
Create an empty
pluginsdirectory inosgi_testdirectoryExtract
plugins/org.apache.felix.gogo.command_(version).jarfrom the SDK asorg.apache.felix.gogo.command.jarinosgi_testdirectory.Extract
plugins/org.apache.felix.gogo.runtime_(version).jarfrom the SDK asorg.apache.felix.gogo.runtime.jarinosgi_testdirectory.Extract
plugins/org.apache.felix.gogo.shell_(version).jarfrom the SDK asorg.apache.felix.gogo.shell.jarinosgi_testdirectory.Extract
plugins/org.eclipse.equinox.console_(version).jarfrom the SDK asorg.eclipse.equinox.console.jarinosgi_testdirectory.Extract
plugins/org.eclipse.osgi_(version).jarfrom the SDK asorg.eclipse.osgi.jarinosgi_testdirectory.At the end of those steps, your
osgi_testdirectory should contain the following items:
Launch the vulnerable application with this command so it listens on port TCP/5555
java -jar org.eclipse.osgi.jar -console 5555Verify that the server is running, you should be prompted with
osgi>telnet localhost 5555From the telnet console, enable the second second server. This one listens on port 2019 by default. Set the IP to an address linked to an external interface if attacker machine is on another host.
telnetd --ip=127.0.0.1 start
If you don't want to go through all those steps manually I recommend you to run the setup script on a Linux host, mount the directory on a Windows VM and start from step 11.
Verification Steps
You can verify the module against the vulnerable application with those steps:
Install the application
Start msfconsole
Do:
use exploit/multi/misc/osgi_console_execDo:
set RHOST 127.0.0.1Do:
set RPORT 5555orset RPORT 2019Do:
check. The target should appear vulnerable.Do:
set payloadwith the payload of your choosing.Do:
runYou should get a shell.
Options
TIME_WAIT
Time to wait for payload to be executed. The default value is set to 20 seconds.
Scenarios
Reverse shell on Linux host
Exploit running against a Ubuntu Linux target:
Reverse shell on Windows host
Exploit running against a Windows 7 target: