From 3469338ab2aeda0450743c8f4f94bd43f04eb1db Mon Sep 17 00:00:00 2001 From: troteK Date: Mon, 28 Nov 2016 22:37:56 +0100 Subject: [PATCH 1/2] - Added @tr0teK as Contributor to README.md - Added more functions to Console to work with single targets - Modified ConsoleExample with a working example --- README.md | 2 +- src/examples/ConsoleExample.java | 23 ++++---- src/me/checkium/vhackapi/console/Console.java | 55 ++++++++++++++----- 3 files changed, 52 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index e1defc5..feba49b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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), [@Qup42](https://github.com/Qup42) +### Contributors: [@Checkium](https://github.com/checkium), [@dude24760](https://github.com/dude24760), [@angelbirth](https://github.com/angelbirth), [@Qup42](https://github.com/Qup42), [@tr0teK](https://github.com/tr0teK) ###### Don't forget to add your name here when you pull request. Current feature list: - Ability to scan the network for IP addresses. diff --git a/src/examples/ConsoleExample.java b/src/examples/ConsoleExample.java index 794d3af..682f944 100644 --- a/src/examples/ConsoleExample.java +++ b/src/examples/ConsoleExample.java @@ -1,7 +1,7 @@ package examples; -import java.util.ArrayList; -import java.util.List; +//import java.util.ArrayList; +//import java.util.List; import me.checkium.vhackapi.vHackAPI; import me.checkium.vhackapi.vHackAPIBuilder; @@ -11,16 +11,15 @@ public class ConsoleExample { public static void main(String[] args) { vHackAPI api = new vHackAPIBuilder().password("pass").username("user").getAPI(); - List ip = api.getConsole().getIPs(1, false, false); - List scanned = api.getConsole().scanIPs(ip); + String ip = api.getConsole().getIP(false, false); + ScannedNode scanned = api.getConsole().scanIP(ip); - if(scanned.get(0).getSuccessRate() <= 90 && scanned.get(0).isAnonymous()) { - ArrayList transfer = api.getConsole().trTransferIPs((ArrayList) ip); - if(transfer.get(0).getSuccess()){ - System.out.println("Got $" + transfer.get(0).getMoneyAmount()); - System.out.println("Gained " + transfer.get(0).getRepGained() + " rep."); - } - } - + if(scanned.getSuccessRate() >= 70) { + TransferResult transfer = api.getConsole().transferTrojanTo(scanned); + if(transfer.getSuccess()){ + System.out.println("Got $" + transfer.getMoneyAmount()); + System.out.println("Gained " + transfer.getRepGained() + " rep."); + } + } } } diff --git a/src/me/checkium/vhackapi/console/Console.java b/src/me/checkium/vhackapi/console/Console.java index a8feffe..df6cad3 100644 --- a/src/me/checkium/vhackapi/console/Console.java +++ b/src/me/checkium/vhackapi/console/Console.java @@ -29,6 +29,21 @@ public Console(String user, String pass, String uHash) { //return this; } + /** + * + * Get IP from console + * + * @param global Use global? + * @param attacked Get already attacked IPs? + */ + public String getIP(boolean attacked, boolean global) throws JSONException { + String result = null; + JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + (global?"1":"0"), "vh_network.php"); + JSONArray jSONArray = json.getJSONArray("data"); + result = jSONArray.getJSONObject(0).getString("ip"); + return result; + } + /** * * Get IPs from console @@ -37,16 +52,12 @@ public Console(String user, String pass, String uHash) { * @param global Use global? * @param attacked Get already attacked IPs? */ - public ArrayList getIPs(int number, boolean attacked, boolean global){ + public ArrayList getIPs(int number, boolean attacked, boolean global) throws JSONException { ArrayList result = new ArrayList(); ArrayList temporary = new ArrayList(); - int globali = 0; - if (global) { - globali = 1; - } if (number > 10) { for (int i = 10; i <= number + 9; i = i + 10) { - JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + Integer.toString(globali), "vh_network.php"); + JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + (global?"1":"0"), "vh_network.php"); JSONArray jSONArray = json.getJSONArray("data"); for (int j = 0; j <= jSONArray.length() - 1; j++) { JSONObject ip = jSONArray.getJSONObject(j); @@ -58,7 +69,7 @@ public ArrayList getIPs(int number, boolean attacked, boolean global){ result.add(temporary.get(k)); } } else { - JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + Integer.toString(globali), "vh_network.php"); + JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + (global?"1":"0"), "vh_network.php"); JSONArray jSONArray = json.getJSONArray("data"); for (int k = 0; k < number; k++) { result.add(jSONArray.getJSONObject(k).getString("ip")); @@ -67,6 +78,23 @@ public ArrayList getIPs(int number, boolean attacked, boolean global){ return result; } + public ScannedNode scanIP(String ip) { + InputStream is; + BufferedReader rd; + ScannedNode result = null; + try { + is = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php")).openStream(); + rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); + String[] temp = ReadBigStringIn(rd); + result = new ScannedNode(temp); + result.setIP(ip); + TimeUnit.MILLISECONDS.sleep(100); + } catch (InterruptedException|IOException e) { + e.printStackTrace(); + } + return result; + } + public List scanIPs(List ips) { InputStream is; BufferedReader rd; @@ -74,7 +102,7 @@ public List scanIPs(List ips) { ScannedNode result; for (String ip : ips) { - try{ + try { is = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php")).openStream(); rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); String[] temp = ReadBigStringIn(rd); @@ -83,7 +111,6 @@ public List scanIPs(List ips) { array.add(result); TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException|IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -94,15 +121,13 @@ public TransferResult transferTrojanTo(ScannedNode node) throws JSONException { JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + node.getIP(), "vh_trTransfer.php"); return new TransferResult(json, node.getIP()); } - - public ArrayList trTransferIPs(ArrayList ips) { + public ArrayList transferTrojansTo(ArrayList nodes) throws JSONException { ArrayList array = new ArrayList(); TransferResult result; - for (int j = 0; j < ips.size(); j++) { - - JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + ips.get(j), "vh_trTransfer.php"); - result = new TransferResult(json, ips.get(j)); + for (int j = 0; j < nodes.size(); j++) { + JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + nodes.get(j).getIP(), "vh_trTransfer.php"); + result = new TransferResult(json, nodes.get(j).getIP()); array.add(result); } return array; From 2b95c62011813ad5702d383f786b739c7b3cdb98 Mon Sep 17 00:00:00 2001 From: Checkium Date: Tue, 29 Nov 2016 15:36:15 +0000 Subject: [PATCH 2/2] Updated to vHack 1.41 --- .../vhackapi/Spyware/SpywareManager.java | 11 +++++++ src/me/checkium/vhackapi/Utils.java | 33 ++----------------- src/me/checkium/vhackapi/vHackAPI.java | 7 +++- src/me/checkium/vhackapi/vHackAPIBuilder.java | 32 +++++++++++++++++- 4 files changed, 51 insertions(+), 32 deletions(-) diff --git a/src/me/checkium/vhackapi/Spyware/SpywareManager.java b/src/me/checkium/vhackapi/Spyware/SpywareManager.java index 7a4cf3e..fca0c5a 100644 --- a/src/me/checkium/vhackapi/Spyware/SpywareManager.java +++ b/src/me/checkium/vhackapi/Spyware/SpywareManager.java @@ -26,6 +26,17 @@ public SpywareUploadResult uploadSpywareTo(ScannedNode node) return new SpywareUploadResult(returnString); } + public boolean removeSpywareFrom(ScannedNode node) + { + String returnString = Utils.StringRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + node.getIP(), "vh_removeSpywareRemote.php"); + JSONObject d = new JSONObject(returnString); + if (d.getInt("result") == 0) { + return true; + } else { + return false; + } + } + public ArrayList getActiveSpyware() { ArrayList list = new ArrayList<>(); diff --git a/src/me/checkium/vhackapi/Utils.java b/src/me/checkium/vhackapi/Utils.java index 4ac3dde..3d1be89 100644 --- a/src/me/checkium/vhackapi/Utils.java +++ b/src/me/checkium/vhackapi/Utils.java @@ -7,15 +7,8 @@ import java.io.Reader; import java.net.URL; import java.nio.charset.Charset; -import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; import org.json.JSONException; import org.json.JSONObject; @@ -29,7 +22,7 @@ public class Utils { static { assertionstatus = !Utils.class.desiredAssertionStatus(); - url = "https://api.vhack.cc/v/7/"; + url = "https://api.vhack.cc/v/8/"; md5s = "MD5"; secret = "aeffl"; byt = new byte[]{(byte) 65, (byte) 66, (byte) 67, (byte) 68, (byte) 69, (byte) 70, (byte) 71, (byte) 72, (byte) 73, (byte) 74, (byte) 75, (byte) 76, (byte) 77, (byte) 78, (byte) 79, (byte) 80, (byte) 81, (byte) 82, (byte) 83, (byte) 84, (byte) 85, (byte) 86, (byte) 87, (byte) 88, (byte) 89, (byte) 90, (byte) 97, (byte) 98, (byte) 99, (byte) 100, (byte) 101, (byte) 102, (byte) 103, (byte) 104, (byte) 105, (byte) 106, (byte) 107, (byte) 108, (byte) 109, (byte) 110, (byte) 111, (byte) 112, (byte) 113, (byte) 114, (byte) 115, (byte) 116, (byte) 117, (byte) 118, (byte) 119, (byte) 120, (byte) 121, (byte) 122, (byte) 48, (byte) 49, (byte) 50, (byte) 51, (byte) 52, (byte) 53, (byte) 54, (byte) 55, (byte) 56, (byte) 57, (byte) 45, (byte) 95}; @@ -57,13 +50,7 @@ public static JSONObject JSONRequest(String format, String data, String php){ 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 { @@ -178,21 +165,7 @@ public static byte[] assertion(byte[] bArr, int i, int i2, byte[] bArr2, int i3) throw new AssertionError(); } - public static TrustManager[] trustAllCerts = new TrustManager[] { - new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - public void checkClientTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - public void checkServerTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - } - }; - - + public static String generateURL(String str, String str2, String str3) { String[] split = str.split("::::"); String[] split2 = str2.split("::::"); diff --git a/src/me/checkium/vhackapi/vHackAPI.java b/src/me/checkium/vhackapi/vHackAPI.java index 4bc16af..2224619 100644 --- a/src/me/checkium/vhackapi/vHackAPI.java +++ b/src/me/checkium/vhackapi/vHackAPI.java @@ -10,6 +10,7 @@ import org.json.JSONObject; +import me.checkium.vhackapi.Spyware.SpywareManager; import me.checkium.vhackapi.chat.Chat; import me.checkium.vhackapi.console.Console; import me.checkium.vhackapi.others.Others; @@ -30,7 +31,11 @@ public Console getConsole() { public UpgradeManager getUpgradeManager() { UpgradeManager manager = new UpgradeManager(username, password, userHash); return manager; - } + } + public SpywareManager getSpywareManager() { + SpywareManager manager = new SpywareManager(username, password, userHash); + return manager; + } public String getStats(Stats stat) { try { diff --git a/src/me/checkium/vhackapi/vHackAPIBuilder.java b/src/me/checkium/vhackapi/vHackAPIBuilder.java index 233d540..f80ce9d 100644 --- a/src/me/checkium/vhackapi/vHackAPIBuilder.java +++ b/src/me/checkium/vhackapi/vHackAPIBuilder.java @@ -1,5 +1,13 @@ package me.checkium.vhackapi; +import java.security.GeneralSecurityException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + import org.json.JSONObject; public class vHackAPIBuilder { @@ -37,8 +45,30 @@ public vHackAPIBuilder register() { public vHackAPI getAPI() { - + try { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + } catch (GeneralSecurityException e) { + } + vHackAPI api = new vHackAPI(username, password); return api; } + + public static TrustManager[] trustAllCerts = new TrustManager[] { + new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + } + }; + + }