-MC password links lock
-...
This commit is contained in:
tonikelope 2016-10-07 17:14:23 +02:00
parent a563690027
commit a4a38a60c9
9 changed files with 85 additions and 73 deletions

View File

@ -35,7 +35,7 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
_byte_file_key = CryptTools.initMEGALinkKey(_download.getFile_key()); _byte_file_key = CryptTools.initMEGALinkKey(_download.getFile_key());
_byte_iv = CryptTools.initMEGALinkKeyIV(_download.getFile_key()); _byte_iv = CryptTools.initMEGALinkKeyIV(_download.getFile_key());
_chunk_queue = new ConcurrentHashMap(); _chunk_queue = new ConcurrentHashMap();
_rejectedChunkIds = new ConcurrentLinkedQueue(); _rejectedChunkIds = new ConcurrentLinkedQueue<>();
if(_download.getProgress() == 0) if(_download.getProgress() == 0)
{ {

View File

@ -121,9 +121,9 @@ public final class Download implements Transference, Runnable, SecureNotifiable
_slots = slots; _slots = slots;
_restart= restart; _restart= restart;
_secure_notify_lock = new Object(); _secure_notify_lock = new Object();
_chunkworkers = new ArrayList(); _chunkworkers = new ArrayList<>();
_partialProgressQueue = new ConcurrentLinkedQueue(); _partialProgressQueue = new ConcurrentLinkedQueue<>();
_rejectedChunkIds = new ConcurrentLinkedQueue(); _rejectedChunkIds = new ConcurrentLinkedQueue<>();
_thread_pool = newCachedThreadPool(); _thread_pool = newCachedThreadPool();
} }
@ -1197,6 +1197,10 @@ public final class Download implements Transference, Runnable, SecureNotifiable
emergencyStopDownloader("MegaCrypter link has expired!"); emergencyStopDownloader("MegaCrypter link has expired!");
break; break;
case 25:
emergencyStopDownloader("MegaCrypter bad password!");
break;
default: default:
if(!retry_request) { if(!retry_request) {

View File

@ -212,7 +212,7 @@ public class GetMegaMasterPasswordDialog extends javax.swing.JDialog {
if(!pass_hash.equals(_current_pass_hash)) { if(!pass_hash.equals(_current_pass_hash)) {
JOptionPane.showMessageDialog(tthis, "Bad password!", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(tthis, "BAD PASSWORD!", "Error", JOptionPane.ERROR_MESSAGE);
swingReflectionInvoke("setText", status_label, ""); swingReflectionInvoke("setText", status_label, "");

View File

@ -61,7 +61,7 @@ import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
*/ */
public final class MainPanel { public final class MainPanel {
public static final String VERSION="1.17"; public static final String VERSION="1.18";
public static final int CONNECTION_TIMEOUT = 30000; public static final int CONNECTION_TIMEOUT = 30000;
public static final int THROTTLE_SLICE_SIZE=16*1024; public static final int THROTTLE_SLICE_SIZE=16*1024;
public static final int STREAMER_PORT = 1337; public static final int STREAMER_PORT = 1337;

View File

@ -9,6 +9,9 @@ import java.net.URL;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import static java.util.logging.Logger.getLogger; import static java.util.logging.Logger.getLogger;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
@ -32,6 +35,8 @@ import org.codehaus.jackson.map.ObjectMapper;
public final class MegaCrypterAPI { public final class MegaCrypterAPI {
public static final String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0"; public static final String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0";
public static final Set<String> PASS_CACHE = new HashSet<>();
public static final Object PASS_LOCK = new Object();
private static String _rawRequest(String request, URL url_api) throws IOException, MegaCrypterAPIException { private static String _rawRequest(String request, URL url_api) throws IOException, MegaCrypterAPIException {
@ -213,12 +218,18 @@ public final class MegaCrypterAPI {
Cipher decrypter; Cipher decrypter;
try { synchronized(PASS_LOCK) {
LinkedList<String> pass_list = new LinkedList(PASS_CACHE);
do do
{ {
bad_pass = false; bad_pass = true;
password = JOptionPane.showInputDialog(panel, "Enter password:"); if((password = pass_list.poll()) == null) {
password = JOptionPane.showInputDialog(panel, "Enter password for MegaCrypter link:");
}
if(password != null) { if(password != null) {
@ -232,22 +243,22 @@ public final class MegaCrypterAPI {
bad_pass = !Arrays.equals(info_key, decrypter.doFinal(key_check)); bad_pass = !Arrays.equals(info_key, decrypter.doFinal(key_check));
} catch (IllegalBlockSizeException | BadPaddingException ex) { if(!bad_pass) {
bad_pass=true; PASS_CACHE.add(password);
} }
} catch (InvalidKeySpecException ex) { } catch (IllegalBlockSizeException | BadPaddingException ex) {}
bad_pass=true; } catch (InvalidKeySpecException ex) {}
}
} }
}while(password!=null && bad_pass); }while(password!=null && bad_pass);
}
if(password==null) if(bad_pass)
{ {
return null; throw new MegaCrypterAPIException("25");
} }
else else
{ {
@ -274,9 +285,6 @@ public final class MegaCrypterAPI {
} }
} catch (Exception ex) {
getLogger(MegaCrypterAPI.class.getName()).log(Level.SEVERE, null, ex);
}
} }
if(fpath != null) if(fpath != null)

View File

@ -124,7 +124,7 @@ public final class MiscTools {
} }
else else
{ {
ArrayList<Integer> list = new ArrayList(); ArrayList<Integer> list = new ArrayList<>();
while(int_buffer.hasRemaining()) { while(int_buffer.hasRemaining()) {
list.add(int_buffer.get()); list.add(int_buffer.get());
@ -151,7 +151,7 @@ public final class MiscTools {
} }
else else
{ {
ArrayList<Byte> list = new ArrayList(); ArrayList<Byte> list = new ArrayList<>();
while(int_buffer.hasRemaining()) { while(int_buffer.hasRemaining()) {
list.add(bin_buffer.get()); list.add(bin_buffer.get());

View File

@ -1226,7 +1226,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
private void delete_all_accounts_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delete_all_accounts_buttonActionPerformed private void delete_all_accounts_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delete_all_accounts_buttonActionPerformed
swingReflectionInvoke("setEnabled", delete_all_accounts_button, true); swingReflectionInvoke("setEnabled", delete_all_accounts_button, false);
final SettingsDialog tthis = this; final SettingsDialog tthis = this;

View File

@ -51,12 +51,12 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
_pause_all_button = pause_all_button; _pause_all_button = pause_all_button;
_clean_all_menu = clean_all_menu; _clean_all_menu = clean_all_menu;
_secure_notify_lock = new Object(); _secure_notify_lock = new Object();
_transference_waitstart_queue = new ConcurrentLinkedQueue(); _transference_waitstart_queue = new ConcurrentLinkedQueue<>();
_transference_provision_queue = new ConcurrentLinkedQueue(); _transference_provision_queue = new ConcurrentLinkedQueue<>();
_transference_remove_queue = new ConcurrentLinkedQueue(); _transference_remove_queue = new ConcurrentLinkedQueue<>();
_transference_finished_queue = new ConcurrentLinkedQueue(); _transference_finished_queue = new ConcurrentLinkedQueue<>();
_transference_running_list = new ConcurrentLinkedQueue(); _transference_running_list = new ConcurrentLinkedQueue<>();
_transference_preprocess_queue = new ConcurrentLinkedQueue(); _transference_preprocess_queue = new ConcurrentLinkedQueue<>();
} }
abstract public void provision(Transference transference); abstract public void provision(Transference transference);

View File

@ -99,9 +99,9 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
_slots = slots; _slots = slots;
_restart = restart; _restart = restart;
_secure_notify_lock = new Object(); _secure_notify_lock = new Object();
_chunkworkers = new ArrayList(); _chunkworkers = new ArrayList<>();
_partialProgressQueue = new ConcurrentLinkedQueue(); _partialProgressQueue = new ConcurrentLinkedQueue<>();
_rejectedChunkIds = new ConcurrentLinkedQueue(); _rejectedChunkIds = new ConcurrentLinkedQueue<>();
_thread_pool = Executors.newCachedThreadPool(); _thread_pool = Executors.newCachedThreadPool();
} }