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

Commit 6f1096a

Browse files
author
Checkium
authored
Merge pull request #18 from tr0teK/development
Console + ConsoleExample Changes
2 parents af71046 + 3469338 commit 6f1096a

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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), [@Qup42](https://github.com/Qup42)
4+
### 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)
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.

src/examples/ConsoleExample.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package examples;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
3+
//import java.util.ArrayList;
4+
//import java.util.List;
55

66
import me.checkium.vhackapi.vHackAPI;
77
import me.checkium.vhackapi.vHackAPIBuilder;
@@ -11,16 +11,15 @@
1111
public class ConsoleExample {
1212
public static void main(String[] args) {
1313
vHackAPI api = new vHackAPIBuilder().password("pass").username("user").getAPI();
14-
List<String> ip = api.getConsole().getIPs(1, false, false);
15-
List<ScannedNode> scanned = api.getConsole().scanIPs(ip);
14+
String ip = api.getConsole().getIP(false, false);
15+
ScannedNode scanned = api.getConsole().scanIP(ip);
1616

17-
if(scanned.get(0).getSuccessRate() <= 90 && scanned.get(0).isAnonymous()) {
18-
ArrayList<TransferResult> transfer = api.getConsole().trTransferIPs((ArrayList<String>) ip);
19-
if(transfer.get(0).getSuccess()){
20-
System.out.println("Got $" + transfer.get(0).getMoneyAmount());
21-
System.out.println("Gained " + transfer.get(0).getRepGained() + " rep.");
22-
}
23-
}
24-
17+
if(scanned.getSuccessRate() >= 70) {
18+
TransferResult transfer = api.getConsole().transferTrojanTo(scanned);
19+
if(transfer.getSuccess()){
20+
System.out.println("Got $" + transfer.getMoneyAmount());
21+
System.out.println("Gained " + transfer.getRepGained() + " rep.");
22+
}
23+
}
2524
}
2625
}

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

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ public Console(String user, String pass, String uHash) {
2929
//return this;
3030
}
3131

32+
/**
33+
*
34+
* Get IP from console
35+
*
36+
* @param global Use global?
37+
* @param attacked Get already attacked IPs?
38+
*/
39+
public String getIP(boolean attacked, boolean global) throws JSONException {
40+
String result = null;
41+
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + (global?"1":"0"), "vh_network.php");
42+
JSONArray jSONArray = json.getJSONArray("data");
43+
result = jSONArray.getJSONObject(0).getString("ip");
44+
return result;
45+
}
46+
3247
/**
3348
*
3449
* Get IPs from console
@@ -37,16 +52,12 @@ public Console(String user, String pass, String uHash) {
3752
* @param global Use global?
3853
* @param attacked Get already attacked IPs?
3954
*/
40-
public ArrayList<String> getIPs(int number, boolean attacked, boolean global){
55+
public ArrayList<String> getIPs(int number, boolean attacked, boolean global) throws JSONException {
4156
ArrayList<String> result = new ArrayList<String>();
4257
ArrayList<String> temporary = new ArrayList<String>();
43-
int globali = 0;
44-
if (global) {
45-
globali = 1;
46-
}
4758
if (number > 10) {
4859
for (int i = 10; i <= number + 9; i = i + 10) {
49-
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + Integer.toString(globali), "vh_network.php");
60+
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + (global?"1":"0"), "vh_network.php");
5061
JSONArray jSONArray = json.getJSONArray("data");
5162
for (int j = 0; j <= jSONArray.length() - 1; j++) {
5263
JSONObject ip = jSONArray.getJSONObject(j);
@@ -58,7 +69,7 @@ public ArrayList<String> getIPs(int number, boolean attacked, boolean global){
5869
result.add(temporary.get(k));
5970
}
6071
} else {
61-
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + Integer.toString(globali), "vh_network.php");
72+
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::global", username + "::::" + password + "::::" + userHash + "::::" + (global?"1":"0"), "vh_network.php");
6273
JSONArray jSONArray = json.getJSONArray("data");
6374
for (int k = 0; k < number; k++) {
6475
result.add(jSONArray.getJSONObject(k).getString("ip"));
@@ -67,14 +78,31 @@ public ArrayList<String> getIPs(int number, boolean attacked, boolean global){
6778
return result;
6879
}
6980

81+
public ScannedNode scanIP(String ip) {
82+
InputStream is;
83+
BufferedReader rd;
84+
ScannedNode result = null;
85+
try {
86+
is = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php")).openStream();
87+
rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
88+
String[] temp = ReadBigStringIn(rd);
89+
result = new ScannedNode(temp);
90+
result.setIP(ip);
91+
TimeUnit.MILLISECONDS.sleep(100);
92+
} catch (InterruptedException|IOException e) {
93+
e.printStackTrace();
94+
}
95+
return result;
96+
}
97+
7098
public List<ScannedNode> scanIPs(List<String> ips) {
7199
InputStream is;
72100
BufferedReader rd;
73101
List<ScannedNode> array = new ArrayList<>();
74102
ScannedNode result;
75103

76104
for (String ip : ips) {
77-
try{
105+
try {
78106
is = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php")).openStream();
79107
rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
80108
String[] temp = ReadBigStringIn(rd);
@@ -83,7 +111,6 @@ public List<ScannedNode> scanIPs(List<String> ips) {
83111
array.add(result);
84112
TimeUnit.MILLISECONDS.sleep(100);
85113
} catch (InterruptedException|IOException e) {
86-
// TODO Auto-generated catch block
87114
e.printStackTrace();
88115
}
89116
}
@@ -94,15 +121,13 @@ public TransferResult transferTrojanTo(ScannedNode node) throws JSONException {
94121
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + node.getIP(), "vh_trTransfer.php");
95122
return new TransferResult(json, node.getIP());
96123
}
97-
98124

99-
public ArrayList<TransferResult> trTransferIPs(ArrayList<String> ips) {
125+
public ArrayList<TransferResult> transferTrojansTo(ArrayList<ScannedNode> nodes) throws JSONException {
100126
ArrayList<TransferResult> array = new ArrayList<TransferResult>();
101127
TransferResult result;
102-
for (int j = 0; j < ips.size(); j++) {
103-
104-
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + ips.get(j), "vh_trTransfer.php");
105-
result = new TransferResult(json, ips.get(j));
128+
for (int j = 0; j < nodes.size(); j++) {
129+
JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + nodes.get(j).getIP(), "vh_trTransfer.php");
130+
result = new TransferResult(json, nodes.get(j).getIP());
106131
array.add(result);
107132
}
108133
return array;

0 commit comments

Comments
 (0)