|
| 1 | +package examples; |
| 2 | + |
| 3 | +import net.olympiccode.vhackos.api.appstore.App; |
| 4 | +import net.olympiccode.vhackos.api.entities.AppType; |
| 5 | +import net.olympiccode.vhackos.api.entities.BruteForceState; |
| 6 | +import net.olympiccode.vhackos.api.entities.impl.TaskManagerImpl; |
| 7 | +import net.olympiccode.vhackos.api.events.Event; |
| 8 | +import net.olympiccode.vhackos.api.events.EventListener; |
| 9 | +import net.olympiccode.vhackos.api.events.StatsUpdateEvent; |
| 10 | +import net.olympiccode.vhackos.api.events.UpdateTaskFinishEvent; |
| 11 | +import net.olympiccode.vhackos.api.exceptions.ExploitFailedException; |
| 12 | +import net.olympiccode.vhackos.api.network.ExploitedTarget; |
| 13 | +import net.olympiccode.vhackos.api.vHackOSAPI; |
| 14 | +import net.olympiccode.vhackos.api.vHackOSAPIBuilder; |
| 15 | + |
| 16 | +import javax.security.auth.login.LoginException; |
| 17 | +import java.io.IOException; |
| 18 | +import java.nio.charset.Charset; |
| 19 | +import java.nio.file.Files; |
| 20 | +import java.nio.file.Path; |
| 21 | +import java.nio.file.Paths; |
| 22 | +import java.util.concurrent.Executors; |
| 23 | +import java.util.concurrent.TimeUnit; |
| 24 | +import java.util.stream.Collectors; |
| 25 | + |
| 26 | +public class BrainStormExample implements EventListener { |
| 27 | + /* |
| 28 | + ATTENTION |
| 29 | +
|
| 30 | + THIS IS THE CLASS I USE TO TEST THE API, I DECIDED TO KEEP IT HERE AS IT HAS MOST API FUNCTIONS AND CAN BE GOOD FOR EXAMPLES |
| 31 | + */ |
| 32 | + public static void main(String[] args) { |
| 33 | + try { |
| 34 | + String l = null; |
| 35 | + try { |
| 36 | + l = Files.readAllLines(Paths.get("example.txt"), Charset.forName("UTF-8")).stream().collect(Collectors.joining()); |
| 37 | + } catch (IOException e) { |
| 38 | + e.printStackTrace(); |
| 39 | + } |
| 40 | + if (l == null || !l.contains("#")) { |
| 41 | + return; |
| 42 | + } |
| 43 | + String username = l.split("#")[0]; |
| 44 | + String pass = l.split("#")[1]; |
| 45 | + System.out.println(username + pass); |
| 46 | + // Proxy proxyTest = new Proxy(Proxy.Type.HTTP,new InetSocketAddress("127.0.0.1", 8888)); |
| 47 | + //OkHttpClient.Builder builder = new OkHttpClient.Builder().proxy(proxyTest); |
| 48 | + vHackOSAPI api = new vHackOSAPIBuilder()/*.setHttpClientBuilder(builder)*/.setUsername(username).setPassword(pass).buildBlocking(); |
| 49 | + api.addEventListener(new BrainStormExample()); |
| 50 | + // Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> System.out.println(api.getTaskManager().getActiveTasks().stream().map(task -> task.getType() + ": " + task.getLevel() + " (" + task.getId() + ") - " + ((task.getEndTimestamp() - System.currentTimeMillis()) / 1000) ).collect(Collectors.joining("\n"))), 0, 5000, TimeUnit.MILLISECONDS); |
| 51 | + // api.getAppManager().getApp(AppType.Spam).getAsUpdateable().fillTasks(); |
| 52 | + int lvl = 10000000; |
| 53 | + App capp = null; |
| 54 | + System.out.println(api.getAppManager().getApps()); |
| 55 | + for (App app : api.getAppManager().getApps()) { |
| 56 | + if (!app.isInstalled() && app.getRequiredLevel() <= api.getStats().getLevel()) app.getAsInstallable().install(); |
| 57 | + if (app.getLevel() != 0 && !app.isOneTime() && app.isInstalled() && app.getLevel() < lvl) { |
| 58 | + lvl = app.getLevel(); |
| 59 | + capp = app; |
| 60 | + } |
| 61 | + } |
| 62 | + if (capp.getPrice() < api.getStats().getMoney()) { |
| 63 | + System.out.println("Starting " + capp.getType().getName()); |
| 64 | + if (!capp.getAsUpdateable().fillTasks()) ((TaskManagerImpl) api.getTaskManager()).reloadTasks(); |
| 65 | + if (api.getTaskManager().getBoosters() > 0) { |
| 66 | + System.out.println("Boosted tasks"); |
| 67 | + api.getTaskManager().boostAll(); |
| 68 | + } |
| 69 | + if (api.getStats().getNetcoins() > 1000) { |
| 70 | + System.out.println("Finished tasks with netcoins"); |
| 71 | + api.getTaskManager().finishAll(); |
| 72 | + } |
| 73 | + } |
| 74 | + Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> { |
| 75 | + System.out.println("Active tasks: " + api.getTaskManager().getActiveTasks().stream().map(task -> task.getId() + " " + task.getType().getName()).collect(Collectors.joining(", "))); |
| 76 | + }, 0, 10000, TimeUnit.MILLISECONDS); |
| 77 | + Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> { |
| 78 | + api.getMiner().start(); |
| 79 | + }, 0, 60000 * 60, TimeUnit.MILLISECONDS); |
| 80 | + Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> { |
| 81 | + final long[] money = {0}; |
| 82 | + api.getTaskManager().getActiveBrutes().forEach(bruteForce -> { |
| 83 | + if (bruteForce.getState() == BruteForceState.SUCCESS) { |
| 84 | + ExploitedTarget etarget = bruteForce.exploit(); |
| 85 | + ExploitedTarget.Banking banking = etarget.getBanking(); |
| 86 | + |
| 87 | + if (banking.isBruteForced()) { |
| 88 | + long av = banking.getAvaliableMoney(); |
| 89 | + if (av > 0 && banking.withdraw()) System.out.println("Got " + av + " of " + banking.getTotal() + " (" + banking.getSavings() + "/" + banking.getMaxSavings() + ") " + (banking.getSavings() / 2 < banking.getMaxSavings())); else System.out.println("fail" + (banking.getSavings() / 2 < banking.getMaxSavings())); |
| 90 | + money[0] = money[0] + av; |
| 91 | + if (!(banking.getSavings() / 2 < banking.getMaxSavings()) && banking.getSavings() < 1000000 && !bruteForce.getUsername().toLowerCase().contains("atjon")) bruteForce.remove(); |
| 92 | + } else { |
| 93 | + banking.startBruteForce(); |
| 94 | + } |
| 95 | + etarget.setSystemLog("Checkium was here #OlympicCode"); |
| 96 | + } |
| 97 | + }); |
| 98 | + api.getStats().getExploits(); |
| 99 | + if (api.getStats().getExploits() > 0) { |
| 100 | + int level = api.getAppManager().getApp(AppType.SDK).getLevel(); |
| 101 | + api.getNetworkManager().getTargets().forEach(target -> { |
| 102 | + if (target.getFirewall() < level && api.getStats().getExploits() > 0) { |
| 103 | + try { |
| 104 | + ExploitedTarget etarget = target.exploit(); |
| 105 | + etarget.getBanking().startBruteForce(); |
| 106 | + etarget.setSystemLog("Checkium was here #OlympicCode"); |
| 107 | + System.out.println("Started brute @ " + etarget.getIp()); |
| 108 | + } catch (ExploitFailedException e) { |
| 109 | + System.out.println(target.getIp() + ": " + e.getMessage()); |
| 110 | + } |
| 111 | + } |
| 112 | + }); |
| 113 | + } |
| 114 | + }, 100, 60000, TimeUnit.MILLISECONDS); |
| 115 | + System.out.println(api.getTaskManager().getActiveBrutes().stream().map(bruteForce -> bruteForce.getUsername() + " " + bruteForce.getState()).collect(Collectors.joining(", "))); |
| 116 | + } catch (LoginException | InterruptedException e) { |
| 117 | + e.printStackTrace(); |
| 118 | + } |
| 119 | + } |
| 120 | + |
| 121 | + @Override |
| 122 | + public void onEvent(Event event) { |
| 123 | + if (event instanceof StatsUpdateEvent) { |
| 124 | + StatsUpdateEvent e = (StatsUpdateEvent) event; |
| 125 | + System.out.println(e.getStats().getExploits() + " " + e.getStats().getMoney() + " " + e.getStats().getNetcoins() + " (" + e.getAPI().getMiner().isRunning() + ")"); |
| 126 | + System.out.println(e.getStats().getLevel() + " - " + e.getStats().getLevelPorcentage()); |
| 127 | + } else if (event instanceof UpdateTaskFinishEvent) { |
| 128 | + UpdateTaskFinishEvent e = (UpdateTaskFinishEvent) event; |
| 129 | + System.out.println(e.getAPI().getTaskManager().getActiveTasks().size() + "Finished " + e.getTask().getType() + " to level " + e.getTask().getLevel()); |
| 130 | + if (e.getAPI().getTaskManager().getActiveTasks().size() == 0) { |
| 131 | + int lvl = 100; |
| 132 | + App capp = null; |
| 133 | + for (App app : e.getAPI().getAppManager().getApps()) { |
| 134 | + if (app.getLevel() != 0 && !app.isOneTime() && app.isInstalled() && app.getLevel() < lvl) { |
| 135 | + lvl = app.getLevel(); |
| 136 | + capp = app; |
| 137 | + } |
| 138 | + } |
| 139 | + System.out.println("Starting " + capp.getType().getName() + " (" + capp.getType().getId() + ")"); |
| 140 | + boolean a = capp.getAsUpdateable().fillTasks(); |
| 141 | + if (!a) { |
| 142 | + a = capp.getAsUpdateable().fillTasks(); |
| 143 | + } |
| 144 | + if (a) { |
| 145 | + if (e.getAPI().getTaskManager().getBoosters() > 0) { |
| 146 | + System.out.println("Boosted tasks"); |
| 147 | + e.getAPI().getTaskManager().boostAll(); |
| 148 | + } |
| 149 | + if (e.getAPI().getStats().getNetcoins() > 1000) { |
| 150 | + System.out.println("Finished tasks with netcoins"); |
| 151 | + e.getAPI().getTaskManager().finishAll(); |
| 152 | + } |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + } |
| 157 | +} |
0 commit comments