Skip to content
This repository was archived by the owner on Nov 24, 2018. It is now read-only.

Commit 96bc0fc

Browse files
committed
vhack update
1 parent 6e74161 commit 96bc0fc

File tree

3 files changed

+31
-36
lines changed

3 files changed

+31
-36
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies {
2020
compile 'com.google.code.gson:gson:2.8.2'
2121
compile 'ch.qos.logback:logback-classic:1.2.3'
2222
compile 'com.google.guava:guava:24.0-jre'
23-
compile 'net.olympiccode:vHackOSAPI-Java:f0deaaa007'
23+
compile 'net.olympiccode:vHackOSAPI-Java:c761a2bb4'
2424
compile 'io.sentry:sentry:1.7.1'
2525
}
2626
mainClassName = "net.olympiccode.vhackos.bot.core.vHackOSBot"

src/main/java/net/olympiccode/vhackos/bot/core/networking/NetworkingService.java

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
import io.sentry.Sentry;
66
import net.olympiccode.vhackos.api.entities.AppType;
77
import net.olympiccode.vhackos.api.entities.BruteForceState;
8-
import net.olympiccode.vhackos.api.entities.impl.BruteForceImpl;
98
import net.olympiccode.vhackos.api.exceptions.ExploitFailedException;
109
import net.olympiccode.vhackos.api.network.BruteForce;
1110
import net.olympiccode.vhackos.api.network.ExploitedTarget;
12-
import net.olympiccode.vhackos.api.network.NetworkManager;
1311
import net.olympiccode.vhackos.bot.core.BotService;
1412
import net.olympiccode.vhackos.bot.core.vHackOSBot;
1513
import org.slf4j.Logger;
@@ -18,7 +16,6 @@
1816
import javax.script.ScriptEngine;
1917
import javax.script.ScriptEngineManager;
2018
import javax.script.ScriptException;
21-
import java.nio.channels.NetworkChannel;
2219
import java.util.ArrayList;
2320
import java.util.concurrent.Executors;
2421
import java.util.concurrent.ScheduledExecutorService;
@@ -28,19 +25,15 @@
2825
public class NetworkingService implements BotService {
2926
public static ScheduledExecutorService networkingService;
3027
Logger LOG = LoggerFactory.getLogger("NetworkingService");
28+
Cache<String, String> cache = CacheBuilder.newBuilder()
29+
.maximumSize(500)
30+
.expireAfterWrite(60 * 5 + 30, TimeUnit.SECONDS).build();
3131

3232
public NetworkingService() {
3333
LOG.info("Creating NetworkingService...");
3434
networkingService = Executors.newScheduledThreadPool(1, new NetworkingServiceFactory());
3535
}
3636

37-
public class NetworkingServiceFactory implements ThreadFactory {
38-
public Thread newThread(Runnable r) {
39-
return new Thread(r, "vHackOSBot-NetworkingService");
40-
}
41-
}
42-
43-
4437
@Override
4538
public ScheduledExecutorService getService() {
4639
return networkingService;
@@ -54,31 +47,28 @@ public void setup() {
5447
networkingService.scheduleAtFixedRate(() -> runService(), 0, 60000, TimeUnit.MILLISECONDS);
5548
}
5649

57-
Cache<String, String> cache = CacheBuilder.newBuilder()
58-
.maximumSize(500)
59-
.expireAfterWrite(60*5+30, TimeUnit.SECONDS).build();
60-
6150
public void runService() {
6251
try {
63-
((ArrayList<BruteForce>)((ArrayList)vHackOSBot.api.getTaskManager().getActiveBrutes()).clone()).forEach(bruteForce -> {
52+
((ArrayList<BruteForce>) ((ArrayList) vHackOSBot.api.getTaskManager().getActiveBrutes()).clone()).forEach(bruteForce -> {
6453
if (cache.asMap().containsKey(bruteForce.getIp())) return;
6554
if (bruteForce.getState() == BruteForceState.SUCCESS) {
6655
cache.put(bruteForce.getIp(), "");
6756
ExploitedTarget etarget = bruteForce.exploit();
6857
ExploitedTarget.Banking banking = etarget.getBanking();
6958

7059
if (banking.isBruteForced()) {
71-
long av = banking.getAvaliableMoney();
72-
if (av > 0 && banking.withdraw(NetworkingConfigValues.withdrawPorcentage)) {
73-
LOG.info("Withdrawed " + av + " of " + banking.getTotal() + " from " + etarget.getIp() + ".");
74-
} else {
75-
LOG.error("Failed to withdraw from " + etarget.getIp() + ".");
60+
if (banking.canAttack()) {
61+
long av = banking.getAvaliableMoney();
62+
if (av > 0 && banking.withdraw(NetworkingConfigValues.withdrawPorcentage)) {
63+
LOG.info("Withdrawed " + av + " of " + banking.getTotal() + " from " + etarget.getIp() + ".");
64+
} else {
65+
LOG.error("Failed to withdraw from " + etarget.getIp() + ".");
66+
}
67+
if (eval(etarget)) {
68+
LOG.info("Removing bruteforce from " + etarget.getIp() + ".");
69+
bruteForce.remove();
70+
}
7671
}
77-
if (eval(etarget)) {
78-
LOG.info("Removing bruteforce from " + etarget.getIp() + ".");
79-
bruteForce.remove();
80-
}
81-
8272
} else {
8373
if (banking.startBruteForce()) {
8474
LOG.info("Started bruteforce at " + etarget.getIp());
@@ -99,20 +89,20 @@ public void runService() {
9989
}
10090
});
10191
if (vHackOSBot.api.getStats().getExploits() > 0) {
102-
int success = 0;
103-
int tries = 6 * 3;
92+
int success = 0;
93+
int tries = 6 * 3;
10494
LOG.info("Starting exploits...");
105-
while (success < 6 && tries > 0) {
106-
success += scan();
107-
tries--;
108-
}
109-
LOG.info("Finished exploits, exploited " + success + " targets in " + tries + " tries.");
95+
while (success < 6 && tries > 0) {
96+
success += scan();
97+
tries--;
98+
}
99+
LOG.info("Finished exploits, exploited " + success + " targets in " + tries + " tries.");
110100
}
111101
} catch (Exception e) {
112102
Sentry.capture(e);
103+
LOG.warn("The networking service has been shutdown due to an error.");
113104
e.printStackTrace();
114105
networkingService.shutdownNow();
115-
LOG.warn("The networking service has been shutdown due to an error.");
116106
}
117107
}
118108

@@ -159,4 +149,10 @@ public boolean eval(ExploitedTarget target) {
159149
}
160150
return false;
161151
}
152+
153+
public class NetworkingServiceFactory implements ThreadFactory {
154+
public Thread newThread(Runnable r) {
155+
return new Thread(r, "vHackOSBot-NetworkingService");
156+
}
157+
}
162158
}

src/main/java/net/olympiccode/vhackos/bot/core/vHackOSBot.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class vHackOSBot {
4343
static Logger LOG = LoggerFactory.getLogger("vHackOSBot");
4444
ConfigFile config = new ConfigFile();
4545
AdvancedConfigFile advConfig = new AdvancedConfigFile();
46-
double curVersion = 1.11;
46+
double curVersion = 1.12;
4747
private long startTime = 0;
4848

4949
public static void main(String[] args) {
@@ -122,7 +122,6 @@ public void run() throws LoginException, InterruptedException {
122122
if (MiscConfigValues.enabled) miscService.setup();
123123
if (NetworkingConfigValues.enabled) networkingService.setup();
124124
maintenanceService.setup();
125-
networkingService.getService().shutdownNow();
126125
} catch (Exception e) {
127126
Sentry.capture(e);
128127
e.printStackTrace();

0 commit comments

Comments
 (0)