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

Commit 49a7bdd

Browse files
author
Checkium
authored
Merge pull request #6 from angelbirth/master
Code cleanup and some fixes
2 parents a88baa9 + 191e85b commit 49a7bdd

File tree

6 files changed

+330
-191
lines changed

6 files changed

+330
-191
lines changed

src/me/checkium/vhackapi/Utils.java

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@
1111
import java.security.GeneralSecurityException;
1212
import java.security.MessageDigest;
1313
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;
2014

2115
import org.json.JSONException;
2216
import org.json.JSONObject;
2317

18+
import javax.net.ssl.HttpsURLConnection;
19+
import javax.net.ssl.SSLContext;
20+
2421
public class Utils {
2522
public static String url;
2623
public static String md5s;
@@ -47,12 +44,11 @@ public static String readJson(Reader rd) throws IOException {
4744

4845
public static JSONObject JSONRequest(String format, String data, String php){
4946
try {
50-
SSLContext sc = SSLContext.getInstance("SSL");
51-
sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom());
47+
SSLContext sc = SSLContext.getInstance("SSL");
48+
sc.init(null, Utils.trustAllCerts, new java.security.SecureRandom());
5249
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
5350
} catch (GeneralSecurityException e) {
5451
}
55-
5652
JSONObject json = null;
5753
InputStream is;
5854
try {
@@ -63,14 +59,8 @@ public static JSONObject JSONRequest(String format, String data, String php){
6359
return null;
6460
}
6561
json = new JSONObject(jsonText);
66-
67-
} catch (MalformedURLException e) {
68-
// TODO Auto-generated catch block
69-
e.printStackTrace();
7062
} catch (IOException e) {
71-
72-
// TODO Auto-generated catch block
73-
e.printStackTrace();
63+
e.printStackTrace();
7464
}
7565
return json;
7666
}
@@ -171,21 +161,21 @@ public static byte[] assertion(byte[] bArr, int i, int i2, byte[] bArr2, int i3)
171161
throw new AssertionError();
172162
}
173163

174-
public static TrustManager[] trustAllCerts = new TrustManager[] {
175-
new X509TrustManager() {
176-
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
164+
public static TrustManager[] trustAllCerts = new TrustManager[] {
165+
new X509TrustManager() {
166+
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
177167
return new X509Certificate[0];
178-
}
179-
public void checkClientTrusted(
168+
}
169+
public void checkClientTrusted(
180170
java.security.cert.X509Certificate[] certs, String authType) {
181-
}
182-
public void checkServerTrusted(
171+
}
172+
public void checkServerTrusted(
183173
java.security.cert.X509Certificate[] certs, String authType) {
184174
}
185-
}
186-
};
175+
}
176+
};
177+
187178

188-
189179
public static String generateURL(String str, String str2, String str3) {
190180
String[] strArr = new String[2];
191181
String[] split = str.split("::::");
Lines changed: 65 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,79 @@
11
package me.checkium.vhackapi.console;
22

3+
import me.checkium.vhackapi.Utils;
4+
import org.json.JSONArray;
5+
import org.json.JSONObject;
6+
37
import java.io.BufferedReader;
48
import java.io.IOException;
59
import java.io.InputStreamReader;
6-
import java.net.MalformedURLException;
710
import java.net.URL;
811
import java.net.URLConnection;
912
import java.util.HashMap;
1013
import java.util.concurrent.TimeUnit;
1114

12-
import org.json.JSONArray;
13-
import org.json.JSONObject;
15+
public class AdwareManager {
1416

15-
import me.checkium.vhackapi.Utils;
17+
protected String password;
18+
protected String username;
1619

17-
public class AdwareManager {
20+
public AdwareManager(String pass, String user) {
21+
password = pass;
22+
username = user;
23+
}
24+
25+
public boolean uploadAdware(String target) {
26+
27+
URLConnection in;
28+
try {
29+
in = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + target, "vh_adwareUpload.php")).openConnection();
30+
31+
BufferedReader br = new BufferedReader(new InputStreamReader((in.getInputStream())));
32+
String line = br.readLine();
33+
return line.contains("0");
34+
} catch (IOException e) {
35+
// TODO Auto-generated catch block
36+
e.printStackTrace();
37+
}
38+
return false;
39+
}
40+
41+
public boolean removeAdware(String target) {
42+
@SuppressWarnings("unused")
43+
URLConnection in;
44+
try {
45+
in = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + target, "vh_removeAdwareRemote.php")).openConnection();
46+
BufferedReader br = new BufferedReader(new InputStreamReader((in.getInputStream())));
47+
String line = br.readLine();
48+
JSONObject json = new JSONObject(line);
49+
return json.getInt("result") == 0;
50+
} catch (IOException e) {
51+
e.printStackTrace();
52+
}
53+
return false;
54+
55+
}
56+
57+
58+
public HashMap<String, Integer> getAdwares() {
59+
try {
60+
TimeUnit.MILLISECONDS.sleep(100);
61+
} catch (InterruptedException e) {
62+
// TODO Auto-generated catch block
63+
e.printStackTrace();
64+
}
65+
HashMap<String, Integer> map = new HashMap<>();
66+
JSONObject json = Utils.JSONRequest("user::::pass", username + "::::" + password, "vh_adwareInfo.php");
67+
if (json.getInt("remote") <= 0) {
68+
return null;
69+
}
70+
JSONArray array = json.getJSONArray("data");
71+
for (int i = 0; i <= array.length() - 1; i++) {
72+
String IP = array.getJSONObject(i).getString("ip");
73+
Integer earn = array.getJSONObject(i).getInt("earn");
74+
map.put(IP, earn);
75+
}
1876

19-
protected String password;
20-
protected String username;
21-
public AdwareManager(String pass, String user) {
22-
password = pass;
23-
username = user;
24-
}
25-
public boolean uploadAdware(String target) {
26-
27-
URLConnection in;
28-
try {
29-
in = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + target, "vh_adwareUpload.php")).openConnection();
30-
31-
BufferedReader br = new BufferedReader(new InputStreamReader((in.getInputStream())));
32-
String line = br.readLine();
33-
if (line.contains("11")) {
34-
return true;
35-
} else {
36-
return false;
37-
}
38-
} catch (MalformedURLException e) {
39-
// TODO Auto-generated catch block
40-
e.printStackTrace();
41-
} catch (IOException e) {
42-
// TODO Auto-generated catch block
43-
e.printStackTrace();
44-
}
45-
return false;
46-
}
47-
48-
public boolean removeAdware(String target) {
49-
@SuppressWarnings("unused")
50-
URLConnection in;
51-
try {
52-
in = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + target, "vh_removeAdwareRemote.php")).openConnection();
53-
} catch (MalformedURLException e) {
54-
e.printStackTrace();
55-
} catch (IOException e) {
56-
e.printStackTrace();
57-
}
58-
59-
return true;
60-
61-
}
62-
63-
64-
public HashMap<String, Integer> getAdware() {
65-
try {
66-
TimeUnit.MILLISECONDS.sleep(100);
67-
} catch (InterruptedException e) {
68-
// TODO Auto-generated catch block
69-
e.printStackTrace();
70-
}
71-
HashMap<String, Integer> map = new HashMap<>();
72-
JSONObject json = Utils.JSONRequest("user::::pass", username + "::::" + password, "vh_adwareInfo.php");
73-
if (json.getInt("remote") <= 0) {
74-
return null;
75-
}
76-
JSONArray array = json.getJSONArray("data");
77-
for (int i = 0; i <= array.length() - 1; i++) {
78-
String IP = array.getJSONObject(i).getString("ip");
79-
Integer earn = array.getJSONObject(i).getInt("earn");
80-
map.put(IP, earn);
81-
}
82-
83-
return map;
84-
}
77+
return map;
78+
}
8579
}

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

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import java.net.URL;
99
import java.nio.charset.Charset;
1010
import java.util.ArrayList;
11+
import java.util.List;
1112
import java.util.concurrent.TimeUnit;
1213

1314
import org.json.JSONArray;
15+
import org.json.JSONException;
1416
import org.json.JSONObject;
1517

1618
import me.checkium.vhackapi.Utils;
@@ -64,36 +66,33 @@ public ArrayList<String> getIPs(int number, boolean attacked, boolean global){
6466
return result;
6567
}
6668

67-
68-
69-
public ArrayList<ScanResult> scanIPs(ArrayList<String> ips){
70-
InputStream is;
71-
BufferedReader rd;
72-
ArrayList<ScanResult> array = new ArrayList<ScanResult>();
73-
ScanResult result;
74-
try {
75-
for (int j = 0; j < ips.size(); j++) {
76-
77-
is = new URL(Utils.generateURL("user::::pass::::target",username + "::::" + password + "::::" + ips.get(j), "vh_scan.php")).openStream();
78-
rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
79-
result = new ScanResult(ReadBigStringIn(rd));
80-
array.add(result);
81-
try {
82-
TimeUnit.MILLISECONDS.sleep(100);
83-
} catch (InterruptedException e) {
84-
// TODO Auto-generated catch block
85-
e.printStackTrace();
86-
}
87-
}
88-
} catch (MalformedURLException e) {
89-
e.printStackTrace();
90-
} catch (IOException e) {
91-
e.printStackTrace();
92-
}
93-
return array;
94-
}
95-
96-
69+
public List<ScannedNode> scanIPs(List<String> ips) {
70+
InputStream is;
71+
BufferedReader rd;
72+
List<ScannedNode> array = new ArrayList<>();
73+
ScannedNode result;
74+
75+
for (String ip : ips) {
76+
try{
77+
is = new URL(Utils.generateURL("user::::pass::::target", username + "::::" + password + "::::" + ip, "vh_scan.php")).openStream();
78+
rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
79+
String[] temp = ReadBigStringIn(rd);
80+
result = new ScannedNode(temp);
81+
result.setIP(ip);
82+
array.add(result);
83+
TimeUnit.MILLISECONDS.sleep(100);
84+
} catch (InterruptedException|IOException e) {
85+
// TODO Auto-generated catch block
86+
e.printStackTrace();
87+
}
88+
}
89+
return array;
90+
}
91+
92+
public TransferResult transferTrojanTo(ScannedNode node) throws JSONException {
93+
JSONObject json = Utils.JSONRequest("user::::pass::::target", username + "::::" + password + "::::" + node.getIP(), "vh_trTransfer.php");
94+
return new TransferResult(json, node.getIP());
95+
}
9796

9897

9998
public ArrayList<TransferResult> trTransferIPs(ArrayList<String> ips) {

0 commit comments

Comments
 (0)