[bglug] [OT] SMS2PC e reverse engineering

Mila76 mila76@mila76.it
Gio 21 Apr 2011 15:04:50 CEST


> 	Perchè non decompili il client?
	
package uk.co.scottastraughan.SMS2PC.desktopclient.networking;

import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;

public final class DES
{
  Cipher ecipher;
  Cipher dcipher;
  byte[] salt = { 
    -87, -101, -56, 50, 86, 53, -29, 3 }
    ;

  int iterationCount = 19;

  public DES(String passPhrase)
  {
    try {
      KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), this.salt,
this.iterationCount);
      SecretKey key = SecretKeyFactory.getInstance(
        "PBEWithMD5AndDES").generateSecret(keySpec);
      this.ecipher = Cipher.getInstance(key.getAlgorithm());
      this.dcipher = Cipher.getInstance(key.getAlgorithm());

      AlgorithmParameterSpec paramSpec = new PBEParameterSpec(this.salt,
this.iterationCount);

      this.ecipher.init(1, key, paramSpec);
      this.dcipher.init(2, key, paramSpec);
    } catch (InvalidAlgorithmParameterException
localInvalidAlgorithmParameterException) {
    } catch (InvalidKeySpecException localInvalidKeySpecException) {
    } catch (NoSuchPaddingException localNoSuchPaddingException) {
    } catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {
    }
    catch (InvalidKeyException localInvalidKeyException) {
    }
  }

  public String encrypt(String str) {
    try {
      byte[] utf8 = str.getBytes("UTF8");

      byte[] enc = this.ecipher.doFinal(utf8);

      return new String(Base64Functions.encode(enc));
    } catch (BadPaddingException localBadPaddingException) {
    } catch (IllegalBlockSizeException localIllegalBlockSizeException) {
    } catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
    }
    return null;
  }

  public String decrypt(String str)
  {
    try {
      byte[] dec = Base64Functions.decode(str);

      byte[] utf8 = this.dcipher.doFinal(dec);

      return new String(utf8, "UTF8");
    } catch (BadPaddingException localBadPaddingException) {
    } catch (IllegalBlockSizeException localIllegalBlockSizeException) {
    } catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
    }
    return null;
  }
}

Così ?

Ciao da Emanuel



Maggiori informazioni sulla lista bglug