16 Commits
v0.0.2 ... main

Author SHA1 Message Date
TheTrouper
8af6e8e7d6 Merge pull request #8 from thetrouper/development
Development
2023-11-07 21:02:20 -06:00
obvWolf
922c126f96 Updated README to reflect the recent changes
Also I forgot to increment version counter so that has been done too
2023-11-07 20:57:06 -06:00
TheTrouper
da3be0db98 Merge pull request #7 from thetrouper/experimental
Experimental
2023-11-07 20:42:05 -06:00
obvWolf
df83249701 Updated gson import 2023-11-07 20:39:20 -06:00
obvWolf
2a31690d61 Cleaned up the main class and finished the config manager 2023-11-07 20:31:53 -06:00
obvWolf
256d2900ac Merge remote-tracking branch 'origin/development' into development 2023-11-06 22:39:22 -06:00
obvWolf
324e11722f Making a universal intObf that can dynamicaly toggle the complexers and increasers that it uses (currently failing at it though) 2023-11-06 22:36:41 -06:00
TheTrouper
2b9eba075e Merge pull request #6 from thetrouper/development
Development
2023-11-06 22:35:32 -06:00
TheTrouper
21e842a31e Finished up complexer picker, it has some bugs, so im making a better verbose system 2023-11-06 22:12:59 -06:00
obvWolf
b909e44e30 Starting to make a complexer toggler and picker 2023-11-06 22:12:59 -06:00
TheTrouper
33d823f754 Finished up complexer picker, it has some bugs, so im making a better verbose system 2023-11-06 16:12:54 -06:00
obvWolf
288ae6f6be Starting to make a complexer toggler and picker 2023-11-06 01:28:34 -06:00
TheTrouper
5e619ee22b Merge pull request #5 from thetrouper/development
Added Support for duckGroup
2023-11-05 12:43:50 -06:00
obvWolf
fb304993a5 Updated readme to reflect the recent changes 2023-11-05 07:38:56 -06:00
obvWolf
7a4f318be6 Added modes DuckGroup and Numselli modulus is on both of them. 2023-11-05 06:55:14 -06:00
TheTrouper
65eaa9a100 Merge pull request #4 from thetrouper/main
Sync Readme
2023-11-04 19:03:21 -05:00
14 changed files with 770 additions and 217 deletions

View File

@@ -16,5 +16,10 @@
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://nexus.stirante.com/repository/maven-snapshots/" />
</remote-repository>
</component>
</project>

1
.idea/misc.xml generated
View File

@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ASMSmaliIdeaPluginConfiguration">
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />

View File

@@ -11,10 +11,13 @@ Countroll uses the following operators to make your integer as complex as possib
- Division | /
- Square Root | sqrt()
- Exponentiation | ^
- Modulus | %
## Compatibility
Countroll is currently only compatible with [Numselli's counting bot](https://counting.numselli.xyz/), although I hope to be able to support more counting bots soon!
Countroll is currently compatible with the following bots, please open an issue if you find another bot that is compatible or one that isn't compatible!
- [Numselli's counting bot](https://counting.numselli.xyz/)
- [DuckGroup's Counting bot](https://countingbot.com/)
## Usage
@@ -34,6 +37,65 @@ There are multiple command line arguments you can use for ease of use
| --color | -rgb | Enables colored output for debug/it looks cool |
| --deep | -d | Will run the Complexers on the Increaser values |
| --help | --h, -h | Shows a message like this table |
| --mode | -m | Changes the mode of the bot |
# Config With Comments
Dont fancy command line interfaces? Config is now implemented with json, here is a commented version
```json
{
"printHelp": false, // Will print help then exit
"mode": "U", // Switch Modes
// U is universal, and will follow all the comlpexer toggles for fully custom setup
// D is duckgroup mode, and will not use lettered functions
// N is numselli mode, and will enable all complexers
"doCopy": false, // Automatically copies the expression to your clipboard
"deep": false, // Executes the Complexers on every integer twice (Doubles output size)
"color": true, // Makes the output Razor Chroma RGB
"useDivide": true, // Toggles the divide Complexer
"useRoot": true, // Toggles the sqrt() Complexer
"usePower": true, // Toggles the power Complexer
"useModDividend": true, // Toggles the Modulus Complexer
"show.progress": false, // Shows the current integer evaluation of the expression
"verbose.all": false, // Enables all the verbose
"verbose.processes": true, // Toggles verbose for main processes
"verbose.complexers": false, // Toggles verbose for the complexers
"verbose.increasers": false, // Toggles verbose for the increasers
"verbose.utils": false, // Toggles verbose for the utils
"verbose.eval": false, // Toggles verbose for the eval function
"verbose.loops": false, // Toggles verbose for the loops itterations
"verbose.errors": true // Toggles verbose errors
}
```
When the config generates automatically it will generate in a random order, here is the ordered version if you prefer to have it readable
```json
{
"printHelp": false,
"mode": "U",
"doCopy": false,
"deep": false,
"color": true,
"useDivide": true,
"useRoot": true,
"usePower": true,
"useModDividend": true,
"show.progress": false,
"verbose.all": false,
"verbose.processes": true,
"verbose.complexers": false,
"verbose.increasers": false,
"verbose.utils": false,
"verbose.eval": false,
"verbose.loops": false,
"verbose.errors": true
}
```
## Modes:
You can change the bot's mode with the --mode option
- `--mode=numselli` or `-m=n` Uses Square Root
- `--mode=duckgroup` or `-m=d` Does not use Square Root
- `--mode=TEST` or `-m=t` testing mode (evaluates a given expression)
DuckGroup does not support square roots, which is why they are seperate
# Compiling
Make sure you have Java 17 or higher installed on your system!

View File

@@ -3,14 +3,18 @@ plugins {
}
group 'me.trouper'
version '0.0.2'
version '0.0.5'
repositories {
mavenCentral()
maven {
url 'https://nexus.stirante.com/repository/maven-snapshots/'
}
}
dependencies {
implementation 'net.objecthunter:exp4j:0.4.8'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
@@ -21,7 +25,7 @@ test {
jar {
manifest {
attributes 'Main-Class': 'me.trouper.Main'
attributes 'Main-Class': 'me.trouper.Countroll'
}
from {
configurations.runtimeClasspath.collect {

View File

@@ -0,0 +1,182 @@
package me.trouper;
import me.trouper.Data.ConfigManager;
import me.trouper.Functions.Complexers;
import me.trouper.Functions.Obf;
import me.trouper.Utils.Timer;
import me.trouper.Utils.Utils;
import me.trouper.Utils.Verbose;
import java.util.Scanner;
import static me.trouper.Functions.Eval.eval;
import static me.trouper.Utils.Utils.copyToClip;
import static me.trouper.Utils.Utils.removeColors;
public class Countroll {
public static boolean showProgress;
public static boolean doCopy;
public static boolean deep;
public static boolean color;
public static boolean printHelp;
public static String mode;
/* Statistics */
public static int errorCount = 0;
public static int expCount = 0;
public static int factorCount = 0;
public static int addCount = 0;
public static int subCount = 0;
public static int divideCount = 0;
public static int powerCount = 0;
public static int rDivisorCount = 0;
public static int rDividendCount = 0;
public static int rootCount = 0;
public static int perfectCount = 0;
public static int total = 0;
public static void clearStats() {
expCount = 0;
factorCount = 0;
addCount = 0;
subCount = 0;
divideCount = 0;
powerCount = 0;
rDivisorCount = 0;
rDividendCount = 0;
rootCount = 0;
perfectCount = 0;
total = 0;
errorCount = 0;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ConfigManager.loadConfig();
parseCommandLineArguments(args);
Verbose.send("INIT", "Loading config");
Verbose.send("INIT", "Config loaded, mode: " + mode);
if (mode.equals("D")) {
Complexers.useRoot = false;
}
if (mode.equals("TEST")) {
handleTestMode(scanner);
}
if (printHelp) {
Utils.printHelp();
System.exit(0);
}
if (color) {
Utils.printColorKey();
}
handleTargetIntegers(scanner);
scanner.close();
}
private static void parseCommandLineArguments(String[] args) {
for (String arg : args) {
switch (arg) {
case "--copy", "-c" -> doCopy = true;
case "--verbose", "-v" -> Verbose.all = true;
case "--deep", "-d" -> deep = true;
case "--color", "-rgb" -> color = true;
case "--help", "--h", "-h" -> printHelp = true;
case "--mode=test", "-m=t" -> mode = "TEST";
case "--mode=duckgroup", "-m=d" -> mode = "D";
case "--mode=numselli", "-m=n" -> mode = "N";
case "--mode=universal", "-m=u" -> mode = "U";
}
}
}
private static void handleTestMode(Scanner scanner) {
while (true) {
System.out.print("Enter an expression (or 'exit' to exit): ");
String userInput = scanner.next();
if (userInput.equals("exit")) {
System.exit(0);
}
try {
double result = eval(userInput);
System.out.println("Result: " + result);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
}
private static void handleTargetIntegers(Scanner scanner) {
while (true) {
System.out.print("Enter Target Integer: ");
if (scanner.hasNextInt()) {
int target = scanner.nextInt();
Timer obfTimer = Timer.start();
String expression = Obf.obfInt(target);
long obfTime = obfTimer.end().timePassed();
double output = eval(removeColors(expression));
printStatistics(obfTime);
printReport(target,expression,output);
if (doCopy) copyToClip(removeColors(expression));
} else {
System.out.println("Exiting the program.");
break;
}
}
}
private static void printReport(int target, String expression, double output) {
String report;
if (target == output) {
report = String.format("""
╔═══════[ Report ]═════════
║ Target Integer: %d
║ Final Result: %s <&ah><&b>✔<&r>
║ Expression Length: %s
╚══════════════════════════
>> %s
""",target,output,expression.length(),expression);
} else {
report = String.format("""
╔═══════[ Report ]═════════
║ Target Integer: %d
║ Final Result: %s <&ch><&e>❌<&r>
║ Expression Length: %s
╚══════════════════════════
>> %s
""",target,output,expression.length(),expression);
}
System.out.println((color) ? Utils.activateColors(report) : removeColors(report));
}
private static void printStatistics(long time) {
String statistics = String.format("""
╔═══════[ Statistics ]═════════
║ Exponents: %d
║ Factors: %d
║ Additions: %d
║ Subtractions: %d
║ Divisors: %d
║ Powers: %d
║ mRootDividends: %d
║ Roots Taken: %d
║ Perfect Squares Found: %d
║ Errors: %d
╠══════════════════════════════
║ Total steps taken: %d
║ Elapsed Time: %d
╚══════════════════════════════
""", expCount, factorCount, addCount, subCount, divideCount, powerCount, rDividendCount, rootCount, perfectCount, errorCount, total, time);
System.out.println(statistics);
}
}

View File

@@ -0,0 +1,87 @@
package me.trouper.Data;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import me.trouper.Countroll;
import me.trouper.Functions.Complexers;
import me.trouper.Utils.Verbose;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class ConfigManager {
private static final String CONFIG_FILENAME = "countroll.json";
public static void loadConfig() {
File configFile = new File(CONFIG_FILENAME);
if (!configFile.exists()) {
generateDefaultConfig();
} else {
try (Reader reader = new FileReader(configFile)) {
Gson gson = new Gson();
Map<String, Object> config = gson.fromJson(reader, HashMap.class);
getConfig(config);
} catch (JsonSyntaxException | JsonIOException | IOException e) {
e.printStackTrace();
generateDefaultConfig();
}
}
}
private static void generateDefaultConfig() {
Map<String, Object> defaultConfig = new HashMap<>();
defaultConfig.put("useDivide", true);
defaultConfig.put("usePower", true);
defaultConfig.put("useRoot", true);
defaultConfig.put("useModDividend", true);
defaultConfig.put("doCopy", false);
defaultConfig.put("deep", false);
defaultConfig.put("color", true);
defaultConfig.put("printHelp", false);
defaultConfig.put("mode", "U");
defaultConfig.put("show.progress", false);
defaultConfig.put("verbose.all",false);
defaultConfig.put("verbose.processes",true);
defaultConfig.put("verbose.loops",false);
defaultConfig.put("verbose.eval",false);
defaultConfig.put("verbose.complexers",false);
defaultConfig.put("verbose.increasers",false);
defaultConfig.put("verbose.utils",false);
defaultConfig.put("verbose.errors",true);
try (Writer writer = new FileWriter(CONFIG_FILENAME)) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
gson.toJson(defaultConfig, writer);
} catch (IOException e) {
e.printStackTrace();
}
getConfig(defaultConfig);
}
private static void getConfig(Map<String, Object> config) {
Verbose.send("INIT", "Loading main class variables");
Complexers.useDivide = (boolean) config.get("useDivide");
Complexers.usePower = (boolean) config.get("usePower");
Complexers.useRoot = (boolean) config.get("useRoot");
Complexers.useRDividend = (boolean) config.get("useModDividend");
Countroll.showProgress = (boolean) config.get("show.progress");
Countroll.doCopy = (boolean) config.get("doCopy");
Countroll.deep = (boolean) config.get("deep");
Countroll.color = (boolean) config.get("color");
Countroll.printHelp = (boolean) config.get("printHelp");
Countroll.mode = (String) config.get("mode");
Verbose.all = (boolean) config.get("verbose.all");
Verbose.processes = (boolean) config.get("verbose.processes");
Verbose.loops = (boolean) config.get("verbose.loops");
Verbose.eval = (boolean) config.get("verbose.eval");
Verbose.complexers = (boolean) config.get("verbose.complexers");
Verbose.increasers = (boolean) config.get("verbose.increasers");
Verbose.utils = (boolean) config.get("verbose.utils");
Verbose.errors = (boolean) config.get("verbose.errors");
Verbose.send("INIT","mode = " + Countroll.mode);
}
}

View File

@@ -1,29 +1,143 @@
package me.trouper.Functions;
import java.util.Random;
import me.trouper.Countroll;
import me.trouper.Utils.Utils;
import me.trouper.Utils.Verbose;
import java.util.*;
import static me.trouper.Functions.Eval.eval;
import static me.trouper.Functions.Eval.isPerfectSquare;
public class Complexers {
public static String divide(int i) {
/* Complexer Toggles */
public static boolean useDivide;
public static boolean usePower;
public static boolean useRoot;
public static boolean useRDividend;
public static String pickComplexer() {
List<String> enabledComplexers = new ArrayList<>();
if (useDivide) enabledComplexers.add("divide");
if (usePower) enabledComplexers.add("power");
if (useRoot) enabledComplexers.add("root");
if (useRDividend) enabledComplexers.add("mrDividend");
Collections.shuffle(enabledComplexers);
if (!enabledComplexers.isEmpty()) {
return enabledComplexers.get(0);
} else {
return "NONE";
}
}
public static String complex(int i, boolean deep) {
String complexer = pickComplexer();
if (isPerfectSquare(i)) complexer = "power";
switch (complexer) {
case "divide" -> {
return divide(i,deep);
}
case "power" -> {
if (!isPerfectSquare(i)) {
return divide(i,deep);
}
return power(i,deep);
}
case "root" -> {
return root(i,deep);
}
case "mrDividend" -> {
return mRootDividend(i,deep);
}
default -> {
return divide(i,false);
}
}
}
/**
* Safe to use with D mode
* @param i Integer to divide
* @return Colored String
*/
public static String divide(int i, boolean deep) {
Verbose.send("COMP", "Running Divide Complexer, I:" + i + " Deep: " + deep);
Countroll.divideCount++;
Random random = new Random();
int factor = random.nextInt(9)+1;
int doubled = i * factor;
String result = "<&f>(<&r><&e>" + doubled + "<&b>/<&r><&e>" + factor + "<&f>)<&r>";
if (eval(result) == i) {
return result;
if (deep) {
result = "<&3>(<&r><&d>" + (complex(doubled,false)) + "<&b>/<&r><&d>" + (complex(factor,false)) + "<&3>)<&r>";
}
return "(" + i + ")";
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to divide <&r>" + i + ", Attempted: " + result + "=" + eval(result));
return eval(result) == i ? result : "<&ch>(" + i + ")<&r>";
}
public static String root(int i) {
/**
* Safe to use with D mode
* Only to be used with perfect squares
* @param i Integer to root+square
* @return Colored String
*/
public static String power(int i, boolean deep) {
Verbose.send("COMP", "Running Power Complexer, I:" + i + " Deep: " + deep);
Countroll.powerCount++;
int root = (int) Math.sqrt(i);
String result = "<&r><&f>(<&e>" + root + "<&b>^<&e>2<&f>)<&r>";
if (deep) {
result = "<&r><&3>(<&d>" + complex(root,false) + "<&b>^<&d>2<&3>)<&r>";
}
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to power <&r>" + i + ", Attempted: " + result + "=" + eval(result));
return eval(result) == i ? result : "<&ch>(" + i + ")<&r>";
}
/**
* Uses sqrt(), not safe with D mode
* @param i integer to square+root
* @return Colored String
*/
public static String root(int i, boolean deep) {
Verbose.send("COMP", "Running Root Complexer, I:" + i + " Deep: " + deep);
Countroll.rootCount++;
int squared = (int) Math.pow(i,2);
String result = "<&9>sqrt<&r><&f>(<&r><&e>" + squared + "<&f>)<&r>";
if (eval(result) == i){
return result;
if (deep) {
result = "<&1>sqrt<&r><&3>(<&r><&d>" + complex(squared, false) + "<&3>)<&r>";
}
return "(" + i + ")";
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to root <&r>" + i + ", Attempted: " + result + "=" + eval(result));
return (eval(result) == i) ? result : "<&ch>(" + i + ")<&r>";
}
/**
* Uses modulus (dividend%ri)=i
* @param i Modulus to return
* @return Colored String
*/
public static String mRootDividend(int i, boolean deep) {
Verbose.send("COMP", "Running mrDividend Complexer, I:" + i + " Deep: " + deep);
Countroll.rDividendCount++;
Random random = new Random();
int divisor = random.nextInt(9)+i+10;
int dividend = Utils.moduRootDividend(divisor,i);
String result = "<&r><&f>(<&e>" + dividend + "<&b>%<&e>" + divisor + "<&f>)<&r>";
if (deep) {
result = "<&r><&7>(<&d>" + complex(dividend,false) + "<&b>%<&d>" + complex(divisor,false) + "<&7>)<&r>";
}
Verbose.send("COMP","<&dh><&b>mRootDividend has been ran!<&r>" +
"\nWanted:" + i +
"\nDivisor: " + divisor +
"\nDividend: " + dividend +
"\nCheck: " + dividend + "%" + divisor + "=" + i +
"\nResult: " + result);
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to mRootDividend<&r> " + i + ", Attempted: " + result + "=" + eval(result));
return (eval(result) == i) ? result : "<&ch>(" + i + ")<&r>";
}
}

View File

@@ -1,22 +1,21 @@
package me.trouper.Functions;
import me.trouper.Utils.Utils;
import me.trouper.Utils.Verbose;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
public class Eval {
public static double eval(String expression) {
final String cleaned = Utils.removeColors(expression);
Utils.verbose("Evaluating Expression: " + cleaned);
Verbose.send("EVAL","Evaluating Expression: " + cleaned);
Expression exp = new ExpressionBuilder(cleaned).build();
return exp.evaluate();
}
public static boolean isPerfectSquare(int num) {
if (num < 0) {
return false;
}
int sqrt = (int) Math.sqrt(num);
return sqrt * sqrt == num;
if (num == 0) return false;
final double sq = Math.sqrt(num);
return sq == Math.floor(sq);
}
public static boolean isInt(double number) {
return (number == Math.floor(number)) && !Double.isInfinite(number);

View File

@@ -1,22 +1,69 @@
package me.trouper.Functions;
import me.trouper.Countroll;
import me.trouper.Utils.Utils;
import me.trouper.Utils.Verbose;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static me.trouper.Functions.Eval.eval;
import static me.trouper.Functions.Eval.isPerfectSquare;
public class Increasers {
public static String multiply(int i, int factor) {
String result = "<&7>(<&r><&2>" + i + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
if (eval(result) == i * factor) {
return result;
public static String increase(int current, int target, int i, boolean deep) {
if (target - current > 64000) {
Countroll.expCount++;
return Increasers.power(i,4,deep);
} else if (target - current > 4069) {
Countroll.expCount++;
return Increasers.power(i,3,deep);
} else if (target - current > 1048) {
Countroll.expCount++;
return Increasers.power(i,2,deep);
} else if (target - current > 128) {
Countroll.factorCount++;
return Increasers.multiply(i,9,deep);
} else {
return multiply(i,2,deep);
}
return "(" + i + ")";
}
public static String power(int i, int exp) {
String result = "<&7>(<&r><&2>" + i + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
public static String multiply(int i, int factor, boolean deep) {
Countroll.factorCount++;
String result;
if (eval(result) == Math.pow(i,exp)) {
return result;
if (deep) {
result = "<&7>(<&r><&2>" + (Complexers.complex(i,true)) + "<&b>*<&r><&2>" + Complexers.complex(i,true) + "<&7>)<&r>";
if (eval(result) == i * factor) return result;
}
return "(" + i + ")";
result = "<&7>(<&r><&2>" + i + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
double calc = eval(result);
if (!(calc == Math.multiplyExact(i,factor))) Verbose.send("ERR", "Failed multiply increaser! " +
"\nAttempted expression: " + result +
"\nTarget: " + i +
"\nCalc: " + calc);
return calc == i * factor ? result : "(" + i + ")";
}
public static String power(int i, int exp, boolean deep) {
Countroll.powerCount++;
String result;
if (deep) {
result = "<&7>(<&r><&2>" + Complexers.complex(i,true) + "<&b>^<&r><&2>" + Complexers.complex(i,true) + "<&7>)<&r>";
if (eval(result) == Math.pow(i,exp)) return result;
}
result = "<&7>(<&r><&2>" + i + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
double calc = eval(result);
if (!(calc == Math.pow(i,exp))) Verbose.send("ERR", "Failed multiply increaser! " +
"\nAttempted expression: " + result +
"\nTarget: " + i +
"\nCalc: " + calc);
return calc == Math.pow(i,exp) ? result : "(" + i + ")";
}
}

View File

@@ -1,34 +1,83 @@
package me.trouper.Functions;
import me.trouper.Countroll;
import me.trouper.Utils.Verbose;
import java.util.Random;
import static me.trouper.Functions.Eval.*;
import static me.trouper.Functions.Eval.eval;
import static me.trouper.Utils.Utils.removeColors;
import static me.trouper.Utils.Utils.verbose;
public class Obf {
public static String obfInt(int target, boolean deep) {
public static String obfInt(int target) {
Verbose.send("PROC", "Starting Obfuscation (Universal)");
StringBuilder expression = new StringBuilder();
Random rand = new Random();
// INIT
int init = rand.nextInt(9)+1;
Verbose.send("PROC", "Initializing Expression: " + init);
expression.append("<&dh><&f>").append(init).append("<&r>");
// MAIN LOOP
Verbose.send("PROC", "Beginning Main Loop: ");
while (eval(expression.toString()) != target) {
Countroll.total++;
int current = (int) eval(expression.toString());
int ri = rand.nextInt(9)+1;
if (Countroll.showProgress) System.out.println("Current Evaluation: " + current);
// Checking for it still being a whole number
if (!isInt(eval(expression.toString()))) {
System.out.println("Something went horribly wrong, Here is the relevant info." +
"\nEvaluation: " + eval(expression.toString()) +
"\nRandom Pick: " + ri +
"\nCaught at: \n" + removeColors(expression.toString()));
break;
}
String comp = Complexers.complex(ri,Countroll.deep);
// Case for if its below
if (current < target) {
Countroll.addCount++;
expression.append("<&b>+<&r><&e>").append(comp).append("<&r>");
if (target - current > 128) {
expression.append("<&b>*<&r><&e>").append(Increasers.increase(current,target,ri,Countroll.deep)).append("<&r>");
}
}
// Case for if its above
if (current > target) {
Countroll.subCount++;
expression.append("<&b>-<&r><&e>").append(comp).append("<&r>");
if (current - target > 128) {
expression.append("<&b>-<&r><&e>").append(Increasers.increase(target,current,ri,Countroll.deep)).append("<&r>");
}
}
}
Verbose.send("PROC", "Broke out of loop.");
return expression.toString();
}
/**
* ObfIntN will work for Numselli's counting bot
* @param target Integer to reach
* @param deep When True, doubles the use of Complexers and Increasers
* @return A colored string
*/
public static String obfIntN(int target, boolean deep) {
if (deep) System.out.println("Deep Obfuscation is coming soon!");
StringBuilder expression = new StringBuilder();
Random random = new Random();
int initializer = random.nextInt(9)+1;
verbose("Initializing Expression: " + initializer);
Verbose.send("PROC","Initializing Expression: " + initializer);
expression.append("<&dh><&f>").append(initializer).append("<&r>");
int cubeCount = 0;
int factorCount = 0;
int addCount = 0;
int subCount = 0;
int rootCount = 0;
int divideCount = 0;
int perfectCount = 0;
int total = 0;
while (eval(expression.toString()) != target) {
total++;
Countroll.total++;
int eval = (int) eval(expression.toString());
int ri = random.nextInt(9)+1;
int op = random.nextInt(2);
@@ -43,81 +92,104 @@ public class Obf {
break;
}
verbose("Random: " + ri);
verbose("Current: " + eval(expression.toString()));
Verbose.send("LOOP","Random: " + ri);
Verbose.send("LOOP","Current: " + eval(expression.toString()));
if (isPerfectSquare(eval) && eval != 1) {
perfectCount++;
verbose("PERFECT SQUARE TIME! (" + perfectCount+ ")");
Countroll.perfectCount++;
Verbose.send("LOOP","PERFECT SQUARE TIME! (" + Countroll.perfectCount+ ")");
expression.insert(0,"<&eh><&b>sqrt(<&r>").append("<&eh><&b>)<&r>");
eval = (int) eval(expression.toString());
}
if (target - eval > 4069) {
mult = true;
cubeCount++;
verbose("Large than (" + cubeCount + ")");
final String toAdd = Increasers.power(ri,3);
expression.append("<&b>+<&r><&a>").append(toAdd).append("<&r>");
} else if (target - eval > 1048) {
mult = true;
cubeCount++;
verbose("Large than (" + cubeCount + ")");
final String toAdd = Increasers.power(ri,2);
expression.append("<&b>+<&r><&a>").append(toAdd).append("<&r>");
} else if (target - eval > 128) {
factorCount++;
verbose("Big than (" + factorCount + ")");
final String toAdd = Increasers.multiply(ri,9);
expression.append("<&b>+<&r><&a>").append(toAdd).append("<&r>");
continue;
}
final String toAdd = Complexers.complex(ri,deep);
if (eval < target) {
addCount++;
if (op == 0) {
divideCount++;
} else {
rootCount++;
if (target - eval > 4069) {
Countroll.expCount++;
Verbose.send("LOOP","Large than (" + Countroll.expCount + ")");
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,3,deep)).append("<&r>");
} else if (target - eval > 1048) {
Countroll.expCount++;
Verbose.send("LOOP","Large than (" + Countroll.expCount + ")");
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,2,deep)).append("<&r>");
} else if (target - eval > 128) {
Countroll.factorCount++;
Verbose.send("LOOP","Big than (" + Countroll.factorCount + ")");
expression.append("<&b>*<&r><&a>").append(Increasers.multiply(ri,9,deep)).append("<&r>");
}
final String toAdd = (op == 0) ? Complexers.divide(ri) : Complexers.root(ri);
expression.append((mult) ? "<&b>*<&r>" : "<&b>+<&r><&e>").append(toAdd).append("<&r>");
verbose("Less than (" + addCount + ")");
Countroll.addCount++;
expression.append("<&b>+<&r><&e>").append(toAdd).append("<&r>");
Verbose.send("LOOP","Less than (" + Countroll.addCount + ")");
}
if (eval > target) {
subCount++;
if (op == 0) {
divideCount++;
} else {
rootCount++;
}
final String toAdd = (op == 0) ? Complexers.divide(ri) : Complexers.root(ri);
/*
String colored = Utils.highlightReg(toAdd);
if (deep) {
colored = Utils.highlightDeep(toAdd);
}*/
Countroll.subCount++;
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
expression.append("<&b>-<&r><&e>").append(toAdd).append("<&r>");
verbose("Greater than (" + subCount + ")");
Verbose.send("LOOP","Greater than (" + Countroll.subCount + ")");
}
}
verbose("Broke out of loop. Value: " + eval(expression.toString()));
verbose("Expression: " + expression);
verbose("Expression (Cleaned): " + removeColors(expression.toString()));
System.out.println("\n\n\n\nStatistics: " +
"\nCubes: " + cubeCount +
"\nFactors: " + factorCount +
"\nAdditions: " + addCount +
"\nSubtractions: " + subCount +
"\nRoots Taken: " + rootCount +
"\nDivisors: " + divideCount +
"\nPerfect Squares Found: " + perfectCount +
"\nTotal steps taken: " + total);
Verbose.send("PROC","Broke out of loop. Value: " + eval(expression.toString()));
Verbose.send("EVAL","Expression: " + expression);
Verbose.send("EVAL","Expression (Cleaned): " + removeColors(expression.toString()));
return expression.toString();
}
/**
* ObfIntD will work with DuckGroups's Counting bot
* @param target Integer to reach
* @param deep When True, doubles the use of Complexers and Increasers
* @return A colored string
*/
public static String obfIntD(int target, boolean deep) {
if (deep) System.out.println("Deep Obfuscation is coming soon!");
StringBuilder expression = new StringBuilder();
Random random = new Random();
int initializer = random.nextInt(9)+1;
expression.append("<&dh><&f>").append(initializer).append("<&r>");
while (eval(expression.toString()) != target) {
Countroll.total++;
int eval = (int) eval(expression.toString());
int ri = random.nextInt(9)+1;
final String toAdd = Complexers.complex(ri,deep);
if (eval < target) {
if (target - eval > 4096) {
Countroll.expCount++;
expression.append("<&b>*<&r>").append(Increasers.power(ri,4,deep));
} else if (target - eval > 1048) {
Countroll.expCount++;
expression.append("<&b>*<&r>").append(Increasers.power(ri,2,deep));
} else if (target - eval > 128) {
Countroll.factorCount++;
expression.append("<&b>*<&r>").append(Increasers.multiply(ri,2,deep));
}
Countroll.addCount++;
expression.append("<&b>+<&r>").append(toAdd);
}
if (eval > target) {
if (eval - target > 4096) {
Countroll.expCount++;
expression.append("<&b>-<&r>").append(Increasers.power(ri,5,deep));
} else if (eval - target> 1048) {
Countroll.expCount++;
expression.append("<&b>-<&r>").append(Increasers.power(ri,3,deep));
} else if (eval - target > 128) {
Countroll.factorCount++;
expression.append("<&b>-<&r>").append(Increasers.multiply(ri,2,deep));
}
Countroll.subCount++;
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
expression.append("<&b>-<&r>").append(toAdd);
}
}
return expression.toString();
}
}

View File

@@ -1,62 +0,0 @@
package me.trouper;
import me.trouper.Functions.Obf;
import me.trouper.Utils.Timer;
import me.trouper.Utils.Utils;
import java.util.Scanner;
import static me.trouper.Functions.Eval.eval;
import static me.trouper.Utils.Utils.removeColors;
public class Main {
public static boolean verbose;
public static boolean deep;
public static boolean color;
public static boolean printHelp;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
boolean doCopy = false;
for (String arg : args) {
switch (arg) {
case "--copy", "-c" -> doCopy = true;
case "--verbose", "-v" -> verbose = true;
case "--deep", "-d" -> deep = true;
case "--color", "-rgb" -> color = true;
case "--help", "--h", "-h" -> printHelp = true;
}
}
if (printHelp) Utils.printHelp();
if (color) Utils.printColorKey();
while (true) {
System.out.print("Enter Target Integer: ");
if (scanner.hasNextInt()) {
int target = scanner.nextInt();
Timer obfTimer = Timer.start();
String expression = Obf.obfInt(target, deep);
long obfTime = obfTimer.end().timePassed();
double output = eval(removeColors(expression));
System.out.println("\nTarget Integer: " + target);
System.out.println("\nElapsed Time: " + obfTime + "ms");
if (output == target) {
System.out.println(Utils.activateColors("<&2h><&f>Expression Correct<&r>\n\n" + ((color) ? expression : removeColors(expression))));
if (doCopy) Utils.copyToClip(removeColors(expression));
} else {
System.out.println(Utils.activateColors("<&ch><&0>!!!! INCORRECT !!!!<&r>\n\n" + ((color) ? expression : removeColors(expression))));
}
} else {
System.out.println("Exiting the program.");
break;
}
}
scanner.close();
}
}

View File

@@ -1,7 +1,8 @@
package me.trouper.Utils;
import me.trouper.Data.MC2Ansi;
import me.trouper.Main;
import me.trouper.Countroll;
import me.trouper.Functions.Eval;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
@@ -9,14 +10,26 @@ import java.awt.datatransfer.StringSelection;
import java.util.Map;
public class Utils {
public static int calcExp(int difference) {
int result = 1;
if (difference >= 4096) result = 2;
if (difference >= 8192) result = 3;
if (difference >= 16384) result = 4;
if (difference >= 32768) result = 5;
if (difference >= 65536) result = 6;
if (difference >= 131072) result = 7;
if (difference >= 262144) result = 8;
if (difference >= 524288) result = 9;
if (difference >= 1048576) result = 10;
return result;
}
public static void copyToClip(String text) {
StringSelection parsed = new StringSelection(text);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(parsed,null);
}
public static void verbose(String text) {
if (Main.verbose) System.out.println(text);
}
public static String removeColors(String input) {
return input.replaceAll("<&[0-9a-fr]>|<&[0-9a-frh]h>", "");
}
@@ -39,14 +52,17 @@ public class Utils {
}
public static void printHelp() {
System.out.println("Usage: java -jar Countroll-<version>.jar [options]");
System.out.println("Options:");
System.out.println(" --copy, -c Copy the generated expression to the clipboard");
System.out.println(" --verbose, -v Enable verbose mode");
System.out.println(" --deep, -d Enable deep obfuscation (under development)");
System.out.println(" --color, -rgb Enable colored output");
System.out.println(" --help, --h, -h Show this help message");
System.out.println("Note: When using multiple options, separate them with spaces.");
System.out.println("""
Usage: java -jar Countroll-<version>.jar [options]
Options: values are formated as such: -m=d or -t=root
--copy, -c Copy the generated expression to the clipboard
--verbose, -v Enable verbose mode
--deep, -d Enable deep obfuscation (under development)
--color, -rgb Enable colored output
--help, --h, -h Show this help message
--mode, -m Toggle the mode Values (Long): [duckgroup, numselli] Values (Brief): [d, n]
--toggle, -t Toggle off Complexer Values: [divide, power, root, mrDividend, mrDivisor]
Note: When using multiple options, separate them with spaces.""");
System.exit(0);
}
public static void printColorKey() {
@@ -58,49 +74,45 @@ public class Utils {
"\n<&e>Yellow:<&r> Complexer";
System.out.println(activateColors(colorKey));
}
/*
public static String highlightReg(String exp) {
final String result = exp
.replaceAll("\\(", ANSI.WHITE + "(" + ANSI.RESET)
.replaceAll("\\)", ANSI.WHITE + ")" + ANSI.RESET)
.replaceAll("\\*", ANSI.BLUE + "*" + ANSI.RESET)
.replaceAll("/", ANSI.BLUE + "/" + ANSI.RESET)
.replaceAll("\\+", ANSI.BLUE + "+" + ANSI.RESET)
.replaceAll("-", ANSI.BLUE + "-" + ANSI.RESET)
.replaceAll("\\^", ANSI.BLUE + "^" + ANSI.RESET)
.replaceAll("\\d+", ANSI.GREEN + "$0" + ANSI.RESET);
verbose("Attempting Ansi Highlight: " + result);
return result;
}
public static String highlightDeep(String exp) {
final String result = exp
.replaceAll("\\(", ANSI.CYAN + "*" + ANSI.RESET)
.replaceAll("\\)", ANSI.CYAN + "*" + ANSI.RESET)
.replaceAll("\\*", ANSI.BLUE + "*" + ANSI.RESET)
.replaceAll("/", ANSI.BLUE + "/" + ANSI.RESET)
.replaceAll("\\+", ANSI.BLUE + "+" + ANSI.RESET)
.replaceAll("-", ANSI.BLUE + "-" + ANSI.RESET)
.replaceAll("\\^", ANSI.BLUE + "^" + ANSI.RESET)
.replaceAll("\\d+", ANSI.PURPLE + "$0" + ANSI.RESET);
verbose("Attempting Ansi Highlight (Deep): " + result);
return result;
}
public static String fixAnsi(String input) {
Pattern pattern = Pattern.compile("(\\[\\d+m)");
Matcher matcher = pattern.matcher(input);
StringBuffer sb = new StringBuffer();
/**
* Returns the divisor of a mod equation given the modulus and dividend
* 5%x=2 -> x=3
* @param modulus Remainder
* @param dividend The number that is getting divided
* @return The divisor
*/
public static int moduRootDivisor(int dividend, int modulus) {
while (matcher.find()) {
// Check if the escape code was not properly closed (e.g., missing reset code)
if (input.substring(matcher.start()).indexOf(ANSI.RESET) < 0) {
String escapeCode = matcher.group(1);
// Re-escape the ANSI escape code
matcher.appendReplacement(sb, escapeCode);
}
int divisor = dividend - modulus;
Verbose.send("UTIL","<&1h><&e>Finding mrDivisor:<&r> " +
"\nDividend (Given): " + dividend +
"\nDivisor (Unknown): " + divisor +
"\nModulus (Given): " + modulus +
"\nCheck: " + dividend + "%" + divisor + "=" + Eval.eval(dividend + "%" + divisor));
return divisor;
/*
int divisor = 1;
while (divisor * dividend % modulus != 0 || divisor != 1) {
divisor++;
}
matcher.appendTail(sb);
return divisor;*/
}
/**
* Returns the dividend of a mod equation given the modulus and divisor
* x%3=2 -> x=5
* @param modulus Remainder
* @param divisor The number that does the dividing
* @return The dividend
*/
public static int moduRootDividend(int divisor, int modulus) {
int dividend = modulus + divisor;
Verbose.send("UTIL","<&1h><&e>Finding mrDivisor:<&r> " +
"\nDividend (Unknown): " + dividend +
"\nDivisor (Given): " + divisor +
"\nModulus (Given): " + modulus);
return dividend;
}
return sb.toString();
}*/
}

View File

@@ -0,0 +1,32 @@
package me.trouper.Utils;
import me.trouper.Countroll;
public class Verbose {
public static boolean processes;
public static boolean all;
public static boolean loops;
public static boolean eval;
public static boolean complexers;
public static boolean increasers;
public static boolean utils;
public static boolean errors;
public static void send(String type, String message) {
message = Utils.activateColors(message);
if (all) {
System.out.println(message);
return;
}
if (type.equals("INIT")) System.out.println(message);
if (type.equals("PROC") && processes) System.out.println(message);
if (type.equals("LOOP") && loops) System.out.println(message);
if (type.equals("UTIL") && utils) System.out.println(message);
if (type.equals("EVAL") && eval) System.out.println(message);
if (type.equals("COMP") && complexers) System.out.println(message);
if (type.equals("INCR") && increasers) System.out.println(message);
if (type.equals("ERR") && errors) {
System.out.println(message);
Countroll.errorCount++;
}
}
}

View File

@@ -1,2 +1,2 @@
Manifest-Version: 1.0
Main-Class: me.trouper.Main
Main-Class: me.trouper.Countroll