Skip to content

Commit

Permalink
2.27
Browse files Browse the repository at this point in the history
  • Loading branch information
tonikelope committed Nov 22, 2017
1 parent 7faefbb commit aa05fcb
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/megabasterd/CryptTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,16 @@ public static HashSet<String> decryptDLC(String data, MainPanel main_panel) {

out.write(buffer, 0, reads);
}
enc_dlc_key = findFirstRegex("< *rc *>(.+)< */ *rc *>", new String(out.toByteArray()), 1);
enc_dlc_key = findFirstRegex("< *rc *>(.+?)< */ *rc *>", new String(out.toByteArray()), 1);
}

String dec_dlc_key = new String(CryptTools.aes_ecb_decrypt(BASE642Bin(enc_dlc_key), hex2bin(dlc_master_key))).trim();

String dec_dlc_data = new String(CryptTools.aes_cbc_decrypt(BASE642Bin(enc_dlc_data), BASE642Bin(dec_dlc_key), BASE642Bin(dec_dlc_key))).trim();

String dec_dlc_data_file = findFirstRegex("< *file *>(.+)< */ *file *>", new String(BASE642Bin(dec_dlc_data)), 1);
String dec_dlc_data_file = findFirstRegex("< *file *>(.+?)< */ *file *>", new String(BASE642Bin(dec_dlc_data), "UTF-8"), 1);

ArrayList<String> urls = findAllRegex("< *url *>(.+)< */ *url *>", dec_dlc_data_file, 1);
ArrayList<String> urls = findAllRegex("< *url *>(.+?)< */ *url *>", dec_dlc_data_file, 1);

for (String s : urls) {

Expand Down
3 changes: 2 additions & 1 deletion src/megabasterd/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
public final class MainPanel {

public static final String VERSION = "2.26";
public static final String VERSION = "2.27";
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
public static final int STREAMER_PORT = 1337;
Expand Down Expand Up @@ -211,6 +211,7 @@ public void run() {
} else {
_mega_proxy_server = null;
}

}

public MegaProxyServer getMega_proxy_server() {
Expand Down
10 changes: 7 additions & 3 deletions src/megabasterd/MegaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,22 @@ private void _realLogin() throws Exception, MegaAPIException {

public void login(String email, String password) throws Exception, MegaAPIException {

_email = email;
String[] email_split = email.split(" *# *");

_email = email_split[0];

_password_aes = MEGAPrepareMasterKey(bin2i32a(password.getBytes()));

_user_hash = MEGAUserHash(email.toLowerCase().getBytes(), _password_aes);
_user_hash = MEGAUserHash(_email.toLowerCase().getBytes(), _password_aes);

_realLogin();
}

public void fastLogin(String email, int[] password_aes, String user_hash) throws Exception, MegaAPIException {

_email = email;
String[] email_split = email.split(" *# *");

_email = email_split[0];

_password_aes = password_aes;

Expand Down
79 changes: 76 additions & 3 deletions src/megabasterd/MiscTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.apache.http.HttpStatus;
import org.apache.http.auth.AuthScope;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.RequestAddCookies;
Expand Down Expand Up @@ -239,15 +240,15 @@ public static long bytearray2long(byte[] val) {
}

public static String findFirstRegex(String regex, String data, int group) {
Pattern pattern = Pattern.compile(regex);
Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);

Matcher matcher = pattern.matcher(data);

return matcher.find() ? matcher.group(group) : null;
}

public static ArrayList<String> findAllRegex(String regex, String data, int group) {
Pattern pattern = Pattern.compile(regex);
Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);

Matcher matcher = pattern.matcher(data);

Expand Down Expand Up @@ -938,6 +939,42 @@ public static boolean checkMegaDownloadUrl(String string_url) {
return url_ok;
}

public static String getMyPublicIP() {

String public_ip = null;

try (CloseableHttpClient httpclient = getApacheKissHttpClientNOProxy()) {

HttpGet httpget = new HttpGet(new URI("http://whatismyip.akamai.com/"));

try (CloseableHttpResponse httpresponse = httpclient.execute(httpget)) {

InputStream is = httpresponse.getEntity().getContent();

try (ByteArrayOutputStream byte_res = new ByteArrayOutputStream()) {

byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE];

int reads;

while ((reads = is.read(buffer)) != -1) {

byte_res.write(buffer, 0, reads);
}

public_ip = new String(byte_res.toByteArray());
}
}

} catch (MalformedURLException ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException | URISyntaxException ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
}

return public_ip;
}

public static String checkNewVersion(String folder_node, String folder_key) {

String new_version = null;
Expand Down Expand Up @@ -1039,6 +1076,42 @@ public static CloseableHttpClient getApacheKissHttpClient() {
return builder.build();
}

public static CloseableHttpClient getApacheKissHttpClientSmartProxy() {

HttpClientBuilder builder = _getApacheKissHttpClientBuilder();

if (MainPanel.isUse_proxy() && MainPanel.getProxy_host() != null) {

HttpHost proxy = new HttpHost(MainPanel.getProxy_host(), MainPanel.getProxy_port());

builder = builder.setProxy(proxy);

if (MainPanel.getProxy_credentials() != null) {

CredentialsProvider credsProvider = new BasicCredentialsProvider();

AuthScope authScope = new AuthScope(MainPanel.getProxy_host(), MainPanel.getProxy_port());

credsProvider.setCredentials(authScope, MainPanel.getProxy_credentials());

builder = builder.setDefaultCredentialsProvider(credsProvider);
}
}

RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(SmartMegaProxyManager.TIMEOUT * 1000)
.setConnectTimeout(SmartMegaProxyManager.TIMEOUT * 1000)
.setConnectionRequestTimeout(SmartMegaProxyManager.TIMEOUT * 1000)
.build();

return builder.setDefaultRequestConfig(requestConfig).build();
}

public static CloseableHttpClient getApacheKissHttpClientNOProxy() {

return _getApacheKissHttpClientBuilder().build();
}

public static byte[] recReverseArray(byte[] arr, int start, int end) {

byte temp;
Expand Down Expand Up @@ -1068,7 +1141,7 @@ public static void restartApplication(int delay) {

cmd.append("-cp ").append(ManagementFactory.getRuntimeMXBean().getClassPath()).append(" ");

cmd.append(MiscTools.class.getName()).append(" ");
cmd.append(MainPanel.class.getName()).append(" ");

cmd.append(String.valueOf(delay));

Expand Down
31 changes: 31 additions & 0 deletions src/megabasterd/SmartMegaProxyManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package megabasterd;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
*
* @author tonikelope
*/
public class SmartMegaProxyManager implements Runnable {

public static final int TIMEOUT = 15;
private final String _proxy_list_url;
private final ConcurrentHashMap<String, HashMap> _proxy_list;

public SmartMegaProxyManager(String proxy_list_url) {
_proxy_list_url = proxy_list_url;
_proxy_list = new ConcurrentHashMap<>();
}

public HashMap getRandomProxy() {

return null;
}

@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

}

0 comments on commit aa05fcb

Please sign in to comment.