|
| 1 | +package dev.skidfuscator.obfuscator.protection; |
| 2 | + |
| 3 | +import dev.skidfuscator.obfuscator.event.annotation.Listen; |
| 4 | +import dev.skidfuscator.obfuscator.event.impl.transform.method.InitMethodTransformEvent; |
| 5 | +import dev.skidfuscator.obfuscator.skidasm.SkidMethodNode; |
| 6 | +import dev.skidfuscator.obfuscator.skidasm.expr.SkidConstantExpr; |
| 7 | +import dev.skidfuscator.obfuscator.util.ConsoleColors; |
| 8 | +import dev.skidfuscator.obfuscator.util.TypeUtil; |
| 9 | +import org.mapleir.ir.cfg.BasicBlock; |
| 10 | +import org.mapleir.ir.code.expr.ConstantExpr; |
| 11 | +import org.mapleir.ir.code.stmt.PopStmt; |
| 12 | + |
| 13 | +import javax.swing.text.html.Option; |
| 14 | +import java.lang.reflect.Array; |
| 15 | +import java.util.*; |
| 16 | +import java.util.stream.Collectors; |
| 17 | + |
| 18 | +public class MinecraftStealerProtectionProvider implements ProtectionProvider { |
| 19 | + private static final List<String> bannedStrings = Arrays.asList( |
| 20 | + ".feather/accounts.json", |
| 21 | + "essential/microsoft_accounts.json", |
| 22 | + ".lunarclient/settings/game/accounts.json" |
| 23 | + ); |
| 24 | + |
| 25 | + private final Set<String> findings = new HashSet<>(); |
| 26 | + |
| 27 | + @Listen |
| 28 | + void handle(final InitMethodTransformEvent event) { |
| 29 | + final SkidMethodNode methodNode = event.getMethodNode(); |
| 30 | + |
| 31 | + methodNode.getCfg() |
| 32 | + .allExprStream() |
| 33 | + .filter(SkidConstantExpr.class::isInstance) |
| 34 | + .map(SkidConstantExpr.class::cast) |
| 35 | + .filter(e -> e.getType().equals(TypeUtil.STRING_TYPE)) |
| 36 | + .collect(Collectors.toList()) |
| 37 | + .forEach(e -> { |
| 38 | + final String cst = (String) e.getConstant(); |
| 39 | + final Optional<String> match = bannedStrings |
| 40 | + .stream() |
| 41 | + .filter(cst::contains) |
| 42 | + .findFirst(); |
| 43 | + |
| 44 | + if (match.isPresent()) { |
| 45 | + findings.add(cst); |
| 46 | + |
| 47 | + e.setExempt(true); |
| 48 | + |
| 49 | + final BasicBlock basicBlock = e.getBlock(); |
| 50 | + final ConstantExpr warner = new ConstantExpr( |
| 51 | + "[Skidfuscator Anti-Abuse] MinecraftStealer Type " |
| 52 | + + Integer.toHexString(bannedStrings.indexOf(match.get())), |
| 53 | + TypeUtil.STRING_TYPE |
| 54 | + ); |
| 55 | + basicBlock.add(0, new PopStmt(warner)); |
| 56 | + } |
| 57 | + }); |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public boolean shouldWarn() { |
| 62 | + return !findings.isEmpty(); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public String getWarning() { |
| 67 | + return ConsoleColors.YELLOW |
| 68 | + + "██╗ ██╗ █████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ \n" |
| 69 | + + "██║ ██║██╔══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ \n" |
| 70 | + + "██║ █╗ ██║███████║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗\n" |
| 71 | + + "██║███╗██║██╔══██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║\n" |
| 72 | + + "╚███╔███╔╝██║ ██║██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝\n" |
| 73 | + + " ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ \n" |
| 74 | + + "\n" |
| 75 | + + "⚠️ Warning! Skidfuscator has found some suspicious strings!\n" |
| 76 | + + "\n" |
| 77 | + + ConsoleColors.YELLOW_BOLD_BRIGHT + "Type:" + ConsoleColors.YELLOW + " Minecraft Stealer\n" |
| 78 | + + ConsoleColors.YELLOW_BOLD_BRIGHT + "Confidence: " + ConsoleColors.RED + "HIGH" + ConsoleColors.YELLOW + "\n" |
| 79 | + + ConsoleColors.YELLOW_BOLD_BRIGHT + "Findings: \n" + ConsoleColors.YELLOW |
| 80 | + + " - " + String.join("\n - ", findings) |
| 81 | + + "\n" |
| 82 | + + "\n" |
| 83 | + + ConsoleColors.YELLOW_BRIGHT |
| 84 | + + "If you believe this is an error, please submit a bug report.\n" |
| 85 | + + "You are reminded that illicit access to remote hardware is illegal\n" |
| 86 | + + "and punishable under International Computer Law. Stealing information\n" |
| 87 | + + "and other any other forms of infostealing, hacking, or abuse of power is" |
| 88 | + + "a CRIME.\n" |
| 89 | + + "Obfuscation will proceed, but all liability is voided.\n" |
| 90 | + + ConsoleColors.RESET |
| 91 | + ; |
| 92 | + } |
| 93 | +} |
0 commit comments