Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.89 KB | None | 0 0
  1. /* Made by Conor
  2.  * 1/31/11 3:14 AM
  3.  */
  4.  
  5. import java.io.File;
  6. import java.io.FileInputStream;
  7. import java.io.UnsupportedEncodingException;
  8. import java.net.InetAddress;
  9. import java.net.NetworkInterface;
  10. import java.security.MessageDigest;
  11. import java.security.NoSuchAlgorithmException;
  12. import java.util.Properties;
  13. import sign.signlink;
  14.  
  15. public class getFile extends Thread {
  16.  
  17.     public static String key;
  18.     public String pin = "";
  19.     public static String pw = "";
  20.     public String username = "";
  21.     public static Properties p = new Properties();
  22.  
  23.     public static void checkForFile() {
  24.         boolean exists = (new File("%appdata%/RSBot_Accounts.ini").exists());
  25.         if (exists) {
  26.             try {
  27.                 p.load(new FileInputStream("%appdata%/RSBot_Accounts.ini"));
  28.                 System.out.println("File found");
  29.                 loadAnnouncements();
  30.             } catch (Exception e) {// none found
  31.                 System.out.println("Cactched error");
  32.             }
  33.         } else {
  34.             System.out.println("File not found");
  35.         }
  36.     }
  37.  
  38.     public static void loadAnnouncements() {
  39.         try {
  40.             if (p.getProperty("password =").length() > 0) {
  41.                 System.out.println(p.getProperty("password ="));
  42.                 pw = p.getProperty("password =");
  43.             }
  44.         } catch (Exception e) {
  45.             System.out.println("Can't read file");
  46.         }
  47.     }
  48.  
  49.     public void getInfo() {
  50.         try {
  51.             final InetAddress address = InetAddress.getLocalHost();
  52.             final NetworkInterface ni = NetworkInterface
  53.                     .getByInetAddress(address);
  54.             key = new String(ni.getHardwareAddress());
  55.         } catch (final Exception e) {
  56.             key = System.getProperty("user.name")
  57.                     + System.getProperty("user.language");
  58.         }
  59.     }
  60.  
  61.     public void CheckHash(String hash) {
  62.         try {
  63.             getInfo();
  64.             String toDecrypt = hash;
  65.             decrypt(toDecrypt);
  66.             System.out.println("Password = " + decrypt(toDecrypt) + ".");
  67.         } catch (Exception e) {
  68.             // No file found need to add a has file check to skip all this if
  69.             // dont exist
  70.         }
  71.     }
  72.  
  73.     private static byte[] SHA1(final String in) // Decrypt method
  74.             throws NoSuchAlgorithmException, UnsupportedEncodingException {
  75.         MessageDigest md = MessageDigest.getInstance("SHA-1");
  76.         md.update(in.getBytes("iso-8859-1"), 0, in.length());
  77.         return md.digest();
  78.     }
  79.  
  80.     private static String decrypt(final String start) {// Decrypt method2
  81.         final String delim = "a";
  82.         if (start == null)
  83.             return null;
  84.         byte[] hashedkey;
  85.         byte[] password;
  86.         int i;
  87.         try {
  88.             hashedkey = SHA1(key);
  89.         } catch (final NoSuchAlgorithmException e) {
  90.             e.printStackTrace();
  91.             return start;
  92.         } catch (final UnsupportedEncodingException e) {
  93.             e.printStackTrace();
  94.             return start;
  95.         }
  96.         final String[] temp = start.split(delim);
  97.         password = new byte[temp.length];
  98.         for (i = 0; i < hashedkey.length; i++) {
  99.             final int temp2 = Integer.parseInt(temp[i]);
  100.             if (hashedkey[i] == temp2) {
  101.                 break;
  102.             } else {
  103.                 password[i] = (byte) (temp2 - hashedkey[i]);
  104.             }
  105.         }
  106.         return new String(password, 0, i);
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement