Java RMI: Detection

Remote code execution (RCE)Exploitation

From PayloadsAllTheThings by Swissky and contributors, under the MIT licence. Shown as written; the title and classification are ours. Licences. Its authors can have this tip removed by writing to abuse@bugbountytips.org.

  • Using nmap:

    powershell
    $ nmap -sV --script "rmi-dumpregistry or rmi-vuln-classloader" -p TARGET_PORT TARGET_IP -Pn -v
    1089/tcp open  java-rmi Java RMI
    | rmi-vuln-classloader:
    |   VULNERABLE:
    |   RMI registry default configuration remote code execution vulnerability
    |     State: VULNERABLE
    |       Default configuration of RMI registry allows loading classes from remote URLs which can lead to remote code execution.
    | rmi-dumpregistry:
    |   jmxrmi
    |     javax.management.remote.rmi.RMIServerImpl_Stub
  • Using qtc-de/remote-method-guesser:

    bash
    $ rmg scan 172.17.0.2 --ports 0-65535
    [+] Scanning 6225 Ports on 172.17.0.2 for RMI services.
    [+]  [HIT] Found RMI service(s) on 172.17.0.2:40393 (DGC)
    [+]  [HIT] Found RMI service(s) on 172.17.0.2:1090  (Registry, DGC)
    [+]  [HIT] Found RMI service(s) on 172.17.0.2:9010  (Registry, Activator, DGC)
    [+]  [6234 / 6234] [#############################] 100%
    [+] Portscan finished.
    
    $ rmg enum 172.17.0.2 9010
    [+] RMI registry bound names:
    [+]
    [+]  - plain-server2
    [+]   --> de.qtc.rmg.server.interfaces.IPlainServer (unknown class)
    [+]       Endpoint: iinsecure.dev:39153 ObjID: [-af587e6:17d6f7bb318:-7ff7, 9040809218460289711]
    [+]  - legacy-service
    [+]   --> de.qtc.rmg.server.legacy.LegacyServiceImpl_Stub (unknown class)
    [+]       Endpoint: iinsecure.dev:39153 ObjID: [-af587e6:17d6f7bb318:-7ffc, 4854919471498518309]
    [+]  - plain-server
    [+]   --> de.qtc.rmg.server.interfaces.IPlainServer (unknown class)
    [+]       Endpoint: iinsecure.dev:39153 ObjID: [-af587e6:17d6f7bb318:-7ff8, 6721714394791464813]
    [...]
  • Using rapid7/metasploit-framework

    bash
    use auxiliary/scanner/misc/java_rmi_server
    set RHOSTS <IPs>
    set RPORT <PORT>
    run

Comments

No comments yet.