From af710468c34ae798b5633de26b85e089ddf44113 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 28 Nov 2016 18:51:10 +0100 Subject: [PATCH] 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 --- README.md | 4 +- src/me/checkium/vhackapi/Spyware/Spyware.java | 75 +++++++++++++++++++ .../vhackapi/Spyware/SpywareManager.java | 41 ++++++++++ .../vhackapi/Spyware/SpywareUploadResult.java | 37 +++++++++ .../Spyware/SpywareUploadResultEnum.java | 5 ++ src/me/checkium/vhackapi/Stats.java | 2 +- src/me/checkium/vhackapi/Utils.java | 48 ++++++------ src/me/checkium/vhackapi/console/Console.java | 4 - src/me/checkium/vhackapi/others/Others.java | 6 ++ .../vhackapi/others/PackageResultEnum.java | 2 +- src/me/checkium/vhackapi/vHackAPI.java | 2 + 11 files changed, 197 insertions(+), 29 deletions(-) create mode 100644 src/me/checkium/vhackapi/Spyware/Spyware.java create mode 100644 src/me/checkium/vhackapi/Spyware/SpywareManager.java create mode 100644 src/me/checkium/vhackapi/Spyware/SpywareUploadResult.java create mode 100644 src/me/checkium/vhackapi/Spyware/SpywareUploadResultEnum.java diff --git a/README.md b/README.md index c90e7c3..e1defc5 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # vHackAPI-Java [![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)]() -### Contributors: [@Checkium](https://github.com/checkium), [@dude24760](https://github.com/dude24760), [@angelbirth](https://github.com/angelbirth) +### Contributors: [@Checkium](https://github.com/checkium), [@dude24760](https://github.com/dude24760), [@angelbirth](https://github.com/angelbirth), [@Qup42](https://github.com/Qup42) ###### Don't forget to add your name here when you pull request. Current feature list: - Ability to scan the network for IP addresses. - Scan IP addresses for stats. - Execute a trTransfer on an IP and retrieve the results. -- Upload adware to a target IP. +- Upload spyware to a target IP and get Infos about the spyware you have installed on remote IPs. - Upgrade software/hardware. - Abort tasks/finish tasks with netcoin. - Open free packages. diff --git a/src/me/checkium/vhackapi/Spyware/Spyware.java b/src/me/checkium/vhackapi/Spyware/Spyware.java new file mode 100644 index 0000000..b7b32b1 --- /dev/null +++ b/src/me/checkium/vhackapi/Spyware/Spyware.java @@ -0,0 +1,75 @@ +package me.checkium.vhackapi.Spyware; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.json.JSONObject; + +public class Spyware { + + protected final Pattern pattern = Pattern.compile("(\\d\\d)m, (\\d\\d)s."); + + protected int av; + protected int fw; + protected int money; + protected int spam; + protected int next; + protected String ip; + protected String username; + + public Spyware (JSONObject json) { + av = json.getInt("av"); + fw = json.getInt("fw"); + money = json.getInt("money"); + spam = json.getInt("spam"); + ip = json.getString("ip"); + username = json.getString("user"); + + String nextString = json.getString("next"); + if ("now.".equals(next)) + { + next = 0; + } + else + { + Matcher matcher = pattern.matcher(nextString); + if(matcher.matches()) + { + next = Integer.valueOf(matcher.group(1)) * 60 + Integer.valueOf(matcher.group(2)); + } + else + { + next = 3600; + } + } + } + + public int getAv() { + return av; + } + + public int getFw() { + return fw; + } + + public int getMoney() { + return money; + } + + public int getSpam() { + return spam; + } + + public int getNext() { + return next; + } + + public String getIp() { + return ip; + } + + public String getUsername() { + return username; + } + +} diff --git a/src/me/checkium/vhackapi/Spyware/SpywareManager.java b/src/me/checkium/vhackapi/Spyware/SpywareManager.java new file mode 100644 index 0000000..7a4cf3e --- /dev/null +++ b/src/me/checkium/vhackapi/Spyware/SpywareManager.java @@ -0,0 +1,41 @@ +package me.checkium.vhackapi.Spyware; + +import java.util.ArrayList; + +import org.json.JSONArray; +import org.json.JSONObject; + +import me.checkium.vhackapi.Utils; +import me.checkium.vhackapi.console.ScannedNode; + +public class SpywareManager { + + protected String password; + protected String username; + protected String userHash; + + public SpywareManager(String user, String pass, String uHash) { + username = user; + password = pass; + userHash = uHash; + } + + public SpywareUploadResult uploadSpywareTo(ScannedNode node) + { + String returnString = Utils.StringRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + node.getIP(), "vh_spywareUpload.php"); + return new SpywareUploadResult(returnString); + } + + public ArrayList getActiveSpyware() + { + ArrayList list = new ArrayList<>(); + JSONObject json = Utils.JSONRequest("user::::pass::::uhash", username + "::::" + password + "::::" + userHash, "vh_spywareInfo.php"); + JSONArray jsonArray = json.getJSONArray("data"); + for (int i = 0; i < jsonArray.length(); i++) + { + Spyware spyware = new Spyware(jsonArray.getJSONObject(i)); + list.add(spyware); + } + return list; + } +} diff --git a/src/me/checkium/vhackapi/Spyware/SpywareUploadResult.java b/src/me/checkium/vhackapi/Spyware/SpywareUploadResult.java new file mode 100644 index 0000000..f79cac0 --- /dev/null +++ b/src/me/checkium/vhackapi/Spyware/SpywareUploadResult.java @@ -0,0 +1,37 @@ +package me.checkium.vhackapi.Spyware; + +public class SpywareUploadResult { + + protected boolean success; + protected SpywareUploadResultEnum result; + + public SpywareUploadResult(String resultString) + { + switch (resultString){ + case "0": + result = SpywareUploadResultEnum.success; + success = true; + break; + case "7": + result = SpywareUploadResultEnum.ip_does_not_exists; + break; + case "11": + result = SpywareUploadResultEnum.spyware_already_uploaded; + break; + case "14": + result = SpywareUploadResultEnum.all_spyware_slots_full; + break; + } + } + + public SpywareUploadResultEnum getResult() + { + return result; + } + + public boolean wasSuccessfull() + { + return success; + } + +} diff --git a/src/me/checkium/vhackapi/Spyware/SpywareUploadResultEnum.java b/src/me/checkium/vhackapi/Spyware/SpywareUploadResultEnum.java new file mode 100644 index 0000000..c4f475e --- /dev/null +++ b/src/me/checkium/vhackapi/Spyware/SpywareUploadResultEnum.java @@ -0,0 +1,5 @@ +package me.checkium.vhackapi.Spyware; + +public enum SpywareUploadResultEnum { + success, ip_does_not_exists, spyware_already_uploaded, all_spyware_slots_full +} diff --git a/src/me/checkium/vhackapi/Stats.java b/src/me/checkium/vhackapi/Stats.java index b7bb3ae..da2557a 100644 --- a/src/me/checkium/vhackapi/Stats.java +++ b/src/me/checkium/vhackapi/Stats.java @@ -2,6 +2,6 @@ public enum Stats { - money, ip, inet, hdd, cpu, ram, fw, av, sdk, ipsp, spam, scan, adw, netcoins, bonus, elo, hash, id, uhash + 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 } diff --git a/src/me/checkium/vhackapi/Utils.java b/src/me/checkium/vhackapi/Utils.java index b80fc93..4ac3dde 100644 --- a/src/me/checkium/vhackapi/Utils.java +++ b/src/me/checkium/vhackapi/Utils.java @@ -45,31 +45,37 @@ public static String readJson(Reader rd) throws IOException { } public static JSONObject JSONRequest(String format, String data, String php){ - System.setProperty("http.agent", "Chrome"); - try { - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom()); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - } catch (GeneralSecurityException e) { - } - - JSONObject json = null; - InputStream is; - try { - is = new URL(Utils.generateURL(format, data, php)).openStream(); - BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); - String jsonText = Utils.readJson(rd); - if (jsonText.length() == 1) { - return null; - } - json = new JSONObject(jsonText); - } catch (IOException e) { - e.printStackTrace(); + JSONObject json = null; + String jsonText = StringRequest(format, data, php); + if (jsonText.length() == 1) { + return null; } + json = new JSONObject(jsonText); return json; } + + public static String StringRequest(String format, String data, String php) + { + System.setProperty("http.agent", "Chrome"); + try { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + } catch (GeneralSecurityException e) { + } + + String jsonText = null; + InputStream is; + try { + is = new URL(Utils.generateURL(format, data, php)).openStream(); + BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); + jsonText = Utils.readJson(rd); + } catch (IOException e) { + e.printStackTrace(); + } + return jsonText; + } - //I sometimes get "Request Failed" private static byte[] m9179a(byte[] arrby, int n2, int n3, byte[] arrby2, int n4, byte[] arrby3) { int n5 = n3 > 0 ? arrby[n2] << 24 >>> 8 : 0; int n6 = n3 > 1 ? arrby[n2 + 1] << 24 >>> 16 : 0; diff --git a/src/me/checkium/vhackapi/console/Console.java b/src/me/checkium/vhackapi/console/Console.java index 6cb13cc..a8feffe 100644 --- a/src/me/checkium/vhackapi/console/Console.java +++ b/src/me/checkium/vhackapi/console/Console.java @@ -118,9 +118,5 @@ public String[] ReadBigStringIn(BufferedReader buffIn) throws IOException { } return string; } - - - - } diff --git a/src/me/checkium/vhackapi/others/Others.java b/src/me/checkium/vhackapi/others/Others.java index fc47070..d66bf80 100644 --- a/src/me/checkium/vhackapi/others/Others.java +++ b/src/me/checkium/vhackapi/others/Others.java @@ -70,7 +70,13 @@ public PackageResult openPackage() { //Bot net pc result = new PackageResult(PackageResultEnum.btntpc, json.getInt("win")); return result; + case 4: + //Booster + //you seem to get only one per package max. + //my test had win: null and lvl: 0 in the result both times i tested it + result = new PackageResult(PackageResultEnum.boost, 1); + return result; } return result; } diff --git a/src/me/checkium/vhackapi/others/PackageResultEnum.java b/src/me/checkium/vhackapi/others/PackageResultEnum.java index cb2565f..92bee84 100644 --- a/src/me/checkium/vhackapi/others/PackageResultEnum.java +++ b/src/me/checkium/vhackapi/others/PackageResultEnum.java @@ -2,5 +2,5 @@ public enum PackageResultEnum { - money, netcoins, av, fw, ipsp, btntpc, sdk, spam, scan, adw + money, netcoins, av, fw, ipsp, btntpc, sdk, spam, scan, adw, boost } diff --git a/src/me/checkium/vhackapi/vHackAPI.java b/src/me/checkium/vhackapi/vHackAPI.java index 5f4e45e..4bc16af 100644 --- a/src/me/checkium/vhackapi/vHackAPI.java +++ b/src/me/checkium/vhackapi/vHackAPI.java @@ -124,6 +124,8 @@ public String humanizeString(String unumanized) { return "ID"; case "btntpc": return "Botnet PC"; + case "boost": + return "Booster"; default: return null; }