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

Commit af71046

Browse files
Qup42Checkium
authored and
Checkium
committed
Merged Pull Requeset (#15): Booster in Bonus pack and partial spyware support
* Add support for booster in bonus packs Added support for booster with pack opening. * Split up StringRequest Split up StringRequest so that not only request with a json return can can be made but also with raw text * Added new stats Added new stats which may be used in the future. Not all from vh_update.php are implemented but all that make sense with the current game features/interface. * Added spyware upload Spyware upload is now possible getting uploaded spywares will follow in a later commit * Added myself to contributors * Moved spyware to a seperate package and added spyware manager All things relating spyware now are in the spyware package. The spyware manager can upload spyware and return all currently active spyware installs * Moved spyware to a seperate package and added spyware manager All things relating spyware now are in the spyware package. The spyware manager can upload spyware and return all currently active spyware installs * Updated README.md Changed adware to spyware (once again?) and added descriptions for the new functions
1 parent 3215855 commit af71046

11 files changed

+197
-29
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# vHackAPI-Java
22
[![Discord](https://img.shields.io/badge/Chat-%20on%20Discord-738bd7.svg)](https://discord.gg/PHgESQn) [![Build Status](https://travis-ci.org/vHack-API/vHackAPI-Java.svg?branch=master)](https://travis-ci.org/vHack-API/vHackAPI-Java) [![Downloads](https://img.shields.io/github/downloads/vHack-API/vHackAPI-Java/total.svg)]() [![GitHub release](https://img.shields.io/github/release/vHackAPI/vHackAPI-Java.svg)]()
33

4-
### Contributors: [@Checkium](https://github.com/checkium), [@dude24760](https://github.com/dude24760), [@angelbirth](https://github.com/angelbirth)
4+
### Contributors: [@Checkium](https://github.com/checkium), [@dude24760](https://github.com/dude24760), [@angelbirth](https://github.com/angelbirth), [@Qup42](https://github.com/Qup42)
55
###### Don't forget to add your name here when you pull request.
66
Current feature list:
77
- Ability to scan the network for IP addresses.
88
- Scan IP addresses for stats.
99
- Execute a trTransfer on an IP and retrieve the results.
10-
- Upload adware to a target IP.
10+
- Upload spyware to a target IP and get Infos about the spyware you have installed on remote IPs.
1111
- Upgrade software/hardware.
1212
- Abort tasks/finish tasks with netcoin.
1313
- Open free packages.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package me.checkium.vhackapi.Spyware;
2+
3+
import java.util.regex.Matcher;
4+
import java.util.regex.Pattern;
5+
6+
import org.json.JSONObject;
7+
8+
public class Spyware {
9+
10+
protected final Pattern pattern = Pattern.compile("(\\d\\d)m, (\\d\\d)s.");
11+
12+
protected int av;
13+
protected int fw;
14+
protected int money;
15+
protected int spam;
16+
protected int next;
17+
protected String ip;
18+
protected String username;
19+
20+
public Spyware (JSONObject json) {
21+
av = json.getInt("av");
22+
fw = json.getInt("fw");
23+
money = json.getInt("money");
24+
spam = json.getInt("spam");
25+
ip = json.getString("ip");
26+
username = json.getString("user");
27+
28+
String nextString = json.getString("next");
29+
if ("now.".equals(next))
30+
{
31+
next = 0;
32+
}
33+
else
34+
{
35+
Matcher matcher = pattern.matcher(nextString);
36+
if(matcher.matches())
37+
{
38+
next = Integer.valueOf(matcher.group(1)) * 60 + Integer.valueOf(matcher.group(2));
39+
}
40+
else
41+
{
42+
next = 3600;
43+
}
44+
}
45+
}
46+
47+
public int getAv() {
48+
return av;
49+
}
50+
51+
public int getFw() {
52+
return fw;
53+
}
54+
55+
public int getMoney() {
56+
return money;
57+
}
58+
59+
public int getSpam() {
60+
return spam;
61+
}
62+
63+
public int getNext() {
64+
return next;
65+
}
66+
67+
public String getIp() {
68+
return ip;
69+
}
70+
71+
public String getUsername() {
72+
return username;
73+
}
74+
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package me.checkium.vhackapi.Spyware;
2+
3+
import java.util.ArrayList;
4+
5+
import org.json.JSONArray;
6+
import org.json.JSONObject;
7+
8+
import me.checkium.vhackapi.Utils;
9+
import me.checkium.vhackapi.console.ScannedNode;
10+
11+
public class SpywareManager {
12+
13+
protected String password;
14+
protected String username;
15+
protected String userHash;
16+
17+
public SpywareManager(String user, String pass, String uHash) {
18+
username = user;
19+
password = pass;
20+
userHash = uHash;
21+
}
22+
23+
public SpywareUploadResult uploadSpywareTo(ScannedNode node)
24+
{
25+
String returnString = Utils.StringRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + node.getIP(), "vh_spywareUpload.php");
26+
return new SpywareUploadResult(returnString);
27+
}
28+
29+
public ArrayList<Spyware> getActiveSpyware()
30+
{
31+
ArrayList<Spyware> list = new ArrayList<>();
32+
JSONObject json = Utils.JSONRequest("user::::pass::::uhash", username + "::::" + password + "::::" + userHash, "vh_spywareInfo.php");
33+
JSONArray jsonArray = json.getJSONArray("data");
34+
for (int i = 0; i < jsonArray.length(); i++)
35+
{
36+
Spyware spyware = new Spyware(jsonArray.getJSONObject(i));
37+
list.add(spyware);
38+
}
39+
return list;
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package me.checkium.vhackapi.Spyware;
2+
3+
public class SpywareUploadResult {
4+
5+
protected boolean success;
6+
protected SpywareUploadResultEnum result;
7+
8+
public SpywareUploadResult(String resultString)
9+
{
10+
switch (resultString){
11+
case "0":
12+
result = SpywareUploadResultEnum.success;
13+
success = true;
14+
break;
15+
case "7":
16+
result = SpywareUploadResultEnum.ip_does_not_exists;
17+
break;
18+
case "11":
19+
result = SpywareUploadResultEnum.spyware_already_uploaded;
20+
break;
21+
case "14":
22+
result = SpywareUploadResultEnum.all_spyware_slots_full;
23+
break;
24+
}
25+
}
26+
27+
public SpywareUploadResultEnum getResult()
28+
{
29+
return result;
30+
}
31+
32+
public boolean wasSuccessfull()
33+
{
34+
return success;
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package me.checkium.vhackapi.Spyware;
2+
3+
public enum SpywareUploadResultEnum {
4+
success, ip_does_not_exists, spyware_already_uploaded, all_spyware_slots_full
5+
}

src/me/checkium/vhackapi/Stats.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public enum Stats {
44

5-
money, ip, inet, hdd, cpu, ram, fw, av, sdk, ipsp, spam, scan, adw, netcoins, bonus, elo, hash, id, uhash
5+
money, ip, inet, hdd, cpu, ram, fw, av, sdk, ipsp, spam, scan, adw, netcoins, bonus, elo, hash, id, uhash, score, boost, clusterID, position, rank, actspyware
66

77
}

src/me/checkium/vhackapi/Utils.java

+27-21
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,37 @@ public static String readJson(Reader rd) throws IOException {
4545
}
4646

4747
public static JSONObject JSONRequest(String format, String data, String php){
48-
System.setProperty("http.agent", "Chrome");
49-
try {
50-
SSLContext sc = SSLContext.getInstance("SSL");
51-
sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom());
52-
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
53-
} catch (GeneralSecurityException e) {
54-
}
55-
56-
JSONObject json = null;
57-
InputStream is;
58-
try {
59-
is = new URL(Utils.generateURL(format, data, php)).openStream();
60-
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
61-
String jsonText = Utils.readJson(rd);
62-
if (jsonText.length() == 1) {
63-
return null;
64-
}
65-
json = new JSONObject(jsonText);
66-
} catch (IOException e) {
67-
e.printStackTrace();
48+
JSONObject json = null;
49+
String jsonText = StringRequest(format, data, php);
50+
if (jsonText.length() == 1) {
51+
return null;
6852
}
53+
json = new JSONObject(jsonText);
6954
return json;
7055
}
56+
57+
public static String StringRequest(String format, String data, String php)
58+
{
59+
System.setProperty("http.agent", "Chrome");
60+
try {
61+
SSLContext sc = SSLContext.getInstance("SSL");
62+
sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom());
63+
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
64+
} catch (GeneralSecurityException e) {
65+
}
66+
67+
String jsonText = null;
68+
InputStream is;
69+
try {
70+
is = new URL(Utils.generateURL(format, data, php)).openStream();
71+
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
72+
jsonText = Utils.readJson(rd);
73+
} catch (IOException e) {
74+
e.printStackTrace();
75+
}
76+
return jsonText;
77+
}
7178

72-
//I sometimes get "Request Failed"
7379
private static byte[] m9179a(byte[] arrby, int n2, int n3, byte[] arrby2, int n4, byte[] arrby3) {
7480
int n5 = n3 > 0 ? arrby[n2] << 24 >>> 8 : 0;
7581
int n6 = n3 > 1 ? arrby[n2 + 1] << 24 >>> 16 : 0;

src/me/checkium/vhackapi/console/Console.java

-4
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,5 @@ public String[] ReadBigStringIn(BufferedReader buffIn) throws IOException {
118118
}
119119
return string;
120120
}
121-
122-
123-
124-
125121

126122
}

src/me/checkium/vhackapi/others/Others.java

+6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ public PackageResult openPackage() {
7070
//Bot net pc
7171
result = new PackageResult(PackageResultEnum.btntpc, json.getInt("win"));
7272
return result;
73+
case 4:
74+
//Booster
7375

76+
//you seem to get only one per package max.
77+
//my test had win: null and lvl: 0 in the result both times i tested it
78+
result = new PackageResult(PackageResultEnum.boost, 1);
79+
return result;
7480
}
7581
return result;
7682
}

src/me/checkium/vhackapi/others/PackageResultEnum.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
public enum PackageResultEnum {
44

5-
money, netcoins, av, fw, ipsp, btntpc, sdk, spam, scan, adw
5+
money, netcoins, av, fw, ipsp, btntpc, sdk, spam, scan, adw, boost
66
}

src/me/checkium/vhackapi/vHackAPI.java

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public String humanizeString(String unumanized) {
124124
return "ID";
125125
case "btntpc":
126126
return "Botnet PC";
127+
case "boost":
128+
return "Booster";
127129
default:
128130
return null;
129131
}

0 commit comments

Comments
 (0)