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

Commit 84a85ee

Browse files
author
Checkium
committed
Fixed update to https
1 parent 188495b commit 84a85ee

File tree

5 files changed

+54
-17
lines changed

5 files changed

+54
-17
lines changed

src/me/checkium/vhackapi/Utils.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
import java.net.MalformedURLException;
99
import java.net.URL;
1010
import java.nio.charset.Charset;
11+
import java.security.GeneralSecurityException;
1112
import java.security.MessageDigest;
1213
import java.security.NoSuchAlgorithmException;
14+
import java.security.cert.X509Certificate;
15+
16+
import javax.net.ssl.HttpsURLConnection;
17+
import javax.net.ssl.SSLContext;
18+
import javax.net.ssl.TrustManager;
19+
import javax.net.ssl.X509TrustManager;
1320

1421
import org.json.JSONException;
1522
import org.json.JSONObject;
@@ -23,7 +30,7 @@ public class Utils {
2330

2431
static {
2532
assertionstatus = !Utils.class.desiredAssertionStatus();
26-
url = "http://vhackxt.com/v/9/";
33+
url = "https://vhackxt.com/v/9/";
2734
md5s = "MD5";
2835
secret = "aeffl";
2936
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};
@@ -39,6 +46,13 @@ public static String readJson(Reader rd) throws IOException {
3946
}
4047

4148
public static JSONObject JSONRequest(String format, String data, String php){
49+
try {
50+
SSLContext sc = SSLContext.getInstance("SSL");
51+
sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom());
52+
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
53+
} catch (GeneralSecurityException e) {
54+
}
55+
4256
JSONObject json = null;
4357
InputStream is;
4458
try {
@@ -157,7 +171,21 @@ public static byte[] assertion(byte[] bArr, int i, int i2, byte[] bArr2, int i3)
157171
throw new AssertionError();
158172
}
159173

174+
public static TrustManager[] trustAllCerts = new TrustManager[] {
175+
new X509TrustManager() {
176+
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
177+
return new X509Certificate[0];
178+
}
179+
public void checkClientTrusted(
180+
java.security.cert.X509Certificate[] certs, String authType) {
181+
}
182+
public void checkServerTrusted(
183+
java.security.cert.X509Certificate[] certs, String authType) {
184+
}
185+
}
186+
};
160187

188+
161189
public static String generateURL(String str, String str2, String str3) {
162190
String[] strArr = new String[2];
163191
String[] split = str.split("::::");

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.net.URL;
99
import java.nio.charset.Charset;
1010
import java.util.ArrayList;
11+
import java.util.concurrent.TimeUnit;
1112

1213
import org.json.JSONArray;
1314
import org.json.JSONObject;
@@ -77,7 +78,12 @@ public ArrayList<ScanResult> scanIPs(ArrayList<String> ips){
7778
rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
7879
result = new ScanResult(ReadBigStringIn(rd));
7980
array.add(result);
80-
81+
try {
82+
TimeUnit.MILLISECONDS.sleep(100);
83+
} catch (InterruptedException e) {
84+
// TODO Auto-generated catch block
85+
e.printStackTrace();
86+
}
8187
}
8288
} catch (MalformedURLException e) {
8389
e.printStackTrace();

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ScanResult(String[] result) {
3030
anonymous = result[9].substring(27);
3131
repsuccess = result[11].substring(32);
3232
repfail = result[12].substring(29);
33-
successrate = result[13].substring(39);
33+
successrate = result[13].substring(39).replace("%", "");
3434
}
3535
}
3636

@@ -65,17 +65,9 @@ public String getTransferedIP(){
6565
return "";
6666
}
6767

68-
public int getMoney(){
69-
return 0;
70-
}
71-
72-
public int getReputation(){
73-
return 0;
74-
}
68+
7569

76-
public int getSucess(){
77-
return 0;
78-
}
70+
7971

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

8577
public String getRepOnSuccess() {
8678
if (!success) { return null; }
79+
8780
return repsuccess;
8881
}
8982

@@ -95,18 +88,26 @@ public String getRepOnFail() {
9588
public boolean anonymous() {
9689
if (!success) { return false; }
9790
boolean anony;
98-
if (anonymous == "YES") {
91+
92+
if (anonymous.contains("YES")) {
9993
anony = true;
10094
} else {
10195
anony = false;
10296
}
10397
return anony;
10498
}
10599

100+
public int getMoney() {
101+
if (!success) { return 0; }
102+
if (money.contains("?")) {
103+
money = "0";
104+
}
105+
return Integer.valueOf(money);
106+
}
106107
public int getSuccessRate() {
107108
if (!success) { return 0; }
108-
if (successrate == "???") {
109-
return 0;
109+
if (successrate.contains("?")) {
110+
successrate = "0";
110111
}
111112
return Integer.valueOf(successrate);
112113

src/me/checkium/vhackapi/vHackAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public String getStats(Stats stat) {
5454
is = new URL(Utils.generateURL("user::::pass", username + "::::" + password, "vh_update.php")).openStream();
5555
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
5656
String jsonText = Utils.readJson(rd);
57-
57+
5858
json = new JSONObject(jsonText);
5959

6060
} catch (MalformedURLException e) {

src/me/checkium/vhackapi/vHackAPIBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ public vHackAPIBuilder email(String email) {
2525

2626
public vHackAPIBuilder register() {
2727
JSONObject json = Utils.JSONRequest("user::::pass::::email", username + "::::" + password + "::::" + email, "vh_register.php");
28+
2829
if (json.getString("result") != "0") {
2930
return null;
3031
} else {
3132
return this;
3233
}
3334
}
3435
public vHackAPI getAPI() {
36+
3537
vHackAPI api = new vHackAPI(username, password);
3638
return api;
3739
}

0 commit comments

Comments
 (0)