Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.tools;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.Random;
- public class AccountCreator {
- public static boolean createAccount(String email, String name, String password) {
- String SUBSTR_BLOCKED = "blocked from creating too many";
- String SUBSTR_TAKEN = "passwords you have";
- String SUBSTR_CREATED = "Click the link we have included in the confirmation email.";
- // Get random age to use when creating the account
- Random r = new Random();
- int age = 18 + r.nextInt(10);
- try {
- String urlParameters = "onlyOneEmail=" + URLEncoder.encode("1", "UTF-8") + "&age="
- + URLEncoder.encode("" + age, "UTF-8") + "&displayname_preset=" + URLEncoder.encode("true", "UTF-8")
- + "&displayname=" + URLEncoder.encode(name, "UTF-8") + "&email1="
- + URLEncoder.encode(email, "UTF-8") + "&password1=" + URLEncoder.encode(password, "UTF-8")
- + "&password2=" + URLEncoder.encode(password, "UTF-8") + "&agree_pp_and_tac="
- + URLEncoder.encode("1", "UTF-8") + "&submit=" + URLEncoder.encode("Join Now", "UTF-8");
- URL ur = new URL("https://secure.runescape.com/m=account-creation/g=oldscape/create_account_funnel.ws");
- HttpURLConnection yc = (HttpURLConnection) ur.openConnection();
- yc.setDoOutput(true);
- yc.setDoInput(true);
- HttpURLConnection.setFollowRedirects(true);
- yc.setRequestMethod("POST");
- yc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- yc.setRequestProperty("charset", "utf-8");
- yc.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
- yc.setUseCaches(false);
- DataOutputStream wr = new DataOutputStream(yc.getOutputStream());
- wr.writeBytes(urlParameters);
- wr.flush();
- wr.close();
- BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
- String inputLine;
- while ((inputLine = in.readLine()) != null) {
- if (inputLine.contains(SUBSTR_TAKEN)) {
- // Account name taken
- System.out.println("NAME TAKEN");
- } else if (inputLine.contains(SUBSTR_BLOCKED)) {
- // Blocked for creating too many accounts
- System.out.println("BLOCKED");
- } else if (inputLine.contains(SUBSTR_CREATED)) {
- // Account successfully created
- System.out.println("SUCESS");
- in.close();
- return true;
- }
- }
- in.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment