This repository has been archived by the owner on Nov 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
11 changed files
with
197 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
5
src/me/checkium/vhackapi/Spyware/SpywareUploadResultEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,9 +118,5 @@ public String[] ReadBigStringIn(BufferedReader buffIn) throws IOException { | |
} | ||
return string; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters