-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_iv = CryptTools.initMEGALinkKeyIV(_download.getFile_key());
_chunk_queue = new ConcurrentHashMap();
_rejectedChunkIds = new ConcurrentLinkedQueue();
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
if(_download.getProgress() == 0)
{

View File

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

View File

@ -212,7 +212,7 @@ public class GetMegaMasterPasswordDialog extends javax.swing.JDialog {
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, "");

View File

@ -61,7 +61,7 @@ import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
*/
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 THROTTLE_SLICE_SIZE=16*1024;
public static final int STREAMER_PORT = 1337;

View File

@ -9,6 +9,9 @@ import java.net.URL;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.logging.Level;
import static java.util.logging.Logger.getLogger;
import java.util.zip.GZIPInputStream;
@ -32,6 +35,8 @@ import org.codehaus.jackson.map.ObjectMapper;
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 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 {
@ -213,70 +218,73 @@ public final class MegaCrypterAPI {
Cipher decrypter;
try {
do
{
bad_pass = false;
password = JOptionPane.showInputDialog(panel, "Enter password:");
if(password!=null) {
synchronized(PASS_LOCK) {
LinkedList<String> pass_list = new LinkedList(PASS_CACHE);
do
{
bad_pass = true;
if((password = pass_list.poll()) == null) {
password = JOptionPane.showInputDialog(panel, "Enter password for MegaCrypter link:");
}
if(password != null) {
try {
info_key=CryptTools.PBKDF2HMACSHA256(password, salt, (int)Math.pow(2, iterations));
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
try {
info_key=CryptTools.PBKDF2HMACSHA256(password, salt, (int)Math.pow(2, iterations));
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
try {
bad_pass = !Arrays.equals(info_key, decrypter.doFinal(key_check));
bad_pass = !Arrays.equals(info_key, decrypter.doFinal(key_check));
if(!bad_pass) {
} catch (IllegalBlockSizeException | BadPaddingException ex) {
bad_pass=true;
PASS_CACHE.add(password);
}
} catch (InvalidKeySpecException ex) {
bad_pass=true;
}
}
}while(password!=null && bad_pass);
if(password==null)
{
return null;
}
else
{
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
} catch (IllegalBlockSizeException | BadPaddingException ex) {}
byte[] decrypted_key = decrypter.doFinal(BASE642Bin(fkey));
fkey = Bin2UrlBASE64(decrypted_key);
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
byte[] decrypted_name = decrypter.doFinal(BASE642Bin(fname));
fname = new String(decrypted_name);
if(fpath != null)
{
byte[] decrypted_fpath = decrypter.doFinal(BASE642Bin(fpath));
fpath = new String(decrypted_fpath);
}
pass=Bin2BASE64(info_key);
} catch (InvalidKeySpecException ex) {}
}
} catch (Exception ex) {
getLogger(MegaCrypterAPI.class.getName()).log(Level.SEVERE, null, ex);
}
}while(password!=null && bad_pass);
}
if(bad_pass)
{
throw new MegaCrypterAPIException("25");
}
else
{
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
byte[] decrypted_key = decrypter.doFinal(BASE642Bin(fkey));
fkey = Bin2UrlBASE64(decrypted_key);
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
byte[] decrypted_name = decrypter.doFinal(BASE642Bin(fname));
fname = new String(decrypted_name);
if(fpath != null)
{
byte[] decrypted_fpath = decrypter.doFinal(BASE642Bin(fpath));
fpath = new String(decrypted_fpath);
}
pass=Bin2BASE64(info_key);
}
}
if(fpath != null)

View File

@ -124,7 +124,7 @@ public final class MiscTools {
}
else
{
ArrayList<Integer> list = new ArrayList();
ArrayList<Integer> list = new ArrayList<>();
while(int_buffer.hasRemaining()) {
list.add(int_buffer.get());
@ -151,7 +151,7 @@ public final class MiscTools {
}
else
{
ArrayList<Byte> list = new ArrayList();
ArrayList<Byte> list = new ArrayList<>();
while(int_buffer.hasRemaining()) {
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
swingReflectionInvoke("setEnabled", delete_all_accounts_button, true);
swingReflectionInvoke("setEnabled", delete_all_accounts_button, false);
final SettingsDialog tthis = this;

View File

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

View File

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