Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AccountCreationDecoder {
- private static boolean BadName(String name) {
- return name.contains("nerd") || name.contains("fuck") || name.contains("gay") || name.contains("motherf");
- }
- private static List<String> SuggestedNames(String name) {
- List<String> Names = new ArrayList<String>();
- for (byte i = 0; i < 5; i++) {
- String newName = name + Misc.random(5000);
- if (AccountExists(newName) || Names.contains(newName))
- continue;
- Names.add(newName);
- }
- return Names;
- }
- private static boolean AccountExists(String name) {
- return new File("./data/savedgames/" + name + ".ser").exists();
- }
- /*
- *Where i say noob hacker means only way to that code part be called is by hacking
- */
- public static void decode(ConnectionHandler c, InStream in) {
- switch(c.getConnectionStage()) {
- case Constants.CHECK_ACC_NAME:
- if(in.remaining() < 8) {
- c.setConnectionStage(Constants.DISCONNECT);
- return;
- }
- List<String> suggestions = null;
- String user = Misc.longToString(in.readLong());
- int packetSize = in.readUnsignedByte();
- int returnCode = 0;
- if(user==null)
- returnCode = 22;
- else if(BadName(user))
- returnCode = 20;
- else if(AccountExists(user)) {
- returnCode = 21;
- OutStream outstream = new OutStream();
- suggestions = SuggestedNames(user);
- } else {
- returnCode = 2;
- }
- OutStream out = new OutStream((suggestions==null)?2:512);
- out.writeByte(returnCode);
- if(returnCode==21) {
- if(suggestions==null) {
- out.writeByte(1);
- out.writeLong(Misc.stringToLong("gtfo"));
- } else {
- out.writeByte(suggestions.size());
- for(String suggestion:suggestions)
- out.writeLong(Misc.stringToLong(suggestion));
- }
- }
- c.write(out);
- c.setConnectionStage(Constants.DISCONNECT);
- break;
- case Constants.MAKE_ACC:
- int length = in.readShort();
- int version = in.readShort();
- int b3 = in.readByte();
- int b4 = in.readByte();
- in.skip(26);
- int b1 = in.readByte();
- int s1 = in.readShort();
- String username = Misc.formatPlayerNameForProtocol(Misc.longToString(in.readLong()));
- int s2 = in.readShort();
- String password = in.readString();
- System.out.println("Creating account: "+username+", password: "+password+".");
- long l1 = in.readLong();
- //2 longs or 4 ints client sided
- long l2 = in.readLong();
- long l3 = in.readLong();
- int i1 = in.readInt();
- out = new OutStream(1);
- out.writeByte(2);
- c.write(out);
- Player player = new Player(username, password, new GregorianCalendar(), new GregorianCalendar(), (short) 1, "", (byte) 1);
- Serializer.SaveAccount(player);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement