This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.loginserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.loginserver.network.L2LoginClient.LoginClientState;
|
||||
import com.l2jserver.loginserver.network.serverpackets.GGAuth;
|
||||
import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
|
||||
|
||||
/**
|
||||
* Format: ddddd
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class AuthGameGuard extends L2LoginClientPacket
|
||||
{
|
||||
private int _sessionId;
|
||||
private int _data1;
|
||||
private int _data2;
|
||||
private int _data3;
|
||||
private int _data4;
|
||||
|
||||
public int getSessionId()
|
||||
{
|
||||
return _sessionId;
|
||||
}
|
||||
|
||||
public int getData1()
|
||||
{
|
||||
return _data1;
|
||||
}
|
||||
|
||||
public int getData2()
|
||||
{
|
||||
return _data2;
|
||||
}
|
||||
|
||||
public int getData3()
|
||||
{
|
||||
return _data3;
|
||||
}
|
||||
|
||||
public int getData4()
|
||||
{
|
||||
return _data4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readImpl()
|
||||
{
|
||||
if (super._buf.remaining() >= 20)
|
||||
{
|
||||
_sessionId = readD();
|
||||
_data1 = readD();
|
||||
_data2 = readD();
|
||||
_data3 = readD();
|
||||
_data4 = readD();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_sessionId == getClient().getSessionId())
|
||||
{
|
||||
getClient().setState(LoginClientState.AUTHED_GG);
|
||||
getClient().sendPacket(new GGAuth(getClient().getSessionId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.loginserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.mmocore.network.ReceivablePacket;
|
||||
|
||||
import com.l2jserver.loginserver.network.L2LoginClient;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public abstract class L2LoginClientPacket extends ReceivablePacket<L2LoginClient>
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(L2LoginClientPacket.class.getName());
|
||||
|
||||
@Override
|
||||
protected final boolean read()
|
||||
{
|
||||
try
|
||||
{
|
||||
return readImpl();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "ERROR READING: " + this.getClass().getSimpleName() + ": " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean readImpl();
|
||||
}
|
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.loginserver.network.clientpackets;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
|
||||
import com.l2jserver.loginserver.LoginController;
|
||||
import com.l2jserver.loginserver.LoginController.AuthLoginResult;
|
||||
import com.l2jserver.loginserver.model.data.AccountInfo;
|
||||
import com.l2jserver.loginserver.network.L2LoginClient;
|
||||
import com.l2jserver.loginserver.network.L2LoginClient.LoginClientState;
|
||||
import com.l2jserver.loginserver.network.serverpackets.AccountKicked;
|
||||
import com.l2jserver.loginserver.network.serverpackets.AccountKicked.AccountKickedReason;
|
||||
import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
|
||||
import com.l2jserver.loginserver.network.serverpackets.LoginOk;
|
||||
import com.l2jserver.loginserver.network.serverpackets.ServerList;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Format: x
|
||||
* 0 (a leading null)
|
||||
* x: the rsa encrypted block with the login an password.
|
||||
*
|
||||
* <pre>
|
||||
*/
|
||||
public class RequestAuthLogin extends L2LoginClientPacket
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(RequestAuthLogin.class.getName());
|
||||
|
||||
private final byte[] _raw1 = new byte[128];
|
||||
private final byte[] _raw2 = new byte[128];
|
||||
private boolean _newAuthMethod = false;
|
||||
|
||||
private String _user;
|
||||
private String _password;
|
||||
private int _ncotp;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return _password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getUser()
|
||||
{
|
||||
return _user;
|
||||
}
|
||||
|
||||
public int getOneTimePassword()
|
||||
{
|
||||
return _ncotp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readImpl()
|
||||
{
|
||||
if (super._buf.remaining() >= 256)
|
||||
{
|
||||
_newAuthMethod = true;
|
||||
readB(_raw1);
|
||||
readB(_raw2);
|
||||
return true;
|
||||
}
|
||||
else if (super._buf.remaining() >= 128)
|
||||
{
|
||||
readB(_raw1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
byte[] decUser = null;
|
||||
byte[] decPass = null;
|
||||
final L2LoginClient client = getClient();
|
||||
try
|
||||
{
|
||||
final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
|
||||
rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey());
|
||||
decUser = rsaCipher.doFinal(_raw1, 0x00, 0x80);
|
||||
if (_newAuthMethod)
|
||||
{
|
||||
decPass = rsaCipher.doFinal(_raw2, 0x00, 0x80);
|
||||
}
|
||||
}
|
||||
catch (GeneralSecurityException e)
|
||||
{
|
||||
_log.log(Level.INFO, "", e);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_newAuthMethod)
|
||||
{
|
||||
_user = new String(decUser, 0x4E, 0xE).trim().toLowerCase();
|
||||
_password = new String(decPass, 0x5C, 0x10).trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
_user = new String(decUser, 0x5E, 0xE).trim().toLowerCase();
|
||||
_password = new String(decUser, 0x6C, 0x10).trim();
|
||||
}
|
||||
_ncotp = decUser[0x7c];
|
||||
_ncotp |= decUser[0x7d] << 8;
|
||||
_ncotp |= decUser[0x7e] << 16;
|
||||
_ncotp |= decUser[0x7f] << 24;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
return;
|
||||
}
|
||||
|
||||
InetAddress clientAddr = getClient().getConnection().getInetAddress();
|
||||
|
||||
final LoginController lc = LoginController.getInstance();
|
||||
AccountInfo info = lc.retriveAccountInfo(clientAddr, _user, _password);
|
||||
if (info == null)
|
||||
{
|
||||
// user or pass wrong
|
||||
client.close(LoginFailReason.REASON_USER_OR_PASS_WRONG);
|
||||
return;
|
||||
}
|
||||
|
||||
AuthLoginResult result = lc.tryCheckinAccount(client, clientAddr, info);
|
||||
switch (result)
|
||||
{
|
||||
case AUTH_SUCCESS:
|
||||
client.setAccount(info.getLogin());
|
||||
client.setState(LoginClientState.AUTHED_LOGIN);
|
||||
client.setSessionKey(lc.assignSessionKeyToClient(info.getLogin(), client));
|
||||
lc.getCharactersOnAccount(info.getLogin());
|
||||
if (Config.SHOW_LICENCE)
|
||||
{
|
||||
client.sendPacket(new LoginOk(getClient().getSessionKey()));
|
||||
}
|
||||
else
|
||||
{
|
||||
getClient().sendPacket(new ServerList(getClient()));
|
||||
}
|
||||
break;
|
||||
case INVALID_PASSWORD:
|
||||
client.close(LoginFailReason.REASON_USER_OR_PASS_WRONG);
|
||||
break;
|
||||
case ACCOUNT_BANNED:
|
||||
client.close(new AccountKicked(AccountKickedReason.REASON_PERMANENTLY_BANNED));
|
||||
return;
|
||||
case ALREADY_ON_LS:
|
||||
L2LoginClient oldClient = lc.getAuthedClient(info.getLogin());
|
||||
if (oldClient != null)
|
||||
{
|
||||
// kick the other client
|
||||
oldClient.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
|
||||
lc.removeAuthedLoginClient(info.getLogin());
|
||||
}
|
||||
// kick also current client
|
||||
client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
|
||||
break;
|
||||
case ALREADY_ON_GS:
|
||||
GameServerInfo gsi = lc.getAccountOnGameServer(info.getLogin());
|
||||
if (gsi != null)
|
||||
{
|
||||
client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
|
||||
|
||||
// kick from there
|
||||
if (gsi.isAuthed())
|
||||
{
|
||||
gsi.getGameServerThread().kickPlayer(info.getLogin());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.loginserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
|
||||
import com.l2jserver.loginserver.network.serverpackets.ServerList;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Format: ddc
|
||||
* d: fist part of session id
|
||||
* d: second part of session id
|
||||
* c: ?
|
||||
* </pre>
|
||||
*/
|
||||
public class RequestServerList extends L2LoginClientPacket
|
||||
{
|
||||
private int _skey1;
|
||||
private int _skey2;
|
||||
private int _data3;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getSessionKey1()
|
||||
{
|
||||
return _skey1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getSessionKey2()
|
||||
{
|
||||
return _skey2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getData3()
|
||||
{
|
||||
return _data3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readImpl()
|
||||
{
|
||||
if (super._buf.remaining() >= 8)
|
||||
{
|
||||
_skey1 = readD(); // loginOk 1
|
||||
_skey2 = readD(); // loginOk 2
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (getClient().getSessionKey().checkLoginPair(_skey1, _skey2))
|
||||
{
|
||||
getClient().sendPacket(new ServerList(getClient()));
|
||||
}
|
||||
else
|
||||
{
|
||||
getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.loginserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.loginserver.LoginController;
|
||||
import com.l2jserver.loginserver.SessionKey;
|
||||
import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
|
||||
import com.l2jserver.loginserver.network.serverpackets.PlayFail.PlayFailReason;
|
||||
import com.l2jserver.loginserver.network.serverpackets.PlayOk;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Format is ddc
|
||||
* d: first part of session id
|
||||
* d: second part of session id
|
||||
* c: server ID
|
||||
* </pre>
|
||||
*/
|
||||
public class RequestServerLogin extends L2LoginClientPacket
|
||||
{
|
||||
private int _skey1;
|
||||
private int _skey2;
|
||||
private int _serverId;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getSessionKey1()
|
||||
{
|
||||
return _skey1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getSessionKey2()
|
||||
{
|
||||
return _skey2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getServerID()
|
||||
{
|
||||
return _serverId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readImpl()
|
||||
{
|
||||
if (super._buf.remaining() >= 9)
|
||||
{
|
||||
_skey1 = readD();
|
||||
_skey2 = readD();
|
||||
_serverId = readC();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
SessionKey sk = getClient().getSessionKey();
|
||||
|
||||
// if we didnt showed the license we cant check these values
|
||||
if (!Config.SHOW_LICENCE || sk.checkLoginPair(_skey1, _skey2))
|
||||
{
|
||||
if (LoginController.getInstance().isLoginPossible(getClient(), _serverId))
|
||||
{
|
||||
getClient().setJoinedGS(true);
|
||||
getClient().sendPacket(new PlayOk(sk));
|
||||
}
|
||||
else
|
||||
{
|
||||
getClient().close(PlayFailReason.REASON_SERVER_OVERLOADED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user