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

Some changes #42

Merged
merged 5 commits into from
Feb 15, 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
104 changes: 55 additions & 49 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@

<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>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.22.6</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
4 changes: 2 additions & 2 deletions src/main/java/examples/PackageExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import me.checkium.vhackapi.vHackAPI;
import me.checkium.vhackapi.vHackAPIBuilder;
import me.checkium.vhackapi.others.PackageResult;
import me.checkium.vhackapi.packages.PackageResult;

public class PackageExample {

vHackAPI api = new vHackAPIBuilder().password("pass").username("user").getAPI();

public void openPackage() {
PackageResult openresult = api.getPackageOpener().openPackage();
PackageResult openresult = api.getPackageManager().openPackage();
System.out.println("Got " + openresult.getResultAmount() + api.humanizeString(openresult.getResultType().toString()));
}
}
110 changes: 99 additions & 11 deletions src/main/java/me/checkium/vhackapi/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;

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 @@ -81,9 +83,31 @@ public static String readJson(Reader rd) throws IOException {
*/
public static JSONObject JSONRequest(String format, String data, String php){
JSONObject json = null;
String jsonText = StringRequest(format, data, php);
if("".equals(jsonText))
{
Future<String> jsonTextC = Request(format, data, php);
String jsonText = "";
try{
if(jsonTextC.isDone() /*|| jsonTextC.get() != ""*/){

jsonText = jsonTextC.get(2000, TimeUnit.MILLISECONDS);

} else {

Thread.sleep(1000);
jsonText = jsonTextC.get(2000, TimeUnit.MILLISECONDS);

}
} catch(Exception e) {

try {
Thread.sleep(1000);
} catch (InterruptedException e1) {

}
JSONRequest(format,data,php);

}
if("".equals(jsonText))
{
throw new RuntimeException("Old API URL");
}
else if("8".equals(jsonText))
Expand All @@ -109,12 +133,14 @@ else if (jsonText.length() == 1) {
* Example: "vHackAPI::::123456::::aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp::::1"
* @param php This is the api endpoint that the request will be sent to. In the case of the vHackAPI it are php documents.<br>
* Example "vh_network.php"
* @return The resulte Json as a String.
* @return The resulte Json as a Future<String>.
*/
//JDOC needs rewriting
@Async
public static String StringRequest(String format, String data, String php)
public static Future<String> Request(String format, String data, String php)
{

Future<String> jText;
System.setProperty("http.agent", "Chrome");
InputStream is;
try {
Expand All @@ -125,12 +151,74 @@ public static String StringRequest(String format, String data, String php)
System.out.println(url.toString());

}
Thread.sleep(1000);
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
jText = Utils.readJson(rd);
jText = new AsyncResult<String>(Utils.readJson(rd));
return jText;
} catch (Exception e) {
e.printStackTrace();
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
Request(format,data,php);
}
return null;
}

public static String StringRequest(String format, String data, String php)
{

Future<String> jsonTextC = Request(format, data, php);
String jsonText = "";
try{
if(jsonTextC.isDone()){

jsonText = jsonTextC.get();
return jsonText;

} else {

Thread.sleep(1000);
jsonText = jsonTextC.get(1000, TimeUnit.MILLISECONDS);
return jsonText;

}
} catch(Exception e) {

StringRequest(format,data,php);

}
return jText;
return null;

}

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

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

}

/**
* 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 static void 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);

}

private static byte[] m9179a(byte[] arrby, int n2, int n3, byte[] arrby2, int n4, byte[] arrby3) {
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/me/checkium/vhackapi/console/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.json.JSONArray;
import org.json.JSONException;
Expand Down Expand Up @@ -74,20 +73,20 @@ public ArrayList<String> getIPs(int number, boolean attacked, boolean global) th
return result;
}

@SuppressWarnings("unused")
public ScannedNode scanIP(String ip) {
ScannedNode result = null;

System.out.println("scanning " + ip);
System.out.println("Scanning [" + ip + "]");

try {
/*try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}

//IDK Why it's here.... it makes the scan slower
String resultString = Utils.StringRequest("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php");
String[] tempParsedResultString = parseScanResult(Utils.StringRequest("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php"));
String[] tempParsedResultString = parseScanResult(Utils.StringRequest("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php")); */
result = new ScannedNode(parseScanResult(Utils.StringRequest("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php")));
result.setIP(ip);

Expand All @@ -103,12 +102,12 @@ public ArrayList<ScannedNode> scanIPs(List<String> ips) {
}

public TransferResult transferTrojanTo(ScannedNode node) throws JSONException {
System.out.println("transfering " + node.getIP());
try {
System.out.println("Transfering trojan [" + node.getIP() + "]");
/*try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}*/

JSONObject json = Utils.JSONRequest("user::::pass::::uhash::::target", username + "::::" + password + "::::" + userHash + "::::" + node.getIP(), "vh_trTransfer.php");

Expand Down
Loading