mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-10 09:22:49 +00:00
GameGuard service implementation
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -21,7 +21,6 @@ import java.util.Set;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
|
||||
import com.l2jserver.game.ProtocolVersion;
|
||||
import com.l2jserver.game.net.codec.Lineage2Decrypter;
|
||||
import com.l2jserver.game.net.codec.Lineage2Encrypter;
|
||||
import com.l2jserver.game.net.codec.Lineage2PacketReader;
|
||||
@@ -189,7 +188,7 @@ public class Lineage2Connection {
|
||||
*
|
||||
* @param version
|
||||
* @return true if version is supported by the client
|
||||
* @see com.l2jserver.game.ProtocolVersion#supports(com.l2jserver.game.ProtocolVersion)
|
||||
* @see com.l2jserver.game.net.ProtocolVersion#supports(com.l2jserver.game.net.ProtocolVersion)
|
||||
*/
|
||||
public boolean supports(ProtocolVersion version) {
|
||||
if (version == null)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.game;
|
||||
package com.l2jserver.game.net;
|
||||
|
||||
/**
|
||||
* Represents the protocol version used by the client
|
||||
@@ -31,7 +31,7 @@ import com.l2jserver.game.net.packet.client.CM_ADMIN_COMMAND;
|
||||
import com.l2jserver.game.net.packet.client.CM_AUTH_LOGIN;
|
||||
import com.l2jserver.game.net.packet.client.CM_CHAR_ACTION;
|
||||
import com.l2jserver.game.net.packet.client.CM_CHAR_APPEARING;
|
||||
import com.l2jserver.game.net.packet.client.CM_CHAR_ATTACK;
|
||||
import com.l2jserver.game.net.packet.client.CM_ATTACK;
|
||||
import com.l2jserver.game.net.packet.client.CM_CHAT;
|
||||
import com.l2jserver.game.net.packet.client.CM_CHAR_CREATE;
|
||||
import com.l2jserver.game.net.packet.client.CM_ACTION_USE;
|
||||
@@ -44,11 +44,11 @@ import com.l2jserver.game.net.packet.client.CM_CHAR_POSITION;
|
||||
import com.l2jserver.game.net.packet.client.CM_ENTER_WORLD;
|
||||
import com.l2jserver.game.net.packet.client.CM_LOGOUT;
|
||||
import com.l2jserver.game.net.packet.client.CM_PROTOCOL_VERSION;
|
||||
import com.l2jserver.game.net.packet.client.CM_REQUEST_ALL_FORTRESS_INFO;
|
||||
import com.l2jserver.game.net.packet.client.CM_EXT_REQ_ALL_FORTRESS_INFO;
|
||||
import com.l2jserver.game.net.packet.client.CM_REQUEST_CHAR_TEMPLATE;
|
||||
import com.l2jserver.game.net.packet.client.CM_GOTO_LOBBY;
|
||||
import com.l2jserver.game.net.packet.client.CM_REQUEST_KEY_MAPPING;
|
||||
import com.l2jserver.game.net.packet.client.CM_REQUEST_MANOR_LIST;
|
||||
import com.l2jserver.game.net.packet.client.CM_EXT_REQ_KEY_MAPPING;
|
||||
import com.l2jserver.game.net.packet.client.CM_EXT_REQ_MANOR_LIST;
|
||||
import com.l2jserver.game.net.packet.client.CM_RESTART;
|
||||
|
||||
/**
|
||||
@@ -139,17 +139,17 @@ public class Lineage2PacketReader extends OneToOneDecoder {
|
||||
return CM_CHAR_CREATE.class;
|
||||
case CM_REQUEST_CHAR_TEMPLATE.OPCODE:
|
||||
return CM_REQUEST_CHAR_TEMPLATE.class;
|
||||
case 0xd0: // COMPOSED
|
||||
case 0xd0: // CM_EXTENDED
|
||||
final int opcode2 = buffer.readUnsignedShort();
|
||||
switch (opcode2) {
|
||||
case CM_GOTO_LOBBY.OPCODE2:
|
||||
return CM_GOTO_LOBBY.class;
|
||||
case CM_REQUEST_KEY_MAPPING.OPCODE2:
|
||||
return CM_REQUEST_KEY_MAPPING.class;
|
||||
case CM_REQUEST_MANOR_LIST.OPCODE2:
|
||||
return CM_REQUEST_MANOR_LIST.class;
|
||||
case CM_REQUEST_ALL_FORTRESS_INFO.OPCODE2:
|
||||
return CM_REQUEST_ALL_FORTRESS_INFO.class;
|
||||
case CM_EXT_REQ_KEY_MAPPING.OPCODE2:
|
||||
return CM_EXT_REQ_KEY_MAPPING.class;
|
||||
case CM_EXT_REQ_MANOR_LIST.OPCODE2:
|
||||
return CM_EXT_REQ_MANOR_LIST.class;
|
||||
case CM_EXT_REQ_ALL_FORTRESS_INFO.OPCODE2:
|
||||
return CM_EXT_REQ_ALL_FORTRESS_INFO.class;
|
||||
default:
|
||||
logger.warn("Unknown opcode2 for 0xd0: 0x{}",
|
||||
Integer.toHexString(opcode2));
|
||||
@@ -182,8 +182,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
|
||||
return CM_ACTION_USE.class;
|
||||
case CM_CHAR_OPEN_MAP.OPCODE:
|
||||
return CM_CHAR_OPEN_MAP.class;
|
||||
case CM_CHAR_ATTACK.OPCODE:
|
||||
return CM_CHAR_ATTACK.class;
|
||||
case CM_ATTACK.OPCODE:
|
||||
return CM_ATTACK.class;
|
||||
default:
|
||||
logger.warn("Unknown opcode: 0x{}", Integer.toHexString(opcode));
|
||||
break;
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.l2jserver.util.geometry.Coordinate;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CM_CHAR_ATTACK extends AbstractClientPacket {
|
||||
public class CM_ATTACK extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ public class CM_CHAR_ATTACK extends AbstractClientPacket {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public CM_CHAR_ATTACK(CharacterService charService,
|
||||
public CM_ATTACK(CharacterService charService,
|
||||
ObjectIDResolver idResolver) {
|
||||
this.charService = charService;
|
||||
this.idResolver = idResolver;
|
||||
@@ -27,7 +27,7 @@ import com.l2jserver.game.net.packet.server.SM_FORT_INFO;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CM_REQUEST_ALL_FORTRESS_INFO extends AbstractClientPacket {
|
||||
public class CM_EXT_REQ_ALL_FORTRESS_INFO extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
@@ -26,7 +26,7 @@ import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CM_REQUEST_KEY_MAPPING extends AbstractClientPacket {
|
||||
public class CM_EXT_REQ_KEY_MAPPING extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
@@ -27,7 +27,7 @@ import com.l2jserver.game.net.packet.server.SM_MANOR_LIST;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CM_REQUEST_MANOR_LIST extends AbstractClientPacket {
|
||||
public class CM_EXT_REQ_MANOR_LIST extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
@@ -29,7 +29,7 @@ import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CM_REQUEST_SHORTCUT_REGISTRY extends AbstractClientPacket {
|
||||
public class CM_EXT_REQ_SHORTCUT_REGISTRY extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ public class CM_REQUEST_SHORTCUT_REGISTRY extends AbstractClientPacket {
|
||||
* The logger
|
||||
*/
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(CM_REQUEST_SHORTCUT_REGISTRY.class);
|
||||
.getLogger(CM_EXT_REQ_SHORTCUT_REGISTRY.class);
|
||||
|
||||
/**
|
||||
* The shortcut type
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver 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.
|
||||
*
|
||||
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.game.net.packet.client;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.service.network.gameguard.GameGuardService;
|
||||
|
||||
/**
|
||||
* The client is requesting a logout. Currently, when this packet is received
|
||||
* the connection is immediately closed.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CM_GG_KEY extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
public static final int OPCODE = 0x00;
|
||||
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private static final Logger log = LoggerFactory.getLogger(CM_GG_KEY.class);
|
||||
|
||||
/**
|
||||
* The {@link GameGuardService}
|
||||
*/
|
||||
private final GameGuardService ggService;
|
||||
|
||||
/**
|
||||
* The Game guard authentication key
|
||||
*/
|
||||
private byte[] key = new byte[8];
|
||||
|
||||
@Inject
|
||||
public CM_GG_KEY(GameGuardService ggService) {
|
||||
this.ggService = ggService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
byte[] part1 = buffer.readBytes(4).array();
|
||||
buffer.readInt();
|
||||
byte[] part2 = buffer.readBytes(4).array();
|
||||
|
||||
// create a single key array
|
||||
System.arraycopy(part1, 0, key, 0, 4);
|
||||
System.arraycopy(part2, 0, key, 4, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
log.debug("Received GG key");
|
||||
switch (ggService.key(conn, key)) {
|
||||
case INVALID:
|
||||
log.warn("Client {} sent an invalid GG key", conn);
|
||||
// if key is invalid, disconnect client
|
||||
conn.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.L2JConstant;
|
||||
import com.l2jserver.game.ProtocolVersion;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.Lineage2CryptographyKey;
|
||||
import com.l2jserver.game.net.ProtocolVersion;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.game.net.packet.server.SM_KEY;
|
||||
import com.l2jserver.service.network.keygen.BlowfishKeygenService;
|
||||
|
||||
@@ -56,6 +56,13 @@ import com.l2jserver.util.BufferUtils;
|
||||
/**
|
||||
* This is an message informing the client of an given player
|
||||
*
|
||||
* <pre>
|
||||
* (c) dddddSddddQdddddddddddddddddddddddddddddddddddddddddddddddddd
|
||||
* ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
|
||||
* fdfdfdfddddSdddddcccddh[h]cdcdhhdhddddccdcccddddcdddddhhhhhhhdddd
|
||||
* d
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SM_CHAR_INFO extends AbstractServerPacket {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.l2jserver.game.net.packet.server;
|
||||
|
||||
import static com.l2jserver.game.ProtocolVersion.FREYA;
|
||||
import static com.l2jserver.game.net.ProtocolVersion.FREYA;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.BELT;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.CHEST;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.CLOAK;
|
||||
|
||||
@@ -28,6 +28,10 @@ import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
* This packet send the encryptation keys for the client. After this message all
|
||||
* communication is done with the cryptography engine enabled.
|
||||
*
|
||||
* <pre>
|
||||
* (c) cbddcd
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SM_KEY extends AbstractServerPacket {
|
||||
|
||||
Reference in New Issue
Block a user