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

Commit

Permalink
Merged Pull Requeset (#15): Booster in Bonus pack and partial spyware…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Qup42 authored and Checkium committed Nov 28, 2016
1 parent 3215855 commit af71046
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
75 changes: 75 additions & 0 deletions src/me/checkium/vhackapi/Spyware/Spyware.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
41 changes: 41 additions & 0 deletions src/me/checkium/vhackapi/Spyware/SpywareManager.java
Original file line number Diff line number Diff line change
@@ -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<Spyware> getActiveSpyware()
{
ArrayList<Spyware> 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;
}
}
37 changes: 37 additions & 0 deletions src/me/checkium/vhackapi/Spyware/SpywareUploadResult.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
5 changes: 5 additions & 0 deletions src/me/checkium/vhackapi/Spyware/SpywareUploadResultEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.checkium.vhackapi.Spyware;

public enum SpywareUploadResultEnum {
success, ip_does_not_exists, spyware_already_uploaded, all_spyware_slots_full
}
2 changes: 1 addition & 1 deletion src/me/checkium/vhackapi/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
48 changes: 27 additions & 21 deletions src/me/checkium/vhackapi/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/me/checkium/vhackapi/console/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,5 @@ public String[] ReadBigStringIn(BufferedReader buffIn) throws IOException {
}
return string;
}





}
6 changes: 6 additions & 0 deletions src/me/checkium/vhackapi/others/Others.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/me/checkium/vhackapi/others/PackageResultEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions src/me/checkium/vhackapi/vHackAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public String humanizeString(String unumanized) {
return "ID";
case "btntpc":
return "Botnet PC";
case "boost":
return "Booster";
default:
return null;
}
Expand Down

0 comments on commit af71046

Please sign in to comment.