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

Minor stuff #41

Merged
merged 6 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>vhack</groupId>
<artifactId>vhack</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>VHackAPI</name>
<repositories>
<repository>
<id>oss.sonatype.org</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.22.6</version>
</dependency>
</dependencies>
<properties>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand All @@ -37,4 +47,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
36 changes: 20 additions & 16 deletions src/main/java/me/checkium/vhackapi/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
import org.json.JSONException;
import org.json.JSONObject;

import com.jcabi.aspects.Async;

public class Utils {

private static String jText = null;
/**
* The url of the current api.<br>
* As of now it is {@value url}.
Expand Down Expand Up @@ -107,26 +111,26 @@ else if (jsonText.length() == 1) {
* Example "vh_network.php"
* @return The resulte Json as a String.
*/
@Async
public static String StringRequest(String format, String data, String php)
{

System.setProperty("http.agent", "Chrome");

String jsonText = null;
InputStream is;
try {
is = new URL(Utils.generateURL(format, data, php)).openStream();
if(debug == true){

URL url = new URL(Utils.generateURL(format, data, php));
System.out.println(url.toString());
InputStream is;
try {
is = new URL(Utils.generateURL(format, data, php)).openStream();
if(debug == true){

}
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
jsonText = Utils.readJson(rd);
} catch (IOException e) {
e.printStackTrace();
}
return jsonText;
URL url = new URL(Utils.generateURL(format, data, php));
System.out.println(url.toString());

}
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
jText = Utils.readJson(rd);
} catch (Exception e) {
e.printStackTrace();
}
return jText;
}

private static byte[] m9179a(byte[] arrby, int n2, int n3, byte[] arrby2, int n4, byte[] arrby3) {
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/me/checkium/vhackapi/botnet/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ public Bot(String username, String password, String userHash, int bID){
this.username = username;
this.password = password;
this.userHash = userHash;
BotnetManager.getInfo();
getBotInfo();

}
protected void getBotInfo(){

JSONArray botsInfo = BotnetManager.botnetInfo.getJSONArray("data");
JSONObject botInfo = botsInfo.getJSONObject(--bID);
JSONObject botInfo = botsInfo.getJSONObject(bID - 1);
this.botInfo = botInfo;

}
Expand All @@ -47,9 +46,16 @@ public int getPrice(){

}

public void refreshBotnetInfo(){

BotnetManager.getInfo();

}

public void update(){

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

}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/me/checkium/vhackapi/botnet/BotnetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public Bot getBot(int bID){
return bot;
}

public Bot[] getBots(){

Bot[] bots = new Bot[getBotCount()];
for(int i = 0; i < getBotCount(); i++){

bots[i] = getBot(i + 1);

}
return bots;

}

public int getBotCount(){

return botnetInfo.getInt("count");
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/me/checkium/vhackapi/cluster/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public ClusterMember[] getClusterRequests(){

}

public void manageClusterRequest(int decision, ClusterMember applicant){

Utils.StringRequest("user::::pass::::uhash::::decision::::uid", ClusterManager.username + "::::" + ClusterManager.password + "::::" + ClusterManager.uhash + "::::" + decision + "::::" + applicant.getID(), "vh_clusterDecision");
//Seems to return 0,1,2,5,10,12

}

public void kickClusterMember(ClusterMember m){

try{
Expand Down Expand Up @@ -122,25 +129,19 @@ public int getNumberOfRequests(){

}

//Too slow, needs working
/*public String[] getClusterMessages(){
public JSONObject[] getClusterMessages(){

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

int i2 = 0;
JSONObject messageRaw = messagesArray.getJSONObject(i);
String dateAuthor = messageRaw.getString("from");
String message = messageRaw.getString("message");
String format = dateAuthor + ": " + message;
messages[i2] = format;
i++;
messages[i] = messageRaw;

}
return messages;

}*/
}

public void chat(String msg){

Expand Down
29 changes: 28 additions & 1 deletion src/main/java/me/checkium/vhackapi/vHackAPIBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,34 @@ public vHackAPIBuilder register() {
}
}



/**
* Sets a proxy for the system
* @param proxyUrl The proxy's IP/URL
* @param proxyPort The proxy's port
*/
public vHackAPIBuilder useProxy(String proxyUrl, int proxyPort){

System.setProperty("http.proxyHost", proxyUrl);
System.setProperty("http.proxyPort", String.valueOf(proxyPort));
return this;
}

/**
* Sets a proxy that requires auth for the system
* @param proxyUrl The proxy's IP/URL
* @param proxyPort The proxy's port
* @param username The proxy's username
* @param password The proxy's password
*/
public vHackAPIBuilder useProxy(String proxyUrl, int proxyPort, String username, String password){

System.setProperty("http.proxyHost", proxyUrl);
System.setProperty("http.proxyPort", String.valueOf(proxyPort));
System.setProperty("http.proxyUser", username);
System.setProperty("http.proxyPassword", password);
return this;
}

public vHackAPI getAPI() {
try {
Expand Down