5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -16,5 +16,10 @@
|
|||||||
<option name="name" value="MavenRepo" />
|
<option name="name" value="MavenRepo" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
</remote-repository>
|
</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>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ASMSmaliIdeaPluginConfiguration">
|
<component name="ASMSmaliIdeaPluginConfiguration">
|
||||||
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />
|
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />
|
||||||
|
|||||||
55
README.md
55
README.md
@@ -11,6 +11,7 @@ Countroll uses the following operators to make your integer as complex as possib
|
|||||||
- Division | /
|
- Division | /
|
||||||
- Square Root | sqrt()
|
- Square Root | sqrt()
|
||||||
- Exponentiation | ^
|
- Exponentiation | ^
|
||||||
|
- Modulus | %
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
@@ -38,6 +39,56 @@ There are multiple command line arguments you can use for ease of use
|
|||||||
| --help | --h, -h | Shows a message like this table |
|
| --help | --h, -h | Shows a message like this table |
|
||||||
| --mode | -m | Changes the mode of the bot |
|
| --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:
|
## Modes:
|
||||||
You can change the bot's mode with the --mode option
|
You can change the bot's mode with the --mode option
|
||||||
- `--mode=numselli` or `-m=n` Uses Square Root
|
- `--mode=numselli` or `-m=n` Uses Square Root
|
||||||
@@ -53,7 +104,3 @@ Make sure you have Java 17 or higher installed on your system!
|
|||||||
3. Build with gradle `$ ./gradlew build`
|
3. Build with gradle `$ ./gradlew build`
|
||||||
4. Build will be output to `/Countroll/build/libs`
|
4. Build will be output to `/Countroll/build/libs`
|
||||||
|
|
||||||
# Up Next
|
|
||||||
Development will continue with the addition of bitwise operations AND (&) and OR (|)
|
|
||||||
- Both bots support these operators, and it will be in both modes
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,18 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'me.trouper'
|
group 'me.trouper'
|
||||||
version '0.0.3'
|
version '0.0.5'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url 'https://nexus.stirante.com/repository/maven-snapshots/'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'net.objecthunter:exp4j:0.4.8'
|
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'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||||
}
|
}
|
||||||
@@ -21,7 +25,7 @@ test {
|
|||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Main-Class': 'me.trouper.Main'
|
attributes 'Main-Class': 'me.trouper.Countroll'
|
||||||
}
|
}
|
||||||
from {
|
from {
|
||||||
configurations.runtimeClasspath.collect {
|
configurations.runtimeClasspath.collect {
|
||||||
|
|||||||
182
src/main/java/me/trouper/Countroll.java
Normal file
182
src/main/java/me/trouper/Countroll.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
87
src/main/java/me/trouper/Data/ConfigManager.java
Normal file
87
src/main/java/me/trouper/Data/ConfigManager.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +1,80 @@
|
|||||||
package me.trouper.Functions;
|
package me.trouper.Functions;
|
||||||
|
|
||||||
import me.trouper.Main;
|
import me.trouper.Countroll;
|
||||||
import me.trouper.Utils.Utils;
|
import me.trouper.Utils.Utils;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.*;
|
||||||
|
|
||||||
import static me.trouper.Functions.Eval.eval;
|
import static me.trouper.Functions.Eval.eval;
|
||||||
import static me.trouper.Functions.Eval.isPerfectSquare;
|
import static me.trouper.Functions.Eval.isPerfectSquare;
|
||||||
|
|
||||||
public class Complexers {
|
public class Complexers {
|
||||||
|
/* 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
|
* Safe to use with D mode
|
||||||
* @param i Integer to divide
|
* @param i Integer to divide
|
||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String divide(int i, boolean deep) {
|
public static String divide(int i, boolean deep) {
|
||||||
Main.divideCount++;
|
Verbose.send("COMP", "Running Divide Complexer, I:" + i + " Deep: " + deep);
|
||||||
|
Countroll.divideCount++;
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
int factor = random.nextInt(9)+1;
|
int factor = random.nextInt(9)+1;
|
||||||
int doubled = i * factor;
|
int doubled = i * factor;
|
||||||
boolean expFac = false;
|
|
||||||
boolean expDoub = false;
|
|
||||||
|
|
||||||
if (isPerfectSquare(factor)) expFac = true;
|
|
||||||
if (isPerfectSquare(doubled)) expDoub = true;
|
|
||||||
|
|
||||||
String result = "<&f>(<&r><&e>" + doubled + "<&b>/<&r><&e>" + factor + "<&f>)<&r>";
|
String result = "<&f>(<&r><&e>" + doubled + "<&b>/<&r><&e>" + factor + "<&f>)<&r>";
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&3>(<&r><&d>" + ((expDoub) ? power(doubled,false) : divide(doubled,false)) + "<&b>/<&r><&d>" + ((expFac) ? power(factor,false) : divide(factor,false)) + "<&3>)<&r>";
|
result = "<&3>(<&r><&d>" + (complex(doubled,false)) + "<&b>/<&r><&d>" + (complex(factor,false)) + "<&3>)<&r>";
|
||||||
}
|
}
|
||||||
if (eval(result) != i) Utils.verbose("Failed to divide " + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to divide <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return eval(result) == i ? result : "(" + i + ")";
|
return eval(result) == i ? result : "<&ch>(" + i + ")<&r>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,19 +84,17 @@ public class Complexers {
|
|||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String power(int i, boolean deep) {
|
public static String power(int i, boolean deep) {
|
||||||
Main.powerCount++;
|
Verbose.send("COMP", "Running Power Complexer, I:" + i + " Deep: " + deep);
|
||||||
if (!Eval.isPerfectSquare(i)) {
|
Countroll.powerCount++;
|
||||||
return "(" + i + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
int root = (int) Math.sqrt(i);
|
int root = (int) Math.sqrt(i);
|
||||||
String result = "<&r><&f>(<&e>" + root + "<&b>^<&e>2<&f>)<&r>";
|
String result = "<&r><&f>(<&e>" + root + "<&b>^<&e>2<&f>)<&r>";
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&r><&3>(<&d>" + divide(root,false) + "<&b>^<&d>2<&3>)<&r>";
|
result = "<&r><&3>(<&d>" + complex(root,false) + "<&b>^<&d>2<&3>)<&r>";
|
||||||
}
|
}
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to power <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to power <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return eval(result) == i ? result : "(" + i + ")";
|
return eval(result) == i ? result : "<&ch>(" + i + ")<&r>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,36 +103,16 @@ public class Complexers {
|
|||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String root(int i, boolean deep) {
|
public static String root(int i, boolean deep) {
|
||||||
Main.rootCount++;
|
Verbose.send("COMP", "Running Root Complexer, I:" + i + " Deep: " + deep);
|
||||||
|
Countroll.rootCount++;
|
||||||
int squared = (int) Math.pow(i,2);
|
int squared = (int) Math.pow(i,2);
|
||||||
String result = "<&9>sqrt<&r><&f>(<&r><&e>" + squared + "<&f>)<&r>";
|
String result = "<&9>sqrt<&r><&f>(<&r><&e>" + squared + "<&f>)<&r>";
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&1>sqrt<&r><&3>(<&r><&d>" + divide(squared,false) + "<&3>)<&r>";
|
result = "<&1>sqrt<&r><&3>(<&r><&d>" + complex(squared, false) + "<&3>)<&r>";
|
||||||
}
|
}
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to root <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to root <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return (eval(result) == i) ? result : "(" + i + ")";
|
return (eval(result) == i) ? result : "<&ch>(" + i + ")<&r>";
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses modulus (ri%divisor)=i
|
|
||||||
* @param i Modulus to return
|
|
||||||
* @return Colored string
|
|
||||||
*/
|
|
||||||
public static String mRootDivisor(int i, boolean deep) {
|
|
||||||
Main.rDivisorCount++;
|
|
||||||
Random random = new Random();
|
|
||||||
int dividend = random.nextInt(9)+i+10;
|
|
||||||
int divisor = Utils.moduRootDivisor(dividend,i);
|
|
||||||
String result = "<&r><&f>(<&e>" + dividend + "<&b>%<&e>" + divisor + "<&f>)<&r>";
|
|
||||||
Utils.verbose("<&dh><&b>mRootDivisor has been ran!<&r>" +
|
|
||||||
"\nWanted: " + i +
|
|
||||||
"\nDivisor: " + divisor +
|
|
||||||
"\nDividend: " + dividend +
|
|
||||||
"\nCheck: " + dividend + "%" + divisor + "=" + i +
|
|
||||||
"\nResult: " + result);
|
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to mRootDivisor<&r> " + i + ", Attempted: " + result + "=" + eval(result));
|
|
||||||
return (eval(result) == i) ? result : "(" + i + ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,18 +121,23 @@ public class Complexers {
|
|||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String mRootDividend(int i, boolean deep) {
|
public static String mRootDividend(int i, boolean deep) {
|
||||||
Main.rDividendCount++;
|
Verbose.send("COMP", "Running mrDividend Complexer, I:" + i + " Deep: " + deep);
|
||||||
|
Countroll.rDividendCount++;
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int divisor = random.nextInt(9)+i+10;
|
int divisor = random.nextInt(9)+i+10;
|
||||||
int dividend = Utils.moduRootDividend(divisor,i);
|
int dividend = Utils.moduRootDividend(divisor,i);
|
||||||
String result = "<&r><&f>(<&e>" + dividend + "<&b>%<&e>" + divisor + "<&f>)<&r>";
|
String result = "<&r><&f>(<&e>" + dividend + "<&b>%<&e>" + divisor + "<&f>)<&r>";
|
||||||
Utils.verbose("<&dh><&b>mRootDividend has been ran!<&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 +
|
"\nWanted:" + i +
|
||||||
"\nDivisor: " + divisor +
|
"\nDivisor: " + divisor +
|
||||||
"\nDividend: " + dividend +
|
"\nDividend: " + dividend +
|
||||||
"\nCheck: " + dividend + "%" + divisor + "=" + i +
|
"\nCheck: " + dividend + "%" + divisor + "=" + i +
|
||||||
"\nResult: " + result);
|
"\nResult: " + result);
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to mRootDividend<&r> " + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to mRootDividend<&r> " + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return (eval(result) == i) ? result : "(" + i + ")";
|
return (eval(result) == i) ? result : "<&ch>(" + i + ")<&r>";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
package me.trouper.Functions;
|
package me.trouper.Functions;
|
||||||
|
|
||||||
import me.trouper.Utils.Utils;
|
import me.trouper.Utils.Utils;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
import net.objecthunter.exp4j.Expression;
|
import net.objecthunter.exp4j.Expression;
|
||||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||||
|
|
||||||
public class Eval {
|
public class Eval {
|
||||||
public static double eval(String expression) {
|
public static double eval(String expression) {
|
||||||
final String cleaned = Utils.removeColors(expression);
|
final String cleaned = Utils.removeColors(expression);
|
||||||
Utils.verbose("Evaluating Expression: " + cleaned);
|
Verbose.send("EVAL","Evaluating Expression: " + cleaned);
|
||||||
Expression exp = new ExpressionBuilder(cleaned).build();
|
Expression exp = new ExpressionBuilder(cleaned).build();
|
||||||
return exp.evaluate();
|
return exp.evaluate();
|
||||||
}
|
}
|
||||||
public static boolean isPerfectSquare(int num) {
|
public static boolean isPerfectSquare(int num) {
|
||||||
if (num < 0) {
|
if (num == 0) return false;
|
||||||
return false;
|
final double sq = Math.sqrt(num);
|
||||||
}
|
return sq == Math.floor(sq);
|
||||||
int sqrt = (int) Math.sqrt(num);
|
|
||||||
return sqrt * sqrt == num;
|
|
||||||
}
|
}
|
||||||
public static boolean isInt(double number) {
|
public static boolean isInt(double number) {
|
||||||
return (number == Math.floor(number)) && !Double.isInfinite(number);
|
return (number == Math.floor(number)) && !Double.isInfinite(number);
|
||||||
|
|||||||
@@ -1,29 +1,69 @@
|
|||||||
package me.trouper.Functions;
|
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.eval;
|
||||||
import static me.trouper.Functions.Eval.isPerfectSquare;
|
import static me.trouper.Functions.Eval.isPerfectSquare;
|
||||||
|
|
||||||
public class Increasers {
|
public class Increasers {
|
||||||
public static String multiply(int i, int factor, boolean deep) {
|
|
||||||
boolean useExp = isPerfectSquare(i);
|
|
||||||
|
|
||||||
String result = "<&7>(<&r><&2>" + i + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static String multiply(int i, int factor, boolean deep) {
|
||||||
|
Countroll.factorCount++;
|
||||||
|
String result;
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&7>(<&r><&2>" + (useExp ? Complexers.power(i,true) : Complexers.divide(i,true)) + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
|
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 eval(result) == i * factor ? result : "(" + 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) {
|
public static String power(int i, int exp, boolean deep) {
|
||||||
boolean useExp = isPerfectSquare(i);
|
Countroll.powerCount++;
|
||||||
|
String result;
|
||||||
String result = "<&7>(<&r><&2>" + i + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
|
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&7>(<&r><&2>" + (useExp ? Complexers.power(i,true) : Complexers.divide(i,true)) + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return eval(result) == Math.pow(i,exp) ? result : "(" + i + ")";
|
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 + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,64 @@
|
|||||||
package me.trouper.Functions;
|
package me.trouper.Functions;
|
||||||
|
|
||||||
import me.trouper.Main;
|
import me.trouper.Countroll;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import static me.trouper.Functions.Eval.*;
|
import static me.trouper.Functions.Eval.*;
|
||||||
import static me.trouper.Functions.Eval.eval;
|
import static me.trouper.Functions.Eval.eval;
|
||||||
import static me.trouper.Utils.Utils.removeColors;
|
import static me.trouper.Utils.Utils.removeColors;
|
||||||
import static me.trouper.Utils.Utils.verbose;
|
|
||||||
|
|
||||||
public class Obf {
|
public class Obf {
|
||||||
|
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
|
* ObfIntN will work for Numselli's counting bot
|
||||||
* @param target Integer to reach
|
* @param target Integer to reach
|
||||||
@@ -23,12 +72,12 @@ public class Obf {
|
|||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
int initializer = random.nextInt(9)+1;
|
int initializer = random.nextInt(9)+1;
|
||||||
verbose("Initializing Expression: " + initializer);
|
Verbose.send("PROC","Initializing Expression: " + initializer);
|
||||||
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
||||||
|
|
||||||
|
|
||||||
while (eval(expression.toString()) != target) {
|
while (eval(expression.toString()) != target) {
|
||||||
Main.total++;
|
Countroll.total++;
|
||||||
int eval = (int) eval(expression.toString());
|
int eval = (int) eval(expression.toString());
|
||||||
int ri = random.nextInt(9)+1;
|
int ri = random.nextInt(9)+1;
|
||||||
int op = random.nextInt(2);
|
int op = random.nextInt(2);
|
||||||
@@ -43,48 +92,48 @@ public class Obf {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose("Random: " + ri);
|
Verbose.send("LOOP","Random: " + ri);
|
||||||
verbose("Current: " + eval(expression.toString()));
|
Verbose.send("LOOP","Current: " + eval(expression.toString()));
|
||||||
|
|
||||||
if (isPerfectSquare(eval) && eval != 1) {
|
if (isPerfectSquare(eval) && eval != 1) {
|
||||||
Main.perfectCount++;
|
Countroll.perfectCount++;
|
||||||
verbose("PERFECT SQUARE TIME! (" + Main.perfectCount+ ")");
|
Verbose.send("LOOP","PERFECT SQUARE TIME! (" + Countroll.perfectCount+ ")");
|
||||||
expression.insert(0,"<&eh><&b>sqrt(<&r>").append("<&eh><&b>)<&r>");
|
expression.insert(0,"<&eh><&b>sqrt(<&r>").append("<&eh><&b>)<&r>");
|
||||||
eval = (int) eval(expression.toString());
|
eval = (int) eval(expression.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
final String toAdd = complex(ri,deep,"n");
|
final String toAdd = Complexers.complex(ri,deep);
|
||||||
|
|
||||||
if (eval < target) {
|
if (eval < target) {
|
||||||
if (target - eval > 4069) {
|
if (target - eval > 4069) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
verbose("Large than (" + Main.expCount + ")");
|
Verbose.send("LOOP","Large than (" + Countroll.expCount + ")");
|
||||||
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,3,deep)).append("<&r>");
|
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,3,deep)).append("<&r>");
|
||||||
} else if (target - eval > 1048) {
|
} else if (target - eval > 1048) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
verbose("Large than (" + Main.expCount + ")");
|
Verbose.send("LOOP","Large than (" + Countroll.expCount + ")");
|
||||||
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,2,deep)).append("<&r>");
|
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,2,deep)).append("<&r>");
|
||||||
} else if (target - eval > 128) {
|
} else if (target - eval > 128) {
|
||||||
Main.factorCount++;
|
Countroll.factorCount++;
|
||||||
verbose("Big than (" + Main.factorCount + ")");
|
Verbose.send("LOOP","Big than (" + Countroll.factorCount + ")");
|
||||||
expression.append("<&b>*<&r><&a>").append(Increasers.multiply(ri,9,deep)).append("<&r>");
|
expression.append("<&b>*<&r><&a>").append(Increasers.multiply(ri,9,deep)).append("<&r>");
|
||||||
}
|
}
|
||||||
Main.addCount++;
|
Countroll.addCount++;
|
||||||
expression.append("<&b>+<&r><&e>").append(toAdd).append("<&r>");
|
expression.append("<&b>+<&r><&e>").append(toAdd).append("<&r>");
|
||||||
verbose("Less than (" + Main.addCount + ")");
|
Verbose.send("LOOP","Less than (" + Countroll.addCount + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eval > target) {
|
if (eval > target) {
|
||||||
Main.subCount++;
|
Countroll.subCount++;
|
||||||
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
||||||
expression.append("<&b>-<&r><&e>").append(toAdd).append("<&r>");
|
expression.append("<&b>-<&r><&e>").append(toAdd).append("<&r>");
|
||||||
verbose("Greater than (" + Main.subCount + ")");
|
Verbose.send("LOOP","Greater than (" + Countroll.subCount + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose("Broke out of loop. Value: " + eval(expression.toString()));
|
Verbose.send("PROC","Broke out of loop. Value: " + eval(expression.toString()));
|
||||||
verbose("Expression: " + expression);
|
Verbose.send("EVAL","Expression: " + expression);
|
||||||
verbose("Expression (Cleaned): " + removeColors(expression.toString()));
|
Verbose.send("EVAL","Expression (Cleaned): " + removeColors(expression.toString()));
|
||||||
return expression.toString();
|
return expression.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,74 +150,46 @@ public class Obf {
|
|||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
int initializer = random.nextInt(9)+1;
|
int initializer = random.nextInt(9)+1;
|
||||||
verbose("Initializing Expression: " + initializer);
|
|
||||||
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
||||||
|
|
||||||
while (eval(expression.toString()) != target) {
|
while (eval(expression.toString()) != target) {
|
||||||
Main.total++;
|
Countroll.total++;
|
||||||
int eval = (int) eval(expression.toString());
|
int eval = (int) eval(expression.toString());
|
||||||
int ri = random.nextInt(9)+1;
|
int ri = random.nextInt(9)+1;
|
||||||
|
|
||||||
|
|
||||||
final String toAdd = complex(ri,deep,"d");
|
final String toAdd = Complexers.complex(ri,deep);
|
||||||
|
|
||||||
if (eval < target) {
|
if (eval < target) {
|
||||||
if (target - eval > 4096) {
|
if (target - eval > 4096) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>*<&r>").append(Increasers.power(ri,4,deep));
|
expression.append("<&b>*<&r>").append(Increasers.power(ri,4,deep));
|
||||||
} else if (target - eval > 1048) {
|
} else if (target - eval > 1048) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>*<&r>").append(Increasers.power(ri,2,deep));
|
expression.append("<&b>*<&r>").append(Increasers.power(ri,2,deep));
|
||||||
} else if (target - eval > 128) {
|
} else if (target - eval > 128) {
|
||||||
Main.factorCount++;
|
Countroll.factorCount++;
|
||||||
expression.append("<&b>*<&r>").append(Increasers.multiply(ri,2,deep));
|
expression.append("<&b>*<&r>").append(Increasers.multiply(ri,2,deep));
|
||||||
}
|
}
|
||||||
Main.addCount++;
|
Countroll.addCount++;
|
||||||
expression.append("<&b>+<&r>").append(toAdd);
|
expression.append("<&b>+<&r>").append(toAdd);
|
||||||
}
|
}
|
||||||
if (eval > target) {
|
if (eval > target) {
|
||||||
if (eval - target > 4096) {
|
if (eval - target > 4096) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>-<&r>").append(Increasers.power(ri,5,deep));
|
expression.append("<&b>-<&r>").append(Increasers.power(ri,5,deep));
|
||||||
} else if (eval - target> 1048) {
|
} else if (eval - target> 1048) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>-<&r>").append(Increasers.power(ri,3,deep));
|
expression.append("<&b>-<&r>").append(Increasers.power(ri,3,deep));
|
||||||
} else if (eval - target > 128) {
|
} else if (eval - target > 128) {
|
||||||
Main.factorCount++;
|
Countroll.factorCount++;
|
||||||
expression.append("<&b>-<&r>").append(Increasers.multiply(ri,2,deep));
|
expression.append("<&b>-<&r>").append(Increasers.multiply(ri,2,deep));
|
||||||
}
|
}
|
||||||
Main.subCount++;
|
Countroll.subCount++;
|
||||||
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
||||||
expression.append("<&b>-<&r>").append(toAdd);
|
expression.append("<&b>-<&r>").append(toAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return expression.toString();
|
return expression.toString();
|
||||||
}
|
}
|
||||||
public static String increase(int target, int current, boolean deep, String mode) {
|
|
||||||
return target + "" + current;
|
|
||||||
}
|
|
||||||
public static String complex(int target, boolean deep, String mode) {
|
|
||||||
Random random = new Random();
|
|
||||||
String toAdd = "(" + target + ")";
|
|
||||||
int rComplexer;
|
|
||||||
switch (mode) {
|
|
||||||
case "n" -> rComplexer = random.nextInt(4)+1;
|
|
||||||
case "d" -> rComplexer = random.nextInt(3)+1;
|
|
||||||
default -> rComplexer = 1;
|
|
||||||
}
|
|
||||||
if (target == 1) {
|
|
||||||
toAdd = Complexers.power(target,deep);
|
|
||||||
} else if (isPerfectSquare(target)) {
|
|
||||||
toAdd = Complexers.power(target,deep);
|
|
||||||
} else {
|
|
||||||
switch (rComplexer) {
|
|
||||||
case 1 -> toAdd = Complexers.divide(target,deep);
|
|
||||||
case 2 -> toAdd = Complexers.mRootDivisor(target,deep);
|
|
||||||
case 3 -> toAdd = Complexers.mRootDividend(target,deep);
|
|
||||||
case 4 -> toAdd = Complexers.root(target,deep); // Won't reach this one, if its "d" due to it stopping at 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (eval(toAdd) == target) ? toAdd : "(" + target + ")";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,126 +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;
|
|
||||||
/* Statistics */
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
boolean doCopy = false;
|
|
||||||
String mode = "N";
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
case "--mode=numselli", "-m=n" -> mode = "N";
|
|
||||||
case "--mode=duckgroup", "-m=d" -> mode = "D";
|
|
||||||
case "--mode=TEST", "-m=t" -> mode = "TEST";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode.equals("TEST")) {
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = null;
|
|
||||||
switch (mode) {
|
|
||||||
case "N" -> expression = Obf.obfIntN(target, deep);
|
|
||||||
case "D" -> expression = Obf.obfIntD(target, deep);
|
|
||||||
}
|
|
||||||
long obfTime = obfTimer.end().timePassed();
|
|
||||||
double output = eval(removeColors(expression));
|
|
||||||
|
|
||||||
System.out.println("\nStatistics" +
|
|
||||||
"\nExponents: " + expCount +
|
|
||||||
"\nFactors: " + factorCount +
|
|
||||||
"\nAdditions: " + addCount +
|
|
||||||
"\nSubtractions: " + subCount +
|
|
||||||
"\nDivisors: " + divideCount +
|
|
||||||
"\nPowers: " + powerCount +
|
|
||||||
"\nmRootDividends: " + rDividendCount +
|
|
||||||
"\nmRootDivisors: " + rDivisorCount +
|
|
||||||
"\nRoots Taken: " + rootCount +
|
|
||||||
"\nPerfect Squares Found: " + perfectCount +
|
|
||||||
"\nTotal steps taken: " + total);
|
|
||||||
System.out.println("\nElapsed Time: " + obfTime + "ms");
|
|
||||||
System.out.println("\nTarget Integer: " + target);
|
|
||||||
|
|
||||||
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));
|
|
||||||
clearStats();
|
|
||||||
} 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package me.trouper.Utils;
|
package me.trouper.Utils;
|
||||||
|
|
||||||
import me.trouper.Data.MC2Ansi;
|
import me.trouper.Data.MC2Ansi;
|
||||||
import me.trouper.Main;
|
import me.trouper.Countroll;
|
||||||
|
import me.trouper.Functions.Eval;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
@@ -9,14 +10,26 @@ import java.awt.datatransfer.StringSelection;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Utils {
|
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) {
|
public static void copyToClip(String text) {
|
||||||
StringSelection parsed = new StringSelection(text);
|
StringSelection parsed = new StringSelection(text);
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
clipboard.setContents(parsed,null);
|
clipboard.setContents(parsed,null);
|
||||||
}
|
}
|
||||||
public static void verbose(String text) {
|
|
||||||
if (Main.verbose) System.out.println(activateColors(text));
|
|
||||||
}
|
|
||||||
public static String removeColors(String input) {
|
public static String removeColors(String input) {
|
||||||
return input.replaceAll("<&[0-9a-fr]>|<&[0-9a-frh]h>", "");
|
return input.replaceAll("<&[0-9a-fr]>|<&[0-9a-frh]h>", "");
|
||||||
}
|
}
|
||||||
@@ -39,14 +52,17 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void printHelp() {
|
public static void printHelp() {
|
||||||
System.out.println("Usage: java -jar Countroll-<version>.jar [options]");
|
System.out.println("""
|
||||||
System.out.println("Options:");
|
Usage: java -jar Countroll-<version>.jar [options]
|
||||||
System.out.println(" --copy, -c Copy the generated expression to the clipboard");
|
Options: values are formated as such: -m=d or -t=root
|
||||||
System.out.println(" --verbose, -v Enable verbose mode");
|
--copy, -c Copy the generated expression to the clipboard
|
||||||
System.out.println(" --deep, -d Enable deep obfuscation (under development)");
|
--verbose, -v Enable verbose mode
|
||||||
System.out.println(" --color, -rgb Enable colored output");
|
--deep, -d Enable deep obfuscation (under development)
|
||||||
System.out.println(" --help, --h, -h Show this help message");
|
--color, -rgb Enable colored output
|
||||||
System.out.println("Note: When using multiple options, separate them with spaces.");
|
--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);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
public static void printColorKey() {
|
public static void printColorKey() {
|
||||||
@@ -67,12 +83,20 @@ public class Utils {
|
|||||||
* @return The divisor
|
* @return The divisor
|
||||||
*/
|
*/
|
||||||
public static int moduRootDivisor(int dividend, int modulus) {
|
public static int moduRootDivisor(int dividend, int modulus) {
|
||||||
|
|
||||||
int divisor = dividend - modulus;
|
int divisor = dividend - modulus;
|
||||||
verbose("<&1h><&e>Finding mrDivisor:<&r> " +
|
Verbose.send("UTIL","<&1h><&e>Finding mrDivisor:<&r> " +
|
||||||
"\nDividend (Given): " + dividend +
|
"\nDividend (Given): " + dividend +
|
||||||
"\nDivisor (Unknown): " + divisor +
|
"\nDivisor (Unknown): " + divisor +
|
||||||
"\nModulus (Given): " + modulus);
|
"\nModulus (Given): " + modulus +
|
||||||
|
"\nCheck: " + dividend + "%" + divisor + "=" + Eval.eval(dividend + "%" + divisor));
|
||||||
return divisor;
|
return divisor;
|
||||||
|
/*
|
||||||
|
int divisor = 1;
|
||||||
|
while (divisor * dividend % modulus != 0 || divisor != 1) {
|
||||||
|
divisor++;
|
||||||
|
}
|
||||||
|
return divisor;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +108,7 @@ public class Utils {
|
|||||||
*/
|
*/
|
||||||
public static int moduRootDividend(int divisor, int modulus) {
|
public static int moduRootDividend(int divisor, int modulus) {
|
||||||
int dividend = modulus + divisor;
|
int dividend = modulus + divisor;
|
||||||
verbose("<&1h><&e>Finding mrDivisor:<&r> " +
|
Verbose.send("UTIL","<&1h><&e>Finding mrDivisor:<&r> " +
|
||||||
"\nDividend (Unknown): " + dividend +
|
"\nDividend (Unknown): " + dividend +
|
||||||
"\nDivisor (Given): " + divisor +
|
"\nDivisor (Given): " + divisor +
|
||||||
"\nModulus (Given): " + modulus);
|
"\nModulus (Given): " + modulus);
|
||||||
|
|||||||
32
src/main/java/me/trouper/Utils/Verbose.java
Normal file
32
src/main/java/me/trouper/Utils/Verbose.java
Normal 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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Main-Class: me.trouper.Main
|
Main-Class: me.trouper.Countroll
|
||||||
|
|||||||
Reference in New Issue
Block a user