Les parties éventuellement intéressantes :
Cliquez pour révéler
Cliquez pour masquer
package com.supercell.titan;
import android.os.Handler;
import android.os.Message;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
// Referenced classes of package com.supercell.titan:
// cc, t, GameApp, cb
public final class ca
implements Runnable
{
public int a;
private String b;
private String c;
private final String d;
private cb e;
private Handler f;
private byte g[];
private cc h;
private byte i[];
private HttpClient j;
private final String k;
public ca()
{
this(new Handler(), "", "");
}
public ca(Handler handler, String s, String s1)
{
b = "";
c = "";
h = cc.b;
f = handler;
d = s;
k = s1;
}
private static byte[] a(File file)
{
MessageDigest messagedigest;
FileInputStream fileinputstream;
byte abyte0[];
int l;
try
{
messagedigest = MessageDigest.getInstance("SHA-1");
}
catch (NoSuchAlgorithmException nosuchalgorithmexception)
{
return null;
}
fileinputstream = new FileInputStream(file);
abyte0 = new byte[8192];
l = 0;
do
{
if (l == -1)
{
break;
}
l = fileinputstream.read(abyte0);
if (l > 0)
{
messagedigest.update(abyte0, 0, l);
}
} while (true);
fileinputstream.close();
return messagedigest.digest();
}
private static byte[] a(InputStream inputstream)
{
if (inputstream instanceof ByteArrayInputStream)
{
int i1 = inputstream.available();
byte abyte1[] = new byte[i1];
inputstream.read(abyte1, 0, i1);
return abyte1;
}
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
byte abyte0[] = new byte[1024];
do
{
int l = inputstream.read(abyte0, 0, 1024);
if (l != -1)
{
bytearrayoutputstream.write(abyte0, 0, l);
} else
{
return bytearrayoutputstream.toByteArray();
}
} while (true);
}
private static DefaultHttpClient d()
{
BasicHttpParams basichttpparams = new BasicHttpParams();
HttpProtocolParams.setVersion(basichttpparams, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(basichttpparams, "utf-8");
basichttpparams.setBooleanParameter("http.protocol.expect-continue", false);
SchemeRegistry schemeregistry = new SchemeRegistry();
schemeregistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
try
{
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(null, null);
t t1 = new t(keystore);
t1.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
schemeregistry.register(new Scheme("https", t1, 443));
}
catch (Exception exception)
{
GameApp.debuggerException(exception);
return null;
}
return new DefaultHttpClient(new ThreadSafeClientConnManager(basichttpparams, schemeregistry), basichttpparams);
}
public final cc a()
{
return h;
}
public final void a(String s, String s1)
{
e = cb.a;
b = s;
g = null;
c = s1;
}
public final void a(String s, byte abyte0[], String s1)
{
e = cb.b;
b = s;
g = abyte0;
c = s1;
}
public final cb b()
{
return e;
}
public final byte[] c()
{
return i;
}
public final void run()
{
boolean flag;
flag = true;
h = cc.c;
j = d();
HttpConnectionParams.setConnectionTimeout(j.getParams(), 15000);
if (e != cb.a) goto _L2; else goto _L1
_L1:
HttpGet httpget = new HttpGet(b);
InputStream inputstream = j.execute(httpget).getEntity().getContent();
if (!k.isEmpty()) goto _L4; else goto _L3
_L3:
i = a(inputstream);
boolean flag1 = flag;
_L8:
Message message;
Exception exception;
ClientProtocolException clientprotocolexception;
File file;
FileOutputStream fileoutputstream;
Exception exception1;
byte abyte0[];
int l;
boolean flag2;
boolean flag3;
Exception exception2;
byte abyte1[];
StringBuilder stringbuilder;
int i1;
int j1;
if (flag1)
{
h = cc.d;
} else
{
h = cc.e;
}
_L16:
message = new Message();
message.obj = this;
f.sendMessage(message);
return;
_L4:
file = File.createTempFile("download", ".tmp", GameApp.getInstance().getCacheDir());
fileoutputstream = new FileOutputStream(file);
abyte0 = new byte[1024];
_L7:
l = inputstream.read(abyte0, 0, 1024);
if (l == -1) goto _L6; else goto _L5
_L5:
fileoutputstream.write(abyte0, 0, l);
goto _L7
exception1;
_L18:
if (fileoutputstream == null)
{
break MISSING_BLOCK_LABEL_214;
}
fileoutputstream.close();
throw exception1;
clientprotocolexception;
GameApp.debuggerException(clientprotocolexception);
flag1 = false;
goto _L8
_L6:
fileoutputstream.close();
flag2 = d.isEmpty();
if (flag2)
{
break MISSING_BLOCK_LABEL_414;
}
abyte1 = a(file);
if (abyte1 != null) goto _L10; else goto _L9
_L9:
flag3 = flag;
_L13:
if (!flag3)
{
break MISSING_BLOCK_LABEL_288;
}
UnknownHostException unknownhostexception;
IOException ioexception;
UnknownHostException unknownhostexception1;
UnknownHostException unknownhostexception2;
HttpPost httppost;
ConnectTimeoutException connecttimeoutexception;
boolean flag4;
UnknownHostException unknownhostexception3;
IOException ioexception1;
Exception exception3;
ClientProtocolException clientprotocolexception1;
if (file.renameTo(new File(k)))
{
flag = false;
}
if (!flag)
{
break MISSING_BLOCK_LABEL_298;
}
file.delete();
flag1 = flag3;
goto _L8
_L10:
stringbuilder = new StringBuilder();
i1 = abyte1.length;
j1 = 0;
_L12:
if (j1 >= i1)
{
break; /* Loop/switch isn't completed */
}
byte byte0 = abyte1[j1];
Object aobj[] = new Object[1];
aobj[0] = Integer.valueOf(byte0 & 0xff);
stringbuilder.append(String.format("%02x", aobj));
j1++;
if (true) goto _L12; else goto _L11
_L11:
if (!stringbuilder.toString().equalsIgnoreCase(d))
{
break MISSING_BLOCK_LABEL_396;
}
flag3 = flag;
goto _L13
k;
flag3 = false;
goto _L13
exception2;
GameApp.debuggerException(exception2);
flag3 = flag;
goto _L13
exception;
GameApp.debuggerException(exception);
flag1 = false;
goto _L8
_L2:
if (e != cb.b) goto _L15; else goto _L14
_L14:
httppost = new HttpPost(b);
httppost.setEntity(new ByteArrayEntity(g));
httppost.setHeader("Content-Type", "application/x-www-form-urlencoded");
httppost.setHeader("X-timestamp", c);
i = a(j.execute(httppost).getEntity().getContent());
flag4 = flag;
_L17:
if (flag4)
{
h = cc.d;
} else
{
h = cc.e;
}
goto _L16
clientprotocolexception1;
GameApp.debuggerException(clientprotocolexception1);
flag4 = false;
goto _L17
exception3;
GameApp.debuggerException(exception3);
flag4 = false;
goto _L17
_L15:
h = cc.e;
goto _L16
ioexception1;
flag4 = false;
goto _L17
unknownhostexception3;
flag4 = false;
goto _L17
connecttimeoutexception;
flag4 = false;
goto _L17
ioexception;
flag1 = false;
goto _L8
unknownhostexception;
flag1 = false;
goto _L8
unknownhostexception1;
flag1 = flag;
goto _L8
unknownhostexception2;
flag1 = flag3;
goto _L8
exception1;
fileoutputstream = null;
goto _L18
}
}
Cliquez pour révéler
Cliquez pour masquer
package com.supercell.titan;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Base64;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
// Referenced classes of package com.supercell.titan:
// GameApp, co
public final class cn
{
private final boolean a;
private final Cipher b;
private final Cipher c;
private final Cipher d;
private final Cipher e;
private final SharedPreferences f;
public cn(Context context, String s, String s1)
{
try
{
b = Cipher.getInstance("AES/CBC/PKCS5Padding");
c = Cipher.getInstance("AES/CBC/PKCS5Padding");
d = Cipher.getInstance("AES/ECB/PKCS5Padding");
e = Cipher.getInstance("AES/ECB/PKCS5Padding");
byte abyte0[] = new byte[b.getBlockSize()];
System.arraycopy("fldsjfodasjifudslfjdsaofshaufihadsf".getBytes(), 0, abyte0, 0, b.getBlockSize());
IvParameterSpec ivparameterspec = new IvParameterSpec(abyte0);
MessageDigest messagedigest = MessageDigest.getInstance("SHA-256");
messagedigest.reset();
SecretKeySpec secretkeyspec = new SecretKeySpec(messagedigest.digest(s1.getBytes("UTF-8")), "AES/CBC/PKCS5Padding");
b.init(1, secretkeyspec, ivparameterspec);
c.init(2, secretkeyspec, ivparameterspec);
d.init(1, secretkeyspec);
e.init(2, secretkeyspec);
f = context.getSharedPreferences(s, 0);
a = true;
return;
}
catch (GeneralSecurityException generalsecurityexception)
{
GameApp.debuggerException(generalsecurityexception);
throw new co(generalsecurityexception);
}
catch (UnsupportedEncodingException unsupportedencodingexception)
{
GameApp.debuggerException(unsupportedencodingexception);
throw new co(unsupportedencodingexception);
}
}
private static String a(String s, Cipher cipher)
{
byte abyte0[];
try
{
abyte0 = a(cipher, s.getBytes("UTF-8"));
}
catch (UnsupportedEncodingException unsupportedencodingexception)
{
GameApp.debuggerException(unsupportedencodingexception);
throw new co(unsupportedencodingexception);
}
return Base64.encodeToString(abyte0, 2);
}
private static byte[] a(Cipher cipher, byte abyte0[])
{
byte abyte1[];
try
{
abyte1 = cipher.doFinal(abyte0);
}
catch (Exception exception)
{
GameApp.debuggerException(exception);
throw new co(exception);
}
return abyte1;
}
private static String b(String s, Cipher cipher)
{
byte abyte0[] = Base64.decode(s, 2);
byte abyte1[];
String s1;
try
{
abyte1 = a(cipher, abyte0);
}
catch (co co1)
{
GameApp.debuggerException(co1);
return "";
}
try
{
s1 = new String(abyte1, "UTF-8");
}
catch (UnsupportedEncodingException unsupportedencodingexception)
{
GameApp.debuggerException(unsupportedencodingexception);
return "";
}
return s1;
}
private String c(String s)
{
if (a)
{
s = a(s, d);
}
return s;
}
public final void a(String s)
{
String s1 = c(s);
if (f.contains(s1))
{
f.edit().remove(s1).apply();
}
}
public final void a(String s, String s1)
{
String s2 = c(s);
if (s1 == null || s1.isEmpty())
{
if (f.contains(s2))
{
f.edit().remove(s2).apply();
}
return;
} else
{
String s3 = a(s1, b);
f.edit().putString(s2, s3).apply();
return;
}
}
public final String b(String s)
{
String s1 = c(s);
if (f.contains(s1))
{
String s2 = b(f.getString(s1, ""), c);
if (s2.isEmpty())
{
f.edit().remove(s1).apply();
}
return s2;
} else
{
return "";
}
}
}