Advertisement
Guest User

Untitled

a guest
Jan 8th, 2016
1,524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 KB | None | 0 0
  1. package driving;
  2. import java.io.BufferedWriter;
  3. import java.io.FileWriter;
  4. import java.util.LinkedList;
  5. import java.util.Queue;
  6.  
  7. import scripts.accountpumper.AccountRequest;
  8. import scripts.accountpumper.FCProxy;
  9. import utils.Utils;
  10.  
  11. public class Main
  12. {
  13.     //constants
  14.     public final static AccountCreatorGUI GUI = new AccountCreatorGUI();
  15.     private final static String OUTPUT_FILE = System.getProperty("user.dir") + "/fcaccounts.txt";
  16.     private final static Queue<FCProxy> PROXIES = new LinkedList<>();
  17.     private final static int MIN_PASS_LENGTH = 6;
  18.    
  19.     //variables
  20.     public static boolean isRunning = true;
  21.     public static boolean isWaitingForGUI = true;
  22.     public static String accessUser;
  23.     public static String accessPin;
  24.     public static String customPassword = null;
  25.     private static int accountsCreated;
  26.     private static long startTime = -1;
  27.     private static AccountRequest request;
  28.    
  29.     public static void main(String[] args)
  30.     {
  31.         GUI.setVisible(true);
  32.        
  33.         while(isRunning)
  34.         {
  35.             try
  36.             {
  37.                 mainLogic();
  38.                 Thread.sleep(100);
  39.             }
  40.             catch(Exception e)
  41.             {
  42.                 e.printStackTrace();
  43.             }
  44.         }
  45.        
  46.         if(request != null)
  47.             request.closeResources();
  48.     }
  49.    
  50.     private static void mainLogic() throws InterruptedException
  51.     {
  52.         if(!isWaitingForGUI)
  53.         {
  54.             if(startTime == -1)
  55.                 startTime = System.currentTimeMillis();
  56.            
  57.             makeAccounts();
  58.             updateStatusFrame();
  59.         }
  60.     }
  61.    
  62.     private static void makeAccounts() throws InterruptedException
  63.     {
  64.         FCProxy proxy = null;
  65.         if(!PROXIES.isEmpty())
  66.         {
  67.             proxy = PROXIES.poll();
  68.             PROXIES.add(proxy);
  69.             System.out.println("Using proxy: " + proxy.getHost() + ":" + proxy.getPort());
  70.         }
  71.        
  72.         String custom = customPassword != null && customPassword.length() >= MIN_PASS_LENGTH ? customPassword : null;
  73.        
  74.         request = new AccountRequest(accessUser, accessPin, proxy, custom);
  75.         if(request.request())
  76.         {
  77.             recordAccount(request);
  78.             accountsCreated++;
  79.         }
  80.         else
  81.         {
  82.             System.out.println("Sleeping 10 seconds before trying again...");
  83.             Thread.sleep(10000);
  84.         }
  85.     }
  86.    
  87.     private static void recordAccount(AccountRequest request)
  88.     {
  89.         System.out.println(request.accountInfo.username);
  90.         System.out.println(request.accountInfo.password);
  91.         System.out.println("Proxy used: " + request.accountInfo.proxy);
  92.        
  93.         try(FileWriter fW = new FileWriter(OUTPUT_FILE, true);
  94.             BufferedWriter bW = new BufferedWriter(fW))
  95.         {
  96.             bW.newLine();
  97.             bW.write(request.accountInfo.username + ":" + request.accountInfo.password + ":" + request.accountInfo.proxy);
  98.         }
  99.         catch(Exception e)
  100.         {
  101.             e.printStackTrace();
  102.             System.out.println("There was an error writing the account to the output file!");
  103.         }
  104.     }
  105.    
  106.     private static void updateStatusFrame()
  107.     {
  108.         GUI.updateAccountsCreated(accountsCreated);
  109.         GUI.updateAccountsPerHour(calculateAccountsPerHour());
  110.     }
  111.    
  112.     private static long calculateAccountsPerHour()
  113.     {
  114.         //return the projected amount per hour
  115.         return Math.round(accountsCreated / (Utils.timeFromMark(startTime) / 3600000.0));
  116.     }
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement