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

Commit 588536b

Browse files
authored
Merge pull request #41 from C0mm4nd/master
Minor stuff
2 parents e113351 + c1cf94c commit 588536b

File tree

6 files changed

+99
-39
lines changed

6 files changed

+99
-39
lines changed

pom.xml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1+
12
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34
<groupId>vhack</groupId>
45
<artifactId>vhack</artifactId>
56
<version>0.0.1-SNAPSHOT</version>
67
<name>VHackAPI</name>
8+
<repositories>
9+
<repository>
10+
<id>oss.sonatype.org</id>
11+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
12+
</repository>
13+
</repositories>
714
<dependencies>
8-
<dependency>
9-
<groupId>org.json</groupId>
10-
<artifactId>json</artifactId>
11-
<version>20160810</version>
12-
</dependency>
13-
15+
<dependency>
16+
<groupId>org.json</groupId>
17+
<artifactId>json</artifactId>
18+
<version>20160810</version>
19+
</dependency>
20+
<dependency>
21+
<groupId>com.jcabi</groupId>
22+
<artifactId>jcabi-aspects</artifactId>
23+
<version>0.22.6</version>
24+
</dependency>
1425
</dependencies>
15-
<properties>
26+
<properties>
1627
<maven.compiler.source>1.8</maven.compiler.source>
1728
<maven.compiler.target>1.8</maven.compiler.target>
1829
</properties>
19-
20-
<build>
30+
<build>
2131
<plugins>
2232
<plugin>
2333
<artifactId>maven-assembly-plugin</artifactId>
@@ -37,4 +47,4 @@
3747
</plugin>
3848
</plugins>
3949
</build>
40-
</project>
50+
</project>

src/main/java/me/checkium/vhackapi/Utils.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
import org.json.JSONException;
1414
import org.json.JSONObject;
1515

16+
import com.jcabi.aspects.Async;
17+
1618
public class Utils {
19+
20+
private static String jText = null;
1721
/**
1822
* The url of the current api.<br>
1923
* As of now it is {@value url}.
@@ -107,26 +111,26 @@ else if (jsonText.length() == 1) {
107111
* Example "vh_network.php"
108112
* @return The resulte Json as a String.
109113
*/
114+
@Async
110115
public static String StringRequest(String format, String data, String php)
111116
{
117+
112118
System.setProperty("http.agent", "Chrome");
113-
114-
String jsonText = null;
115-
InputStream is;
116-
try {
117-
is = new URL(Utils.generateURL(format, data, php)).openStream();
118-
if(debug == true){
119-
120-
URL url = new URL(Utils.generateURL(format, data, php));
121-
System.out.println(url.toString());
119+
InputStream is;
120+
try {
121+
is = new URL(Utils.generateURL(format, data, php)).openStream();
122+
if(debug == true){
122123

123-
}
124-
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
125-
jsonText = Utils.readJson(rd);
126-
} catch (IOException e) {
127-
e.printStackTrace();
128-
}
129-
return jsonText;
124+
URL url = new URL(Utils.generateURL(format, data, php));
125+
System.out.println(url.toString());
126+
127+
}
128+
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
129+
jText = Utils.readJson(rd);
130+
} catch (Exception e) {
131+
e.printStackTrace();
132+
}
133+
return jText;
130134
}
131135

132136
private static byte[] m9179a(byte[] arrby, int n2, int n3, byte[] arrby2, int n4, byte[] arrby3) {

src/main/java/me/checkium/vhackapi/botnet/Bot.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ public Bot(String username, String password, String userHash, int bID){
1717
this.username = username;
1818
this.password = password;
1919
this.userHash = userHash;
20-
BotnetManager.getInfo();
2120
getBotInfo();
2221

2322
}
2423
protected void getBotInfo(){
2524

2625
JSONArray botsInfo = BotnetManager.botnetInfo.getJSONArray("data");
27-
JSONObject botInfo = botsInfo.getJSONObject(--bID);
26+
JSONObject botInfo = botsInfo.getJSONObject(bID - 1);
2827
this.botInfo = botInfo;
2928

3029
}
@@ -47,9 +46,16 @@ public int getPrice(){
4746

4847
}
4948

49+
public void refreshBotnetInfo(){
50+
51+
BotnetManager.getInfo();
52+
53+
}
54+
5055
public void update(){
5156

5257
Utils.JSONRequest("user::::pass::::uhash::::bID", username + "::::" + password + "::::" + userHash + "::::" + bID, "vh_upgradeBotnet.php");
58+
refreshBotnetInfo();
5359
getBotInfo();
5460

5561
}

src/main/java/me/checkium/vhackapi/botnet/BotnetManager.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ public Bot getBot(int bID){
2828
return bot;
2929
}
3030

31+
public Bot[] getBots(){
32+
33+
Bot[] bots = new Bot[getBotCount()];
34+
for(int i = 0; i < getBotCount(); i++){
35+
36+
bots[i] = getBot(i + 1);
37+
38+
}
39+
return bots;
40+
41+
}
42+
3143
public int getBotCount(){
3244

3345
return botnetInfo.getInt("count");

src/main/java/me/checkium/vhackapi/cluster/Cluster.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ public ClusterMember[] getClusterRequests(){
7979

8080
}
8181

82+
public void manageClusterRequest(int decision, ClusterMember applicant){
83+
84+
Utils.StringRequest("user::::pass::::uhash::::decision::::uid", ClusterManager.username + "::::" + ClusterManager.password + "::::" + ClusterManager.uhash + "::::" + decision + "::::" + applicant.getID(), "vh_clusterDecision");
85+
//Seems to return 0,1,2,5,10,12
86+
87+
}
88+
8289
public void kickClusterMember(ClusterMember m){
8390

8491
try{
@@ -122,25 +129,19 @@ public int getNumberOfRequests(){
122129

123130
}
124131

125-
//Too slow, needs working
126-
/*public String[] getClusterMessages(){
132+
public JSONObject[] getClusterMessages(){
127133

128134
JSONArray messagesArray = cData.getJSONArray("messages");
129-
String[] messages = new String[messagesArray.length() - 1];
135+
JSONObject[] messages = new JSONObject[messagesArray.length()];
130136
for(int i = (messagesArray.length() - 1); i >= 0; i--){
131137

132-
int i2 = 0;
133138
JSONObject messageRaw = messagesArray.getJSONObject(i);
134-
String dateAuthor = messageRaw.getString("from");
135-
String message = messageRaw.getString("message");
136-
String format = dateAuthor + ": " + message;
137-
messages[i2] = format;
138-
i++;
139+
messages[i] = messageRaw;
139140

140141
}
141142
return messages;
142143

143-
}*/
144+
}
144145

145146
public void chat(String msg){
146147

src/main/java/me/checkium/vhackapi/vHackAPIBuilder.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,34 @@ public vHackAPIBuilder register() {
4242
}
4343
}
4444

45-
45+
46+
/**
47+
* Sets a proxy for the system
48+
* @param proxyUrl The proxy's IP/URL
49+
* @param proxyPort The proxy's port
50+
*/
51+
public vHackAPIBuilder useProxy(String proxyUrl, int proxyPort){
52+
53+
System.setProperty("http.proxyHost", proxyUrl);
54+
System.setProperty("http.proxyPort", String.valueOf(proxyPort));
55+
return this;
56+
}
57+
58+
/**
59+
* Sets a proxy that requires auth for the system
60+
* @param proxyUrl The proxy's IP/URL
61+
* @param proxyPort The proxy's port
62+
* @param username The proxy's username
63+
* @param password The proxy's password
64+
*/
65+
public vHackAPIBuilder useProxy(String proxyUrl, int proxyPort, String username, String password){
66+
67+
System.setProperty("http.proxyHost", proxyUrl);
68+
System.setProperty("http.proxyPort", String.valueOf(proxyPort));
69+
System.setProperty("http.proxyUser", username);
70+
System.setProperty("http.proxyPassword", password);
71+
return this;
72+
}
4673

4774
public vHackAPI getAPI() {
4875
try {

0 commit comments

Comments
 (0)