Thread: RSA and flooder

Results 1 to 4 of 4
  1. #1 RSA and flooder 
    Donator
    ownervs911's Avatar
    Join Date
    Jul 2013
    Posts
    166
    Thanks given
    6
    Thanks received
    4
    Rep Power
    11
    I am using the flooder from Professor Oak but its seem that my Server is blocking the connection There is no error from the RSA and no error from the server It only shows that its work but no accounts are created
    Anyone care to help?


    P.s I have checked the login protocol and the login decoder but can't seem to find why it's blocking the connection

    the source is Elvarg

    here my login decoder
    Code:
    package com.elvarg.net.codec;
    
    import java.math.BigInteger;
    import java.security.SecureRandom;
    import java.util.List;
    import java.util.Random;
    
    import com.elvarg.Elvarg;
    import com.elvarg.net.NetworkConstants;
    import com.elvarg.net.ByteBufUtils;
    import com.elvarg.net.login.LoginDetailsMessage;
    import com.elvarg.net.login.LoginResponses;
    import com.elvarg.net.login.LoginUtils;
    import com.elvarg.net.security.IsaacRandom;
    import com.elvarg.util.Misc;
    
    import io.netty.buffer.ByteBuf;
    import io.netty.buffer.Unpooled;
    import io.netty.channel.ChannelHandlerContext;
    import io.netty.handler.codec.ByteToMessageDecoder;
    
    /**
     * Decodes login.
     * @author Swiffy
     */
    public final class LoginDecoder extends ByteToMessageDecoder {
    
    	/**
    	 * Generates random numbers via secure cryptography. Generates the session key for packet
    	 * encryption.
    	 */
    	private static final Random random = new SecureRandom();
    
    	/**
    	 * The size of the encrypted data.
    	 */
    	private int encryptedLoginBlockSize;
    
    	/**
    	 * The current login decoder state
    	 */
    	private LoginDecoderState state = LoginDecoderState.LOGIN_REQUEST;
    	
    	@Override
    	protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
    		switch(state) {
    		
    		case LOGIN_REQUEST:
    			decodeRequest(ctx, buffer);
    			break;
    			
    		case LOGIN_TYPE:
    			decodeType(ctx, buffer);
    			break;
    			
    		case LOGIN:
    			decodeLogin(ctx, buffer, out);
    			break;
    		}
    	}
    
    	private void decodeRequest(ChannelHandlerContext ctx, ByteBuf buffer) {
    		
    		if(!buffer.isReadable()) {
    			ctx.channel().close();
    			return;
    		}
    		
    		int request = buffer.readUnsignedByte();
    		if (request != NetworkConstants.LOGIN_REQUEST_OPCODE) {
    			Elvarg.getLogger().info("Session rejected for bad login request id: "+request);
    			LoginUtils.sendResponseCode(ctx, LoginResponses.LOGIN_SERVER_OFFLINE);
    			return;
    		}
    
    		//Send information to the client
    		ByteBuf buf = Unpooled.buffer(19);
    		buf.writeByte(0); //0 = continue login
    		buf.writeLong(random.nextLong()); // This long will be used for encryption later on
    		ctx.writeAndFlush(buf);
    		
    		state = LoginDecoderState.LOGIN_TYPE;
    	}
    
    	private void decodeType(ChannelHandlerContext ctx, ByteBuf buffer) {
    		
    		if(!buffer.isReadable()) {
    			ctx.channel().close();
    			return;
    		}
    		
    		int connectionType = buffer.readUnsignedByte();
    		if (connectionType != NetworkConstants.NEW_CONNECTION_OPCODE
    				&& connectionType != NetworkConstants.RECONNECTION_OPCODE) {
    			Elvarg.getLogger().info("Session rejected for bad connection type id: "+connectionType);
    			LoginUtils.sendResponseCode(ctx, LoginResponses.LOGIN_SERVER_OFFLINE);
    			return;
    		}
    		
    		state = LoginDecoderState.LOGIN;
    	}
    
    	private void decodeLogin(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) {
    		
    		if(!buffer.isReadable()) {
    			ctx.channel().close();
    			return;
    		}
    		
    		encryptedLoginBlockSize = buffer.readUnsignedByte();
    
    
    		if (encryptedLoginBlockSize != buffer.readableBytes()) {
    			Elvarg.getLogger().info(String.format("[host= %s] encryptedLoginBlockSize != readable bytes",
    					ctx.channel().remoteAddress()));
    			LoginUtils.sendResponseCode(ctx, LoginResponses.LOGIN_REJECT_SESSION);
    			return;
    		}
    
    		if(buffer.isReadable(encryptedLoginBlockSize)) {
    
    			int magicId = buffer.readUnsignedByte();
    			if(magicId != 0xFF) {
    				Elvarg.getLogger().info(String.format("[host= %s] [magic= %d] was rejected for the wrong magic value.",
    						ctx.channel().remoteAddress(), magicId));
    				LoginUtils.sendResponseCode(ctx, LoginResponses.LOGIN_REJECT_SESSION);
    				return;
    			}
    
    			int clientVersion = buffer.readShort();
    
    			int memory =  buffer.readByte();
    			if (memory != 0 && memory != 1) {
    				Elvarg.getLogger().info(String.format("[host= %s] was rejected for having the memory setting.",
    						ctx.channel().remoteAddress()));
    				LoginUtils.sendResponseCode(ctx, LoginResponses.LOGIN_REJECT_SESSION);
    				return;
    			}
    
    			/*int[] archiveCrcs = new int[9];
    			for (int i = 0; i < 9; i++) {
    				archiveCrcs[i] = buffer.readInt();
    			}*/
    
    			/**
    			 * Our RSA components. 
    			 */
    			int length = buffer.readUnsignedByte();
    			byte[] rsaBytes = new byte[length];
    			buffer.readBytes(rsaBytes);
    
    			ByteBuf rsaBuffer = Unpooled.wrappedBuffer(new BigInteger(rsaBytes)
    					.modPow(NetworkConstants.RSA_EXPONENT, NetworkConstants.RSA_MODULUS).toByteArray());
    
    			int securityId = rsaBuffer.readByte();
    			
    			if(securityId != 10) {
    				Elvarg.getLogger().info(String.format("[host= %s] was rejected for having the wrong securityId.",
    						ctx.channel().remoteAddress()));
    				LoginUtils.sendResponseCode(ctx, LoginResponses.LOGIN_REJECT_SESSION);
    				return;
    				
    			}
    
    			long clientSeed = rsaBuffer.readLong();
    			long seedReceived = rsaBuffer.readLong();
    
    			int[] seed = {(int) (clientSeed >> 32), (int) clientSeed, (int) (seedReceived >> 32), (int) seedReceived};
    			IsaacRandom decodingRandom = new IsaacRandom(seed);
    			for (int i = 0; i < seed.length; i++) {
    				seed[i] += 50;
    			}
    
    			int uid = rsaBuffer.readInt();
    
    			String username = Misc.formatText(ByteBufUtils.readString(rsaBuffer).toLowerCase());
    			String password = ByteBufUtils.readString(rsaBuffer);
    
    			if (username.length() > 12 || password.length() > 20) {
    				LoginUtils.sendResponseCode(ctx, LoginResponses.INVALID_CREDENTIALS);
    				return;
    			}
    
    			out.add(new LoginDetailsMessage(ctx, username, password, ByteBufUtils.getHost(ctx.channel()), clientVersion, uid, new IsaacRandom(seed), decodingRandom));
    		}
    	}
    	
    	private enum LoginDecoderState {
    		LOGIN_REQUEST,
    		LOGIN_TYPE,
    		LOGIN;
    	}
    }


    Reply With Quote  
     

  2. #2  
    Registered Member derpscape's Avatar
    Join Date
    Jul 2011
    Posts
    201
    Thanks given
    31
    Thanks received
    17
    Rep Power
    18
    Make sure the IP, Port, Version, UID, Magic Number, NPC Bits, and absolutely everything the server uses to communicate with the client are all in order, and then check to see if there is anything limiting the speed at which clients connect to the server.

    I haven't looked at the flooder but if it is missing any of that information the server is asking for that would be the problem.
    Reply With Quote  
     

  3. #3  
    Donator
    ownervs911's Avatar
    Join Date
    Jul 2013
    Posts
    166
    Thanks given
    6
    Thanks received
    4
    Rep Power
    11
    I made sure that everything is connecting still nothing happen

    I have RSA public key and private key
    But still there are no error from the connection

    Port and ip are local; still not the probleme

    My thinking is that flooder was outdated with the old ways off login ?
    Reply With Quote  
     

  4. #4  
    sorry

    Yasin's Avatar
    Join Date
    Nov 2015
    Posts
    112
    Thanks given
    212
    Thanks received
    180
    Rep Power
    621
    idk maybe look at your own login protocol see what's missing
    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. Why RSA and ISAAC should not be removed
    By Sean in forum Informative Threads
    Replies: 64
    Last Post: 05-10-2013, 10:48 PM
  2. RSA and ISAAC
    By Kruznyak in forum Help
    Replies: 9
    Last Post: 06-08-2010, 03:34 AM
  3. rsa and isaac
    By public class in forum Help
    Replies: 11
    Last Post: 07-04-2009, 09:54 PM
  4. Enabling RSA and ISAAC
    By Nathan in forum Requests
    Replies: 0
    Last Post: 05-04-2009, 10:27 PM
  5. Why RSA and ISAAC should not be removed
    By Sean in forum RS 503+ Client & Server
    Replies: 28
    Last Post: 05-04-2009, 12:21 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
  •