Initial commit

master
Akkariin Meiko 2019-02-06 04:05:27 +08:00
commit 31f4fc407f
7 changed files with 149 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 KasuganoSoras
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1
README.md Normal file
View File

@ -0,0 +1 @@
# Anti-CatServer

2
manifest.mf Normal file
View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Premain-Class: org.natfrp.Anti.CatServer.Loader

View File

@ -0,0 +1,38 @@
package org.natfrp.Anti.CatServer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class Http {
private static String rstr;
public static String GET(String WebURL, String WebRequest) throws IOException {
String getURL = WebURL + URLEncoder.encode(WebRequest, "utf-8");
URL getUrl = new URL(getURL);
HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection();
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
return line;
}
reader.close();
connection.disconnect();
return null;
}
public static String Request(String URL, String Request) {
try {
return GET(URL, Request);
} catch (IOException ex) {
System.err.println(ex.getMessage());
}
return null;
}
}

View File

@ -0,0 +1,62 @@
package org.natfrp.Anti.CatServer;
import java.lang.instrument.Instrumentation;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
public class Loader {
static class TimerTaskImpl extends TimerTask {
private static final String mainClass = "catserver.server.CatServer";
@Override
public void run() {
try {
// 检测到 CatServer 主类存在
if (Class.forName(mainClass) != null) {
throw new SecurityException();
}
} catch (ClassNotFoundException ignored) {
// 服务端非 CatServer 或暂时未载入
} catch (SecurityException se) {
System.out.println("======================= [ Anti CatServer ] =======================");
System.out.println("CatServer 服务端已被管理员禁止使用,请更换其他服务端后再尝试启动服务器。");
System.out.println("因为该服务端存在后门,出于保护您和其他用户数据的安全,我们禁止使用此服务端。");
System.out.println("如果您多次尝试加载该服务端,或者尝试绕过我们的检测,您的服务器将会被停机。");
System.out.println("==================================================================");
System.exit(-1);
throw se;
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
private static final Map<String, Runnable> solutions = new HashMap<>();
static {
solutions.put("hardcore", () -> new Timer(true).schedule(new TimerTaskImpl(), 0, 1000));
}
public static void premain(String agentOps, Instrumentation inst) {
agentOps = agentOps != null ? (agentOps.isEmpty() ? "hardcore" : agentOps) : "hardcore";
Runnable solution = solutions.get(agentOps);
if (solution != null) {
try {
solution.run();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
throw e;
}
} else {
throw new IllegalArgumentException(agentOps);
}
}
}

View File

@ -0,0 +1,23 @@
package org.natfrp.Anti.CatServer;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class RunCommand {
public static String exec(String cmd) throws Exception {
Process pcs = Runtime.getRuntime().exec(cmd);
String result = null;
BufferedInputStream in = new BufferedInputStream(pcs.getInputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String lineStr;
while ((lineStr = br.readLine()) != null) {
result = lineStr;
}
br.close();
in.close();
return result;
}
}