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

Commit c63bdc3

Browse files
committed
vhack update & freeze fix
1 parent 3d9581c commit c63bdc3

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

build.gradle

+1-1
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:dev-SNAPSHOT'
23+
compile 'net.olympiccode:vHackOSAPI-Java:8fa096f72b'
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/config/AdvancedConfigFile.java

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public AdvancedConfigFile() {
2626
JsonObject configJson = new JsonObject();
2727
File file = new File("advanced.json");
2828
Logger LOG = LoggerFactory.getLogger("vHackOSBot-ConfigAdv");
29+
30+
public JsonObject getConfigJson() {
31+
return configJson;
32+
}
33+
2934
public void setupConfig() {
3035
LOG.info("Loading advanced config...");
3136
long time = System.currentTimeMillis();

src/main/java/net/olympiccode/vhackos/bot/core/config/AdvancedConfigValues.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ public class AdvancedConfigValues {
77
@AdvancedConfigOption(path = "loglevel", defaultValue = "info", options = {"all", "debug", "error", "info", "off", "trace", "warn"})
88
public static String logLevel;
99

10-
@AdvancedConfigOption(path = "networking.runTime", defaultValue = "3000", options = {""})
11-
public static int a;
10+
@AdvancedConfigOption(path = "login.accesstoken", defaultValue = "---", options = {""})
11+
public static String token;
12+
13+
@AdvancedConfigOption(path = "login.uid", defaultValue = "---", options = {""})
14+
public static String uid;
1215
}

src/main/java/net/olympiccode/vhackos/bot/core/config/ConfigFile.java

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public ConfigFile() {
2727
LOG.info("Creating ConfigFile...");
2828
}
2929

30+
public JsonObject getConfigJson() {
31+
return configJson;
32+
}
33+
3034
public void setupConfig() {
3135
LOG.info("Loading config...");
3236
long time = System.currentTimeMillis();

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public void setup() {
5252
}
5353

5454
Cache<String, String> cache = CacheBuilder.newBuilder()
55-
.maximumSize(300)
56-
.expireAfterWrite(30, TimeUnit.MINUTES).build();
55+
.maximumSize(500)
56+
.expireAfterWrite(60*5+30, TimeUnit.SECONDS).build();
5757

5858
public void runService() {
5959
try {
@@ -97,9 +97,13 @@ public void runService() {
9797
});
9898
if (vHackOSBot.api.getStats().getExploits() > 0) {
9999
int success = 0;
100-
while (success < 6) {
100+
int tries = 6 * 3;
101+
LOG.info("Starting exploits...");
102+
while (success < 6 && tries > 0) {
101103
success += scan();
104+
tries--;
102105
}
106+
LOG.info("Finished exploits, exploited " + success + " targets in " + tries + " tries.");
103107
}
104108
} catch (Exception e) {
105109
Sentry.capture(e);

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.olympiccode.vhackos.api.vHackOSAPIBuilder;
99
import net.olympiccode.vhackos.api.vHackOSInfo;
1010
import net.olympiccode.vhackos.bot.core.config.AdvancedConfigFile;
11+
import net.olympiccode.vhackos.bot.core.config.AdvancedConfigValues;
1112
import net.olympiccode.vhackos.bot.core.config.ConfigFile;
1213
import net.olympiccode.vhackos.bot.core.config.ConfigValues;
1314
import net.olympiccode.vhackos.bot.core.misc.MiscConfigValues;
@@ -95,17 +96,19 @@ public void run() throws LoginException, InterruptedException {
9596
LOG.error("Please set your login data in the config file");
9697
System.exit(0);
9798
}
98-
api = new vHackOSAPIBuilder().setUsername(ConfigValues.username).setPassword(ConfigValues.password).buildBlocking();
99+
api = new vHackOSAPIBuilder().setUsername(ConfigValues.username).setPassword(ConfigValues.password).buildBlocking();
99100
Sentry.getContext().setUser(
100101
new UserBuilder().setUsername(ConfigValues.username).build()
101102
);
102103
Sentry.getContext().recordBreadcrumb(
103104
new BreadcrumbBuilder().setMessage("Service setup").build()
104105
);
105106
try {
107+
startTime = System.currentTimeMillis();
106108
if (UpdateConfigValues.enabled) updateService.setup();
107109
if (MiscConfigValues.enabled) miscService.setup();
108110
if (NetworkingConfigValues.enabled) networkingService.setup();
111+
109112
} catch (Exception e) {
110113
Sentry.capture(e);
111114
e.printStackTrace();
@@ -127,7 +130,7 @@ public void run() throws LoginException, InterruptedException {
127130
break;
128131
case "stats":
129132
System.out.println("Username: " + api.getStats().getUsername() + SEPARATOR + "Money: " + api.getStats().getMoney() + SEPARATOR + "Netcoins: " + api.getStats().getNetcoins() +
130-
"\n" + "Exploits: " + api.getStats().getExploits() + SEPARATOR + "IP: " + api.getStats().getIpAddress() + "\n" +
133+
"\n" + "Exploits: " + api.getStats().getExploits() + SEPARATOR + "IP: " + api.getStats().getIpAddress() + SEPARATOR + " Running for: " + getRunningTime() + "\n" +
131134
"Level: " + api.getStats().getLevel() + getProgressBar());
132135
break;
133136
case "tasks":
@@ -173,6 +176,13 @@ private String getTimeLeft() {
173176
TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
174177
TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
175178
}
179+
private long startTime = 0;
180+
private String getRunningTime() {
181+
long millis = System.currentTimeMillis() - startTime;
182+
return String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis),
183+
TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
184+
TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
185+
}
176186

177187
private String getProgressBar() {
178188
long barnum = (Math.round(api.getStats().getLevelPorcentage() / 10)) - 1;

0 commit comments

Comments
 (0)