Thread: RSA Help.

Results 1 to 5 of 5
  1. #1 RSA Help. 
    Banned
    Join Date
    Jun 2013
    Posts
    527
    Thanks given
    78
    Thanks received
    61
    Rep Power
    0
    Code:
    Unable to decode RSA block properly!

    I'm trying to login and I'm getting this error. It was working fine last night when I logged in, now it's not letting me login. I've checked client sided and RSA is disabled...

    Also if it makes any difference, I'm using a blank Pi with Eliminate's V5.

    Here is my RS2LoginProtocol:

    Code:
    package server.net.login;
    
    import java.security.SecureRandom;
    
    import org.jboss.netty.buffer.ChannelBuffer;
    import org.jboss.netty.channel.Channel;
    import org.jboss.netty.channel.ChannelFuture;
    import org.jboss.netty.channel.ChannelFutureListener;
    import org.jboss.netty.channel.ChannelHandlerContext;
    import org.jboss.netty.handler.codec.frame.FrameDecoder;
    
    import server.Config;
    import server.Connection;
    import server.Server;
    import server.model.players.Client;
    import server.model.players.PlayerHandler;
    import server.model.players.PlayerSave;
    import server.net.PacketBuilder;
    import server.util.ISAACCipher;
    import server.util.Misc;
    public class RS2LoginProtocol extends FrameDecoder {
    
    	private static final int CONNECTED = 0;
    	private static final int LOGGING_IN = 1;
    	private int state = CONNECTED;
    
    	@Override
    	protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
    		if(!channel.isConnected()) {
    			return null;
    		}
    		switch (state) {
    		case CONNECTED:
    			if (buffer.readableBytes() < 2)
    				return null;
    			int request = buffer.readUnsignedByte();
    			if (request != 14) {
    				System.out.println("Invalid login request: " + request);
    				channel.close();
    				return null;
    			}
    			buffer.readUnsignedByte();
    			channel.write(new PacketBuilder().putLong(0).put((byte) 0).putLong(new SecureRandom().nextLong()).toPacket());
    			state = LOGGING_IN;
    			return null;
    		case LOGGING_IN:
    			
    			if (buffer.readableBytes() < 2) {
    				return null;
    			}
    			
    			int loginType = buffer.readByte();
    			if (loginType != 16 && loginType != 18) {
    				System.out.println("Invalid login type: " + loginType);
    				//channel.close();
    				//return null;
    			}
    			//System.out.println("Login type = "+loginType);
    			int blockLength = buffer.readByte() & 0xff;
    			if (buffer.readableBytes() < blockLength) {
    				return null;
    			}
    			
    			buffer.readByte();
    			
    			buffer.readByte();
    			
    			for (int i = 0; i < 9; i++)
    				buffer.readInt();
    			
    			
    			buffer.readByte();
    			
    			int rsaOpcode = buffer.readByte();
    			if (rsaOpcode != 10) {
    				System.out.println("Unable to decode RSA block properly!");
    				channel.close();
    				return null;
    			}
    			
    			final long clientHalf = buffer.readLong();
    			final long serverHalf = buffer.readLong();
    			final int[] isaacSeed = { (int) (clientHalf >> 32), (int) clientHalf, (int) (serverHalf >> 32), (int) serverHalf };
    			final ISAACCipher inCipher = new ISAACCipher(isaacSeed);
    			for (int i = 0; i < isaacSeed.length; i++)
    				isaacSeed[i] += 50;
    			final ISAACCipher outCipher = new ISAACCipher(isaacSeed);
    			final int version = buffer.readInt();
    			final String name = Misc.formatPlayerName(Misc.getRS2String(buffer));
    			final String pass = Misc.getRS2String(buffer);
    			channel.getPipeline().replace("decoder", "decoder", new RS2Decoder(inCipher));
    			return login(channel, inCipher, outCipher, version, name, pass);
    		}
    		return null;
    	}
    
    	private static Client login(Channel channel, ISAACCipher inCipher, ISAACCipher outCipher, int version, String name, String pass) {
    		int returnCode = 2;
    		if (!name.matches("[A-Za-z0-9 ]+")) {
    			returnCode = 4;
    		}
    		if (name.length() > 12) {
    			returnCode = 8;
    		}
    		Client cl = new Client(channel, -1);
    		cl.playerName = name;
    		cl.playerName2 = cl.playerName;
    		cl.playerPass = pass;
    		cl.outStream.packetEncryption = outCipher;
    		cl.saveCharacter = false;
    		cl.isActive = true;
    		if (Connection.isNamedBanned(cl.playerName)) {
    			returnCode = 4;
    		}
    		if (PlayerHandler.isPlayerOn(name)) {
    			returnCode = 5;
    		}
    		if (PlayerHandler.getPlayerCount() >= Config.MAX_PLAYERS) {
    			returnCode = 7;
    		}
    		if (Server.UpdateServer) {
    			returnCode = 14;
    		}
    		if (returnCode == 2) {
    			int load = PlayerSave.loadGame(cl, cl.playerName, cl.playerPass);
    			if (load == 0)
    				cl.addStarter = true;
    			if (load == 3) {
    				returnCode = 3;
    				cl.saveFile = false;
    			} else {
    				for (int i = 0; i < cl.playerEquipment.length; i++) {
    					if (cl.playerEquipment[i] == 0) {
    						cl.playerEquipment[i] = -1;
    						cl.playerEquipmentN[i] = 0;
    					}
    				}
    				if (!Server.playerHandler.newPlayerClient(cl)) {
    					returnCode = 7;
    					cl.saveFile = false;
    				} else {
    					cl.saveFile = true;
    				}
    			}
    		}
    		if(returnCode == 2) {
    			cl.saveCharacter = true;
    			cl.packetType = -1;
    			cl.packetSize = 0;
    			final PacketBuilder bldr = new PacketBuilder();
    			bldr.put((byte) 2);
    			if (cl.playerRights == 3) {
    				bldr.put((byte) 2);
    			} else {
    				bldr.put((byte) cl.playerRights);
    			}
    			bldr.put((byte) 0);
    			channel.write(bldr.toPacket());
    		} else {
    			System.out.println("returncode:" + returnCode);
    			sendReturnCode(channel, returnCode);
    			return null;
    		}
    		synchronized (PlayerHandler.lock) {
    			cl.initialize();
    			cl.initialized = true;
    		}
    		return cl;
    	}
    
    	public static void sendReturnCode(final Channel channel, final int code) {
    		channel.write(new PacketBuilder().put((byte) code).toPacket()).addListener(new ChannelFutureListener() {
    			@Override
    			public void operationComplete(final ChannelFuture arg0) throws Exception {
    				arg0.getChannel().close();
    			}
    		});
    	}
    
    }
    Reply With Quote  
     

  2. #2  
    Registered Member veysell1's Avatar
    Join Date
    Dec 2012
    Posts
    73
    Thanks given
    17
    Thanks received
    1
    Rep Power
    0
    use enums
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Mar 2013
    Posts
    3,046
    Thanks given
    82
    Thanks received
    375
    Rep Power
    0
    Quote Originally Posted by veysell1 View Post
    use enums
    looooooooooooool
    Reply With Quote  
     

  4. Thankful users:


  5. #4  
    Banned
    Join Date
    Jun 2013
    Posts
    527
    Thanks given
    78
    Thanks received
    61
    Rep Power
    0
    Quote Originally Posted by veysell1 View Post
    use enums
    Leave the forums and never come back.

    EDIT: Paying $3 for fix.
    Reply With Quote  
     

  6. #5  
    Donator

    Join Date
    Oct 2013
    Posts
    351
    Thanks given
    207
    Thanks received
    59
    Rep Power
    38
    No need anymore.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. RSA implemented, Remove Help?
    By xoodreyoox in forum Help
    Replies: 1
    Last Post: 07-14-2013, 05:21 AM
  2. RSA with netty help
    By James-RevolutionX in forum Help
    Replies: 8
    Last Post: 07-03-2013, 07:09 PM
  3. Help please, (rsa keys) uid and stuff
    By mr zipper in forum Help
    Replies: 7
    Last Post: 02-09-2011, 06:26 AM
  4. Need gfx help?
    By Beh3moth2 in forum General
    Replies: 1
    Last Post: 04-03-2007, 11:50 AM
  5. Need help choosing sig
    By Zane in forum Showcase
    Replies: 7
    Last Post: 04-02-2007, 03:14 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •