-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors caused by NAT port mapping #42
Comments
Hi @genxor 👋 did you only map the What you did is only mapping the RMI registry. This is the naming service of Java RMI that maps human readable bound names to the actual RMI endpoints ( Notice that regular RMI tools (e.g. Now you probably ask how to map a randomly assigned port? Luckily, Java RMI allows multiple remote objects to run on the same port. Therefore, you can use the same port for the RMI registry and the JMX service. If you use Java's default JMX service, you can achieve this by using the following
If the above written stuff does not make sense to you, you may want to take a look at my Java RMI Arsenal talk. It starts with a beginner friendly overview of Java RMI :) |
Hi @qtc-de , Thanks for your reply. I followed your instructions and modified the configuration, but it seems that beanshooter still doesn't work, like showing in the following pic
My additional inquiry concerns whether there are potential exploitation techniques available if the JMX service port is not mapped externally but is instead listening only within an internal network environment. Looking forward to your answer. |
I'm sorry, I was missing this detail in my explanation above. The problem is now the port mapping. The RMI registry now tells beanshooter to connect to port
This should work. I may add an option to beanshooter in future that allows to overwrite the JMX IP/port. However, you will probably never encounter a configuration like yours in an productive environment. It is simply wrong configured and no Tool will be able to work with it. But well, never say never and administrators could of course fail to configure JMX properly. So I will add these options in future 👍 If the JMX service port is only available internally you can only exploit it if there are other vulnerabilities. E.g. the registry itself could be vulnerable (you can use https://github.com/qtc-de/remote-method-guesser to check this). Or you may have other services that allow to perform SSRF attacks (check this blog https://blog.tneitzel.eu/posts/01-attacking-java-rmi-via-ssrf/). |
Hi @qtc-de, Thank you for answering my doubts. Really appreciated your feeback. Btw, could you elaborate on how to overwrite the JMX IP/port? Many Thanks. |
Added the --overwrite-host and --overwrite-port options that allow to overwrite the destination endpoint pointed to by a bound name (see #42).
Overwriting the JMX IP/Port is not that straight forward. These properties are deeply anchored within the internal Java types used during RMI communication. Luckily, beanshooter already implements host redirection (as mentioned above). This is done by defining a custom socket factory. Java RMI lets you define which socket factory to use when RMI objects create outbound connection. beanshooter creates a custom socket factory on startup, which saves the initially entered target host as variable. Afterwards, if RMI connections attempt to connect to a different host, the socket factory will replace the new target with the previously specified one. I extended this functionality a little bit. Users can now specify the With these options, you should now be able to solve your problem from above. The options are only available on the develop branch yet and were not tested. Feel free to report any bugs you encounter 🙃 |
This issue has been troubling me for a long time. When encountering a JMX service in the internal network, and the jmxremote.port is mapped to the upstream IP through NAT port forwarding, all tests will fail. I look forward to a solution.
Here, my setup is as follows:
vmware workstation host
ip: 172.16.67.128
os: Ubuntu 20.04
docker container
ip:172.17.0.2
image: docker pull tomcat:7.0.68-jre8
a Docker container installed on VMHost, with Tomcat 7.0.68 running JMX service, IP mapped from 172.17.0.2:9999 to 172.16.67.128:39001.
The 1st screenshot describes the problem I encountered.
The 2nd screenshot shows that testing is successful when directly accessing the internal IP and port.
The text was updated successfully, but these errors were encountered: