Advertisement
Guest User

McKay.exe

a guest
May 4th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. import java.io.BufferedWriter;
  2. import java.io.File;
  3. import java.io.FileWriter;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.nio.file.Files;
  7. import java.nio.file.Paths;
  8. import java.text.DecimalFormat;
  9. import java.util.ArrayList;
  10. import java.util.Collections;
  11. import java.util.HashMap;
  12. import java.util.Iterator;
  13. import java.util.Map;
  14. import java.util.Set;
  15. import java.util.concurrent.TimeUnit;
  16. import java.util.regex.Matcher;
  17. import java.util.regex.Pattern;
  18. import java.util.stream.Collectors;
  19.  
  20. /**
  21. * @Author: Xyle | integerarray@hotmail.com
  22. */
  23.  
  24. /* "FileParser" yeah... let's call it that LOL */
  25.  
  26. public class FileParser {
  27.  
  28. /* Fastest execution for parsing and writing 125.6k files was 45.0 seconds! Total written bytes: 10,734 KB.
  29.  
  30. // Eventually, write code that shows frequency of passwords in order.
  31. // static HashMap<String,Integer> passwords = new HashMap<String,Integer>();
  32.  
  33. /**
  34. * The encryption algorithm used in RecklessPK is Base64.
  35. * Project insanity uses character serialization. Read PasswordUtils.java for information on deserializing.
  36. */
  37.  
  38. static String ENCODING = "UTF-8";
  39. static boolean DESERIALIZE = false;
  40. static String CHARACTERS_PATH = "C:/Users/Gacoa/Desktop/characters/"; // Must have '/' at the end before last quote.
  41. /* Format: static String PASSWORD_LINE = "character-password ="; // Space after '=' causes StringOutOfBoundsException */
  42. static String HASH_LINE = "Pass="; // More of a "hash" than a password. Use "character-password =" for 'Project Insanity' char files.
  43. static String SALT_LINE = "Salt=";
  44. static String IP_LINE = "IP=";
  45. static File FOLDER = new File(CHARACTERS_PATH);
  46. static String EXT = ".txt"; // Sometimes character data may be stored in ".dat" extension.
  47. static File OUTPUT_FILE = new File("recklesspk_july_25_2015.txt");
  48.  
  49. public static void main(String[] args) {
  50. long startTime = System.nanoTime(); // Set current time in nanoseconds to a memory address to be calculated at end of program.
  51. String username = "";
  52. //String password = ""; // Use this variable when not dealing with encrypted passwords
  53. // ( excluding serialized passwords, use: deserialize method in PasswordUtils.java ).
  54. File[] listOfFiles = FOLDER.listFiles(); // Gets the total amount of files in a directory. @CHARACTERS_PATH
  55. for(int i = 0; i < listOfFiles.length; i++) { // i being the index of the current File.
  56. if(listOfFiles[i].isFile()) {
  57. username = listOfFiles[i].getName().split("\\.")[0]; // The username is the name of the file with ".txt" extension truncated.
  58. try {
  59. String hashLine = Files.readAllLines(Paths.get(CHARACTERS_PATH + username + EXT)).get(1); // Second line of current File
  60. String saltLine = Files.readAllLines(Paths.get(CHARACTERS_PATH + username + EXT)).get(2); // Third line of current File.
  61. String ipLine = Files.readAllLines(Paths.get(CHARACTERS_PATH + username + EXT)).get(3); // Fourth line of current File.
  62.  
  63. // Substring the password at the end of "Pass=" until the end of the line.
  64. String indexHash = hashLine.substring(HASH_LINE.length(), hashLine.length());
  65. String indexSalt = saltLine.substring(SALT_LINE.length(), saltLine.length());
  66. String indexIp = ipLine.substring(IP_LINE.length(), ipLine.length());
  67.  
  68. /* A bad way of checking if the File name contains more than one space and if the File contains numbers. */
  69. // if(!username.contains(" ") && !username.contains("0") && !username.contains("1") && !username.contains("2") && !username.contains("3") && !username.contains("4") && !username.contains("5") && !username.contains("6") && !username.contains("7") && !username.contains("8") && !username.contains("9")) {
  70.  
  71. /* Formatting the output to be written to the output File. */
  72. String output = username + ":" + indexHash + ":" + indexSalt + ":" + indexIp;
  73. try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(OUTPUT_FILE, true)))) {
  74.  
  75. //<bulk>
  76.  
  77. /* Writing to file */
  78. out.println(output);
  79.  
  80. /* Console */
  81. System.out.println(output);
  82.  
  83. }catch (IOException e) {
  84. e.printStackTrace();
  85. }
  86. } catch (IOException e) {
  87. e.printStackTrace();
  88. }
  89. }
  90. }
  91. //finish
  92. long endTime = System.nanoTime();
  93. long duration = (endTime - startTime);
  94. double totalFiles = listOfFiles.length;
  95. DecimalFormat formatter = new DecimalFormat("#,###");
  96. String files = formatter.format(totalFiles);
  97. String kilobytes = formatter.format(1 + (OUTPUT_FILE.length() / 1024));
  98. double time = ((double) Math.round(duration / 1000000000.0) * 100.0) / 100.0;
  99. System.out.println();
  100. System.out.println("Finished writing " + kilobytes + " kilobytes to " + "./" + OUTPUT_FILE);
  101. System.out.println("Files parsed: " + files);
  102. System.out.println("Time: " + time + " seconds");
  103. }
  104.  
  105.  
  106. void get(int line) {
  107.  
  108. }
  109.  
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement