· 9 years ago · Jun 06, 2017, 02:44 AM
1/*
2 * Created with IntelliJ IDEA.
3 * User: aaron
4 * Project: RSNameFinder
5 * Date: 3/7/14
6 * Time: 11:37 AM
7 */
8
9/*
10 * This program must be run in conjunction with the node.js based database provided in the archive as well as the
11 * in-game script to listen for name change packets from the friend server. Instructions for running each of these are
12 * included in their respective folders. If you need help setting up node on the droplets, getting the script running
13 * in-game, additional information, etc., contact me on Skype: deejaypeaches
14 */
15
16package com.RSNameFinder;
17
18import java.io.*;
19import java.util.ArrayList;
20
21class Main {
22
23 private static long start_time;
24 private static int checks;
25 private String[] names;
26 private NameChecker nc;
27
28 public static void main(String[] args) throws Exception {
29 Console c = System.console();
30 if (c == null) {
31 System.err.println("No console.");
32 System.exit(1);
33 }
34 Main main = new Main();
35 while (main.nc == null || main.nc.getSession() == null) {
36 main.nc = new NameChecker("gmail_address+" + ((int) (Math.random() * 40)) + "@gmail.com", session_id());
37 }
38 checks = 0;
39 start_time = System.currentTimeMillis();
40 if (args.length > 0) {
41 System.out.println("Program ran with args, running file through check and register loop");
42 main.names = main.loadFileFromPath(main.parseParams(args)[1]);
43 System.out.println("Checking file...");
44 int iterations = 0;
45 while (main.checker(true)) {
46 if (++iterations % 5 == 0) {
47 main.names = main.loadFileFromPath(main.parseParams(args)[1]);
48 }
49 }
50 }
51 boolean flag = true;
52 while (flag) {
53 String command;
54 command = c.readLine("Command: ");
55 if (command == null) {
56 System.out.println("Something went wrong, stopping");
57 return;
58 }
59 String[] str = main.parseParams(command.split(" "));
60 switch (str[0]) {
61 case "check":
62 checks = 0;
63 start_time = System.currentTimeMillis();
64 if (str.length > 1) {
65 if (str[1].contains("and register")) {
66 main.checker(true);
67 break;
68 }
69 main.nc.setName(str[1]);
70 switch (main.nc.check()) {
71 case 0:
72 System.out.println(main.nc.getName() + " is not available.");
73 break;
74 case 1:
75 System.out.println(main.nc.getName() + " is available.");
76 break;
77 case 2:
78 System.err.println(main.nc.getName() + " is invalid.");
79 break;
80 case 3:
81 System.out.println("Error checking " + main.nc.getName());
82 break;
83 }
84 } else {
85 main.checker(false);
86 }
87 break;
88 case "snipe":
89 checks = 0;
90 start_time = System.currentTimeMillis();
91 if (str.length > 1) {
92 Registration reg;
93 if (c.readLine("Use existing account? (y/n): ").equalsIgnoreCase("y")) {
94 String session;
95 if (c.readLine("Use session ID? (y/n): ").equalsIgnoreCase("y")) {
96 reg = new Registration("", "", false);
97 reg.setEmail("");
98 session = c.readLine("Session: ");
99 } else {
100 String username = c.readLine("Username: ");
101 String password = c.readLine("Password: ");
102 if (password.equals("")) {
103 password = session_id();
104 }
105 reg = new Registration(username, password, false);
106 reg.setEmail(username);
107 session = new SessionGenerator().generateSessionId(reg.getEmail(), reg.getPassword());
108 }
109 reg.setSession(session);
110 reg.registerName(str[1], true);
111 break;
112 } else {
113 reg = new Registration(getEmail(), session_id(), false);
114 while (reg.getEmail() == null) {
115 reg.registerEmail();
116 }
117 String session = new SessionGenerator().generateSessionId(reg.getEmail(), reg.getPassword());
118 reg.setSession(session);
119 reg.registerName(str[1], true);
120 break;
121 }
122 } else {
123 System.out.println("Enter a name to snipe.");
124 }
125 break;
126 case "register":
127 if (str.length > 1) {
128 new Registration(getEmail(), session_id(), false).registerName(str[1], false);
129 } else {
130 System.out.println("Enter a name to register.");
131 }
132 break;
133 case "monitor":
134 checks = 0;
135 start_time = System.currentTimeMillis();
136 Registration reg;
137 reg = new Registration(getEmail(), session_id(), true);
138 reg.getRecentNames();
139 while (true) {
140 reg.setEmail(null);
141 while (reg.getEmail() == null) {
142 reg.registerEmail();
143 }
144 reg.registerName(null, true);
145 }
146 case "load":
147 if (str.length < 2) {
148 System.out.println("Include a path");
149 break;
150 }
151 main.names = main.loadFileFromPath(str[1]);
152 break;
153 case "exit":
154 flag = false;
155 break;
156 case "help":
157 System.out.println("Use \"check\" to check all loaded names");
158 System.out.println("Use \"check <name>\" to check a single name");
159 System.out.println("Use \"register <name>\" to register a name");
160 System.out.println("Use \"load <path>\" to load usernames from a list separated by new lines");
161 System.out.println("Use \"exit\" to exit");
162 break;
163 default:
164 System.out.println("Unknown command. Type \"help\" to see commands");
165 }
166 }
167 System.out.println("Goodbye");
168 }
169
170 static String getEmail() {
171 // can get away with one, but multiple addresses are ideal. nothing special required.
172 String[] emails = {
173 "folt1@gmail.com",
174 "folt2@gmail.com",
175 "folt3@gmail.com",
176 "folt4@gmail.com",
177 "folt5@gmail.com",
178 "folt6@gmail.com",
179 "folt7@gmail.com",
180 "folt8@gmail.com"
181 };
182 return emails[(int) (Math.random() * emails.length)];
183 }
184
185 static String session_id() {
186 return "password";
187 }
188
189 String[] parseParams(String[] params) {
190 String[] arrayOfStr = new String[(params.length > 1) ? 2 : 1];
191 arrayOfStr[0] = params[0];
192 if (arrayOfStr.length == 1) {
193 return arrayOfStr;
194 }
195 StringBuilder sb = new StringBuilder();
196 for (int i = 1; i < params.length; ++i) {
197 sb.append(params[i]);
198 if (i < params.length - 1) {
199 sb.append(" ");
200 }
201 }
202 arrayOfStr[1] = sb.toString();
203 return arrayOfStr;
204 }
205
206 String[] loadFileFromPath(String path) {
207 System.out.println("Loading in names from " + path + "...");
208 BufferedReader br = null;
209 ArrayList<String> names = new ArrayList<>();
210 String currentline;
211 int count = 0;
212 try {
213 br = new BufferedReader(new FileReader(path));
214 while ((currentline = br.readLine()) != null) {
215 names.add(currentline.trim());
216 count++;
217 }
218 } catch (FileNotFoundException e) {
219 System.out.println(path + " not found.");
220 } catch (IOException e) {
221 e.printStackTrace();
222 } finally {
223 try {
224 if (br != null) {
225 br.close();
226 }
227 } catch (IOException e) {
228 e.printStackTrace();
229 }
230 }
231 System.out.println(count + " names loaded from " + path + ".");
232 String[] nameArray;
233 nameArray = names.toArray(new String[names.size()]);
234 return nameArray;
235 }
236
237 boolean checker(boolean register) {
238 int length = names.length;
239 if (length == 0) {
240 System.err.println("No names loaded.");
241 return false;
242 }
243 ArrayList<String> available = new ArrayList<>();
244 for (int i = 0; i < length; ++i) {
245 nc.setName(names[i]);
246 switch (nc.check()) {
247 case 0:
248 ++checks;
249 break;
250 case 1:
251 ++checks;
252 if (register) {
253 try {
254 new Registration(getEmail(), session_id(), false).registerName(nc.getName(), false);
255 } catch (NoClassDefFoundError e) {
256 System.out.println("Error loading Registration class");
257 --i;
258 break;
259 }
260 } else {
261 available.add(nc.getName());
262 }
263 //System.out.println(available.toString());
264 break;
265 case 2:
266 System.err.println(nc.getName() + " is invalid.");
267 break;
268 case 3:
269 --i;
270 break;
271 }
272 try {
273 Thread.sleep(500L);
274 } catch (InterruptedException e) {
275 e.printStackTrace();
276 }
277 int ms = perHour(checks);
278 System.out.println("Checking... (" + (i + 1) + "/" + length + ") \"" + nc.getName() + "\" - average " + ms + "/h");
279 }
280 if (!register && available.size() > 0) {
281 try {
282 String filename = System.currentTimeMillis() + "_available.txt";
283 save(filename, available);
284 System.out.println("Wrote names to " + filename);
285 } catch (FileNotFoundException e) {
286 System.out.println("File not found.");
287 }
288 System.out.println(available.toString());
289 }
290 return true;
291 }
292
293 void save(String fileName, ArrayList<String> available) throws FileNotFoundException {
294 PrintWriter pw = new PrintWriter(new FileOutputStream("accounts" + File.separatorChar + fileName));
295 for (String name : available)
296 pw.println(name);
297 pw.close();
298 }
299
300 int perHour(int total) {
301 long time = ((System.currentTimeMillis() - start_time) / 1000L);
302 if (time < 1L) {
303 time = 1L;
304 }
305 return ((int) ((total * 60L * 60L) / time));
306 }
307}
308
309
310/*
311 * Created with IntelliJ IDEA.
312 * User: aaron
313 * Project: RSNameFinder
314 * Date: 3/7/14
315 * Time: 11:37 AM
316 */
317
318/*
319 * This program must be run in conjunction with the node.js based database provided in the archive as well as the
320 * in-game script to listen for name change packets from the friend server. Instructions for running each of these are
321 * included in their respective folders. If you need help setting up node on the droplets, getting the script running
322 * in-game, additional information, etc., contact me on Skype: deejaypeaches
323 */
324
325package com.RSNameFinder;
326
327import javax.net.ssl.HttpsURLConnection;
328import java.io.BufferedReader;
329import java.io.DataOutputStream;
330import java.io.IOException;
331import java.io.InputStreamReader;
332import java.net.*;
333
334class NameChecker {
335
336 private final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36";
337
338 private final String email;
339 private final String password;
340 private String session;
341 private String name;
342 private int errors;
343 private int timeouts;
344
345 public NameChecker(String email, String password) {
346 this.email = email;
347 this.password = password;
348 this.session = new SessionGenerator().generateSessionId(email, password);
349 this.errors = 0;
350 this.timeouts = 0;
351 }
352
353 public String getSession() {
354 return session;
355 }
356
357 public void setSession(String session) {
358 this.session = session;
359 }
360
361 public String getName() {
362 return name;
363 }
364
365 public void setName(String name) {
366 this.name = name;
367 }
368
369 public int check() {
370 if (name.length() > 12) {
371 return 2;
372 }
373 if (errors > 5 || timeouts > 20) {
374 session = new SessionGenerator().generateSessionId(email, password);
375 errors = 0;
376 timeouts = 0;
377 }
378 String status = "";
379 try {
380// URL obj = new URL("https://secure.runescape.com/m=account-creation/check_displayname.ajax");
381// HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
382// con.setRequestMethod("POST");
383// con.setRequestProperty("User-Agent", USER_AGENT);
384// con.setRequestProperty("Host", "secure.runescape.com");
385// con.setRequestProperty("Referer", "https://secure.runescape.com/m=account-creation/create_account_funnel.ws");
386// con.setRequestProperty("X-Requested-With", "XMLHttpRequest");
387// con.setDoOutput(true);
388// con.setReadTimeout(5000);
389// con.setConnectTimeout(5000);
390// String urlParameters = "displayname=" + name + "&noNameSuggestions=true";
391// DataOutputStream wr = new DataOutputStream(con.getOutputStream());
392// wr.writeBytes(urlParameters);
393// wr.flush();
394// wr.close();
395// BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
396// status = br.readLine();
397// br.close();
398// String[] response;
399// String[][] keyValuePairs = null;
400// if (status.contains("displayNameIsValid")) {
401// status = status.replace("{", "").replace("}", "").replace("\"", "");
402// response = status.split(",");
403// keyValuePairs = new String[response.length][2];
404// for (int i = 0; i < keyValuePairs.length; i++) {
405// keyValuePairs[i] = response[i].split(":");
406// }
407// }
408// if (keyValuePairs == null) {
409// return 3;
410// }
411// for (String[] keyValuePair : keyValuePairs) {
412// if (keyValuePair[0].equals("displayNameIsValid")) {
413// if (keyValuePair[1].equals("true")) {
414// return 1;
415// } else {
416// return 0;
417// }
418// }
419// }
420// return 3;
421
422
423 String urlString = "https://secure.runescape.com/m=displaynames/" + session + "/check_name.ws?displayname=" + name;
424 URL url = new URL(urlString);
425 URLConnection conn = url.openConnection();
426 conn.setConnectTimeout(5000);
427 conn.setReadTimeout(5000);
428 conn.addRequestProperty("Host", "secure.runescape.com");
429 conn.addRequestProperty("X-Requested-With", "XMLHttpRequest");
430 conn.addRequestProperty("Referer", "https://secure.runescape.com/m=displaynames/c=0000000000/name.ws");
431 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
432 status = br.readLine();
433 br.close();
434 } catch (NoRouteToHostException e) {
435 System.out.println("NoRouteToHostException while checking availability");
436 } catch (SocketTimeoutException e) {
437 System.out.println("SocketTimeoutException while checking availability");
438 timeouts++;
439 errors = 0;
440 return 3; // Timeouts are not expected but not fatal
441 } catch (SocketException e) {
442 System.out.println("SocketException while checking availability");
443 } catch (MalformedURLException e) {
444 System.out.println("MalformedURLException while checking availability");
445 } catch (IOException e) {
446 System.out.println("IOException while checking availability");
447 }
448// try {
449// Thread.sleep(100L);
450// } catch (InterruptedException e) {
451// e.printStackTrace();
452// }
453 if (status == null) {
454 return 3;
455 }
456 switch (status) { // Reset errors when we receive expected responses
457 case "NOK":
458 errors = 0;
459 timeouts = 0;
460 return 0;
461 case "OK":
462 errors = 0;
463 timeouts = 0;
464 return 1;
465 case "NONAME":
466 errors = 0;
467 timeouts = 0;
468 return 2;
469 default:
470 errors++;
471 return 3;
472 }
473 }
474}
475
476
477
478/*
479 * Created with IntelliJ IDEA.
480 * User: aaron
481 * Project: RSNameFinder
482 * Date: 3/16/14
483 * Time: 12:12 AM
484 */
485
486/*
487 * This program must be run in conjunction with the node.js based database provided in the archive as well as the
488 * in-game script to listen for name change packets from the friend server. Instructions for running each of these are
489 * included in their respective folders. If you need help setting up node on the droplets, getting the script running
490 * in-game, additional information, etc., contact me on Skype: deejaypeaches
491 */
492
493package com.RSNameFinder;
494
495import javax.net.ssl.HttpsURLConnection;
496import java.io.DataOutputStream;
497import java.io.IOException;
498import java.net.*;
499import java.util.ArrayList;
500
501class SessionGenerator {
502
503 private final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36";
504
505 public SessionGenerator() {
506 }
507
508 public String generateSessionId(String username, String password) {
509 System.out.println("Generating login session ID...");
510 try {
511 username = URLEncoder.encode(username, "UTF-8");
512 URL obj = new URL("https://secure.runescape.com/m=weblogin/login.ws");
513 HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
514 con.setRequestMethod("POST");
515 con.setRequestProperty("User-Agent", USER_AGENT);
516 con.setDoOutput(true);
517 con.setReadTimeout(30000);
518 con.setConnectTimeout(30000);
519 String urlParameters = "rem=on&username=" + username + "&password=" + password + "&submit=Log+In&mod=www&ssl=1&dest=account_settings.ws";
520 DataOutputStream wr = new DataOutputStream(con.getOutputStream());
521 wr.writeBytes(urlParameters);
522 wr.flush();
523 wr.close();
524 con.getResponseCode();
525 String[] split = con.getURL().toString().split("/");
526 for (String segment : split) {
527 if (segment.contains("s=")) {
528 System.out.println("Login session ID generated.");
529 return segment;
530 }
531 }
532 System.out.println("Login session ID not found in URL");
533 } catch (NoRouteToHostException e) {
534 System.out.println("NoRouteToHostException while generating login session ID");
535 } catch (SocketTimeoutException e) {
536 System.out.println("SocketTimeoutException while generating login session ID");
537 } catch (SocketException e) {
538 System.out.println("SocketException while generating login session ID");
539 } catch (MalformedURLException e) {
540 System.out.println("MalformedURLException while generating login session ID");
541 } catch (IOException e) {
542 System.out.println("IOException while generating login session ID");
543 }
544 return null;
545 }
546}
547
548
549/*
550 * Created with IntelliJ IDEA.
551 * User: aaron
552 * Project: RSNameFinder
553 * Date: 3/15/14
554 * Time: 11:42 PM
555 */
556
557/*
558 * This program must be run in conjunction with the node.js based database provided in the archive as well as the
559 * in-game script to listen for name change packets from the friend server. Instructions for running each of these are
560 * included in their respective folders. If you need help setting up node on the droplets, getting the script running
561 * in-game, additional information, etc., contact me on Skype: deejaypeaches
562 */
563
564package com.RSNameFinder;
565
566import javax.net.ssl.HttpsURLConnection;
567import java.io.*;
568import java.net.*;
569import java.util.ArrayList;
570import java.util.Timer;
571import java.util.TimerTask;
572
573class Registration implements Serializable {
574
575 private final String[] NOUNS = {"ad", "it", "if", "go", "way", "art", "map", "two", "law", "mom", "lab", "mud", "pie", "son", "tea", "dad", "ear", "hat", "sir", "air", "day", "job", "end", "fat", "key", "top", "web", "fun", "oil", "age", "bad", "tax", "man", "act", "car", "dog", "sun", "war", "bus", "eye", "box", "bit", "pot", "egg", "ice", "gas", "sky", "fan", "red", "log", "net", "sea", "dot", "fee", "bat", "kid", "sex", "cap", "cup", "lie", "tip", "bag", "bed", "gap", "arm", "bet", "god", "pin", "bar", "boy", "row", "bid", "bug", "cat", "cow", "guy", "leg", "lip", "pen", "toe", "you", "can", "one", "use", "few", "she", "put", "set", "big", "cut", "try", "pay", "let", "ask", "buy", "low", "run", "due", "mix", "fly", "hit", "cry", "eat", "fix", "tap", "win", "raw", "dig", "tie", "sad", "lay", "pop", "rip", "rub", "pig", "mob", "fog", "pan", "zoo", "dam", "gun", "ash", "meat", "year", "data", "food", "bird", "love", "fact", "idea", "area", "oven", "week", "exam", "army", "goal", "news", "user", "disk", "road", "role", "soup", "math", "wood", "unit", "cell", "lake", "city", "debt", "loss", "seat", "mall", "hair", "mode", "song", "town", "wife", "gate", "girl", "hall", "meal", "poem", "desk", "king", "menu", "beer", "dirt", "gene", "lady", "poet", "tale", "time", "work", "film", "game", "life", "form", "part", "fish", "back", "heat", "hand", "book", "type", "home", "body", "size", "card", "list", "mind", "line", "care", "risk", "word", "name", "boss", "page", "term", "test", "kind", "soil", "rate", "site", "case", "boat", "cash", "plan", "side", "rule", "head", "rock", "salt", "note", "rent", "bank", "half", "fire", "step", "face", "item", "room", "view", "ball", "gift", "tool", "wind", "sign", "task", "hope", "date", "link", "post", "star", "self", "shot", "exit", "lack", "spot", "wing", "foot", "mood", "rain", "wall", "base", "pair", "text", "file", "bowl", "club", "edge", "lock", "pack", "park", "skin", "sort", "baby", "dish", "trip", "gear", "land", "sale", "tree", "wave", "belt", "copy", "drop", "path", "tour", "blue", "duty", "hour", "luck", "milk", "pipe", "team", "crew", "gold", "mark", "pain", "shop", "suit", "tone", "band", "bath", "bone", "coat", "door", "east", "hole", "hook", "nose", "rice", "bill", "cake", "code", "ease", "farm", "host", "loan", "nail", "race", "sand", "west", "wine", "blow", "chip", "dust", "golf", "iron", "mail", "mess", "pool", "shoe", "tank", "bake", "bell", "bike", "clue", "diet", "fear", "fuel", "pace", "peak", "till", "yard", "bend", "bite", "harm", "knee", "load", "neck", "ruin", "ship", "snow", "tune", "zone", "boot", "camp", "hell", "joke", "jury", "mate", "ring", "roof", "rope", "sail", "sock", "will", "many", "most", "make", "good", "look", "help", "read", "keep", "give", "long", "play", "feel", "high", "past", "show", "call", "move", "turn", "hold", "main", "cook", "cold", "deal", "fall", "talk", "tell", "cost", "glad", "rest", "safe", "stay", "rise", "walk", "pick", "lift", "stop", "gain", "rich", "save", "lead", "meet", "sell", "ride", "wait", "deep", "flow", "dump", "push", "fill", "jump", "kick", "pass", "vast", "beat", "burn", "dark", "draw", "hire", "join", "kill", "drag", "pull", "soft", "wear", "dead", "feed", "sing", "wish", "hang", "hunt", "hate", "sick", "hurt", "swim", "wash", "fold", "grab", "hide", "miss", "roll", "sink", "slip", "calm", "male", "mine", "rush", "suck", "bear", "dare", "dear", "kiss", "neat", "quit", "tear", "wake", "wrap", "port", "bomb", "corn", "tube", "wire", "ally", "fine", "hero", "flag", "jail", "hill", "coal", "mass", "drug", "arms", "poor", "moon", "noon", "zero", "navy", "seed", "root", "money", "world", "music", "power", "story", "media", "thing", "video", "movie", "basis", "paper", "child", "month", "truth", "night", "event", "phone", "scene", "death", "woman", "blood", "skill", "depth", "heart", "photo", "topic", "steak", "union", "entry", "limit", "virus", "actor", "drama", "hotel", "match", "owner", "bread", "guest", "bonus", "queen", "ratio", "tooth", "error", "river", "buyer", "chest", "honey", "piano", "salad", "apple", "cheek", "pizza", "shirt", "uncle", "youth", "water", "while", "study", "place", "field", "point", "value", "guide", "state", "radio", "price", "trade", "group", "force", "light", "level", "order", "sense", "piece", "sport", "house", "sound", "focus", "board", "range", "image", "cause", "coast", "mouse", "class", "store", "space", "stock", "model", "earth", "birth", "scale", "speed", "style", "craft", "frame", "issue", "cycle", "metal", "paint", "share", "black", "shape", "table", "north", "voice", "brush", "front", "plant", "taste", "theme", "track", "brain", "click", "staff", "sugar", "phase", "stage", "stick", "title", "novel", "carry", "fruit", "glass", "joint", "chart", "ideal", "party", "bench", "south", "stuff", "angle", "dream", "essay", "juice", "mouth", "peace", "storm", "trick", "beach", "blank", "catch", "chain", "cream", "score", "screw", "agent", "block", "court", "layer", "curve", "dress", "fight", "grade", "horse", "noise", "pause", "proof", "smoke", "towel", "wheel", "aside", "buddy", "bunch", "coach", "cross", "draft", "floor", "habit", "judge", "knife", "pound", "shame", "trust", "blame", "brick", "chair", "devil", "glove", "lunch", "nurse", "panic", "plane", "shock", "spite", "spray", "alarm", "blind", "cable", "clerk", "cloud", "plate", "skirt", "slice", "trash", "anger", "award", "candy", "clock", "crack", "fault", "grass", "motor", "nerve", "pride", "prize", "tower", "truck", "other", "great", "being", "might", "still", "start", "human", "local", "today", "major", "check", "guard", "offer", "whole", "dance", "worth", "spend", "drive", "green", "leave", "reach", "serve", "watch", "break", "visit", "cover", "white", "final", "teach", "broad", "maybe", "stand", "young", "heavy", "hello", "worry", "press", "tough", "brown", "shoot", "touch", "pitch", "total", "treat", "abuse", "print", "raise", "sleep", "equal", "claim", "drink", "guess", "minor", "solid", "weird", "count", "doubt", "round", "slide", "strip", "march", "adult", "brief", "crazy", "prior", "rough", "laugh", "nasty", "royal", "split", "train", "upper", "crash", "funny", "quote", "spare", "sweet", "swing", "twist", "usual", "brave", "grand", "quiet", "shake", "shift", "shine", "steal", "delay", "drunk", "hurry", "punch", "reply", "silly", "smile", "spell", "clash", "album", "radar", "sheep", "wheat", "tribe", "stove", "cloth", "enemy", "slave", "stone", "truce", "jewel", "crime", "trial", "fluid", "steel", "mercy", "wages", "pilot", "crops", "fence", "humor", "ocean", "mayor", "color", "tears", "steam", "chief", "civil", "grain", "people", "family", "health", "system", "thanks", "person", "method", "theory", "nature", "safety", "player", "policy", "series", "camera", "growth", "income", "energy", "nation", "moment", "office", "driver", "flight", "length", "dealer", "debate", "member", "advice", "effort", "wealth", "county", "estate", "recipe", "studio", "agency", "memory", "aspect", "cancer", "region", "device", "engine", "height", "sample", "boring", "cousin", "editor", "extent", "guitar", "leader", "singer", "tennis", "basket", "church", "coffee", "dinner", "orange", "poetry", "police", "sector", "volume", "farmer", "injury", "speech", "winner", "worker", "writer", "breath", "cookie", "drawer", "insect", "ladder", "potato", "sister", "tongue", "affair", "client", "throat", "number", "market", "course", "school", "amount", "answer", "matter", "access", "garden", "reason", "future", "demand", "action", "record", "result", "period", "chance", "figure", "source", "design", "object", "profit", "inside", "stress", "review", "screen", "medium", "bottom", "choice", "impact", "career", "credit", "square", "effect", "friend", "couple", "living", "summer", "button", "desire", "notice", "damage", "target", "animal", "author", "budget", "ground", "lesson", "minute", "bridge", "letter", "option", "plenty", "weight", "factor", "master", "muscle", "appeal", "mother", "season", "signal", "spirit", "street", "status", "ticket", "degree", "doctor", "father", "stable", "detail", "shower", "window", "corner", "finger", "garage", "manner", "winter", "battle", "bother", "horror", "phrase", "relief", "string", "border", "branch", "breast", "expert", "league", "native", "parent", "salary", "silver", "tackle", "assist", "closet", "collar", "jacket", "reward", "bottle", "candle", "flower", "lawyer", "mirror", "purple", "stroke", "switch", "bitter", "carpet", "island", "priest", "resort", "scheme", "script", "public", "common", "change", "simple", "second", "single", "travel", "excuse", "search", "remove", "return", "middle", "charge", "active", "visual", "affect", "report", "beyond", "junior", "unique", "listen", "handle", "finish", "normal", "secret", "spread", "spring", "cancel", "formal", "remote", "double", "attack", "wonder", "annual", "nobody", "repeat", "divide", "survey", "escape", "gather", "repair", "strike", "employ", "mobile", "senior", "strain", "yellow", "permit", "abroad", "prompt", "refuse", "regret", "reveal", "female", "invite", "resist", "stupid", "clergy", "circle", "rocket", "desert", "statue", "parade", "planet", "custom", "valley", "cotton", "motion", "troops", "sailor", "ballot", "forest", "prison", "bullet", "danger", "rubber", "poison", "liquid", "treaty", "crisis", "curfew", "weapon", "terror", "colony", "asylum", "victim", "beauty", "hunger", "Senate", "history", "reading", "problem", "control", "ability", "science", "library", "product", "society", "quality", "variety", "country", "physics", "thought", "freedom", "writing", "article", "fishing", "failure", "meaning", "teacher", "disease", "success", "student", "context", "finding", "message", "concept", "housing", "opinion", "payment", "reality", "passion", "setting", "college", "storage", "version", "alcohol", "highway", "mixture", "tension", "anxiety", "climate", "emotion", "manager", "respect", "charity", "outcome", "revenue", "session", "cabinet", "clothes", "drawing", "hearing", "vehicle", "airport", "arrival", "chapter", "village", "warning", "courage", "garbage", "grocery", "penalty", "wedding", "analyst", "bedroom", "diamond", "fortune", "funeral", "speaker", "surgery", "trainer", "example", "process", "economy", "company", "service", "picture", "section", "nothing", "subject", "weather", "program", "chicken", "feature", "purpose", "outside", "benefit", "account", "balance", "machine", "address", "average", "culture", "morning", "contact", "network", "attempt", "capital", "plastic", "feeling", "savings", "officer", "trouble", "maximum", "quarter", "traffic", "kitchen", "minimum", "project", "finance", "mission", "contest", "lecture", "meeting", "parking", "partner", "profile", "routine", "airline", "evening", "holiday", "husband", "mistake", "package", "patient", "stomach", "tourist", "brother", "opening", "pattern", "request", "shelter", "comment", "monitor", "weekend", "welcome", "bicycle", "concert", "counter", "leather", "pension", "channel", "comfort", "passage", "promise", "station", "witness", "general", "tonight", "current", "natural", "special", "working", "primary", "produce", "present", "support", "complex", "regular", "reserve", "classic", "private", "western", "concern", "leading", "release", "display", "extreme", "deposit", "advance", "consist", "forever", "impress", "whereas", "combine", "command", "initial", "mention", "scratch", "illegal", "respond", "convert", "recover", "resolve", "suspect", "anybody", "stretch", "factory", "blanket", "remains", "balloon", "volcano", "anarchy", "percent", "hostage", "soldier", "refugee", "citizen", "theater", "deficit", "mineral", "victory", "surplus", "missile", "barrier", "century", "mystery", "customs", "treason", "embassy", "surface", "biology", "ecology", "computer", "software", "internet", "activity", "industry", "language", "security", "analysis", "strategy", "instance", "audience", "marriage", "medicine", "location", "addition", "painting", "politics", "decision", "property", "shopping", "category", "magazine", "teaching", "customer", "resource", "patience", "solution", "attitude", "director", "response", "argument", "contract", "emphasis", "currency", "republic", "delivery", "election", "football", "guidance", "priority", "elevator", "employee", "employer", "disaster", "feedback", "homework", "judgment", "relation", "accident", "baseball", "database", "hospital", "presence", "proposal", "quantity", "reaction", "weakness", "ambition", "bathroom", "birthday", "midnight", "platform", "stranger", "sympathy", "business", "interest", "training", "practice", "research", "exercise", "building", "material", "question", "standard", "exchange", "position", "pressure", "function", "distance", "discount", "register", "campaign", "evidence", "strength", "relative", "progress", "daughter", "pleasure", "calendar", "district", "schedule", "swimming", "designer", "mountain", "occasion", "sentence", "shoulder", "vacation", "document", "mortgage", "sandwich", "surprise", "champion", "engineer", "entrance", "incident", "resident", "specific", "possible", "personal", "national", "physical", "increase", "purchase", "positive", "creative", "original", "negative", "anything", "familiar", "official", "valuable", "chemical", "conflict", "opposite", "anywhere", "internal", "constant", "external", "ordinary", "struggle", "upstairs", "estimate", "surround", "tomorrow", "religion", "passport", "ancestor", "treasure", "minister", "chairman", "criminal", "diplomat", "railroad", "dictator", "airplane", "universe", "skeleton", "ceremony", "creature", "children", "delegate", "activist", "militant", "memorial", "movement", "military", "sickness", "majority", "Congress", "minority", "grandson"};
576 private final String[] ADJECTIVES = {"all", "any", "apt", "bad", "big", "dim", "dry", "far", "fat", "few", "hot", "icy", "ill", "key", "low", "mad", "new", "odd", "old", "our", "raw", "red", "sad", "shy", "tan", "wan", "wee", "wet", "wry", "able", "aged", "ajar", "arid", "back", "bare", "best", "blue", "bold", "bony", "both", "busy", "calm", "cold", "cool", "cute", "damp", "dark", "dead", "dear", "deep", "drab", "dual", "dull", "each", "easy", "even", "evil", "fair", "fake", "fast", "fine", "firm", "flat", "fond", "free", "full", "glum", "good", "gray", "grim", "half", "hard", "high", "huge", "icky", "idle", "keen", "kind", "lame", "last", "late", "lazy", "lean", "left", "limp", "live", "lone", "long", "lost", "loud", "male", "mean", "meek", "mild", "near", "neat", "next", "nice", "numb", "oily", "only", "open", "oval", "pale", "past", "pink", "poor", "posh", "puny", "pure", "rare", "rash", "real", "rich", "ripe", "rosy", "rude", "safe", "same", "sane", "sick", "slim", "slow", "smug", "soft", "some", "sore", "sour", "spry", "tall", "tame", "tart", "taut", "that", "thin", "this", "tidy", "tiny", "torn", "trim", "TRUE", "twin", "ugly", "used", "vain", "vast", "warm", "wary", "wavy", "weak", "wide", "wild", "wiry", "wise", "worn", "zany", "adept", "agile", "alert", "alive", "ample", "angry", "aware", "awful", "baggy", "basic", "black", "bland", "blank", "bleak", "blind", "blond", "bogus", "bossy", "bowed", "brave", "brief", "brisk", "brown", "bulky", "bumpy", "burly", "cheap", "chief", "clean", "clear", "close", "corny", "crazy", "crisp", "cruel", "curly", "curvy", "dense", "dirty", "dizzy", "dopey", "eager", "early", "empty", "equal", "every", "faint", "FALSE", "fancy", "fatal", "first", "fixed", "flaky", "fluid", "frail", "frank", "fresh", "front", "funny", "fussy", "fuzzy", "giant", "giddy", "glass", "grand", "grave", "great", "green", "grimy", "gross", "grown", "gummy", "hairy", "handy", "happy", "harsh", "hasty", "heavy", "hefty", "husky", "ideal", "itchy", "jaded", "joint", "jolly", "juicy", "jumbo", "jumpy", "known", "kooky", "lanky", "large", "leafy", "legal", "light", "lined", "livid", "loose", "loyal", "lucky", "lumpy", "major", "mealy", "meaty", "merry", "messy", "milky", "minor", "minty", "misty", "mixed", "moist", "moral", "muddy", "murky", "mushy", "musty", "muted", "naive", "nasty", "needy", "nifty", "nippy", "noisy", "noted", "novel", "nutty", "obese", "other", "perky", "pesky", "petty", "phony", "plain", "plump", "plush", "prime", "prize", "proud", "pushy", "quick", "quiet", "rapid", "ready", "regal", "rigid", "right", "rough", "round", "rowdy", "royal", "ruddy", "runny", "rural", "rusty", "salty", "sandy", "scaly", "scary", "shady", "sharp", "shiny", "short", "showy", "silky", "silly", "slimy", "small", "smart", "soggy", "solid", "soupy", "spicy", "staid", "stale", "stark", "steep", "stiff", "steel", "sunny", "super", "sweet", "swift", "tasty", "tense", "tepid", "testy", "these", "thick", "third", "those", "tight", "tired", "total", "tough", "tubby", "unfit", "upset", "urban", "utter", "vague", "valid", "vapid", "vital", "vivid", "weary", "weepy", "weird", "which", "white", "whole", "windy", "witty", "woozy", "wordy", "worse", "worst", "wrong", "young", "yummy", "zesty", "whose", "civil", "sorry", "inner", "aching", "acidic", "active", "actual", "adored", "afraid", "amused", "annual", "arctic", "barren", "better", "bitter", "boring", "bouncy", "bright", "broken", "bronze", "bubbly", "candid", "canine", "caring", "cheery", "chilly", "chubby", "clever", "closed", "cloudy", "clumsy", "coarse", "common", "cooked", "costly", "crafty", "creamy", "creepy", "cuddly", "dapper", "daring", "deadly", "decent", "dental", "direct", "dismal", "dreary", "doting", "double", "drafty", "droopy", "edible", "elated", "entire", "exotic", "expert", "famous", "feisty", "feline", "female", "fickle", "filthy", "flashy", "flawed", "flimsy", "fluffy", "forked", "formal", "frayed", "French", "frigid", "frilly", "frizzy", "frosty", "frozen", "frugal", "gentle", "gifted", "giving", "gloomy", "glossy", "golden", "greedy", "grubby", "grumpy", "guilty", "hearty", "hidden", "hoarse", "hollow", "homely", "honest", "humble", "hungry", "impish", "impure", "inborn", "intent", "jagged", "jaunty", "jovial", "joyful", "joyous", "junior", "kindly", "klutzy", "knobby", "knotty", "kosher", "lavish", "lawful", "likely", "linear", "liquid", "little", "lively", "lonely", "lovely", "loving", "mature", "meager", "measly", "medium", "mellow", "modern", "modest", "narrow", "nimble", "normal", "oblong", "orange", "ornate", "ornery", "paltry", "pastel", "polite", "poised", "portly", "pretty", "pricey", "proper", "purple", "putrid", "quaint", "queasy", "quirky", "ragged", "recent", "remote", "ringed", "robust", "rotten", "scarce", "scared", "second", "secret", "serene", "severe", "shabby", "shoddy", "shrill", "silent", "silver", "simple", "sinful", "single", "skinny", "sleepy", "slight", "slushy", "smoggy", "smooth", "snappy", "sneaky", "snoopy", "somber", "sparse", "speedy", "spiffy", "square", "stable", "starry", "sticky", "stingy", "stormy", "strict", "strong", "stupid", "sturdy", "subtle", "sudden", "sugary", "superb", "svelte", "sweaty", "tender", "thorny", "timely", "tinted", "tragic", "tricky", "trusty", "uneven", "unique", "united", "unripe", "unruly", "unsung", "untidy", "untrue", "unused", "upbeat", "usable", "useful", "vacant", "violet", "warped", "watery", "webbed", "weekly", "wicked", "wiggly", "wilted", "winged", "wobbly", "woeful", "wooden", "worthy", "yearly", "yellow", "zigzag", "mental", "global", "latter", "former", "unfair", "sexual", "unable", "asleep", "admired", "alarmed", "amazing", "amusing", "ancient", "angelic", "another", "antique", "anxious", "ashamed", "assured", "austere", "average", "awesome", "awkward", "babyish", "belated", "beloved", "blaring", "boiling", "bruised", "buoyant", "buttery", "buzzing", "capital", "careful", "classic", "complex", "content", "corrupt", "crooked", "crowded", "damaged", "darling", "dearest", "decimal", "defiant", "delayed", "devoted", "digital", "dimpled", "distant", "dutiful", "earnest", "elastic", "elderly", "elegant", "eminent", "enraged", "envious", "ethical", "exalted", "excited", "failing", "faraway", "far-off", "fearful", "fitting", "flowery", "focused", "foolish", "gaseous", "general", "genuine", "glaring", "gleeful", "grouchy", "growing", "harmful", "hateful", "healthy", "helpful", "hideous", "honored", "hopeful", "humming", "hurtful", "idiotic", "illegal", "immense", "jealous", "jittery", "knowing", "lasting", "leading", "likable", "limited", "limping", "lovable", "made-up", "mammoth", "married", "massive", "medical", "melodic", "miserly", "monthly", "muffled", "mundane", "natural", "naughty", "nervous", "nonstop", "notable", "noxious", "obvious", "oddball", "offbeat", "optimal", "opulent", "orderly", "organic", "overdue", "parched", "partial", "peppery", "perfect", "pitiful", "plastic", "playful", "pleased", "pointed", "popular", "potable", "present", "prickly", "primary", "private", "profuse", "prudent", "pungent", "puzzled", "radiant", "regular", "roasted", "rubbery", "rundown", "scented", "scrawny", "selfish", "serious", "several", "shadowy", "shallow", "shocked", "similar", "soulful", "Spanish", "spotted", "squeaky", "stained", "starchy", "strange", "striped", "stylish", "subdued", "tedious", "teeming", "thirsty", "thrifty", "trained", "trivial", "unaware", "unhappy", "uniform", "unkempt", "unknown", "unlined", "unlucky", "untried", "unusual", "upright", "useless", "velvety", "vibrant", "vicious", "violent", "virtual", "visible", "warlike", "wealthy", "weighty", "welcome", "willing", "winding", "worldly", "worried", "yawning", "zealous", "various", "federal", "typical", "capable", "foreign", "eastern", "logical", "curious", "absolute", "adorable", "academic", "accurate", "advanced", "agitated", "alarming", "anchored", "animated", "aromatic", "artistic", "athletic", "attached", "blissful", "blushing", "bustling", "carefree", "careless", "cautious", "charming", "cheerful", "circular", "clueless", "colorful", "colossal", "complete", "composed", "concrete", "confused", "constant", "creative", "criminal", "critical", "crushing", "cultured", "dazzling", "decisive", "definite", "deserted", "detailed", "diligent", "discrete", "disloyal", "distinct", "dramatic", "ecstatic", "educated", "electric", "enormous", "esteemed", "euphoric", "exciting", "fabulous", "faithful", "familiar", "fatherly", "favorite", "fearless", "feminine", "finished", "flawless", "flippant", "forceful", "forsaken", "fragrant", "frequent", "friendly", "fruitful", "fumbling", "generous", "gigantic", "gleaming", "glorious", "gorgeous", "graceful", "gracious", "granular", "grateful", "gripping", "grizzled", "grounded", "growling", "gruesome", "gullible", "handmade", "handsome", "harmless", "haunting", "heavenly", "helpless", "horrible", "idolized", "ignorant", "impolite", "indolent", "infamous", "inferior", "infinite", "informal", "innocent", "insecure", "internal", "intrepid", "ironclad", "jubilant", "juvenile", "lopsided", "luminous", "lustrous", "majestic", "mediocre", "menacing", "metallic", "mindless", "motherly", "nautical", "negative", "obedient", "official", "ordinary", "original", "outlying", "outgoing", "parallel", "peaceful", "perfumed", "periodic", "personal", "physical", "piercing", "pleasant", "pleasing", "polished", "positive", "possible", "powerful", "precious", "previous", "pristine", "probable", "punctual", "puzzling", "quixotic", "reckless", "reliable", "relieved", "required", "rotating", "sardonic", "scornful", "scratchy", "separate", "shameful", "shocking", "sizzling", "skeletal", "slippery", "snarling", "sociable", "specific", "spirited", "spiteful", "splendid", "spotless", "squiggly", "standard", "straight", "strident", "striking", "studious", "stunning", "suburban", "superior", "tangible", "tattered", "tempting", "terrible", "terrific", "thankful", "thorough", "trifling", "troubled", "trusting", "truthful", "ultimate", "uncommon", "unfolded", "unlawful", "unsteady", "untimely", "unwieldy", "utilized", "valuable", "variable", "vengeful", "vigilant", "vigorous", "virtuous", "wasteful", "watchful", "well-lit", "well-off", "whopping", "wrathful", "wretched", "writhing", "youthful", "pregnant", "relevant", "suitable", "numerous", "cultural", "existing", "southern", "unlikely"};
577 private final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36";
578 private final String BASE_EMAIL;
579 private final String PASSWORD;
580 private String email;
581 private String session;
582 private String[] names = new String[0];
583 private boolean monitor;
584 private int session_slot_id;
585
586
587 public Registration(String base_email, String password, boolean monitor) {
588 BASE_EMAIL = base_email;
589 PASSWORD = password;
590 session_slot_id = (int) (Math.random() * 10000000) + 1000000;
591 if (monitor) {
592 this.monitor = true;
593 Timer timer = new Timer();
594 timer.schedule(new Monitor(), 10000, 10000);
595 }
596 }
597
598 static String session_id() {
599 return "password";
600 }
601
602 public void setSession(String session) {
603 this.session = session;
604 }
605
606 public String getEmail() {
607 if (email == null) {
608 registerEmail();
609 }
610 return email;
611 }
612
613 public void setEmail(String email) {
614 this.email = email;
615 }
616
617 public String getPassword() {
618 return PASSWORD;
619 }
620
621 public void registerName(String username, boolean snipe) {
622 while (email == null) {
623 registerEmail();
624 }
625 NameChecker nc = new NameChecker(email, PASSWORD);
626 session = nc.getSession();
627 while (session == null) {
628 session = new SessionGenerator().generateSessionId(email, PASSWORD);
629 }
630
631 int current = -1;
632 if (username == null) {
633 current = 0;
634 } else if (username.contains(",")) {
635 current = 0;
636 names = username.split(",");
637 }
638
639 boolean checking = true;
640 int i = 0;
641 int status = 0;
642 int error = 0;
643 if (snipe) {
644 if (current != -1) {
645 for (int it = 0; it < names.length; it++) {
646 names[it] = names[it].trim();
647 writeNameToFile(names[it]);
648 }
649 } else {
650 writeNameToFile(username);
651 }
652 do {
653 if (current != -1) {
654 current++;
655 if (current >= names.length) {
656 current = 0;
657 }
658 if (names.length != 0) {
659 username = names[current];
660 }
661 }
662
663 nc.setName(username);
664 switch (nc.check()) {
665 case 0:
666 System.err.println(nc.getName() + " is unavailable.");
667 status = 1;
668 break;
669 case 1:
670 System.out.println(nc.getName() + " is available.");
671 session = nc.getSession();
672 int tries = 20;
673 while (status != 2 && tries-- > 0) {
674 status = setName(session, nc.getName());
675 if (status == 1) {
676 System.out.println(nc.getName() + " is unavailable.");
677 }
678 }
679 checking = false;
680 break;
681 case 2:
682 System.err.println(nc.getName() + " is invalid.");
683 break;
684 }
685
686 if (status != 3) {
687 i = 0;
688 error = 0;
689 continue;
690 }
691 if (monitor && error > 5) {
692 break;
693 }
694 if (++i >= 3) {
695 i = 0;
696 error++;
697 session = new SessionGenerator().generateSessionId(email, PASSWORD);
698 }
699// try {
700// Thread.sleep(500L);
701// } catch (InterruptedException e) {
702// e.printStackTrace();
703// }
704// } while (checking);
705 } while (checking);
706 } else {
707 do {
708 System.out.println("Setting name...");
709 if (i > 0) {
710 session = new SessionGenerator().generateSessionId(email, PASSWORD);
711 }
712 } while ((status = setName(session, username)) != 2 && ++i < 5);
713 }
714
715 for (String name : names) {
716 writeNameToFile(name);
717 }
718 writeNameToFile(username);
719
720 if (status == 1) {
721 System.out.println("That username is not available. Tried setting it anyway.");
722 System.out.println("Username: " + username);
723 System.out.println("Email: " + email);
724 return;
725 }
726 if (status == 3) {
727 System.out.println("Something went wrong setting the username.");
728 System.out.println("Username: " + username);
729 System.out.println("Email: " + email);
730 return;
731 }
732
733 int tries = 5;
734 while (tries-- > 0) {
735 try {
736 System.out.println("Posting details to web");
737 URL url = new URL("http://example.com/log?name=" + URLEncoder.encode(username, "UTF-8") + "&email=" + URLEncoder.encode(email, "UTF-8"));
738 HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
739 con.setRequestProperty("User-Agent", USER_AGENT);
740 con.setConnectTimeout(10000);
741 con.setReadTimeout(10000);
742 con.getInputStream();
743 break;
744 } catch (MalformedURLException e) {
745 System.out.println("MalformedURLException while posting details to web");
746 } catch (SocketTimeoutException e) {
747 System.out.println("SocketTimeoutException while posting details to web");
748 } catch (IOException e) {
749 System.out.println("IOException while posting details to web");
750 e.printStackTrace();
751 }
752 }
753 }
754
755 // grab list of rare names that have changed their names to something else in the past few seconds
756 public void getRecentNames() {
757 try {
758 URLConnection conn = new URL("http://example.com/recent?ssid=" + session_slot_id).openConnection();
759 conn.setConnectTimeout(5000);
760 conn.setReadTimeout(5000);
761 BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
762 String line;
763 while ((line = in.readLine()) != null) {
764 if (line.contains(",")) {
765 names = line.split(",");
766 }
767 }
768 in.close();
769 } catch (MalformedURLException e) {
770 System.out.println("MalformedURLException while fetching list");
771 } catch (SocketTimeoutException e) {
772 System.out.println("SocketTimeoutException while fetching list");
773 } catch (IOException e) {
774 System.out.println("IOException while fetching list");
775 e.printStackTrace();
776 }
777 }
778
779 private void writeNameToFile(String username) {
780 try {
781 File file = new File("." + File.separatorChar + "accounts" + File.separatorChar);
782 if (!file.exists()) {
783 file.mkdir();
784 }
785 file = new File("." + File.separatorChar + "accounts" + File.separatorChar + username + ".txt");
786 if (!file.exists()) {
787 file.createNewFile();
788 }
789 FileWriter fw = new FileWriter(file.getAbsoluteFile());
790 BufferedWriter bw = new BufferedWriter(fw);
791 bw.write(email);
792 bw.newLine();
793 bw.close();
794 file = new File("." + File.separatorChar + "accounts" + File.separatorChar + "emails.txt");
795 if (!file.exists()) {
796 file.createNewFile();
797 }
798 fw = new FileWriter(file.getAbsoluteFile(), true);
799 bw = new BufferedWriter(fw);
800 bw.append(username).append("\t").append(email);
801 bw.newLine();
802 bw.close();
803 System.out.println("Wrote " + email + " to file.");
804 } catch (IOException e) {
805 System.out.println("Error writing account to file.");
806 System.out.println(username + " " + email);
807 e.printStackTrace();
808 }
809 }
810
811 private int setName(String session, String username) {
812 try {
813 URL obj = new URL("https://secure.runescape.com/m=displaynames/" + session + "/name.ws");
814 HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
815 con.setRequestMethod("POST");
816 con.setRequestProperty("User-Agent", USER_AGENT);
817 con.setDoOutput(true);
818 con.setReadTimeout(5000);
819 con.setConnectTimeout(5000);
820 String urlParameters = "name=" + username + "&ssl=-1&confirm=Yes";
821 DataOutputStream wr = new DataOutputStream(con.getOutputStream());
822 wr.writeBytes(urlParameters);
823 wr.flush();
824 wr.close();
825 BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
826 String line;
827 ArrayList<String> page = new ArrayList<>();
828 while ((line = br.readLine()) != null) {
829 page.add(line);
830 if (line.contains("There was an unknown error changing your name") || line.contains("The name you have chosen is not available")) {
831 System.out.println(username + " is unavailable.");
832 br.close();
833 return 1;
834 }
835 if (line.contains("Your name has been changed successfully")) {
836 System.out.println("Name changed successfully.");
837 br.close();
838 return 2;
839 }
840 if (line.contains("Purchase RuneScape membership</a> to change your name.")) {
841 System.out.println("Purchase RuneScape membership to change your name.");
842 br.close();
843 return 3;
844 }
845 }
846 System.out.println(page.toString());
847 System.out.println("UnexpectedResponse while setting name");
848 } catch (NoRouteToHostException e) {
849 System.out.println("NoRouteToHostException while setting name");
850 } catch (SocketTimeoutException e) {
851 System.out.println("SocketTimeoutException while setting name");
852 return 1;
853 } catch (IOException e) {
854 System.out.println("IOException while setting name");
855 }
856 return 3;
857 }
858
859 /*
860 Generates a (hopefully) unique e-mail address using Google spam prevention features
861
862 Given example@gmail.com, this method will return something along the lines of
863 "example+lqsau9238@gmail.com",
864 which is a valid e-mail address alias representing the original example@gmail.com
865 */
866// private String generateUniqueEmail() {
867// String[] email = BASE_EMAIL.split("@");
868// StringBuilder sb = new StringBuilder();
869// sb.append(email[0]);
870// sb.append('+');
871// for (int i = 0; i < 5; ++i) {
872// sb.append((char) (97 + (int) (Math.random() * 26)));
873// }
874// sb.append((int) (Math.random() * 10000));
875// sb.append('@');
876// sb.append(email[1]);
877// return sb.toString();
878// }
879
880 /*
881 Generates a (hopefully) unique e-mail address using Google spam prevention features
882
883 Given example@gmail.com, this method will return something along the lines of
884 "example+SmellyRedCat285@gmail.com",
885 which is a valid e-mail address alias representing the original example@gmail.com
886 */
887 private String generateUniqueEmail() {
888 String[] email = BASE_EMAIL.split("@");
889 StringBuilder sb = new StringBuilder();
890 sb.append(email[0]);
891 sb.append('+');
892 if (Math.random() > .5D) {
893 sb.append(ADJECTIVES[(int) (Math.random() * (ADJECTIVES.length - 1))]);
894 } else {
895 sb.append(NOUNS[(int) (Math.random() * (NOUNS.length - 1))]);
896 }
897// sb.append(toProperCase(ADJECTIVES[(int) (Math.random() * (ADJECTIVES.length - 1))]));
898// sb.append(toProperCase(ADJECTIVES[(int) (Math.random() * (ADJECTIVES.length - 1))]));
899// sb.append(toProperCase(NOUNS[(int) (Math.random() * (NOUNS.length - 1))]));
900 sb.append((int) (Math.random() * 1000));
901 sb.append('@');
902 sb.append(email[1]);
903 return sb.toString();
904 }
905
906 private String toProperCase(String name) {
907 return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
908 }
909
910 public void registerEmail() {
911 System.out.println("Creating new account...");
912 String email = generateUniqueEmail();
913 try {
914 URL obj = new URL("https://secure.runescape.com/m=account-creation/create_account_funnel.ws");
915 HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
916 con.setRequestMethod("POST");
917 con.setRequestProperty("User-Agent", USER_AGENT);
918 con.setDoOutput(true);
919 con.setReadTimeout(10000);
920 con.setConnectTimeout(10000);
921 String urlParameters = "onlyOneEmail=1&age=24&email1=" + URLEncoder.encode(email, "UTF-8") + "&password1=" + session_id() + "&password2=" + session_id() + "&agree_pp_and_tac=1&submit=Join+Now";
922 DataOutputStream wr = new DataOutputStream(con.getOutputStream());
923 wr.writeBytes(urlParameters);
924 wr.flush();
925 wr.close();
926 BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
927 String line;
928 while ((line = br.readLine()) != null) {
929 if (line.contains("Click the link we have included in the confirmation email.")) {
930 System.out.println("Account has been created.");
931 this.email = email;
932 writeNameToFile("ACCOUNT CREATED");
933 return;
934 }
935 }
936 } catch (NoRouteToHostException e) {
937 System.out.println("NoRouteToHostException while registering e-mail");
938 } catch (SocketTimeoutException e) {
939 System.out.println("SocketTimeoutException while registering e-mail");
940 } catch (IOException e) {
941 System.out.println("IOException while registering e-mail");
942 e.printStackTrace();
943 }
944 this.email = null;
945 }
946
947 private class Monitor extends TimerTask {
948 private Monitor() {
949 }
950
951 @Override
952 public void run() {
953 getRecentNames();
954 }
955 }
956}