ysoserial (Java deserialization)
java -jar ysoserial.jar CommonsCollections1 "<cmd>" | base64
Tool for generating Java deserialization payloads for various gadgets.
When you encounter a Java application that deserializes untrusted data (e.g., serialized objects in cookies, parameters, or headers). ysoserial generates serialized objects that, upon deserialization, execute commands. Use different gadgets depending on the vulnerable library (CommonsCollections, Spring, etc.).
If you don't know what libraries the target has, it's a shot in the dark. Prefer to do a prior analysis of the application to identify dependencies. Also not if the system has a deserialization filter (JEP 290) that blocks payloads.