Code:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: Applet_Sub1.java
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import java.security.MessageDigest;
import java.util.Properties;
import java.util.zip.Inflater;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public final class Loader extends Applet
implements Runnable
{
public static String cacheDisk = "";
public static boolean LoadingFromMain = false;
public static Properties props = new Properties();
@SuppressWarnings("unchecked")
public final void run()
{
File faa = new File("/rscacheq/");
if (!faa.exists())
{
faa.mkdir();
}
unsignedUrl = getParameter("unsignedurl");
if(unsignedUrl != null)
try
{
SecurityManager securitymanager = System.getSecurityManager();
if(securitymanager != null)
securitymanager.checkExec("echo");
}
catch(SecurityException securityexception)
{
loaderCrash = true;
try
{
getAppletContext().showDocument(new URL(unsignedUrl), "_parent");
}
catch(Exception exception) { }
return;
}
Object obj1;
crashURL = getParameter("crashurl");
int gamearrayid = 0;
String gameid = getParameter("cachesubdirid");
if(gameid != null)
{
gamearrayid = Integer.parseInt(gameid);
if(gamearrayid < 0 || Settings.GameNames.length <= gamearrayid)
gamearrayid = 0;
}
String colourid = getParameter("colourid");
if(colourid != null)
{
colourId = Integer.parseInt(colourid);
if(colourId < 0 || colourId >= Settings.Colors.length)
colourId = 0;
}
clientImages = Settings.LoaderImages[colourId];
loaderWidth = getSize().width;
loaderHeight = getSize().height;
int platform = 32;
try
{
int pltfrm = Integer.parseInt(getParameter("modewhat"));
platform += pltfrm;
}
catch(Exception exception1) { }
try
{
String lang = getParameter("lang");
if(lang != null)
language = Integer.parseInt(lang);
}
catch(Exception exception2) { }
Cache.loadConstants(platform, Settings.GameNames[gamearrayid]);
if(clientImages != null)
{
try
{
loaderFont = new Font(clientImages.fontName, 0, clientImages.fontSize);
loaderFontMetrics = getFontMetrics(loaderFont);
loaderColor = new Color(clientImages.loaderColor);
loaderBar = loadImage(clientImages.loaderBar);
loaderBackground = loadImage(clientImages.loaderBackground);
loaderLeft = loadImage(clientImages.loaderLeft);
loaderRight = loadImage(clientImages.loaderRight);
loaderTop = loadImage(clientImages.loaderTop);
loaderBottom = loadImage(clientImages.loaderBottom);
loaderBodyLeft = loadImage(clientImages.loaderBodyLeft);
loaderBodyRight = loadImage(clientImages.loaderBodyRight);
loaderBodyFill = loadImage(clientImages.loaderBodyFill);
Image aimage[] = {
loaderBar, loaderBackground, loaderLeft, loaderRight, loaderTop, loaderBottom, loaderBodyLeft, loaderBodyRight, loaderBodyFill
};
MediaTracker mediatracker = new MediaTracker(this);
for (int l = 0; aimage.length > l; l++)
{
mediatracker.addImage(aimage[l], l);
}
try
{
mediatracker.waitForAll();
}
catch(InterruptedException interruptedexception) { }
}
catch(Throwable throwable1)
{
setNoImageDrawModeEnabled(true);
}
}
try
{
Cache.trygetCacheFile("cload.dat", (byte)0);
setNoImageDrawModeEnabled(true);
this.drawtextNoImage("Preparing cache download.",0);
Loader.sleep(1000);
DownloadableRunescapeFile filelist = new DownloadableRunescapeFile("508cache/folderinfo.txt","508cache/folderinfo.txt",new String[] { "Getting cache file list" , "Getting cache file list" , "Getting cache file list" , "Getting cache file list" },1113,1113,null);
byte[] flistdata = this.downloadFile(false, filelist, 0);
if (flistdata == null)
{
this.loaderErrorOccured("Failed to get file list.", 0);
}
else
{
this.drawtextNoImage("Starting to check files...",100);
Loader.sleep(1000);
BufferedReader input = new BufferedReader(new CharArrayReader(new String(flistdata).toCharArray()));
for (;;)
{
try
{
String fname = input.readLine();
if (fname == null)
break;
int fsize = Integer.parseInt(input.readLine());
DownloadableRunescapeFile ftd = new DownloadableRunescapeFile("508cache/" + fname,"508cache/" + fname,new String[] { "Downloading " + fname },fsize,fsize,null);
File f = new File(Loader.cacheDisk + "/rscacheq/cache/runescape/" + fname);
boolean needsdownload = true;
if (f.exists())
{
if (f.length() == fsize)
{
needsdownload = false;
}
else
{
f.delete();
}
}
if (needsdownload)
{
f.createNewFile();
byte[] data = this.downloadFile(false, ftd, 0);
this.writeToFile(f, data);
}
}
catch (IOException ex)
{
this.loaderErrorOccured("io exception...", 0);
throw ex;
}
}
this.drawtextNoImage("Preparing custom model download.",0);
Loader.sleep(1000);
DownloadableRunescapeFile modellist = new DownloadableRunescapeFile("508cache/models/folderinfo.txt","508cache/models/folderinfo.txt",new String[] { "Getting model file list" , "Getting model file list" , "Getting model file list" , "Getting model file list" },11402,11402,null);
byte[] modellistdata = this.downloadFile(false, modellist, 0);
if (modellistdata == null)
{
this.loaderErrorOccured("Failed to get model file list.", 0);
}
else
{
File mf = new File(Loader.cacheDisk + "/rscacheq/cache/runescape/models/");
if (!mf.exists())
{
mf.mkdir();
}
this.drawtextNoImage("Starting to check model files...",100);
Loader.sleep(1000);
BufferedReader minput = new BufferedReader(new CharArrayReader(new String(modellistdata).toCharArray()));
for (;;)
{
try
{
String fname = minput.readLine();
if (fname == null)
break;
int fsize = Integer.parseInt(minput.readLine());
DownloadableRunescapeFile ftd = new DownloadableRunescapeFile("508cache/models/" + fname,"508cache/models/" + fname,new String[] { "Downloading " + fname },fsize,fsize,null);
File f = new File(Loader.cacheDisk + "/rscacheq/cache/runescape/models/" + fname);
boolean needsdownload = true;
if (f.exists())
{
if (f.length() == fsize)
{
needsdownload = false;
}
else
{
f.delete();
}
}
if (needsdownload)
{
f.createNewFile();
byte[] data = this.downloadFile(false, ftd, 0);
this.writeToFile(f, data);
}
}
catch (IOException ex)
{
this.loaderErrorOccured("io exception...", 0);
throw ex;
}
}
}
client client = new client();
CustomSprites.loadCustomSprites(client);
props.put("worldid", "66");
props.put("members", "1");
props.put("modewhat", "0");
props.put("modewhere", "0");
props.put("safemode", "0");
props.put("game", "0");
props.put("js", "1");
props.put("lang", "0");
props.put("affid", "0");
props.put("settings", "kKmok3kJqOeN6D3mDdihco3oPeYN2KFy6W5--vZUbNA");
props.put("lowmem", "0");
SignLink signlink = new SignLink(true, this, 32, "runescape", 27);
Applet_Sub1.method24(signlink);
Applet applet = (Applet) new client();
applet.init();
}
}
catch (Exception obj)
{
LoaderException.exceptionId = 0xc887d028;
if ((obj instanceof InvocationTargetException))
{
Throwable throwable = ((InvocationTargetException)obj).getTargetException();
if(throwable instanceof ThreadDeath)
return;
LoaderException.reportException(this, ((Throwable) (obj)).toString(), throwable);
}
obj.printStackTrace();
loaderErrorOccured("crash", 12073);
}
}
private final boolean writeToFile(File file, byte buffer[])
{
try
{
FileOutputStream fileoutputstream = new FileOutputStream(file);
fileoutputstream.write(buffer, 0, buffer.length);
fileoutputstream.close();
return true;
}
catch (IOException obj)
{
loaderErrorOccured("savefile", 12073);
return false;
}
}
public static void main(String[] args)
{
Loader l = new Loader();
l.CreateFrame();
l.init();
Loader.LoadingFromMain = true;
}
public void CreateFrame()
{
aJFrame2 = new JFrame("Client");
aJFrame2.setLayout(new BorderLayout());
aJPanel3.setLayout(new BorderLayout());
aJPanel3.add(this);
aJPanel3.setPreferredSize(new Dimension(765, 503));
aJFrame2.getContentPane().add(aJPanel3, "Center");
aJFrame2.pack();
aJFrame2.setVisible(true);
aJFrame2.setDefaultCloseOperation(3);
}
public String getParameter(String p){
return (String)props.get(p);
}
public URL getDocumentBase() {
return getCodeBase();
}
public URL getCodeBase() {
try {
//return new URL("http://127.0.0.1");
return new URL("http://78.57.114.61");
} catch(Exception _ex){
//_ex.printStackTrace();
}
return null;
}
@SuppressWarnings("deprecation")
public void DestroyFrame()
{
aJFrame2.dispose();
aJPanel3.disable();
}
public final synchronized void init()
{
Container container = getParent();
if(container != null)
container.setBackground(Color.black); // Color.black
ClientStopped = false;
setBackground(Color.black);
Thread thread = new Thread(this);
thread.start();
}
private final byte[] readFile(int i, File file)
{
try
{
if(!file.exists())
return null;
int length;
DataInputStream datainputstream;
length = (int)file.length();
datainputstream = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
byte buffer[];
buffer = new byte[length];
datainputstream.readFully(buffer, 0, length);
datainputstream.close();
return buffer;
}
catch (Exception obj)
{
throw LoaderException.generateException(((Throwable) (obj)), "loader.K(" + i + ',' + (file == null ? "null" : "{...}") + ')');
}
}
public final synchronized void start()
{
ShouldStartClient = true;
ShouldStopClient = false;
if(clientApplet != null)
clientApplet.start();
}
public final synchronized void destroy()
{
ClientStopped = true;
ShouldStartClient = ShouldStopClient = false;
if(clientApplet != null)
clientApplet.destroy();
clientApplet = null;
}
private final void loaderErrorOccured(String s, int i)
{
out("Loader error:" + s);
javax.swing.JOptionPane.showMessageDialog(null, "Sorry but error occured: " + s);
try
{
if(loaderCrash)
return;
}
catch(RuntimeException runtimeexception)
{
throw LoaderException.generateException(runtimeexception, "loader.A(" + (s == null ? "null" : "{...}") + ',' + i + ')');
}
loaderCrash = true;
try
{
if(crashURL == null)
{
getAppletContext().showDocument(new URL(getCodeBase(), "error_loader_" + s + ".ws"), "_top");
}
getAppletContext().showDocument(new URL(crashURL + "&s=" + s), "_parent");
System.exit(0); // custom
}
catch(Exception exception) { }
}
private Image loadImage(String s) throws IOException
{
Image image;
InputStream inputstream = getClass().getResourceAsStream(s);
byte abyte0[] = new byte[1000];
int k = 0;
try
{
//for (int j; (j = inputstream.read()) != -1;)
for (;;)
{
int j;
if((j = inputstream.read()) == -1)
break;
abyte0[k++] = (byte)j;
}
image = Toolkit.getDefaultToolkit().createImage(abyte0);
return image;
}
catch (Exception obj)
{
throw new IOException();
}
}
public final void paint(Graphics g)
{
if(clientApplet != null)
clientApplet.paint(g);
}
private final boolean drawtextNoImage(String text, int percentage)
{
if(loaderFont == null)
{
loaderFont = new Font("Helvetica", 1, 13);
loaderFontMetrics = getFontMetrics(loaderFont);
aColor17 = new Color(Settings.Colors[colourId]);
aColor13 = new Color(Settings.Colors01[colourId]);
loaderColor = new Color(Settings.Colors02[colourId]);
}
Graphics g = getGraphics();
if(g != null) // g == null
//break MISSING_BLOCK_LABEL_630;
{
try
{
if(clientImage == null)
clientImage = createImage(loaderWidth, loaderHeight);
Graphics g1 = clientImage.getGraphics();
g1.setColor(Color.black);
g1.fillRect(0, 0, loaderWidth, loaderHeight);
g1.setColor(aColor17);
int j = loaderWidth / 2 - 152;
int l = loaderHeight / 2 - 18;
g1.drawRect(j, l, 303, 33);
g1.setColor(aColor13);
g1.fillRect(j + 2, l + 2, percentage * 3, 30);
g1.setColor(Color.black);
g1.drawRect(j + 1, l + 1, 301, 31);
g1.fillRect(j + percentage * 3 + 2, l + 2, -(percentage * 3) + 300, 30);
g1.setFont(loaderFont);
String s1 = text + " - " + percentage + "%";
g1.setColor(loaderColor);
g1.drawString(s1, (loaderWidth - loaderFontMetrics.stringWidth(s1)) / 2, loaderHeight / 2 + 4);
g.drawImage(clientImage, 0, 0, null);
}
catch(Exception exception)
{
g.setColor(Color.black);
g.fillRect(0, 0, loaderWidth, loaderHeight);
g.setColor(aColor17);
int k = loaderWidth / 2 - 152;
int i1 = loaderHeight / 2 - 18;
g.drawRect(k, i1, 303, 33);
g.setColor(aColor13);
g.fillRect(k + 2, i1 + 2, 3 * percentage, 30);
g.setColor(Color.black);
g.drawRect(k + 1, i1 + 1, 301, 31);
g.fillRect(k + percentage * 3 + 2, i1 + 2, 300 - 3 * percentage, 30);
String s2 = text + " - " + percentage + "%";
g.setFont(loaderFont);
g.setColor(loaderColor);
g.drawString(s2, (loaderWidth - loaderFontMetrics.stringWidth(s2)) / 2, loaderHeight / 2 + 4);
}
return true;
}
else
{
repaint();
return false;
}
}
private static final void PrintHash(String filename, byte hash[])
{
StringBuilder builder = new StringBuilder();
for(int i = 0; i < 20; i++)
builder.append((new StringBuilder(String.valueOf(hash[i]))).append(",").toString());
out((new StringBuilder("FileHash:")).append(filename).append(":").append(builder.toString()).toString());
}
private final boolean checkSHA(byte fileBytes[], DownloadableRunescapeFile filetoCompareWith, byte byte0)
{
if(fileBytes == null)
return false; // no data force download
// if (1 == 1)
// return true; // not doing sha checks -_-
try
{
byte hash[];
MessageDigest messagedigest = MessageDigest.getInstance("SHA");
messagedigest.reset();
messagedigest.update(fileBytes);
hash = messagedigest.digest();
PrintHash(filetoCompareWith.downloadedFileName, hash);
for (int i = 0; i < 20; i++)
{
if (hash[i] != filetoCompareWith.shaHash[i])
return false;
}
return true;
}
catch (Exception exception)
{
loaderErrorOccured("sha", 12073);
return false;
}
}
public final int CalculateBarStuff() /* custom */
{
int j = 0;
if(clientImages != null && null != loaderBar)
j = loaderBar.getWidth(null);
if (j == 0)
return 0;
return (int)((System.currentTimeMillis() / 200L) * (long)clientImages.offsetPerTenCycles) % j;
}
private final byte[] downloadFile(boolean useJAGGRAB, DownloadableRunescapeFile file, int timepass)
{
byte buffer[];
int currbarWidth;
buffer = new byte[file.fileLength];
currbarWidth = 0;
if(clientImages != null && null != loaderBar)
currbarWidth = loaderBar.getWidth(null);
try
{
InputStream inputstream;
if(useJAGGRAB)
{
URL url = getCodeBase();
Socket socket = new Socket(InetAddress.getByName(url.getHost()), 443);
socket.setSoTimeout(10000);
OutputStream outputstream = socket.getOutputStream();
outputstream.write(17);
outputstream.write(("JAGGRAB " + url.getFile() + file.fileNameInUpdateServer + "\n\n").getBytes());
inputstream = socket.getInputStream();
}
else
{
inputstream = (new URL(getCodeBase(), file.fileNameInUpdateServer)).openStream();
}
int lastpercentage = -1;
int lasttimepass = timepass;
int reallen = 0;
for (int readbyte = 0; readbyte < buffer.length;)
{
if(readbyte >= buffer.length)
break;
int left = buffer.length - readbyte;
if(left > 1000)
left = 1000;
int bytesRead = inputstream.read(buffer, readbyte, left);
reallen += bytesRead;
if(0 > bytesRead)
{
reallen -= 1;
out("REALLEN:" + reallen);
throw new EOFException();
}
readbyte += bytesRead;
int percentage = (readbyte * 100) / buffer.length;
int timepassed = 0;
if(clientImages != null && loaderBar != null)
timepassed = (int)((System.currentTimeMillis() / 200L) * (long)clientImages.offsetPerTenCycles) % currbarWidth;
if(lastpercentage != percentage || lasttimepass != timepassed)
{
try
{
if(drawLoadingText(timepassed, file.fileLanguageTexts[language], percentage))
{
lasttimepass = timepassed;
lastpercentage = percentage;
}
}
catch(Exception exception1) { }
}
}
inputstream.close();
if(file.fileLength != file.decompressedLength)
{
byte decompressedbuffer[] = new byte[file.decompressedLength];
Inflater inflater = new Inflater(true);
inflater.setInput(buffer);
inflater.inflate(decompressedbuffer);
buffer = decompressedbuffer;
}
}
catch (Exception exception)
{
exception.printStackTrace();
return null;
}
//if(!checkSHA(buffer, file, (byte)116)) // pointless...
//return null;
return buffer;
}
private final boolean drawLoadingText(int barFlashStuff, String text, int percentage)
{
if(Settings.LoaderImages[colourId] == null || drawImageDisabled)
return drawtextNoImage(text, percentage);
throw new RuntimeException("Can't draw images..");
}
public final synchronized void stop()
{
ShouldStopClient = true;
ShouldStartClient = false;
if(clientApplet != null)
clientApplet.stop();
}
private final void setNoImageDrawModeEnabled(boolean flag)
{
drawImageDisabled = flag;
loaderFontMetrics = null;
loaderFont = null;
}
private void destroyImage()
{
aColor13 = null;
clientImage = null;
anImage26 = null;
aColor17 = null;
}
public final void update(Graphics g)
{
if(clientApplet != null)
clientApplet.update(g);
}
private final byte[] loadSetting(DownloadableRunescapeFile downloadablefile)
{
File file;
try
{
file = Cache.trygetCacheFile(downloadablefile.downloadedFileName, (byte)-106);
}
catch(Exception exception)
{
loaderErrorOccured("nocache", 12073);
return null;
}
byte filebytes[];
filebytes = readFile(-7135, file);
if(!checkSHA(filebytes, downloadablefile, (byte)95)) // checks maybe old file is still same revision and if not downloads new
filebytes = downloadFile(false, downloadablefile, 0);
if(null == filebytes)
filebytes = downloadFile(true, downloadablefile, 0);
if(filebytes == null)
{
loaderErrorOccured("download", 12073);
return null;
}
if(!writeToFile(file, filebytes))
return null;
filebytes = readFile(-7135, file);
if(!checkSHA(filebytes, downloadablefile, (byte)124)) // we don't check if the client is valid
{
loaderErrorOccured("mismatch", 12073);
return null;
}
return filebytes;
}
private static void sleep(long milisecs) /* custom */
{
try {
Thread.sleep(milisecs);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void out(Object text)
{
if (debug)
System.out.println(text);
}
public Loader()
{
ClientStopped = false;
loaderCrash = false;
language = 0;
ShouldStopClient = false;
ShouldStartClient = false;
}
public Image loaderBodyFill;
public FontMetrics loaderFontMetrics;
private static String crashURL;
public Image loaderTop;
public Image loaderBodyLeft;
private boolean ClientStopped;
public Font loaderFont;
private boolean loaderCrash;
private int loaderWidth;
private static String unsignedUrl;
private boolean ShouldStartClient;
private int language;
private Color aColor13;
public Image loaderBackground;
public Image loaderBar;
public Image loaderLeft;
private Color aColor17;
private static int colourId = 0;
private Image clientImage;
public Image loaderBottom;
public Canvas loaderCanvas;
private boolean ShouldStopClient;
public RSScreen clientImages;
public Color loaderColor;
public Image loaderRight;
public Image anImage26;
private int loaderHeight;
public Image loaderBodyRight;
private boolean drawImageDisabled;
private Applet clientApplet;
public JFrame aJFrame2;
public JPanel aJPanel3 = new JPanel();
public boolean sinit = false;
public static boolean rs = false;
public static boolean debug = true;
}
well , i will be never making webclients for ppl again -_-