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

Commit

Permalink
Fixed update to https
Browse files Browse the repository at this point in the history
  • Loading branch information
Checkium committed Sep 2, 2016
1 parent 188495b commit 84a85ee
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 17 deletions.
30 changes: 29 additions & 1 deletion src/me/checkium/vhackapi/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
import java.net.MalformedURLException;
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;
Expand All @@ -23,7 +30,7 @@ public class Utils {

static {
assertionstatus = !Utils.class.desiredAssertionStatus();
url = "http://vhackxt.com/v/9/";
url = "https://vhackxt.com/v/9/";
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};
Expand All @@ -39,6 +46,13 @@ public static String readJson(Reader rd) throws IOException {
}

public static JSONObject JSONRequest(String format, String data, String php){
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (GeneralSecurityException e) {
}

JSONObject json = null;
InputStream is;
try {
Expand Down Expand Up @@ -157,7 +171,21 @@ 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[] strArr = new String[2];
String[] split = str.split("::::");
Expand Down
8 changes: 7 additions & 1 deletion src/me/checkium/vhackapi/console/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

import org.json.JSONArray;
import org.json.JSONObject;
Expand Down Expand Up @@ -77,7 +78,12 @@ public ArrayList<ScanResult> scanIPs(ArrayList<String> ips){
rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
result = new ScanResult(ReadBigStringIn(rd));
array.add(result);

try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
Expand Down
29 changes: 15 additions & 14 deletions src/me/checkium/vhackapi/console/ScanResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ScanResult(String[] result) {
anonymous = result[9].substring(27);
repsuccess = result[11].substring(32);
repfail = result[12].substring(29);
successrate = result[13].substring(39);
successrate = result[13].substring(39).replace("%", "");
}
}

Expand Down Expand Up @@ -65,17 +65,9 @@ public String getTransferedIP(){
return "";
}

public int getMoney(){
return 0;
}

public int getReputation(){
return 0;
}


public int getSucess(){
return 0;
}


public String getUsername() {
if (!success) { return null; }
Expand All @@ -84,6 +76,7 @@ public String getUsername() {

public String getRepOnSuccess() {
if (!success) { return null; }

return repsuccess;
}

Expand All @@ -95,18 +88,26 @@ public String getRepOnFail() {
public boolean anonymous() {
if (!success) { return false; }
boolean anony;
if (anonymous == "YES") {

if (anonymous.contains("YES")) {
anony = true;
} else {
anony = false;
}
return anony;
}

public int getMoney() {
if (!success) { return 0; }
if (money.contains("?")) {
money = "0";
}
return Integer.valueOf(money);
}
public int getSuccessRate() {
if (!success) { return 0; }
if (successrate == "???") {
return 0;
if (successrate.contains("?")) {
successrate = "0";
}
return Integer.valueOf(successrate);

Expand Down
2 changes: 1 addition & 1 deletion src/me/checkium/vhackapi/vHackAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String getStats(Stats stat) {
is = new URL(Utils.generateURL("user::::pass", username + "::::" + password, "vh_update.php")).openStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = Utils.readJson(rd);

json = new JSONObject(jsonText);

} catch (MalformedURLException e) {
Expand Down
2 changes: 2 additions & 0 deletions src/me/checkium/vhackapi/vHackAPIBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ public vHackAPIBuilder email(String email) {

public vHackAPIBuilder register() {
JSONObject json = Utils.JSONRequest("user::::pass::::email", username + "::::" + password + "::::" + email, "vh_register.php");

if (json.getString("result") != "0") {
return null;
} else {
return this;
}
}
public vHackAPI getAPI() {

vHackAPI api = new vHackAPI(username, password);
return api;
}
Expand Down

0 comments on commit 84a85ee

Please sign in to comment.