├── .dockerignore ├── .editorconfig ├── .gitattributes ├── .gitignore ├── Jenkinsfile ├── LICENSE ├── README.md ├── clank-diagram.png ├── clank-logo.png ├── clank.bat ├── clank.sh ├── config ├── README.md ├── dme.json.example ├── mas.json.example ├── mls.json.example ├── monolith.json.example ├── muis.json.example └── nat.json.example ├── docker ├── README.md ├── clank-dev.dockerfile ├── clank.dockerfile └── settings.sh ├── plugins └── README.md ├── pom.xml └── src └── main ├── java └── net │ └── hashsploit │ └── clank │ ├── Clank.java │ ├── Config.java │ ├── EmulationMode.java │ ├── EventBus.java │ ├── EventType.java │ ├── HexDump.java │ ├── ITriggerableEvent.java │ ├── Main.java │ ├── Terminal.java │ ├── cli │ ├── AnsiColor.java │ ├── ICLICommand.java │ ├── ICLIEvent.java │ ├── ICLIInvalidCommand.java │ └── commands │ │ ├── CLIBroadcastCommand.java │ │ ├── CLIExitCommand.java │ │ ├── CLIHelpCommand.java │ │ ├── CLIPlayersCommand.java │ │ ├── CLIPluginsCommand.java │ │ └── CLIVersionCommand.java │ ├── config │ ├── AbstractConfig.java │ ├── configs │ │ ├── DmeConfig.java │ │ ├── MasConfig.java │ │ ├── MediusConfig.java │ │ ├── MlsConfig.java │ │ ├── MpsConfig.java │ │ ├── MuisConfig.java │ │ └── NatConfig.java │ └── objects │ │ ├── DatabaseInfo.java │ │ └── ServerInfo.java │ ├── database │ ├── DbManager.java │ ├── IDatabase.java │ ├── MariaDb.java │ └── SimDb.java │ ├── events │ ├── ConnectEvent.java │ └── TickEvent.java │ ├── plugin │ ├── ClankEvent.java │ ├── ClankLib.java │ ├── IClankPlugin.java │ ├── LuaChunk.java │ ├── LuaPlugin.java │ └── PluginManager.java │ ├── rt │ ├── RtMessageHandler.java │ ├── RtPacketMap.java │ ├── handlers │ │ ├── RtMsgClientAppToServer.java │ │ ├── RtMsgClientConnectTcp.java │ │ ├── RtMsgClientCryptKeyPublicHandler.java │ │ ├── RtMsgClientDisconnect.java │ │ ├── RtMsgClientEcho.java │ │ ├── RtMsgClientHello.java │ │ ├── RtMsgServerApp.java │ │ └── RtMsgServerCryptKeyPeerHandler.java │ └── serializers │ │ ├── RT_ClientAppToServer.java │ │ ├── RT_ClientConnectTcp.java │ │ ├── RT_ClientConnectTcpAuxUdp.java │ │ ├── RT_ClientCryptKeyPublic.java │ │ ├── RT_ClientEcho.java │ │ ├── RT_ClientHello.java │ │ ├── RT_ServerApp.java │ │ ├── RT_ServerConnectAcceptTcp.java │ │ ├── RT_ServerConnectComplete.java │ │ ├── RT_ServerCryptKeyGame.java │ │ └── RT_ServerCryptKeyPeer.java │ ├── server │ ├── AbstractServer.java │ ├── ApplicationIds.java │ ├── ChatColor.java │ ├── ClientState.java │ ├── GameList.java │ ├── IClient.java │ ├── IRTMessage.java │ ├── IServer.java │ ├── MediusClient.java │ ├── MediusClientChannelInitializer.java │ ├── MediusGame.java │ ├── Player.java │ ├── RTMessage.java │ ├── RtMessageId.java │ ├── TcpServer.java │ ├── UdpServer.java │ ├── dme │ │ ├── DMEInitStatus.java │ │ ├── DmePlayer.java │ │ ├── DmeServer.java │ │ ├── DmeTcpClient.java │ │ ├── DmeTcpClientInitializer.java │ │ ├── DmeUdpClient.java │ │ ├── DmeUdpClientInitializer.java │ │ ├── DmeUdpServer.java │ │ ├── DmeWorld.java │ │ └── DmeWorldManager.java │ ├── medius │ │ ├── IMediusSerializableObject.java │ │ ├── MediusAuthenticationServer.java │ │ ├── MediusCallbackStatus.java │ │ ├── MediusConstants.java │ │ ├── MediusLobbyServer.java │ │ ├── MediusMessageType.java │ │ ├── MediusPacketHandler.java │ │ ├── MediusServer.java │ │ ├── handlers │ │ │ ├── MediusAccountGetIdHandler.java │ │ │ ├── MediusAccountLoginHandler.java │ │ │ ├── MediusAccountLogoutHandler.java │ │ │ ├── MediusAccountRegistrationHandler.java │ │ │ ├── MediusAccountUpdateStatsHandler.java │ │ │ ├── MediusAddToBuddyListHandler.java │ │ │ ├── MediusChannelInfoHandler.java │ │ │ ├── MediusChannelListHandler.java │ │ │ ├── MediusChannelList_ExtraInfoOneHandler.java │ │ │ ├── MediusChatMessageHandler.java │ │ │ ├── MediusChatToggleHandler.java │ │ │ ├── MediusCheckMyClanInvitationsHandler.java │ │ │ ├── MediusClearGameListFilterZeroHandler.java │ │ │ ├── MediusCreateClanHandler.java │ │ │ ├── MediusCreateGameOneHandler.java │ │ │ ├── MediusDnasSignaturePostHandler.java │ │ │ ├── MediusEndGameReportHandler.java │ │ │ ├── MediusFindPlayerHandler.java │ │ │ ├── MediusFindWorldByNameHandler.java │ │ │ ├── MediusGameInfoZeroHandler.java │ │ │ ├── MediusGameListHandler.java │ │ │ ├── MediusGameList_ExtraInfoZeroHandler.java │ │ │ ├── MediusGameWorldPlayerListHandler.java │ │ │ ├── MediusGetAllAnnouncementsHandler.java │ │ │ ├── MediusGetAnnouncementsHandler.java │ │ │ ├── MediusGetBuddyInvitationsHandler.java │ │ │ ├── MediusGetBuddyList_ExtraInfoHandler.java │ │ │ ├── MediusGetClanInvitationsSentHandler.java │ │ │ ├── MediusGetClanMemberList_ExtraInfoHandler.java │ │ │ ├── MediusGetIgnoreListHandler.java │ │ │ ├── MediusGetLadderStatsWideHandler.java │ │ │ ├── MediusGetLobbyPlayerNames_ExtraInfoHandler.java │ │ │ ├── MediusGetLocationsHandler.java │ │ │ ├── MediusGetMyClanMessagesHandler.java │ │ │ ├── MediusGetMyClansHandler.java │ │ │ ├── MediusGetMyIPHandler.java │ │ │ ├── MediusGetUniverseInformationHandler.java │ │ │ ├── MediusGetWorldSecurityLevelHandler.java │ │ │ ├── MediusJoinChannelHandler.java │ │ │ ├── MediusJoinGameHandler.java │ │ │ ├── MediusLadderList_ExtraInfoHandler.java │ │ │ ├── MediusLadderPositionHandler.java │ │ │ ├── MediusLadderPosition_ExtraInfoHandler.java │ │ │ ├── MediusLobbyWorldPlayerListHandler.java │ │ │ ├── MediusPickLocationHandler.java │ │ │ ├── MediusPlayerInfoHandler.java │ │ │ ├── MediusPlayerReportHandler.java │ │ │ ├── MediusPolicyHandler.java │ │ │ ├── MediusServerAuthenticationHandler.java │ │ │ ├── MediusServerSessionBeginHandler.java │ │ │ ├── MediusSessionBeginHandler.java │ │ │ ├── MediusSessionEndHandler.java │ │ │ ├── MediusSetGameListFilterZeroHandler.java │ │ │ ├── MediusSetLobbyWorldFilterHandler.java │ │ │ ├── MediusSetLocalizationParamsHandler.java │ │ │ ├── MediusTextFilterHandler.java │ │ │ ├── MediusUpdateLadderStatsWideHandler.java │ │ │ ├── MediusUpdateUserStateHandler.java │ │ │ ├── MediusVersionServerHandler.java │ │ │ └── MediusWorldReportZeroHandler.java │ │ ├── objects │ │ │ ├── BillingServiceProvider.java │ │ │ ├── Channel.java │ │ │ ├── Clan.java │ │ │ ├── DmePlayerStatus.java │ │ │ ├── GameHostType.java │ │ │ ├── Location.java │ │ │ ├── MediusAccountType.java │ │ │ ├── MediusApplicationType.java │ │ │ ├── MediusBuddyAddType.java │ │ │ ├── MediusChatMessageType.java │ │ │ ├── MediusClanInvitationResponseStatus.java │ │ │ ├── MediusConnectionType.java │ │ │ ├── MediusFindWorldType.java │ │ │ ├── MediusGameHostType.java │ │ │ ├── MediusMessage.java │ │ │ ├── MediusPlayerOnlineState.java │ │ │ ├── MediusPlayerSearchType.java │ │ │ ├── MediusPlayerStatus.java │ │ │ ├── MediusSortOrder.java │ │ │ ├── MediusWorldSecurityLevelType.java │ │ │ ├── MediusWorldStatus.java │ │ │ ├── NetAddress.java │ │ │ ├── NetAddressList.java │ │ │ ├── NetAddressType.java │ │ │ ├── NetConnectionInfo.java │ │ │ ├── NetConnectionType.java │ │ │ └── TextFilterType.java │ │ └── serializers │ │ │ ├── AccountGetIdRequest.java │ │ │ ├── AccountGetIdResponse.java │ │ │ ├── AccountLoginRequest.java │ │ │ ├── AccountLoginResponse.java │ │ │ ├── AccountLogoutRequest.java │ │ │ ├── AccountLogoutResponse.java │ │ │ ├── AccountRegistrationRequest.java │ │ │ ├── AccountRegistrationResponse.java │ │ │ ├── AccountUpdateStatsRequest.java │ │ │ ├── AccountUpdateStatsResponse.java │ │ │ ├── AddToBuddyListRequest.java │ │ │ ├── AddToBuddyListResponse.java │ │ │ ├── ChannelInfoRequest.java │ │ │ ├── ChannelInfoResponse.java │ │ │ ├── ChannelListRequest.java │ │ │ ├── ChannelListResponse.java │ │ │ ├── ChannelList_ExtraInfoOneRequest.java │ │ │ ├── ChannelList_ExtraInfoOneResponse.java │ │ │ ├── ChatFwdMessageResponse.java │ │ │ ├── ChatMessageRequest.java │ │ │ ├── ChatToggleRequest.java │ │ │ ├── ChatToggleResponse.java │ │ │ ├── CheckMyClanInvitationsRequest.java │ │ │ ├── CheckMyClanInvitationsResponse.java │ │ │ ├── ClearGameListFilterResponse.java │ │ │ ├── ClearGameListFilterZeroRequest.java │ │ │ ├── CreateClanRequest.java │ │ │ ├── CreateClanResponse.java │ │ │ ├── CreateGameOneRequest.java │ │ │ ├── CreateGameResponse.java │ │ │ ├── DnasSignaturePostRequest.java │ │ │ ├── FindPlayerRequest.java │ │ │ ├── FindPlayerResponse.java │ │ │ ├── FindWorldByNameRequest.java │ │ │ ├── FindWorldByNameResponse.java │ │ │ ├── GameInfoResponseZero.java │ │ │ ├── GameInfoZeroRequest.java │ │ │ ├── GameListRequest.java │ │ │ ├── GameListResponse.java │ │ │ ├── GameList_ExtraInfoZeroRequest.java │ │ │ ├── GameList_ExtraInfoZeroResponse.java │ │ │ ├── GameWorldPlayerListRequest.java │ │ │ ├── GameWorldPlayerListResponse.java │ │ │ ├── GenericChatFwdMessageResponse.java │ │ │ ├── GetAllAnnouncementsRequest.java │ │ │ ├── GetAnnouncementsRequest.java │ │ │ ├── GetAnnouncementsResponse.java │ │ │ ├── GetBuddyInvitationsRequest.java │ │ │ ├── GetBuddyInvitationsResponse.java │ │ │ ├── GetLobbyPlayerNames_ExtraInfoRequest.java │ │ │ ├── GetLobbyPlayerNames_ExtraInfoResponse.java │ │ │ ├── GetMyIPRequest.java │ │ │ ├── GetMyIPResponse.java │ │ │ ├── GetUniverseInformationRequest.java │ │ │ ├── GetUniverseInformationResponse.java │ │ │ ├── GetWorldSecurityLevelRequest.java │ │ │ ├── GetWorldSecurityLevelResponse.java │ │ │ ├── JoinGameRequest.java │ │ │ ├── JoinGameResponse.java │ │ │ ├── LadderList_ExtraInfoRequest.java │ │ │ ├── LadderList_ExtraInfoResponse.java │ │ │ ├── LadderPositionRequest.java │ │ │ ├── LadderPositionResponse.java │ │ │ ├── LadderPosition_ExtraInfoRequest.java │ │ │ ├── LadderPosition_ExtraInfoResponse.java │ │ │ ├── LobbyWorldPlayerListRequest.java │ │ │ ├── LobbyWorldPlayerListResponse.java │ │ │ ├── PickLocationRequest.java │ │ │ ├── PickLocationResponse.java │ │ │ ├── PlayerInfoRequest.java │ │ │ ├── PlayerInfoResponse.java │ │ │ ├── PlayerReportRequest.java │ │ │ ├── ServerAuthenticationRequest.java │ │ │ ├── ServerAuthenticationResponse.java │ │ │ ├── ServerSessionBeginRequest.java │ │ │ ├── ServerSessionBeginResponse.java │ │ │ ├── SessionEndRequest.java │ │ │ ├── SessionEndResponse.java │ │ │ ├── SetLocalizationParamsRequest.java │ │ │ ├── SetLocalizationParamsResponse.java │ │ │ ├── VersionServerRequest.java │ │ │ ├── VersionServerResponse.java │ │ │ └── WorldReportZeroRequest.java │ ├── muis │ │ ├── MediusUniverseInformationServer.java │ │ └── UniverseInfo.java │ ├── nat │ │ ├── NatClient.java │ │ ├── NatClientInitializer.java │ │ └── NatServer.java │ ├── pipeline │ │ ├── MasHandler.java │ │ ├── MlsHandler.java │ │ ├── MuisHandler.java │ │ ├── NatHandler.java │ │ ├── RtDecryptionHandler.java │ │ ├── RtEncryptionHandler.java │ │ ├── RtFrameDecoderHandler.java │ │ ├── RtFrameEncoderHandler.java │ │ ├── TestHandlerDmeTcp.java │ │ ├── TestHandlerDmeUdp.java │ │ ├── TestHandlerMAS.java │ │ ├── TestHandlerMLS.java │ │ ├── TestHandlerMUIS.java │ │ └── TimeoutHandler.java │ ├── rpc │ │ ├── AbstractRpcServer.java │ │ ├── ClankDmeRpcClient.java │ │ ├── ClankMasRpcClient.java │ │ ├── ClankMlsRpcServer.java │ │ ├── RpcConfig.java │ │ └── RpcServerConfig.java │ └── scert │ │ ├── ISCERTObject.java │ │ ├── SCERTConstants.java │ │ ├── SCERTObject.java │ │ └── objects │ │ ├── RTMsgEncodingType.java │ │ └── RTMsgLanguageType.java │ └── utils │ ├── FileHelper.java │ ├── MathHelper.java │ ├── MediusMessageMapInitializer.java │ ├── RtBuffer.java │ ├── RtBufferDeframer.java │ ├── Timer.java │ └── Utils.java └── proto └── clank_mls_service.proto /.dockerignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | bin/ 3 | target/ 4 | clank.jar 5 | LICENSE 6 | *.md 7 | *.bat 8 | 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Matches multiple files with brace expansion notation 7 | [*.{java,sh,bat,dockerfile,proto,lua,json,xml}] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | charset = utf-8 11 | indent_style = tab 12 | indent_size = 4 13 | 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh linguist-language=Shell 2 | *.bat linguist-language=Batchfile 3 | *.java linguist-language=Java 4 | *.proto linguist-language=Protocol_Buffer 5 | Dockerfile linguist-language=Dockerfile 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE files 2 | .classpath 3 | .project 4 | .settings/ 5 | 6 | # Configs 7 | config/* 8 | !config/*.json.example 9 | 10 | # Logs 11 | logs/ 12 | 13 | # Custom plugins (closed-source) 14 | !plugins/README.md 15 | plugins/* 16 | 17 | # Bins 18 | target/ 19 | bin/ 20 | clank.jar 21 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | stages { 4 | stage('Build') { 5 | steps { 6 | sh './build.sh' 7 | } 8 | } 9 | 10 | stage('Artifact') { 11 | steps { 12 | archiveArtifacts 'clank.jar' 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 hashsploit 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /clank-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hashsploit/clank/eb637c2fd65114044f5bcbd624eae7d7ec828d67/clank-diagram.png -------------------------------------------------------------------------------- /clank-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hashsploit/clank/eb637c2fd65114044f5bcbd624eae7d7ec828d67/clank-logo.png -------------------------------------------------------------------------------- /config/dme.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "DME_SERVER", 3 | "log_level": "INFO", 4 | "file_log_level": null, 5 | "address": null, 6 | "udp_address": null, 7 | "port": 10079, 8 | "udp_port": 50001, 9 | "encryption": true, 10 | "capacity": 200, 11 | "timeout": 15000, 12 | "parent_threads": 1, 13 | "child_threads": 4, 14 | "udp_threads": 8, 15 | "application_id": 10684, 16 | "rpc": { 17 | "address": "127.0.0.1", 18 | "port": 8484 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /config/mas.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "MEDIUS_AUTHENTICATION_SERVER", 3 | "log_level": "INFO", 4 | "file_log_level": null, 5 | "address": null, 6 | "port": 10075, 7 | "encryption": true, 8 | "capacity": 200, 9 | "timeout": 15000, 10 | "parent_threads": 1, 11 | "child_threads": 4, 12 | "max_login_attempts": 20, 13 | "max_accounts_per_ip": 6, 14 | "username_blacklist": null, 15 | "application_id": 10684, 16 | "mls": { 17 | "address": "0.0.0.0", 18 | "port": 10078 19 | }, 20 | "nat": { 21 | "address": "0.0.0.0", 22 | "port": 10077 23 | }, 24 | "whitelist": { 25 | "enabled": true, 26 | "players": { 27 | "exampleUsername": "examplePassword", 28 | "hashsploit": "hashpass", 29 | "fourbolt": "fourpass" 30 | } 31 | }, 32 | "channels": [ 33 | { 34 | "id": 1, 35 | "name": "Channel 1", 36 | "capacity": 256 37 | }, 38 | { 39 | "id": 2, 40 | "name": "Channel 2", 41 | "capacity": 256 42 | }, 43 | { 44 | "id": 3, 45 | "name": "Channel 3", 46 | "capacity": 256 47 | }, 48 | { 49 | "id": 4, 50 | "name": "Channel 4", 51 | "capacity": 256 52 | } 53 | ], 54 | "locations": [ 55 | { 56 | "id": 1, 57 | "name": "Location 1" 58 | }, 59 | { 60 | "id": 2, 61 | "name": "Location 2" 62 | } 63 | ], 64 | "system_message": { 65 | "enabled": false, 66 | "severity": 200, 67 | "message": "" 68 | }, 69 | "rpc": { 70 | "address": "127.0.0.1", 71 | "port": 8484 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /config/mls.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "MEDIUS_LOBBY_SERVER", 3 | "log_level": "INFO", 4 | "file_log_level": null, 5 | "address": null, 6 | "port": 10078, 7 | "encryption": true, 8 | "capacity": 200, 9 | "timeout": 15000, 10 | "parent_threads": 1, 11 | "child_threads": 4, 12 | "application_id": 10684, 13 | "nat": { 14 | "address": "0.0.0.0", 15 | "port": 10070 16 | }, 17 | "dme": { 18 | "address": "0.0.0.0", 19 | "port": 10079 20 | }, 21 | "rpc_server": { 22 | "address": "127.0.0.1", 23 | "port": 8484, 24 | "encryption": { 25 | "enabled": false, 26 | "cert_chain": null, 27 | "private_key": null 28 | } 29 | }, 30 | "policy": "Welcome, this is the default policy for the clank server emulator. \r\n\r\nhttps://github.com/hashsploit/clank", 31 | "announcements": [ 32 | "This is an announcement." 33 | ], 34 | "operators": [ 35 | "hashsploit", 36 | "fourbolt" 37 | ], 38 | "chat": { 39 | "enabled": true, 40 | "blacklist": "blacklisted_words.txt", 41 | "command_prefix": "/", 42 | "strip_special_chars": true 43 | }, 44 | "channels": [ 45 | { 46 | "id": 1, 47 | "name": "Channel 1", 48 | "capacity": 256 49 | }, 50 | { 51 | "id": 2, 52 | "name": "Channel 2", 53 | "capacity": 256 54 | }, 55 | { 56 | "id": 3, 57 | "name": "Channel 3", 58 | "capacity": 256 59 | }, 60 | { 61 | "id": 4, 62 | "name": "Channel 4", 63 | "capacity": 256 64 | } 65 | ], 66 | "locations": [ 67 | { 68 | "id": 1, 69 | "name": "Location 1" 70 | }, 71 | { 72 | "id": 2, 73 | "name": "Location 2" 74 | } 75 | ], 76 | "system_message": { 77 | "enabled": false, 78 | "severity": 200, 79 | "message": "" 80 | }, 81 | "database": { 82 | "mode": "", 83 | "host": "", 84 | "database": "", 85 | "username": "", 86 | "password": "" 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /config/muis.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "MEDIUS_UNIVERSE_INFORMATION_SERVER", 3 | "log_level": "INFO", 4 | "file_log_level": null, 5 | "address": null, 6 | "port": 10071, 7 | "encryption": true, 8 | "capacity": 200, 9 | "timeout": 15000, 10 | "parent_threads": 1, 11 | "child_threads": 4, 12 | "universes": [ 13 | { 14 | "application_id": 11184, 15 | "name": "R&C DL Production", 16 | "description": "Ratchet: Deadlocked Production", 17 | "universe_id": 1, 18 | "hostname": "ratchetdl-prod.pdonline.scea.com", 19 | "port": 10075 20 | }, 21 | { 22 | "application_id": 10994, 23 | "name": "Jak X NTSC Production", 24 | "description": "Jak X: Combat Racing US", 25 | "universe_id": 1, 26 | "hostname": "jakx-prod.muis.pdonline.scea.com", 27 | "port": 10075 28 | }, 29 | { 30 | "application_id": 11204, 31 | "name": "Jak X PAL Production", 32 | "description": "Jak X: Combat Racing EU", 33 | "universe_id": 2, 34 | "hostname": "jakx-palmaster.muis.online.scee.com", 35 | "port": 10075 36 | }, 37 | { 38 | "application_id": 10724, 39 | "name": "Killzone Production", 40 | "description": "Killzone Production US", 41 | "universe_id": 1, 42 | "hostname": "killzone-prod.muis.pdonline.scea.com", 43 | "port": 10075 44 | } 45 | ], 46 | "rpc": { 47 | "address": "127.0.0.1", 48 | "port": 8484 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /config/nat.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "NAT_SERVER", 3 | "log_level": "INFO", 4 | "file_log_level": null, 5 | "address": null, 6 | "port": 10070, 7 | "udp_threads": 4 8 | } 9 | -------------------------------------------------------------------------------- /docker/settings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # GraalVM (JVM) source code 4 | GRAALVM_SOURCE="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0.2/graalvm-ce-java11-linux-amd64-21.0.0.2.tar.gz" 5 | 6 | # This is for aarch64 (ARM) hardware 7 | if [[ "$(uname -i)" =~ .*aarch64* ]]; then 8 | GRAALVM_SOURCE="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0.2/graalvm-ce-java11-linux-aarch64-21.0.0.2.tar.gz" 9 | fi 10 | 11 | # Maven source code 12 | MAVEN_SOURCE="https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz" 13 | 14 | # CI Builds Server 15 | CI_SERVER="https://ci.arcadiamc.cz/job/clank/job/master/lastSuccessfulBuild/artifact/clank.jar" 16 | 17 | -------------------------------------------------------------------------------- /plugins/README.md: -------------------------------------------------------------------------------- 1 | # Clank Plugins 2 | 3 | See [https://github.com/hashsploit/clank-plugins](https://github.com/hashsploit/clank-plugins) for trusted plugins, examples, and more. -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/Config.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank; 2 | 3 | import org.json.JSONObject; 4 | 5 | public abstract class Config { 6 | 7 | private JSONObject json; 8 | 9 | public Config(JSONObject json) { 10 | this.json = json; 11 | } 12 | 13 | public JSONObject getJSON() { 14 | return json; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/EmulationMode.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | /** 6 | * The server mode in which Clank is currently running as. 7 | * 8 | * @author hashsploit 9 | * 10 | */ 11 | public enum EmulationMode { 12 | 13 | /** 14 | * Handles universe information synchronization component. 15 | */ 16 | @SerializedName("MEDIUS_UNIVERSE_INFORMATION_SERVER") 17 | MEDIUS_UNIVERSE_INFORMATION_SERVER(1), 18 | 19 | /** 20 | * Handles player login and token authentication. 21 | */ 22 | @SerializedName("MEDIUS_AUTHENTICATION_SERVER") 23 | MEDIUS_AUTHENTICATION_SERVER(2), 24 | 25 | /** 26 | * Handles out-of-game lobby, chat, clan and player management. 27 | */ 28 | @SerializedName("MEDIUS_LOBBY_SERVER") 29 | MEDIUS_LOBBY_SERVER(4), 30 | 31 | /** 32 | * NAT server component. 33 | */ 34 | @SerializedName("NAT_SERVER") 35 | NAT_SERVER(8), 36 | 37 | /** 38 | * DME server component. 39 | */ 40 | @SerializedName("DME_SERVER") 41 | DME_SERVER(16); 42 | 43 | private final int value; 44 | 45 | EmulationMode(final int value) { 46 | this.value = value; 47 | } 48 | 49 | public int getValue() { 50 | return value; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/EventBus.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank; 2 | 3 | import java.util.HashMap; 4 | import java.util.HashSet; 5 | 6 | public class EventBus { 7 | 8 | private Clank clank; 9 | private HashMap> events; 10 | 11 | public EventBus(Clank clank) { 12 | this.clank = clank; 13 | } 14 | 15 | public void subscribe(EventType type) { 16 | 17 | } 18 | 19 | public void unsubscribe(EventType type) { 20 | 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/EventType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank; 2 | 3 | public enum EventType { 4 | 5 | /** 6 | * A normal update event. 7 | */ 8 | TICK_EVENT, 9 | 10 | /** 11 | * A client connected. 12 | */ 13 | CONNECT_EVENT, 14 | 15 | /** 16 | * A client disconnected or timed out. 17 | */ 18 | DISCONNECT_EVENT 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/ITriggerableEvent.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank; 2 | 3 | public interface ITriggerableEvent { 4 | 5 | public void fire(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/cli/ICLICommand.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.cli; 2 | 3 | import net.hashsploit.clank.Terminal; 4 | 5 | public interface ICLICommand { 6 | 7 | /** 8 | * The command name that identifies this command that will be invoked 9 | */ 10 | public String commandName(); 11 | 12 | /** 13 | * The description of this command, use NULL for no description 14 | */ 15 | public String commandDescription(); 16 | 17 | /** 18 | * This method is a callback from when the command name gets invoked 19 | * 20 | * @param command parameters 21 | */ 22 | public void invoke(Terminal term, String[] params); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/cli/ICLIEvent.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.cli; 2 | 3 | public interface ICLIEvent { 4 | 5 | /** 6 | * On user interrupt [SIGTERM] (such as ^C) 7 | */ 8 | public void userInterruptEvent(); 9 | 10 | /** 11 | * On End-Of-File/Line (such as ^D) 12 | */ 13 | public void eofInterruptEvent(); 14 | 15 | /** 16 | * Called whenever any command is invoked 17 | */ 18 | public void onReturnEvent(String line); 19 | 20 | /** 21 | * Called whenever a valid command is invoked 22 | */ 23 | public void onCommandEvent(String command, String[] params, ICLICommand handler); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/cli/ICLIInvalidCommand.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.cli; 2 | 3 | public interface ICLIInvalidCommand { 4 | 5 | /** 6 | * The command that was invoked but not found 7 | */ 8 | public void invalidInvoke(String command, String[] params); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/cli/commands/CLIExitCommand.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.cli.commands; 2 | 3 | import net.hashsploit.clank.Clank; 4 | import net.hashsploit.clank.Terminal; 5 | import net.hashsploit.clank.cli.ICLICommand; 6 | 7 | public class CLIExitCommand implements ICLICommand { 8 | 9 | @Override 10 | public void invoke(Terminal term, String[] params) { 11 | Clank.getInstance().shutdown(); 12 | } 13 | 14 | @Override 15 | public String commandName() { 16 | return "exit"; 17 | } 18 | 19 | @Override 20 | public String commandDescription() { 21 | return "Shutdown the server."; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/cli/commands/CLIHelpCommand.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.cli.commands; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import net.hashsploit.clank.Terminal; 6 | import net.hashsploit.clank.cli.AnsiColor; 7 | import net.hashsploit.clank.cli.ICLICommand; 8 | 9 | public class CLIHelpCommand implements ICLICommand { 10 | 11 | private static final Logger logger = Logger.getLogger(""); 12 | 13 | @Override 14 | public void invoke(Terminal term, String[] params) { 15 | if (params.length == 1) { 16 | for (ICLICommand c : term.getRegisteredCommands()) { 17 | if (c.commandName().equalsIgnoreCase(params[1])) { 18 | logger.info("---- Help for '" + c.commandName() + "' ----"); 19 | logger.info(String.format(Terminal.colorize(AnsiColor.GREEN + "%s" + AnsiColor.RESET + " - " + AnsiColor.GOLD + "%s" + AnsiColor.RESET), c.commandName(), c.commandDescription())); 20 | } 21 | } 22 | return; 23 | } 24 | logger.info("---- Help Commands ----"); 25 | for (ICLICommand c : term.getRegisteredCommands()) { 26 | logger.info(String.format(Terminal.colorize(AnsiColor.GREEN + "%s" + AnsiColor.RESET + " - " + AnsiColor.GOLD + "%s" + AnsiColor.RESET), c.commandName(), c.commandDescription())); 27 | } 28 | } 29 | 30 | @Override 31 | public String commandName() { 32 | return "help"; 33 | } 34 | 35 | @Override 36 | public String commandDescription() { 37 | return "Show a list of commands."; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/cli/commands/CLIVersionCommand.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.cli.commands; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import net.hashsploit.clank.Clank; 6 | import net.hashsploit.clank.Terminal; 7 | import net.hashsploit.clank.cli.ICLICommand; 8 | 9 | public class CLIVersionCommand implements ICLICommand { 10 | 11 | private static final Logger logger = Logger.getLogger(""); 12 | 13 | @Override 14 | public void invoke(Terminal term, String[] params) { 15 | logger.info(String.format("This server is running %s v%s (implementing %s)", Clank.NAME, Clank.VERSION, Clank.getInstance().getConfig().getEmulationMode().name())); 16 | } 17 | 18 | @Override 19 | public String commandName() { 20 | return "version"; 21 | } 22 | 23 | @Override 24 | public String commandDescription() { 25 | return "Show the current server version."; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/AbstractConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.google.gson.annotations.SerializedName; 5 | import net.hashsploit.clank.EmulationMode; 6 | import net.hashsploit.clank.config.objects.ServerInfo; 7 | 8 | import java.util.logging.Level; 9 | 10 | public class AbstractConfig extends ServerInfo { 11 | 12 | private JsonObject jsonObject; 13 | 14 | @SerializedName("mode") 15 | private EmulationMode emulationMode; 16 | 17 | @SerializedName("log_level") 18 | private String logLevel = "INFO"; 19 | 20 | @SerializedName("file_log_level") 21 | private String fileLogLevel = null; 22 | 23 | public JsonObject getJsonObject() { 24 | return jsonObject; 25 | } 26 | 27 | public EmulationMode getEmulationMode() { 28 | return emulationMode; 29 | } 30 | 31 | // TODO: Log4J 32 | public Level getLogLevel() { 33 | return logLevel != null ? Level.parse(logLevel) : null; 34 | } 35 | 36 | // TODO: Log4J 37 | public Level getFileLogLevel() { 38 | return fileLogLevel != null ? Level.parse(fileLogLevel) : null; 39 | } 40 | 41 | public void setJsonObject(JsonObject jsonObject) { 42 | this.jsonObject = jsonObject; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/configs/DmeConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.configs; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | import net.hashsploit.clank.config.AbstractConfig; 5 | import net.hashsploit.clank.config.objects.ServerInfo; 6 | 7 | public class DmeConfig extends AbstractConfig { 8 | 9 | @SerializedName("parent_threads") 10 | private int parentThreads = 1; 11 | 12 | @SerializedName("child_threads") 13 | private int childThreads = 4; 14 | 15 | @SerializedName("timeout") 16 | private int timeout = 0; 17 | 18 | @SerializedName("capacity") 19 | private int capacity = 100; 20 | 21 | @SerializedName("udp_threads") 22 | private int udpThreads = 0; 23 | 24 | @SerializedName("udp_address") 25 | private String udpAddress = null; 26 | 27 | @SerializedName("udp_port") 28 | private int udpPort = 0; 29 | 30 | @SerializedName("rpc") 31 | private ServerInfo rpcConfig = new ServerInfo(); 32 | 33 | public int getParentThreads() { 34 | return parentThreads; 35 | } 36 | 37 | public int getChildThreads() { 38 | return childThreads; 39 | } 40 | 41 | public int getTimeout() { 42 | return timeout; 43 | } 44 | 45 | public int getCapacity() { 46 | return capacity; 47 | } 48 | 49 | public int getUdpThreads() { 50 | return udpThreads; 51 | } 52 | 53 | public String getUdpAddress() { 54 | return udpAddress; 55 | } 56 | 57 | public int getUdpPort() { 58 | return udpPort; 59 | } 60 | 61 | public ServerInfo getRpcConfig() { 62 | return rpcConfig; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/configs/MasConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.configs; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | import net.hashsploit.clank.config.objects.ServerInfo; 5 | import net.hashsploit.clank.server.medius.objects.Channel; 6 | import net.hashsploit.clank.server.medius.objects.Location; 7 | 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | 12 | public class MasConfig extends MediusConfig { 13 | 14 | @SerializedName("mls") 15 | private ServerInfo mlsConfig = new ServerInfo(); 16 | 17 | @SerializedName("whitelist") 18 | private Whitelist whitelist = new Whitelist(); 19 | 20 | @SerializedName("channels") 21 | private List channels = new ArrayList<>(); 22 | 23 | @SerializedName("locations") 24 | private List locations = new ArrayList<>(); 25 | 26 | public ServerInfo getMlsConfig() { 27 | return mlsConfig; 28 | } 29 | 30 | public Whitelist getWhitelist() { 31 | return whitelist; 32 | } 33 | 34 | public List getChannels() { 35 | return channels; 36 | } 37 | 38 | public List getLocations() { 39 | return locations; 40 | } 41 | 42 | public static class Whitelist { 43 | 44 | @SerializedName("enabled") 45 | private boolean enabled = false; 46 | 47 | @SerializedName("players") 48 | private HashMap players = new HashMap<>(); 49 | 50 | public boolean isEnabled() { 51 | return enabled; 52 | } 53 | 54 | public HashMap getPlayers() { 55 | return players; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/configs/MediusConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.configs; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | import net.hashsploit.clank.config.AbstractConfig; 5 | import net.hashsploit.clank.config.objects.ServerInfo; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class MediusConfig extends AbstractConfig { 11 | 12 | @SerializedName("encryption") 13 | private boolean encrypted = false; 14 | 15 | @SerializedName("parent_threads") 16 | private int parentThreads = 1; 17 | 18 | @SerializedName("child_threads") 19 | private int childThreads = 4; 20 | 21 | @SerializedName("capacity") 22 | private int capacity = 100; 23 | 24 | @SerializedName("nat") 25 | private ServerInfo natConfig = new ServerInfo(); 26 | 27 | @SerializedName("rpc") 28 | private ServerInfo rpcConfig = new ServerInfo(); 29 | 30 | @SerializedName("policy") 31 | private String policy = ""; 32 | 33 | @SerializedName("announcements") 34 | private List announcements = new ArrayList<>(); 35 | 36 | public boolean isEncrypted() { 37 | return encrypted; 38 | } 39 | 40 | public int getParentThreads() { 41 | return parentThreads; 42 | } 43 | 44 | public int getChildThreads() { 45 | return childThreads; 46 | } 47 | 48 | public int getCapacity() { 49 | return capacity; 50 | } 51 | 52 | public ServerInfo getNatConfig() { 53 | return natConfig; 54 | } 55 | 56 | public ServerInfo getRpcConfig() { 57 | return rpcConfig; 58 | } 59 | 60 | public String getPolicy() { 61 | return policy; 62 | } 63 | 64 | public List getAnnouncements() { 65 | return announcements; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/configs/MlsConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.configs; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | import net.hashsploit.clank.config.objects.DatabaseInfo; 5 | import net.hashsploit.clank.config.objects.ServerInfo; 6 | import net.hashsploit.clank.server.medius.objects.Channel; 7 | import net.hashsploit.clank.server.medius.objects.Location; 8 | import net.hashsploit.clank.server.rpc.RpcServerConfig; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class MlsConfig extends MediusConfig { 14 | 15 | @SerializedName("dme") 16 | private ServerInfo dmeConfig = new ServerInfo(); 17 | 18 | @SerializedName("operators") 19 | private List operators = new ArrayList<>(); 20 | 21 | @SerializedName("channels") 22 | private List channels = new ArrayList<>(); 23 | 24 | @SerializedName("locations") 25 | private List locations = new ArrayList<>(); 26 | 27 | @SerializedName("database") 28 | private DatabaseInfo databaseInfo = new DatabaseInfo(); 29 | 30 | @SerializedName("rpc_server") 31 | private RpcServerConfig rpcServerConfig = new RpcServerConfig(); 32 | 33 | public ServerInfo getDmeConfig() { 34 | return dmeConfig; 35 | } 36 | 37 | public List getOperators() { 38 | return operators; 39 | } 40 | 41 | public List getChannels() { 42 | return channels; 43 | } 44 | 45 | public List getLocations() { 46 | return locations; 47 | } 48 | 49 | public DatabaseInfo getDatabaseInfo() { 50 | return databaseInfo; 51 | } 52 | 53 | public RpcServerConfig getRpcServerConfig() { 54 | return rpcServerConfig; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/configs/MpsConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.configs; 2 | 3 | 4 | public class MpsConfig extends MediusConfig { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/configs/MuisConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.configs; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | import net.hashsploit.clank.server.muis.UniverseInfo; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class MuisConfig extends MediusConfig { 10 | 11 | @SerializedName("universes") 12 | private List universes = new ArrayList<>(); 13 | 14 | public List getUniverseInformation() { 15 | return universes; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/configs/NatConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.configs; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | import net.hashsploit.clank.config.AbstractConfig; 5 | 6 | public class NatConfig extends AbstractConfig { 7 | 8 | @SerializedName("udp_threads") 9 | private int udpThreads = 0; 10 | 11 | public int getUdpThreads() { 12 | return udpThreads; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/objects/DatabaseInfo.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.objects; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class DatabaseInfo { 6 | 7 | @SerializedName("mode") 8 | private String mode = "MariaDb"; 9 | 10 | @SerializedName("host") 11 | private String host = "127.0.0.1"; 12 | 13 | @SerializedName("database") 14 | private String database = "clank"; 15 | 16 | @SerializedName("username") 17 | private String username = "root"; 18 | 19 | @SerializedName("password") 20 | private String password = null; 21 | 22 | public String getHost() { 23 | return host; 24 | } 25 | 26 | public String getDatabase() { 27 | return database; 28 | } 29 | 30 | public String getUsername() { 31 | return username; 32 | } 33 | 34 | public String getPassword() { 35 | return password; 36 | } 37 | 38 | public String getMode() { 39 | return mode; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/config/objects/ServerInfo.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.config.objects; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class ServerInfo { 6 | 7 | @SerializedName("address") 8 | private String address = null; 9 | 10 | @SerializedName("port") 11 | private int port = 0; 12 | 13 | public String getAddress() { 14 | return address; 15 | } 16 | 17 | public int getPort() { 18 | return port; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "ServerInfo{" + 24 | "address='" + address + '\'' + 25 | ", port=" + port + 26 | '}'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/database/IDatabase.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.database; 2 | 3 | import java.sql.ResultSet; 4 | 5 | public interface IDatabase { 6 | 7 | String generateSessionKey(); 8 | 9 | int validateAccount(String sessionKey, String username, String password); 10 | 11 | String generateMlsToken(int accountId); 12 | 13 | boolean validateMlsAccessToken(String mlsToken); 14 | 15 | int getAccountIdFromSessionKey(String sessionKey); 16 | 17 | String getUsername(int accountId); 18 | 19 | String getStats(int accountId); 20 | 21 | void setStats(int accountId, String stats); 22 | 23 | void setLadderStatsWide(Integer accountId, String stats); 24 | 25 | String getLadderStatsWide(int accountId); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/events/ConnectEvent.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.events; 2 | 3 | import net.hashsploit.clank.EventType; 4 | import net.hashsploit.clank.plugin.ClankEvent; 5 | 6 | public class ConnectEvent extends ClankEvent { 7 | 8 | private final String ipAddress; 9 | private final int port; 10 | 11 | public ConnectEvent(String ipAddress, int port) { 12 | super(EventType.CONNECT_EVENT); 13 | this.ipAddress = ipAddress; 14 | this.port = port; 15 | } 16 | 17 | /** 18 | * Incoming client connection from this IP Address. 19 | * @return 20 | */ 21 | public String getIpAddress() { 22 | return ipAddress; 23 | } 24 | 25 | /** 26 | * Incoming client connection from this port. 27 | * @return 28 | */ 29 | public int getPort() { 30 | return port; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/events/TickEvent.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.events; 2 | 3 | import net.hashsploit.clank.EventType; 4 | import net.hashsploit.clank.plugin.ClankEvent; 5 | 6 | public class TickEvent extends ClankEvent { 7 | 8 | public TickEvent() { 9 | super(EventType.TICK_EVENT); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/plugin/ClankEvent.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.plugin; 2 | 3 | import net.hashsploit.clank.EventType; 4 | 5 | public abstract class ClankEvent { 6 | 7 | private EventType type; 8 | 9 | public ClankEvent(EventType type) { 10 | this.type = type; 11 | } 12 | 13 | public EventType getType() { 14 | return type; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/plugin/IClankPlugin.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.plugin; 2 | 3 | import java.util.HashSet; 4 | 5 | import net.hashsploit.clank.EventType; 6 | import net.hashsploit.clank.cli.ICLICommand; 7 | 8 | public interface IClankPlugin { 9 | 10 | /** 11 | * Get the plugin name. 12 | * @return 13 | */ 14 | public String getName(); 15 | 16 | /** 17 | * Get the plugin version as a string. 18 | * @return 19 | */ 20 | public String getVersion(); 21 | 22 | /** 23 | * Get the plugin version revision 0.0.x. 24 | * @return 25 | */ 26 | public int getVersionRevision(); 27 | 28 | /** 29 | * Get the plugin version minor 0.x.0. 30 | * @return 31 | */ 32 | public int getVersionMinor(); 33 | 34 | /** 35 | * Get the plugin version major x.0.0. 36 | * @return 37 | */ 38 | public int getVersionMajor(); 39 | 40 | /** 41 | * Get the plugin description. 42 | * @return 43 | */ 44 | public String getDescription(); 45 | 46 | /** 47 | * Plugin initialization function 48 | */ 49 | public void init(); 50 | 51 | /** 52 | * Get all the CLI commands this plugin registers. 53 | * @return 54 | */ 55 | public HashSet getRegisteredCommands(); 56 | 57 | /** 58 | * Get all the clank event types this plugin subscribes to. 59 | * @return 60 | */ 61 | public HashSet getRegisteredEventTypes(); 62 | 63 | /** 64 | * Plugin event call. 65 | */ 66 | public void onEvent(ClankEvent event); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/RtMessageHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt; 2 | 3 | import java.util.List; 4 | import java.util.logging.Logger; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | import net.hashsploit.clank.server.MediusClient; 8 | import net.hashsploit.clank.server.RTMessage; 9 | import net.hashsploit.clank.server.RtMessageId; 10 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 11 | 12 | public abstract class RtMessageHandler { 13 | 14 | protected static final Logger logger = Logger.getLogger(MediusPacketHandler.class.getName()); 15 | private final RtMessageId id; 16 | 17 | public RtMessageHandler(final RtMessageId id) { 18 | this.id = id; 19 | } 20 | 21 | /** 22 | * Get the RT message type. 23 | * @return 24 | */ 25 | public RtMessageId getId() { 26 | return id; 27 | } 28 | 29 | /** 30 | * This method is called on when a message should be handled to be read by the server. 31 | * @param buffer 32 | */ 33 | public abstract void read(final ByteBuf buffer); 34 | 35 | /** 36 | * This method is called on when a message should be sent back to the client. 37 | * @return 38 | */ 39 | public abstract List write(MediusClient client); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/RtPacketMap.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt; 2 | 3 | import java.util.HashMap; 4 | 5 | import net.hashsploit.clank.rt.handlers.RtMsgClientAppToServer; 6 | import net.hashsploit.clank.rt.handlers.RtMsgClientConnectTcp; 7 | import net.hashsploit.clank.rt.handlers.RtMsgClientCryptKeyPublicHandler; 8 | import net.hashsploit.clank.rt.handlers.RtMsgClientDisconnect; 9 | import net.hashsploit.clank.rt.handlers.RtMsgClientEcho; 10 | import net.hashsploit.clank.rt.handlers.RtMsgClientHello; 11 | import net.hashsploit.clank.rt.handlers.RtMsgServerCryptKeyPeerHandler; 12 | import net.hashsploit.clank.server.RtMessageId; 13 | 14 | public class RtPacketMap { 15 | 16 | // Prevent instantiation 17 | private RtPacketMap() {} 18 | 19 | /** 20 | * This builds a static-mapping of RT message types to corresponding RT handlers. 21 | * 22 | * @param client 23 | * @return 24 | */ 25 | public static HashMap buildRtPacketMap() { 26 | final HashMap mp = new HashMap(); 27 | 28 | mp.put(RtMessageId.CLIENT_HELLO, new RtMsgClientHello()); 29 | 30 | mp.put(RtMessageId.CLIENT_CONNECT_TCP, new RtMsgClientConnectTcp()); 31 | mp.put(RtMessageId.CLIENT_DISCONNECT, new RtMsgClientDisconnect()); 32 | 33 | 34 | mp.put(RtMessageId.CLIENT_CRYPTKEY_PUBLIC, new RtMsgClientCryptKeyPublicHandler()); 35 | mp.put(RtMessageId.SERVER_CRYPTKEY_PEER, new RtMsgServerCryptKeyPeerHandler()); 36 | 37 | mp.put(RtMessageId.CLIENT_APP_TOSERVER, new RtMsgClientAppToServer()); 38 | 39 | mp.put(RtMessageId.CLIENT_ECHO, new RtMsgClientEcho()); 40 | 41 | return mp; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/handlers/RtMsgClientDisconnect.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.handlers; 2 | 3 | import java.util.List; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import net.hashsploit.clank.rt.RtMessageHandler; 7 | import net.hashsploit.clank.server.MediusClient; 8 | import net.hashsploit.clank.server.RTMessage; 9 | import net.hashsploit.clank.server.RtMessageId; 10 | 11 | public class RtMsgClientDisconnect extends RtMessageHandler { 12 | 13 | public RtMsgClientDisconnect() { 14 | super(RtMessageId.CLIENT_DISCONNECT); 15 | } 16 | 17 | @Override 18 | public void read(ByteBuf buffer) { 19 | 20 | } 21 | 22 | @Override 23 | public List write(MediusClient client) { 24 | 25 | return null; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/handlers/RtMsgClientEcho.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | import net.hashsploit.clank.rt.RtMessageHandler; 8 | import net.hashsploit.clank.rt.serializers.RT_ClientEcho; 9 | import net.hashsploit.clank.server.MediusClient; 10 | import net.hashsploit.clank.server.RTMessage; 11 | import net.hashsploit.clank.server.RtMessageId; 12 | 13 | public class RtMsgClientEcho extends RtMessageHandler { 14 | 15 | private RT_ClientEcho reqPacket; 16 | 17 | public RtMsgClientEcho() { 18 | super(RtMessageId.CLIENT_ECHO); 19 | } 20 | 21 | @Override 22 | public void read(ByteBuf buffer) { 23 | reqPacket = new RT_ClientEcho(buffer); 24 | } 25 | 26 | @Override 27 | public List write(MediusClient client) { 28 | List responses = new ArrayList(); 29 | responses.add(reqPacket); 30 | return responses; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/handlers/RtMsgClientHello.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | import net.hashsploit.clank.rt.RtMessageHandler; 8 | import net.hashsploit.clank.rt.serializers.RT_ClientHello; 9 | import net.hashsploit.clank.server.MediusClient; 10 | import net.hashsploit.clank.server.RTMessage; 11 | import net.hashsploit.clank.server.RtMessageId; 12 | 13 | public class RtMsgClientHello extends RtMessageHandler { 14 | 15 | private RT_ClientHello reqPacket; 16 | 17 | public RtMsgClientHello() { 18 | super(RtMessageId.CLIENT_HELLO); 19 | } 20 | 21 | @Override 22 | public void read(ByteBuf buffer) { 23 | reqPacket = new RT_ClientHello(buffer); 24 | } 25 | 26 | @Override 27 | public List write(MediusClient client) { 28 | List responses = new ArrayList(); 29 | responses.add(reqPacket); 30 | return responses; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/handlers/RtMsgServerApp.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | import net.hashsploit.clank.rt.RtMessageHandler; 8 | import net.hashsploit.clank.rt.serializers.RT_ServerApp; 9 | import net.hashsploit.clank.server.MediusClient; 10 | import net.hashsploit.clank.server.RTMessage; 11 | import net.hashsploit.clank.server.RtMessageId; 12 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 13 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 14 | 15 | public class RtMsgServerApp extends RtMessageHandler { 16 | 17 | private RT_ServerApp reqPacket; 18 | 19 | public RtMsgServerApp() { 20 | super(RtMessageId.SERVER_APP); 21 | } 22 | 23 | @Override 24 | public void read(ByteBuf buffer) { 25 | reqPacket = new RT_ServerApp(buffer); 26 | } 27 | 28 | @Override 29 | public List write(MediusClient client) { 30 | 31 | List responses = new ArrayList(); 32 | 33 | // Detect which medius packet is being parsed 34 | MediusPacketHandler mediusPacket = client.getMediusMessageMap().get(reqPacket.getMediusMessageType()); 35 | 36 | // Process this medius packet 37 | mediusPacket.read(client, new MediusMessage(reqPacket.getMediusPayload())); 38 | mediusPacket.write(client); 39 | 40 | return responses; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/handlers/RtMsgServerCryptKeyPeerHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.handlers; 2 | 3 | import java.util.List; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import net.hashsploit.clank.rt.RtMessageHandler; 7 | import net.hashsploit.clank.rt.serializers.RT_ServerCryptKeyPeer; 8 | import net.hashsploit.clank.server.MediusClient; 9 | import net.hashsploit.clank.server.RTMessage; 10 | import net.hashsploit.clank.server.RtMessageId; 11 | 12 | public class RtMsgServerCryptKeyPeerHandler extends RtMessageHandler { 13 | 14 | private RT_ServerCryptKeyPeer reqPacket; 15 | 16 | 17 | public RtMsgServerCryptKeyPeerHandler() { 18 | super(RtMessageId.SERVER_CRYPTKEY_PEER); 19 | } 20 | 21 | @Override 22 | public void read(ByteBuf buffer) { 23 | reqPacket = new RT_ServerCryptKeyPeer(buffer); 24 | } 25 | 26 | @Override 27 | public List write(MediusClient client) { 28 | 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ClientAppToServer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.hashsploit.clank.server.RTMessage; 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | 8 | public class RT_ClientAppToServer extends RTMessage { 9 | 10 | private final MediusMessageType type; 11 | private final byte[] mediusPayload; 12 | 13 | public RT_ClientAppToServer(ByteBuf payload) { 14 | super(payload); 15 | type = MediusMessageType.getTypeByShort(payload.readShortLE()); 16 | mediusPayload = new byte[MediusConstants.MEDIUS_MESSAGE_MAXLEN.value]; 17 | payload.readBytes(mediusPayload, 0, payload.readableBytes()); 18 | } 19 | 20 | /** 21 | * Returns the Medius message type. 22 | * @return 23 | */ 24 | public MediusMessageType getMediusMessageType() { 25 | return type; 26 | } 27 | 28 | /** 29 | * Returns the Medius payload without the Medius message type. 30 | * @return 31 | */ 32 | public byte[] getMediusPayload() { 33 | return mediusPayload; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ClientConnectTcp.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.hashsploit.clank.server.RTMessage; 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.utils.Utils; 7 | 8 | public class RT_ClientConnectTcp extends RTMessage { 9 | 10 | private byte[] unknown; // 0108 for UYA 11 | private int appId; 12 | private int targetWorldId; 13 | private byte[] key; 14 | private byte[] sessionKey; 15 | private byte[] accessToken; 16 | 17 | public RT_ClientConnectTcp(ByteBuf payload) { 18 | super(payload); 19 | 20 | payload.readShort(); // the unknown short (0108 for UYA) 21 | payload.readByte(); // extra byte 22 | targetWorldId = (int) payload.readShortLE(); 23 | appId = payload.readIntLE(); 24 | key = new byte[64]; // TODO: Make this a constant 25 | payload.readBytes(key); 26 | 27 | if (payload.readerIndex() < this.getLength()) { 28 | sessionKey = Utils.nettyByteBufToByteArray(payload.readBytes(MediusConstants.SESSIONKEY_MAXLEN.value)); 29 | accessToken = Utils.nettyByteBufToByteArray(payload.readBytes(MediusConstants.ACCESSKEY_MAXLEN.value)); 30 | } 31 | } 32 | 33 | 34 | @Override 35 | public String toString() { 36 | return Utils.generateDebugPacketString(RT_ClientConnectTcp.class.getName(), 37 | new String[] { 38 | "key" 39 | }, 40 | new String[] { 41 | Utils.bytesToHex(key) 42 | } 43 | ); 44 | } 45 | 46 | 47 | public int getTargetWorldId() { 48 | return targetWorldId; 49 | } 50 | 51 | 52 | public int getAppId() { 53 | return appId; 54 | } 55 | 56 | 57 | public byte[] getKey() { 58 | return key; 59 | } 60 | 61 | 62 | public byte[] getSessionKey() { 63 | return sessionKey; 64 | } 65 | 66 | 67 | public byte[] getAccessToken() { 68 | return accessToken; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ClientConnectTcpAuxUdp.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.hashsploit.clank.server.RTMessage; 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.utils.Utils; 7 | 8 | public class RT_ClientConnectTcpAuxUdp extends RTMessage { 9 | 10 | private byte[] unknown; // 0108 for UYA 11 | private int appId; 12 | private int targetWorldId; 13 | private byte[] key; 14 | private byte[] sessionKey; 15 | private byte[] accessToken; 16 | 17 | public RT_ClientConnectTcpAuxUdp(ByteBuf payload) { 18 | super(payload); 19 | 20 | payload.readShort(); // the unknown short (0108 for UYA) 21 | payload.readByte(); // extra byte 22 | targetWorldId = (int) payload.readShortLE(); 23 | appId = payload.readIntLE(); 24 | key = new byte[64]; // TODO: Make this a constant 25 | payload.readBytes(key); 26 | if (payload.readerIndex() < this.getLength()) { 27 | sessionKey = Utils.nettyByteBufToByteArray(payload.readBytes(MediusConstants.SESSIONKEY_MAXLEN.value)); 28 | accessToken = Utils.nettyByteBufToByteArray(payload.readBytes(MediusConstants.ACCESSKEY_MAXLEN.value)); 29 | } 30 | } 31 | 32 | public byte[] getUnknown() { 33 | return unknown; 34 | } 35 | 36 | public int getAppId() { 37 | return appId; 38 | } 39 | 40 | public int getTargetWorldId() { 41 | return targetWorldId; 42 | } 43 | 44 | public byte[] getKey() { 45 | return key; 46 | } 47 | 48 | public byte[] getSessionKey() { 49 | return sessionKey; 50 | } 51 | 52 | public byte[] getAccessToken() { 53 | return accessToken; 54 | } 55 | 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ClientCryptKeyPublic.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.hashsploit.clank.server.RTMessage; 5 | import net.hashsploit.clank.utils.Utils; 6 | 7 | public class RT_ClientCryptKeyPublic extends RTMessage { 8 | 9 | private static final int RSA_KEY_SIZE = 64; 10 | private final byte[] key; 11 | 12 | public RT_ClientCryptKeyPublic(ByteBuf payload) { 13 | super(payload); 14 | key = new byte[RSA_KEY_SIZE]; 15 | payload.readBytes(key); 16 | } 17 | 18 | /** 19 | * Returns the RSA key the client sent to us encrypted. 20 | * @return 21 | */ 22 | public byte[] getRSAKey() { 23 | return key; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return Utils.generateDebugPacketString(RT_ClientCryptKeyPublic.class.getName(), 29 | new String[] { 30 | "key" 31 | }, 32 | new String[] { 33 | Utils.bytesToHex(key) 34 | } 35 | ); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ClientEcho.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.hashsploit.clank.server.RTMessage; 5 | 6 | public class RT_ClientEcho extends RTMessage { 7 | 8 | private final byte heartbeat; 9 | 10 | public RT_ClientEcho(ByteBuf payload) { 11 | super(payload); 12 | heartbeat = payload.readByte(); 13 | } 14 | 15 | /** 16 | * Returns the heartbeat payload. 17 | * @return 18 | */ 19 | public byte getHeartbeat() { 20 | return heartbeat; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ClientHello.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | import net.hashsploit.clank.server.RTMessage; 6 | import net.hashsploit.clank.server.RtMessageId; 7 | 8 | import io.netty.channel.ChannelHandlerContext; 9 | import io.netty.channel.ChannelInboundHandlerAdapter; 10 | 11 | public class RT_ClientHello extends RTMessage { 12 | 13 | public RT_ClientHello(ByteBuf payload) { 14 | super(RtMessageId.SERVER_HELLO); //Sends back 0x25, but doesn't give the proper response. Needs Fixing. 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ServerApp.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.hashsploit.clank.server.RTMessage; 5 | import net.hashsploit.clank.server.RtMessageId; 6 | import net.hashsploit.clank.server.medius.MediusConstants; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | 9 | public class RT_ServerApp extends RTMessage { 10 | 11 | private final MediusMessageType type; 12 | private final byte[] mediusPayload; 13 | 14 | public RT_ServerApp(ByteBuf payload) { 15 | super(RtMessageId.SERVER_APP, payload.readableBytes(), payload); 16 | type = MediusMessageType.getTypeByShort(payload.readShortLE()); 17 | mediusPayload = new byte[MediusConstants.MEDIUS_MESSAGE_MAXLEN.value]; 18 | payload.readBytes(mediusPayload, 0, payload.readableBytes()); 19 | } 20 | 21 | /** 22 | * Returns the Medius message type. 23 | * @return 24 | */ 25 | public MediusMessageType getMediusMessageType() { 26 | return type; 27 | } 28 | 29 | /** 30 | * Returns the Medius payload without the Medius message type. 31 | * @return 32 | */ 33 | public byte[] getMediusPayload() { 34 | return mediusPayload; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ServerConnectAcceptTcp.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | import net.hashsploit.clank.server.RTMessage; 6 | import net.hashsploit.clank.server.RtMessageId; 7 | import net.hashsploit.clank.utils.Utils; 8 | 9 | public class RT_ServerConnectAcceptTcp extends RTMessage { 10 | 11 | private final short unk00; 12 | private final int unk02; 13 | private final short unk06; 14 | private final String ipAddress; 15 | 16 | public RT_ServerConnectAcceptTcp(ByteBuf payload) { 17 | super(RtMessageId.SERVER_CONNECT_ACCEPT_TCP, payload.readableBytes(), payload); 18 | unk00 = payload.readShortLE(); 19 | unk02 = payload.readIntLE(); 20 | unk06 = payload.readByte(); 21 | 22 | final byte[] ipAddrBytes = new byte[16]; 23 | 24 | payload.readBytes(ipAddrBytes); 25 | ipAddress = Utils.bytesToStringClean(ipAddrBytes); 26 | } 27 | 28 | public static RT_ServerConnectAcceptTcp build(short unk00, int unk02, byte unk06, String ipAddress) { 29 | ByteBuf buffer = Unpooled.buffer(); 30 | buffer.writeShortLE(unk00); 31 | buffer.writeIntLE(unk02); 32 | buffer.writeByte(unk06); // TODO: this is a short in 1.9+ 33 | buffer.writeBytes(Utils.buildByteArrayFromString(ipAddress, 16)); 34 | return new RT_ServerConnectAcceptTcp(buffer); 35 | } 36 | 37 | /** 38 | * Get the ip address 39 | * @return 40 | */ 41 | public String getIpAddress() { 42 | return ipAddress; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return Utils.generateDebugPacketString(RT_ServerConnectAcceptTcp.class.getName(), 48 | new String[] { 49 | "unk00", 50 | "unk02", 51 | "unk06", 52 | "ipAddress" 53 | }, 54 | new String[] { 55 | "" + unk00, 56 | "" + unk02, 57 | "" + unk06, 58 | ipAddress 59 | } 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ServerConnectComplete.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | import net.hashsploit.clank.server.RTMessage; 6 | import net.hashsploit.clank.server.RtMessageId; 7 | import net.hashsploit.clank.utils.Utils; 8 | 9 | public class RT_ServerConnectComplete extends RTMessage { 10 | 11 | private final short unk00; 12 | 13 | public RT_ServerConnectComplete(ByteBuf payload) { 14 | super(RtMessageId.SERVER_CONNECT_COMPLETE, payload.readableBytes(), payload); 15 | unk00 = payload.readShortLE(); 16 | } 17 | 18 | public static RT_ServerConnectComplete build(short unk00) { 19 | ByteBuf buffer = Unpooled.buffer(2); 20 | buffer.writeShortLE(unk00); 21 | return new RT_ServerConnectComplete(buffer); 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return Utils.generateDebugPacketString(RT_ServerConnectComplete.class.getName(), 27 | new String[] { 28 | "unk00" 29 | }, 30 | new String[] { 31 | "" + unk00 32 | } 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ServerCryptKeyGame.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | import net.hashsploit.clank.server.RTMessage; 6 | import net.hashsploit.clank.server.RtMessageId; 7 | import net.hashsploit.clank.utils.Utils; 8 | 9 | public class RT_ServerCryptKeyGame extends RTMessage { 10 | 11 | private final byte[] serverKey; 12 | 13 | public RT_ServerCryptKeyGame(ByteBuf payload) { 14 | super(RtMessageId.SERVER_CRYPTKEY_GAME, payload.readableBytes(), payload); 15 | serverKey = new byte[64]; 16 | payload.readBytes(serverKey); 17 | } 18 | 19 | public static RT_ServerCryptKeyGame build(byte[] serverKey) { 20 | ByteBuf payload = Unpooled.wrappedBuffer(serverKey); 21 | return new RT_ServerCryptKeyGame(payload); 22 | } 23 | 24 | /** 25 | * Returns the key that will be sent back to the 26 | * @return 27 | */ 28 | public byte[] getServerKey() { 29 | return serverKey; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return Utils.generateDebugPacketString(RT_ServerCryptKeyGame.class.getName(), 35 | new String[] { 36 | "serverKey" 37 | }, 38 | new String[] { 39 | Utils.bytesToHex(serverKey) 40 | } 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/rt/serializers/RT_ServerCryptKeyPeer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.rt.serializers; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.hashsploit.clank.server.RTMessage; 5 | import net.hashsploit.clank.server.RtMessageId; 6 | import net.hashsploit.clank.utils.Utils; 7 | 8 | public class RT_ServerCryptKeyPeer extends RTMessage { 9 | 10 | private static final int RC_KEY_SIZE = 64; 11 | private byte[] key; 12 | 13 | public RT_ServerCryptKeyPeer(ByteBuf payload) { 14 | super(RtMessageId.SERVER_CRYPTKEY_PEER, payload.readableBytes(), payload); 15 | key = new byte[RC_KEY_SIZE]; 16 | payload.readBytes(key); 17 | } 18 | 19 | /** 20 | * Returns the key that will be sent back to the 21 | * @return 22 | */ 23 | public byte[] getRCKey() { 24 | return key; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return Utils.generateDebugPacketString(RT_ServerCryptKeyPeer.class.getName(), 30 | new String[] { 31 | "key" 32 | }, 33 | new String[] { 34 | Utils.bytesToHex(key) 35 | } 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/AbstractServer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server; 2 | 3 | import java.util.HashSet; 4 | import java.util.logging.Logger; 5 | 6 | public abstract class AbstractServer implements IServer { 7 | 8 | private static final Logger logger = Logger.getLogger(AbstractServer.class.getName()); 9 | 10 | private final String address; 11 | private final int port; 12 | private HashSet clients; 13 | 14 | public AbstractServer(final String address, final int port) { 15 | this.port = port; 16 | this.clients = new HashSet(); 17 | 18 | if (address == null || address.isEmpty()) { 19 | this.address = "0.0.0.0"; 20 | } else { 21 | this.address = address; 22 | } 23 | 24 | } 25 | 26 | /** 27 | * Start this server. 28 | */ 29 | public void start() { 30 | 31 | } 32 | 33 | /** 34 | * Shutdown this server. 35 | */ 36 | public void stop() { 37 | clients.clear(); 38 | } 39 | 40 | /** 41 | * Get the address this server is bound to. 42 | */ 43 | public String getAddress() { 44 | return address; 45 | } 46 | 47 | /** 48 | * Get the port number this server is running on. 49 | * 50 | * @return 51 | */ 52 | public int getPort() { 53 | return port; 54 | } 55 | 56 | /** 57 | * Get all the clients. 58 | * 59 | * @return 60 | */ 61 | @Override 62 | public HashSet getClients() { 63 | return clients; 64 | } 65 | 66 | /** 67 | * Add a client to the total clients. 68 | * 69 | * @param client 70 | */ 71 | @Override 72 | public void addClient(IClient client) { 73 | clients.add(client); 74 | } 75 | 76 | /** 77 | * Remove a client from the total clients. 78 | * 79 | * @param client 80 | */ 81 | @Override 82 | public void removeClient(IClient client) { 83 | clients.remove(client); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/ApplicationIds.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server; 2 | 3 | public enum ApplicationIds { 4 | 5 | /** 6 | * Amplitude (March 24, 2003) 7 | * Medius ?.?? 8 | * NTSC 9 | */ 10 | AMPLITUDE_NTSC(0), 11 | 12 | /** 13 | * Syphon Filter: The Omega Strain (May 4, 2004) 14 | * Medius 1.08 15 | * NTSC 16 | */ 17 | SYPHON_FILTER_THE_OMEGA_STRAIN_NTSC(10411), 18 | 19 | /** 20 | * Ratchet & Clank: Up Your Arsenal (November 3, 2004) 21 | * Medius 1.08 22 | * PAL 23 | */ 24 | RATCHET_AND_CLANK_UYA_PAL(10683), 25 | 26 | /** 27 | * Ratchet & Clank: Up Your Arsenal (November 3, 2004) 28 | * Medius 1.08 29 | * NTSC 30 | */ 31 | RATCHET_AND_CLANK_UYA_NTSC(10684), 32 | 33 | /** 34 | * Gran Turismo 4 (December 28, 2004) 35 | * Medius 1.10 36 | * NTSC 37 | */ 38 | GRAN_TURISMO_4_BETA_NTSC(10782), 39 | 40 | /** 41 | * Jak X: Combat Racing (October 18, 2005) 42 | * Medius 1.09 43 | * NTSC 44 | */ 45 | JAK_X_COMBAT_RACING_NTSC(10994), 46 | 47 | /** 48 | * Ratchet: Deadlocked (October 25, 2005) 49 | * Medius 1.10 50 | * NTSC 51 | */ 52 | RATCHET_DEADLOCKED_NTSC(11184), 53 | 54 | /** 55 | * Ratchet: Deadlocked (October 25, 2005) 56 | * Medius 1.10 57 | * PAL 58 | */ 59 | RATCHET_DEADLOCKED_PAL(0), 60 | 61 | /** 62 | * Jak X: Combat Racing (November 4, 2005) 63 | * Medius 1.09 64 | * PAL 65 | */ 66 | JAK_X_COMBAT_RACING_PAL(11204); 67 | 68 | 69 | 70 | private final int value; 71 | 72 | private ApplicationIds(int value) { 73 | this.value = value; 74 | } 75 | 76 | public final int getValue() { 77 | return value; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/ClientState.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server; 2 | 3 | /** 4 | * A bitmask of possible "flags" or "states" a client has on the server-side. 5 | * For example, a client can be AUTHENTICATED and THROTTLED at the same time. 6 | * 7 | * @author hashsploit 8 | * 9 | */ 10 | public enum ClientState { 11 | 12 | /** 13 | * Client is not authenticated and is not in the process of authenticating. 14 | */ 15 | UNAUTHENTICATED(1), 16 | 17 | /** 18 | * Client is in the process of authenticating. 19 | */ 20 | AUTHENTICATING(2), 21 | 22 | /** 23 | * Client has successfully authenticated. 24 | */ 25 | AUTHENTICATED(4), 26 | 27 | /** 28 | * Client is being throttled. 29 | */ 30 | THROTTLED(8), 31 | 32 | /** 33 | * Client has operator control over the server. 34 | */ 35 | OPERATOR(16), 36 | 37 | /** 38 | * Client is currently in spectator mode. 39 | */ 40 | SPECTATE(32); 41 | 42 | private final int clientState; 43 | 44 | private ClientState(int clientState) { 45 | this.clientState = clientState; 46 | } 47 | 48 | /** 49 | * Get the integer value of the bitmask. 50 | * @return 51 | */ 52 | public final int getValue() { 53 | return clientState; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/IClient.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server; 2 | 3 | public interface IClient { 4 | 5 | /** 6 | * Get the client's IP Address as a string. 7 | * @return 8 | */ 9 | public String getIPAddress(); 10 | 11 | /** 12 | * Get the client's remote port. 13 | * @return 14 | */ 15 | public int getPort(); 16 | 17 | /** 18 | * Get the current client's state. 19 | * @return 20 | */ 21 | public ClientState getClientState(); 22 | 23 | 24 | /** 25 | * Called on a client's disconnect. 26 | */ 27 | public void onDisconnect(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/IRTMessage.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | 5 | public interface IRTMessage { 6 | 7 | /** 8 | * Get the SCE-RT/RTIME packet ID. 9 | * @return 10 | */ 11 | public RtMessageId getId(); 12 | 13 | /** 14 | * Get the data length. 15 | * @return 16 | */ 17 | public int getLength(); 18 | 19 | /** 20 | * Get the raw data. 21 | * @return 22 | */ 23 | public ByteBuf getPayload(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/IServer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server; 2 | 3 | import java.util.HashSet; 4 | 5 | public interface IServer { 6 | 7 | /** 8 | * Start the server. 9 | */ 10 | public void start(); 11 | 12 | /** 13 | * Stop the server. 14 | */ 15 | public void stop(); 16 | 17 | public HashSet getClients(); 18 | 19 | /** 20 | * Add a client to the current server. 21 | * @param client 22 | */ 23 | public void addClient(IClient client); 24 | 25 | /** 26 | * Remove a client from the current server. 27 | * @param client 28 | */ 29 | public void removeClient(IClient client); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/MediusClientChannelInitializer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.ChannelInitializer; 5 | import io.netty.channel.FixedRecvByteBufAllocator; 6 | import io.netty.channel.socket.SocketChannel; 7 | import io.netty.handler.timeout.ReadTimeoutException; 8 | import net.hashsploit.clank.Clank; 9 | import net.hashsploit.clank.server.medius.MediusServer; 10 | 11 | public class MediusClientChannelInitializer extends ChannelInitializer { 12 | 13 | private final MediusServer server; 14 | 15 | public MediusClientChannelInitializer(MediusServer server) { 16 | super(); 17 | this.server = server; 18 | } 19 | 20 | @Override 21 | protected void initChannel(SocketChannel ch) { 22 | 23 | // TODO: Pull bytebuffer allocator from config 24 | ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(2048)); 25 | 26 | final MediusClient client = new MediusClient(server, ch); 27 | server.addClient(client); 28 | } 29 | 30 | @Override 31 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) { 32 | 33 | if (!(e.getCause() instanceof ReadTimeoutException)) { 34 | Clank.getInstance().getTerminal().handleException(e); 35 | } 36 | 37 | ctx.channel().close().awaitUninterruptibly(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/dme/DMEInitStatus.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.dme; 2 | 3 | /** 4 | * Enumeration used to identify whether or not the DME layer has been 5 | * initialized prior to the call to MGCLInitialize. 6 | */ 7 | public enum DMEInitStatus { 8 | 9 | /** 10 | * The DME has been initialized prior to this function call. 11 | */ 12 | DMEInitialized(0), 13 | 14 | /** 15 | * The DME has NOT been initialized prior to this function call. 16 | */ 17 | DMENotInitialized(1); 18 | 19 | private final int value; 20 | 21 | private DMEInitStatus(int value) { 22 | this.value = (short) value; 23 | } 24 | 25 | public final int getValue() { 26 | return value; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/dme/DmeTcpClientInitializer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.dme; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.ChannelInitializer; 5 | import io.netty.channel.FixedRecvByteBufAllocator; 6 | import io.netty.channel.WriteBufferWaterMark; 7 | import io.netty.channel.socket.SocketChannel; 8 | import io.netty.handler.timeout.ReadTimeoutException; 9 | import net.hashsploit.clank.Clank; 10 | import net.hashsploit.clank.server.IServer; 11 | 12 | public class DmeTcpClientInitializer extends ChannelInitializer { 13 | 14 | private final IServer server; 15 | 16 | public DmeTcpClientInitializer(IServer server) { 17 | super(); 18 | this.server = server; 19 | } 20 | 21 | @Override 22 | protected void initChannel(SocketChannel ch) { 23 | 24 | // TODO: Pull bytebuffer allocator from config 25 | ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(2048)); 26 | ch.config().setWriteBufferWaterMark(new WriteBufferWaterMark(2048, 4096)); 27 | 28 | final DmeTcpClient client = new DmeTcpClient(server, ch); 29 | server.addClient(client); 30 | } 31 | 32 | @Override 33 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) { 34 | 35 | if (!(e.getCause() instanceof ReadTimeoutException)) { 36 | Clank.getInstance().getTerminal().handleException(e); 37 | } 38 | 39 | ctx.channel().close().awaitUninterruptibly(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/dme/DmeUdpClientInitializer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.dme; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.ChannelInitializer; 5 | import io.netty.channel.FixedRecvByteBufAllocator; 6 | import io.netty.channel.socket.DatagramChannel; 7 | import io.netty.handler.timeout.ReadTimeoutException; 8 | import net.hashsploit.clank.Clank; 9 | import net.hashsploit.clank.server.IServer; 10 | import net.hashsploit.clank.server.UdpServer; 11 | 12 | public class DmeUdpClientInitializer extends ChannelInitializer { 13 | 14 | private final IServer server; 15 | 16 | public DmeUdpClientInitializer(UdpServer server) { 17 | super(); 18 | this.server = server; 19 | } 20 | 21 | @Override 22 | protected void initChannel(DatagramChannel ch) { 23 | 24 | // TODO: Pull bytebuffer allocator from config 25 | ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(2048)); 26 | 27 | 28 | final DmeUdpClient client = new DmeUdpClient(server, ch); 29 | server.addClient(client); 30 | } 31 | 32 | @Override 33 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) { 34 | 35 | if (!(e.getCause() instanceof ReadTimeoutException)) { 36 | Clank.getInstance().getTerminal().handleException(e); 37 | } 38 | 39 | ctx.channel().close().awaitUninterruptibly(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/dme/DmeUdpServer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.dme; 2 | 3 | import io.netty.channel.EventLoopGroup; 4 | import net.hashsploit.clank.server.UdpServer; 5 | 6 | public class DmeUdpServer extends UdpServer { 7 | 8 | private final DmeWorldManager dmeWorldManager; 9 | 10 | public DmeUdpServer(final String address, final int port, final EventLoopGroup eventLoopGroup, DmeWorldManager dmeWorldManager) { 11 | super(address, port, eventLoopGroup); 12 | this.dmeWorldManager = dmeWorldManager; 13 | } 14 | 15 | public DmeWorldManager getDmeWorldManager() { 16 | return dmeWorldManager; 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/IMediusSerializableObject.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius; 2 | 3 | public interface IMediusSerializableObject { 4 | 5 | 6 | 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/MediusPacketHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius; 2 | 3 | import java.util.List; 4 | import java.util.logging.Logger; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public abstract class MediusPacketHandler { 10 | 11 | protected static final Logger logger = Logger.getLogger(MediusPacketHandler.class.getName()); 12 | 13 | public final MediusMessageType type; 14 | public final MediusMessageType responseType; 15 | 16 | public MediusPacketHandler(final MediusMessageType type, final MediusMessageType responseType) { 17 | this.type = type; 18 | this.responseType = responseType; 19 | } 20 | 21 | public MediusMessageType getType() { 22 | return type; 23 | } 24 | 25 | /** 26 | * This method is called on when a message should be handled to be read by the server. 27 | * @param message 28 | */ 29 | public abstract void read(final MediusClient client, final MediusMessage message); 30 | 31 | /** 32 | * This method is called on when a message should be sent back to the client. 33 | * @param client 34 | */ 35 | public abstract List write(final MediusClient client); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusAccountGetIdHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.AccountGetIdRequest; 12 | import net.hashsploit.clank.server.medius.serializers.AccountGetIdResponse; 13 | import net.hashsploit.clank.utils.Utils; 14 | 15 | public class MediusAccountGetIdHandler extends MediusPacketHandler { 16 | 17 | private AccountGetIdRequest reqPacket; 18 | private AccountGetIdResponse respPacket; 19 | 20 | public MediusAccountGetIdHandler() { 21 | super(MediusMessageType.AccountGetId, MediusMessageType.AccountGetIdResponse); 22 | } 23 | 24 | @Override 25 | public void read(MediusClient client, MediusMessage mm) { 26 | reqPacket = new AccountGetIdRequest(mm.getPayload()); 27 | logger.finest(reqPacket.toString()); 28 | } 29 | 30 | @Override 31 | public List write(MediusClient client) { 32 | 33 | byte[] callbackStatus = Utils.intToBytesLittle((MediusCallbackStatus.SUCCESS.getValue())); 34 | byte[] mlsToken = Utils.hexStringToByteArray("00000000000000000000000000000000000000"); 35 | 36 | respPacket = new AccountGetIdResponse(reqPacket.getMessageID(), Utils.intToBytesLittle(9), callbackStatus); 37 | 38 | List response = new ArrayList(); 39 | response.add(respPacket); 40 | return response; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusAccountLogoutHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.AccountLogoutRequest; 12 | import net.hashsploit.clank.server.medius.serializers.AccountLogoutResponse; 13 | import net.hashsploit.clank.utils.Utils; 14 | 15 | public class MediusAccountLogoutHandler extends MediusPacketHandler { 16 | private AccountLogoutRequest reqPacket; 17 | 18 | public MediusAccountLogoutHandler() { 19 | super(MediusMessageType.AccountLogout, MediusMessageType.AccountLogoutResponse); 20 | } 21 | @Override 22 | public void read(MediusClient client, MediusMessage mm) { 23 | reqPacket = new AccountLogoutRequest(mm.getPayload()); 24 | logger.finest(reqPacket.toString()); 25 | } 26 | 27 | @Override 28 | public List write(MediusClient client) { 29 | AccountLogoutResponse respPacket = new AccountLogoutResponse(reqPacket.getMessageID(), Utils.intToBytesLittle(MediusCallbackStatus.SUCCESS.getValue())); 30 | List response = new ArrayList(); 31 | response.add(respPacket); 32 | return response; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusAccountRegistrationHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 9 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 10 | import net.hashsploit.clank.server.medius.serializers.AccountRegistrationRequest; 11 | import net.hashsploit.clank.server.medius.serializers.AccountRegistrationResponse; 12 | 13 | public class MediusAccountRegistrationHandler extends MediusPacketHandler { 14 | 15 | private AccountRegistrationRequest reqPacket; 16 | private AccountRegistrationResponse respPacket; 17 | 18 | private byte[] messageId; 19 | 20 | public MediusAccountRegistrationHandler() { 21 | super(MediusMessageType.AccountLogin, MediusMessageType.AccountLoginResponse); 22 | } 23 | 24 | @Override 25 | public void read(MediusClient client, MediusMessage mm) { 26 | reqPacket = new AccountRegistrationRequest(mm.getPayload()); 27 | messageId = reqPacket.getMessageID(); 28 | } 29 | 30 | @Override 31 | public List write(MediusClient client) { 32 | respPacket = new AccountRegistrationResponse(messageId); 33 | 34 | List response = new ArrayList(); 35 | response.add(respPacket); 36 | return response; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusAccountUpdateStatsHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.Clank; 7 | import net.hashsploit.clank.server.MediusClient; 8 | import net.hashsploit.clank.server.medius.MediusLobbyServer; 9 | import net.hashsploit.clank.server.medius.MediusMessageType; 10 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 11 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 12 | import net.hashsploit.clank.server.medius.serializers.AccountUpdateStatsRequest; 13 | import net.hashsploit.clank.server.medius.serializers.AccountUpdateStatsResponse; 14 | import net.hashsploit.clank.utils.Utils; 15 | 16 | public class MediusAccountUpdateStatsHandler extends MediusPacketHandler { 17 | 18 | private AccountUpdateStatsRequest reqPacket; 19 | private AccountUpdateStatsResponse respPacket; 20 | 21 | 22 | public MediusAccountUpdateStatsHandler() { 23 | super(MediusMessageType.AccountUpdateStats, MediusMessageType.AccountUpdateStatsResponse); 24 | } 25 | 26 | @Override 27 | public void read(MediusClient client, MediusMessage mm) { 28 | reqPacket = new AccountUpdateStatsRequest(mm.getPayload()); 29 | logger.finest(reqPacket.toString()); 30 | } 31 | 32 | @Override 33 | public List write(MediusClient client) { 34 | byte[] callbackStatus = Utils.intToBytesLittle(0); 35 | 36 | respPacket = new AccountUpdateStatsResponse(reqPacket.getMessageID(), callbackStatus); 37 | 38 | MediusLobbyServer server = (MediusLobbyServer) client.getServer(); 39 | Clank.getInstance().getDatabase().updatePlayerStats(client.getPlayer().getAccountId(), Utils.bytesToHex(reqPacket.getStats())); 40 | 41 | List response = new ArrayList(); 42 | response.add(respPacket); 43 | return response; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusAddToBuddyListHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.AddToBuddyListRequest; 12 | import net.hashsploit.clank.server.medius.serializers.AddToBuddyListResponse; 13 | import net.hashsploit.clank.utils.Utils; 14 | 15 | public class MediusAddToBuddyListHandler extends MediusPacketHandler { 16 | 17 | private AddToBuddyListRequest reqPacket; 18 | private AddToBuddyListResponse respPacket; 19 | 20 | public MediusAddToBuddyListHandler() { 21 | super(MediusMessageType.AddToBuddyList, MediusMessageType.AddToBuddyListResponse); 22 | } 23 | 24 | @Override 25 | public void read(MediusClient client, MediusMessage mm) { 26 | reqPacket = new AddToBuddyListRequest(mm.getPayload()); 27 | logger.finest(reqPacket.toString()); 28 | } 29 | 30 | @Override 31 | public List write(MediusClient client) { 32 | 33 | byte[] callbackStatus = Utils.intToBytesLittle((MediusCallbackStatus.SUCCESS.getValue())); 34 | 35 | respPacket = new AddToBuddyListResponse(reqPacket.getMessageID(), callbackStatus); 36 | 37 | List response = new ArrayList(); 38 | response.add(respPacket); 39 | return response; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusChannelListHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.ChannelListRequest; 12 | import net.hashsploit.clank.server.medius.serializers.ChannelListResponse; 13 | 14 | public class MediusChannelListHandler extends MediusPacketHandler { 15 | 16 | private ChannelListRequest reqPacket; 17 | private ChannelListResponse respPacket; 18 | 19 | public MediusChannelListHandler() { 20 | super(MediusMessageType.ChannelList, MediusMessageType.ChannelListResponse); 21 | } 22 | 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new ChannelListRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | 32 | MediusCallbackStatus callbackStatus = MediusCallbackStatus.SUCCESS; 33 | int mediusWorldId = 1; 34 | String lobbyName = "AEQLITUDE"; 35 | int playerCount = 3; 36 | boolean endOfList = true; 37 | 38 | respPacket = new ChannelListResponse(reqPacket.getMessageId(), callbackStatus, mediusWorldId, lobbyName, playerCount, endOfList); 39 | 40 | List response = new ArrayList(); 41 | response.add(respPacket); 42 | return response; 43 | } 44 | 45 | 46 | } -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusChatToggleHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.ChatToggleRequest; 12 | import net.hashsploit.clank.server.medius.serializers.ChatToggleResponse; 13 | import net.hashsploit.clank.utils.Utils; 14 | 15 | public class MediusChatToggleHandler extends MediusPacketHandler { 16 | 17 | private ChatToggleRequest reqPacket; 18 | private ChatToggleResponse respPacket; 19 | 20 | public MediusChatToggleHandler() { 21 | super(MediusMessageType.ChatToggle, MediusMessageType.ChatToggleResponse); 22 | } 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new ChatToggleRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | byte[] callbackStatus = Utils.intToBytesLittle((MediusCallbackStatus.SUCCESS.getValue())); 32 | 33 | respPacket = new ChatToggleResponse(reqPacket.getMessageID(), callbackStatus); 34 | 35 | List response = new ArrayList(); 36 | response.add(respPacket); 37 | return response; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusClearGameListFilterZeroHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 9 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 10 | import net.hashsploit.clank.server.medius.serializers.ClearGameListFilterResponse; 11 | import net.hashsploit.clank.server.medius.serializers.ClearGameListFilterZeroRequest; 12 | import net.hashsploit.clank.utils.Utils; 13 | 14 | public class MediusClearGameListFilterZeroHandler extends MediusPacketHandler { 15 | 16 | private ClearGameListFilterZeroRequest reqPacket; 17 | private ClearGameListFilterResponse respPacket; 18 | 19 | public MediusClearGameListFilterZeroHandler() { 20 | super(MediusMessageType.ClearGameListFilter0, MediusMessageType.ClearGameListFilterResponse); 21 | } 22 | 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new ClearGameListFilterZeroRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | //byte[] callbackStatus = Utils.intToBytes(MediusCallbackStatus.MediusSuccess.getValue()); 32 | byte[] callbackStatus = Utils.hexStringToByteArray("2CFCFFFF"); 33 | 34 | respPacket = new ClearGameListFilterResponse(reqPacket.getMessageID(), callbackStatus); 35 | 36 | List response = new ArrayList(); 37 | response.add(respPacket); 38 | return response; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusCreateClanHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.CreateClanRequest; 12 | import net.hashsploit.clank.server.medius.serializers.CreateClanResponse; 13 | 14 | public class MediusCreateClanHandler extends MediusPacketHandler { 15 | 16 | private CreateClanRequest reqPacket; 17 | private CreateClanResponse respPacket; 18 | 19 | public MediusCreateClanHandler() { 20 | super(MediusMessageType.CreateClan, MediusMessageType.CreateClanResponse); 21 | } 22 | 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new CreateClanRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | 32 | MediusCallbackStatus callbackStatus = MediusCallbackStatus.REQUEST_DENIED; 33 | int clanId = 0; 34 | 35 | 36 | 37 | callbackStatus = MediusCallbackStatus.SUCCESS; 38 | clanId = 1; 39 | 40 | 41 | 42 | respPacket = new CreateClanResponse(reqPacket.getMessageId(), callbackStatus, clanId); 43 | 44 | List responses = new ArrayList(); 45 | responses.add(respPacket); 46 | return responses; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusDnasSignaturePostHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.List; 4 | 5 | import net.hashsploit.clank.server.MediusClient; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.server.medius.serializers.DnasSignaturePostRequest; 10 | 11 | public class MediusDnasSignaturePostHandler extends MediusPacketHandler { 12 | 13 | private DnasSignaturePostRequest reqPacket; 14 | 15 | public MediusDnasSignaturePostHandler() { 16 | super(MediusMessageType.DnasSignaturePost, null); 17 | } 18 | 19 | @Override 20 | public void read(MediusClient client, MediusMessage mm) { 21 | reqPacket = new DnasSignaturePostRequest(mm.getPayload()); 22 | logger.finest(reqPacket.toString()); 23 | } 24 | 25 | @Override 26 | public List write(MediusClient client) { 27 | return null; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusEndGameReportHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.List; 4 | 5 | import net.hashsploit.clank.server.MediusClient; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | 10 | public class MediusEndGameReportHandler extends MediusPacketHandler { 11 | 12 | public MediusEndGameReportHandler() { 13 | super(MediusMessageType.EndGameReport, null); 14 | } 15 | 16 | @Override 17 | public void read(MediusClient client, MediusMessage message) { 18 | 19 | } 20 | 21 | @Override 22 | public List write(MediusClient client) { 23 | return null; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusGetMyIPHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.GetMyIPRequest; 12 | import net.hashsploit.clank.server.medius.serializers.GetMyIPResponse; 13 | 14 | public class MediusGetMyIPHandler extends MediusPacketHandler { 15 | 16 | private GetMyIPRequest reqPacket; 17 | private GetMyIPResponse respPacket; 18 | 19 | public MediusGetMyIPHandler() { 20 | super(MediusMessageType.GetMyIP, MediusMessageType.GetMyIPResponse); 21 | } 22 | 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new GetMyIPRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | 32 | String ipAddress = client.getIPAddress(); 33 | int port = client.getPort(); 34 | MediusCallbackStatus callbackStatus = MediusCallbackStatus.SUCCESS; 35 | 36 | respPacket = new GetMyIPResponse(reqPacket.getMessageId(), ipAddress, port, callbackStatus); 37 | 38 | List response = new ArrayList(); 39 | response.add(respPacket); 40 | return response; 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusLadderPositionHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 9 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 10 | import net.hashsploit.clank.server.medius.serializers.LadderPositionRequest; 11 | import net.hashsploit.clank.server.medius.serializers.LadderPositionResponse; 12 | 13 | public class MediusLadderPositionHandler extends MediusPacketHandler { 14 | 15 | private LadderPositionRequest reqPacket; 16 | private LadderPositionResponse respPacket; 17 | 18 | private byte[] messageId; 19 | 20 | public MediusLadderPositionHandler() { 21 | super(MediusMessageType.LadderPosition, MediusMessageType.LadderPositionResponse); 22 | } 23 | 24 | @Override 25 | public void read(MediusClient client, MediusMessage mm) { 26 | reqPacket = new LadderPositionRequest(mm.getPayload()); 27 | 28 | 29 | messageId = reqPacket.getMessageId(); 30 | } 31 | 32 | @Override 33 | public List write(MediusClient client) { 34 | 35 | respPacket = new LadderPositionResponse(messageId); 36 | 37 | List response = new ArrayList(); 38 | response.add(respPacket); 39 | return response; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusLadderPosition_ExtraInfoHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.LadderPosition_ExtraInfoRequest; 12 | import net.hashsploit.clank.server.medius.serializers.LadderPosition_ExtraInfoResponse; 13 | import net.hashsploit.clank.utils.Utils; 14 | 15 | public class MediusLadderPosition_ExtraInfoHandler extends MediusPacketHandler { 16 | 17 | private LadderPosition_ExtraInfoRequest reqPacket; 18 | private LadderPosition_ExtraInfoResponse respPacket; 19 | 20 | public MediusLadderPosition_ExtraInfoHandler() { 21 | super(MediusMessageType.LadderPosition_ExtraInfo, MediusMessageType.LadderPosition_ExtraInfoResponse); 22 | } 23 | 24 | @Override 25 | public void read(MediusClient client, MediusMessage message) { 26 | reqPacket = new LadderPosition_ExtraInfoRequest(message.getPayload()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | byte[] callbackStatus = Utils.intToBytesLittle(MediusCallbackStatus.SUCCESS.getValue()); 32 | byte[] ladderPosition = Utils.intToBytesLittle(1); 33 | byte[] totalRankings = Utils.intToBytesLittle(10); 34 | 35 | respPacket = new LadderPosition_ExtraInfoResponse(reqPacket.getMessageID(), callbackStatus, ladderPosition, totalRankings); 36 | 37 | List responses = new ArrayList(); 38 | responses.add(respPacket); 39 | return responses; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusPickLocationHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.PickLocationRequest; 12 | import net.hashsploit.clank.server.medius.serializers.PickLocationResponse; 13 | 14 | public class MediusPickLocationHandler extends MediusPacketHandler { 15 | 16 | private PickLocationRequest reqPacket; 17 | private PickLocationResponse respPacket; 18 | 19 | public MediusPickLocationHandler() { 20 | super(MediusMessageType.PickLocation, MediusMessageType.PickLocationResponse); 21 | } 22 | 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new PickLocationRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | 32 | // TODO: return a valid callback status 33 | MediusCallbackStatus callbackStatus = MediusCallbackStatus.SUCCESS; 34 | 35 | respPacket = new PickLocationResponse(reqPacket.getMessageId(), callbackStatus); 36 | 37 | List response = new ArrayList(); 38 | response.add(respPacket); 39 | return response; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusPlayerReportHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.List; 4 | 5 | import net.hashsploit.clank.server.MediusClient; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.server.medius.serializers.PlayerReportRequest; 10 | 11 | public class MediusPlayerReportHandler extends MediusPacketHandler { 12 | 13 | private PlayerReportRequest reqPacket; 14 | 15 | public MediusPlayerReportHandler() { 16 | super(MediusMessageType.PlayerReport, null); 17 | } 18 | 19 | @Override 20 | public void read(MediusClient client, MediusMessage mm) { 21 | reqPacket = new PlayerReportRequest(mm.getPayload()); 22 | logger.finest(reqPacket.toString()); 23 | } 24 | 25 | @Override 26 | public List write(MediusClient client) { 27 | return null; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusSessionEndHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.SessionEndRequest; 12 | import net.hashsploit.clank.server.medius.serializers.SessionEndResponse; 13 | 14 | public class MediusSessionEndHandler extends MediusPacketHandler { 15 | 16 | private SessionEndRequest request; 17 | 18 | public MediusSessionEndHandler() { 19 | super(MediusMessageType.SessionEnd, MediusMessageType.SessionEndResponse); 20 | } 21 | 22 | @Override 23 | public void read(MediusClient client, MediusMessage mm) { 24 | request = new SessionEndRequest(mm.getPayload()); 25 | } 26 | 27 | @Override 28 | public List write(MediusClient client) { 29 | 30 | MediusCallbackStatus callbackStatus = MediusCallbackStatus.SUCCESS; 31 | 32 | List responses = new ArrayList(); 33 | 34 | SessionEndResponse response = new SessionEndResponse(request.getMessageId(), callbackStatus); 35 | 36 | responses.add(response); 37 | 38 | return responses; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusSetLocalizationParamsHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.server.MediusClient; 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.SetLocalizationParamsRequest; 12 | import net.hashsploit.clank.server.medius.serializers.SetLocalizationParamsResponse; 13 | 14 | public class MediusSetLocalizationParamsHandler extends MediusPacketHandler { 15 | 16 | private SetLocalizationParamsRequest reqPacket; 17 | private SetLocalizationParamsResponse respPacket; 18 | 19 | public MediusSetLocalizationParamsHandler() { 20 | super(MediusMessageType.SetLocalizationParams, MediusMessageType.SetLocalizationParamsResponse); 21 | } 22 | 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new SetLocalizationParamsRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | 32 | MediusCallbackStatus callbackStatus = MediusCallbackStatus.SUCCESS; 33 | 34 | respPacket = new SetLocalizationParamsResponse(reqPacket.getMessageId(), callbackStatus); 35 | 36 | List response = new ArrayList(); 37 | response.add(respPacket); 38 | return response; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusVersionServerHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.hashsploit.clank.Clank; 7 | import net.hashsploit.clank.server.MediusClient; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.server.medius.serializers.VersionServerRequest; 12 | import net.hashsploit.clank.server.medius.serializers.VersionServerResponse; 13 | 14 | public class MediusVersionServerHandler extends MediusPacketHandler { 15 | 16 | private VersionServerRequest reqPacket; 17 | private VersionServerResponse respPacket; 18 | 19 | public MediusVersionServerHandler() { 20 | super(MediusMessageType.ChannelList, MediusMessageType.ChannelListResponse); 21 | } 22 | 23 | @Override 24 | public void read(MediusClient client, MediusMessage mm) { 25 | reqPacket = new VersionServerRequest(mm.getPayload()); 26 | logger.finest(reqPacket.toString()); 27 | } 28 | 29 | @Override 30 | public List write(MediusClient client) { 31 | 32 | String serverVersion = Clank.NAME + " v" + Clank.VERSION; 33 | 34 | respPacket = new VersionServerResponse(reqPacket.getMessageId(), serverVersion); 35 | 36 | List response = new ArrayList(); 37 | response.add(respPacket); 38 | return response; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/handlers/MediusWorldReportZeroHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.handlers; 2 | 3 | import java.util.List; 4 | 5 | import net.hashsploit.clank.server.MediusClient; 6 | import net.hashsploit.clank.server.medius.MediusLobbyServer; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.MediusPacketHandler; 9 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 10 | import net.hashsploit.clank.server.medius.objects.MediusWorldStatus; 11 | import net.hashsploit.clank.server.medius.serializers.WorldReportZeroRequest; 12 | import net.hashsploit.clank.utils.Utils; 13 | 14 | public class MediusWorldReportZeroHandler extends MediusPacketHandler { 15 | 16 | private WorldReportZeroRequest reqPacket; 17 | 18 | public MediusWorldReportZeroHandler() { 19 | super(MediusMessageType.WorldReport0, null); 20 | } 21 | 22 | @Override 23 | public void read(MediusClient client, MediusMessage mm) { 24 | reqPacket = new WorldReportZeroRequest(mm.getPayload()); 25 | logger.finest(reqPacket.toString()); 26 | } 27 | 28 | @Override 29 | public List write(MediusClient client) { 30 | // Update the logichandler with the world 31 | MediusLobbyServer server = (MediusLobbyServer) client.getServer(); 32 | 33 | int worldId = Utils.bytesToIntLittle(reqPacket.getWorldID()); 34 | int worldStatus = Utils.bytesToIntLittle(reqPacket.getWorldStatus()); 35 | if (worldStatus == 2) { 36 | server.updateDmeWorldStatus(worldId, MediusWorldStatus.WORLD_ACTIVE); 37 | } 38 | 39 | return null; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/BillingServiceProvider.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum BillingServiceProvider { 4 | 5 | SCEA("SCEA"), 6 | 7 | SCEE("SCEE"), 8 | 9 | SCEK("SCEK"); 10 | 11 | public final String value; 12 | 13 | private BillingServiceProvider(String value) { 14 | this.value = value; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/Channel.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class Channel { 6 | 7 | @SerializedName("id") 8 | private int id = 0; 9 | 10 | @SerializedName("name") 11 | private String name = ""; 12 | 13 | @SerializedName("capacity") 14 | private int capacity = 256; 15 | 16 | public int getId() { 17 | return id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public int getCapacity() { 25 | return capacity; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/DmePlayerStatus.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum DmePlayerStatus { 4 | 5 | DISCONNECTED(0), 6 | 7 | CONNECTING(1), 8 | 9 | STAGING(2), 10 | 11 | ACTIVE(3); 12 | 13 | private final int value; 14 | 15 | private DmePlayerStatus(int value) { 16 | this.value = value; 17 | } 18 | 19 | public final int getValue() { 20 | return value; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/GameHostType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum GameHostType { 4 | 5 | HOST_CLIENT_SERVER(0), 6 | 7 | HOST_INTEGRATED_SERVER(1), 8 | 9 | HOST_PEER_TO_PEER(2), 10 | 11 | HOST_LAN_PLAY(3), 12 | 13 | HOST_CLIENT_SERVER_AUX_UDP(4); 14 | 15 | private final int value; 16 | 17 | private GameHostType(int value) { 18 | this.value = value; 19 | } 20 | 21 | public final int getValue() { 22 | return value; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/Location.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class Location { 6 | 7 | @SerializedName("id") 8 | private int id = 0; 9 | 10 | @SerializedName("name") 11 | private String name = ""; 12 | 13 | public int getId() { 14 | return id; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusAccountType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusAccountType { 4 | 5 | MEDIUS_CHILD_ACCOUNT(0), 6 | 7 | MEDIUS_MASTER_ACCOUNT(1); 8 | 9 | private final int value; 10 | 11 | private MediusAccountType(int value) { 12 | this.value = value; 13 | } 14 | 15 | public final int getValue() { 16 | return value; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusApplicationType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusApplicationType { 4 | 5 | MEDIUS_APP_TYPE_GAME(0), 6 | 7 | LOBBY_CHAT_CHANNEL(1); 8 | 9 | public final int value; 10 | 11 | private MediusApplicationType(int value) { 12 | this.value = value; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusBuddyAddType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusBuddyAddType { 4 | 5 | ADD_SINGLE(0), 6 | 7 | ADD_SYMMETRIC(1); 8 | 9 | private final int value; 10 | 11 | private MediusBuddyAddType(int value) { 12 | this.value = value; 13 | } 14 | 15 | public final int getValue() { 16 | return value; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusChatMessageType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | import java.util.Collections; 4 | import java.util.Map; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | 7 | public enum MediusChatMessageType { 8 | 9 | BROADCAST(0), 10 | 11 | WHISPER(1), 12 | 13 | BROADCAST_ACROSS_ENTIRE_UNIVERSE(2), 14 | 15 | CLAN_CHAT_TYPE(3), 16 | 17 | BUDDY_CHAT_TYPE(4); 18 | 19 | private final int value; 20 | 21 | private static final Map ENUM_MAP; 22 | 23 | private MediusChatMessageType(int value) { 24 | this.value = value; 25 | } 26 | 27 | public final int getValue() { 28 | return value; 29 | } 30 | 31 | static { 32 | Map map = new ConcurrentHashMap(); 33 | for (MediusChatMessageType instance : MediusChatMessageType.values()) { 34 | map.put(instance.getValue(), instance); 35 | } 36 | ENUM_MAP = Collections.unmodifiableMap(map); 37 | } 38 | 39 | public static MediusChatMessageType getByValue(int type) { 40 | return ENUM_MAP.get(type); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusClanInvitationResponseStatus.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusClanInvitationResponseStatus { 4 | 5 | CLAN_INVITATION_UNDECIDED(0), 6 | 7 | CLAN_INVITATION_ACCEPT(1), 8 | 9 | CLAN_INVITATION_DECLINE(2), 10 | 11 | CLAN_INVITATION_REVOKED(3); 12 | 13 | private final int value; 14 | 15 | private MediusClanInvitationResponseStatus(int value) { 16 | this.value = value; 17 | } 18 | 19 | public final int getValue() { 20 | return value; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusConnectionType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusConnectionType { 4 | 5 | MODEM(0), 6 | 7 | ETHERNET(1), 8 | 9 | WIRELESS(2); 10 | 11 | private final int value; 12 | 13 | private MediusConnectionType(int value) { 14 | this.value = value; 15 | } 16 | 17 | public final int getValue() { 18 | return value; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusFindWorldType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusFindWorldType { 4 | 5 | FIND_GAME_WORLD(0), 6 | 7 | FIND_LOBBY_WORLD(1), 8 | 9 | FIND_ALL_WORLDS(2); 10 | 11 | private final int value; 12 | 13 | private MediusFindWorldType(int value) { 14 | this.value = value; 15 | } 16 | 17 | public final int getValue() { 18 | return value; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusGameHostType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public enum MediusGameHostType { 7 | 8 | HOST_CLIENT_SERVER(0), 9 | 10 | HOST_INTEGRATED_SERVER(1), 11 | 12 | HOST_PEER_TO_PEER(2), 13 | 14 | HOST_LAN_PLAY(3), 15 | 16 | HOST_CLIENT_SERVER_AUX_UDP(4); 17 | 18 | public final int value; 19 | private static Map enumMapping = new HashMap<>(); 20 | 21 | private MediusGameHostType(int value) { 22 | this.value = value; 23 | } 24 | 25 | public static MediusGameHostType getTypeFromValue(int value) { 26 | return enumMapping.get(value); 27 | } 28 | 29 | static { 30 | for (MediusGameHostType ght : MediusGameHostType.values()) { 31 | enumMapping.put(ght.value, ght); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusMessage.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.Arrays; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.utils.Utils; 8 | 9 | public class MediusMessage { 10 | 11 | private MediusMessageType packetType; 12 | private byte[] data; 13 | 14 | public MediusMessage(byte[] incomingData) { 15 | // Get medius packet type 16 | short testingShortVal = Utils.bytesToShortLittle(incomingData[0], incomingData[1]); 17 | 18 | // TODO: Make this not O(n) 19 | for (MediusMessageType p : MediusMessageType.values()) { 20 | if (p.getShort() == testingShortVal) { 21 | packetType = p; 22 | break; 23 | } 24 | } 25 | data = Arrays.copyOfRange(incomingData, 2, incomingData.length); 26 | } 27 | 28 | public MediusMessage(MediusMessageType type, byte[] data) { 29 | // Get medius packet type 30 | this.packetType = type; 31 | this.data = data; 32 | } 33 | 34 | public MediusMessage(MediusMessageType type) { 35 | this.packetType = type; 36 | } 37 | 38 | public byte[] getPayload() { 39 | return data; 40 | } 41 | 42 | public MediusMessageType getMediusPacketType() { 43 | return packetType; 44 | } 45 | 46 | public byte[] toBytes() { 47 | ByteBuffer bb = ByteBuffer.allocate(2 + getPayload().length); 48 | bb.put(packetType.getShortByte()); 49 | bb.put(getPayload()); 50 | bb.flip(); 51 | return bb.array(); 52 | } 53 | 54 | // FIXME: make this abstract 55 | public String getDebugString() { 56 | return null; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return super.toString(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusPlayerSearchType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusPlayerSearchType { 4 | 5 | PLAYER_ACCOUNT_ID(0), 6 | 7 | PLAYER_ACCOUNT_NAME(1); 8 | 9 | private final int value; 10 | 11 | private MediusPlayerSearchType(int value) { 12 | this.value = value; 13 | } 14 | 15 | public final int getValue() { 16 | return value; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusPlayerStatus.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusPlayerStatus { 4 | 5 | /** 6 | * Player is not connected. 7 | */ 8 | MEDIUS_PLAYER_DISCONNECTED(0), 9 | 10 | /** 11 | * Player is currently on an authentication world. 12 | * @return 13 | */ 14 | MEDIUS_PLAYER_IN_AUTH_WORLD(1), 15 | 16 | /** 17 | * Player is currently on a chat channel. 18 | */ 19 | MEDIUS_PLAYER_IN_CHAT_WORLD(2), 20 | 21 | /** 22 | * Player is currently on a game world. 23 | */ 24 | MEDIUS_PLAYER_IN_GAME_WORLD(3), 25 | 26 | /** 27 | * Player is online in another universe. 28 | */ 29 | MEDIUS_PLAYER_IN_OTHER_UNIVERSE(4); 30 | 31 | private final int value; 32 | 33 | private MediusPlayerStatus(int value) { 34 | this.value = value; 35 | } 36 | 37 | public final int getValue() { 38 | return value; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusSortOrder.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusSortOrder { 4 | 5 | MEDIUS_ASCENDING(0), 6 | 7 | MEDIUS_DESCENDING(1); 8 | 9 | private final int value; 10 | 11 | private MediusSortOrder(int value) { 12 | this.value = value; 13 | } 14 | 15 | public final int getValue() { 16 | return value; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusWorldSecurityLevelType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusWorldSecurityLevelType { 4 | 5 | /** 6 | * No security on world. 7 | */ 8 | WORLD_SECURITY_NONE(0), 9 | 10 | /** 11 | * Password required to join as a player 12 | */ 13 | WORLD_SECURITY_PLAYER_PASSWORD(1), 14 | 15 | /** 16 | * World is closed to new players 17 | */ 18 | WORLD_SECURITY_CLOSED(2), 19 | 20 | /** 21 | * Password is required to join as a spectator 22 | */ 23 | WORLD_SECURITY_SPECTATOR_PASSWORD(4); 24 | 25 | public final int value; 26 | 27 | private MediusWorldSecurityLevelType(int value) { 28 | this.value = value; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/MediusWorldStatus.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum MediusWorldStatus { 4 | 5 | WORLD_INACTIVE(0), 6 | 7 | WORLD_STAGING(1), 8 | 9 | WORLD_ACTIVE(2), 10 | 11 | WORLD_CLOSED(3), 12 | 13 | WORLD_PENDING_CREATION(4), 14 | 15 | WORLD_PENDING_CONNECT_TO_GAME(5); 16 | 17 | public final int value; 18 | 19 | private MediusWorldStatus(int value) { 20 | this.value = value; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/NetAddress.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.scert.SCERTConstants; 6 | import net.hashsploit.clank.server.scert.SCERTObject; 7 | import net.hashsploit.clank.utils.Utils; 8 | 9 | public class NetAddress extends SCERTObject { 10 | 11 | public final NetAddressType type; 12 | public final String address; 13 | public final int port; 14 | 15 | public NetAddress(final NetAddressType type, final String address, final int port) { 16 | this.type = type; 17 | this.address = address; 18 | this.port = port; 19 | } 20 | 21 | public NetAddressType getType() { 22 | return type; 23 | } 24 | 25 | public String getAddress() { 26 | return address; 27 | } 28 | 29 | public int getPort() { 30 | return port; 31 | } 32 | 33 | @Override 34 | public byte[] serialize() { 35 | ByteBuffer buffer = ByteBuffer.allocate(4 + SCERTConstants.NET_MAX_NETADDRESS_LENGTH.getValue() + 4); 36 | 37 | buffer.put(Utils.intToBytesLittle(type.getValue())); 38 | 39 | final byte[] ipAddr = address.getBytes(); 40 | final int numZeros = 16 - address.length(); 41 | final String zeroString = new String(new char[numZeros]).replace("\0", "00"); 42 | final byte[] zeroTrail = Utils.hexStringToByteArray(zeroString); 43 | 44 | buffer.put(ipAddr); 45 | buffer.put(zeroTrail); 46 | buffer.put(Utils.intToBytesLittle(port)); 47 | 48 | return buffer.array(); 49 | } 50 | 51 | public void deserialize(byte[] data) { 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/NetAddressList.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public class NetAddressList { 4 | 5 | public static final int NET_ADDRESS_LIST_COUNT = 2; 6 | private final NetAddress[] addressList; 7 | 8 | public NetAddressList(NetAddress first, NetAddress second) { 9 | this.addressList = new NetAddress[NET_ADDRESS_LIST_COUNT]; 10 | this.addressList[0] = first; 11 | this.addressList[1] = second; 12 | } 13 | 14 | public NetAddress getFirst() { 15 | return addressList[0]; 16 | } 17 | 18 | public NetAddress getSecond() { 19 | return addressList[1]; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/NetAddressType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum NetAddressType { 4 | 5 | /** 6 | * (0) This value is "Not in use" 7 | */ 8 | NET_ADDRESS_NONE(0), 9 | 10 | /** 11 | * (1) ASCII string of client's public IPv4 address. 12 | */ 13 | NET_ADDRESS_TYPE_EXTERNAL(1), 14 | 15 | /** 16 | * (2) ASCII string of client's private IPv4 address. 17 | */ 18 | NET_ADDRESS_TYPE_INTERNAL(2), 19 | 20 | /** 21 | * (3) ASCII string representation of a NAT resolution server's IPv4 address. 22 | */ 23 | NET_ADDRESS_NAT_SERVICE(3), 24 | 25 | /** 26 | * (4) 4-byte binary representation of client's public IPv4 address. 27 | */ 28 | NET_ADDRESS_TYPE_BINARY_EXTERNAL(4), 29 | 30 | /** 31 | * (5) 4-byte binary representation of a client's public IPv4 address. 32 | */ 33 | NET_ADDRESS_TYPE_BINARY_INTERNAL(5), 34 | 35 | /** 36 | * (6) 4-byte binary representation of a client's public IPv4 address. 37 | * The Port parameter contains a 2-byte virtual port in 2 high bytes and 38 | * the actual network port in the 2 low bytes. 39 | */ 40 | NET_ADDRESS_TYPE_BINARY_EXTERNAL_VPORT(6), 41 | 42 | /** 43 | * (7) 4-byte binary representation of a client's public IPv4 address. 44 | * The Port parameter contains a 2-byte virtual port in 2 high bytes and 45 | * the actual network port in the 2 low bytes. 46 | */ 47 | NET_ADDRESS_TYPE_BINARY_INTERNAL_VPORT(7), 48 | 49 | /** 50 | * (8) Contains two 4-byte binary representations of NAT resolution servers 51 | * IPv4 addresses stored back to back. 52 | */ 53 | NET_ADDRESS_TYPE_BINARY_NAT_SERVICES(8); 54 | 55 | private final int value; 56 | 57 | private NetAddressType(int value) { 58 | this.value = value; 59 | } 60 | 61 | public final int getValue() { 62 | return value; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/NetConnectionType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum NetConnectionType { 4 | 5 | /** 6 | * (0) No information is present. 7 | */ 8 | NET_CONNECTION_NONE(0), 9 | 10 | /** 11 | * (1) Connection to TCP server. 12 | */ 13 | NET_CONNECTION_TYPE_CLIENT_SERVER_TCP(1), 14 | 15 | /** 16 | * (2) Connection to another peer via UDP. 17 | */ 18 | NET_CONNECTION_TYPE_PEER_TO_PEER_UDP(2), 19 | 20 | /** 21 | * (3) Connection to a TCP server with UDP aux. 22 | */ 23 | NET_CONNECTION_TYPE_CLIENT_SERVER_TCP_AUX_UDP(3), 24 | 25 | /** 26 | * (4) Connection to a TCP spectator. 27 | */ 28 | NET_CONNECTION_TYPE_CLIENT_LISTENER_TCP(4); 29 | 30 | private final int value; 31 | 32 | private NetConnectionType(int value) { 33 | this.value = (byte) value; 34 | } 35 | 36 | public final int getValue() { 37 | return value; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/objects/TextFilterType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.objects; 2 | 3 | public enum TextFilterType { 4 | 5 | TEXT_FILTER_PASS_FAIL(0), 6 | 7 | TEXT_FILTER_REPLACE(1); 8 | 9 | 10 | private final int value; 11 | 12 | private TextFilterType(int value) { 13 | this.value = value; 14 | } 15 | 16 | public final int getValue() { 17 | return value; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AccountGetIdRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class AccountGetIdRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private byte[] accountName = new byte[MediusConstants.ACCOUNTNAME_MAXLEN.value]; 15 | 16 | public AccountGetIdRequest(byte[] data) { 17 | super(MediusMessageType.AccountGetId, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageID); 21 | buf.get(sessionKey); 22 | buf.get(accountName); 23 | } 24 | 25 | public String toString() { 26 | return "AccountGetIDRequest: \n" + 27 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 28 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 29 | "usernameBytes: " + Utils.bytesToHex(accountName); 30 | } 31 | 32 | public byte[] getMessageID() { 33 | return messageID; 34 | } 35 | 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AccountGetIdResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class AccountGetIdResponse extends MediusMessage { 11 | 12 | private byte[] messageID; 13 | private byte[] accountID; 14 | private byte[] callbackStatus; 15 | 16 | public AccountGetIdResponse(byte[] messageID, byte[] accountID, byte[] callbackStatus) { 17 | super(MediusMessageType.AccountGetIdResponse); 18 | 19 | this.messageID = messageID; 20 | this.accountID = accountID; 21 | this.callbackStatus = callbackStatus; 22 | } 23 | 24 | @Override 25 | public byte[] getPayload() { 26 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 27 | 28 | try { 29 | outputStream.write(messageID); 30 | outputStream.write(Utils.hexStringToByteArray("000000")); 31 | outputStream.write(accountID); 32 | outputStream.write(callbackStatus); 33 | } catch (IOException e) { 34 | // TODO Auto-generated catch block 35 | e.printStackTrace(); 36 | } 37 | return outputStream.toByteArray(); 38 | } 39 | 40 | 41 | public String toString() { 42 | return "AccountGetIDResponse: \n" + 43 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 44 | "accountID: " + Utils.bytesToHex(accountID) + '\n' + 45 | "callbackStatus: " + Utils.bytesToHex(callbackStatus); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AccountLogoutRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class AccountLogoutRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | 15 | public AccountLogoutRequest(byte[] data) { 16 | super(MediusMessageType.AccountLogin, data); 17 | 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageID); 20 | buf.get(sessionKey); 21 | } 22 | 23 | public String toString() { 24 | return "AccountLogoutRequest: \n" + 25 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 26 | "sessionKey: " + Utils.bytesToHex(sessionKey); 27 | } 28 | 29 | public synchronized byte[] getMessageID() { 30 | return messageID; 31 | } 32 | 33 | public synchronized void setMessageID(byte[] messageID) { 34 | this.messageID = messageID; 35 | } 36 | 37 | public synchronized byte[] getSessionKey() { 38 | return sessionKey; 39 | } 40 | 41 | public synchronized void setSessionKey(byte[] sessionKey) { 42 | this.sessionKey = sessionKey; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AccountLogoutResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.nio.ByteBuffer; 6 | 7 | import net.hashsploit.clank.server.medius.MediusConstants; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 10 | import net.hashsploit.clank.utils.Utils; 11 | 12 | public class AccountLogoutResponse extends MediusMessage { 13 | 14 | private byte[] messageID; 15 | private byte[] callbackStatus; 16 | 17 | public AccountLogoutResponse(byte[] messageID, byte[] callbackStatus) { 18 | super(MediusMessageType.AccountLoginResponse); 19 | 20 | this.messageID = messageID; 21 | this.callbackStatus = callbackStatus; 22 | } 23 | 24 | @Override 25 | public byte[] getPayload() { 26 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 27 | 28 | try { 29 | outputStream.write(messageID); 30 | outputStream.write(Utils.hexStringToByteArray("000000")); 31 | outputStream.write(callbackStatus); 32 | } catch (IOException e) { 33 | // TODO Auto-generated catch block 34 | e.printStackTrace(); 35 | } 36 | return outputStream.toByteArray(); 37 | } 38 | 39 | 40 | public String toString() { 41 | return "AccountLogoutResponse: \n" + 42 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 43 | "callbackStatus: " + Utils.bytesToHex(callbackStatus); 44 | } 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AccountRegistrationRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusAccountType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | 10 | public class AccountRegistrationRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private MediusAccountType accountType; 15 | private String username; 16 | private String password; 17 | 18 | public AccountRegistrationRequest(byte[] data) { 19 | super(MediusMessageType.AccountRegistration, data); 20 | 21 | ByteBuffer buf = ByteBuffer.wrap(data); 22 | buf.get(messageID); 23 | buf.get(sessionKey); 24 | 25 | // FIXME: ADD REGISTRATION SHIT 26 | // accountType 27 | // accountName (username) 28 | // password 29 | 30 | // TODO: Username most likely is 32-bytes (14+18). 31 | //buf.get(usernameBytes); 32 | //buf.get(new byte[18]); 33 | // TODO: Password is also most likely 32-bytes, probably has 18-bytes trailing. 34 | //buf.get(passwordBytes); 35 | } 36 | 37 | public byte[] getMessageID() { 38 | return messageID; 39 | } 40 | 41 | public synchronized void setMessageID(byte[] messageID) { 42 | this.messageID = messageID; 43 | } 44 | 45 | public byte[] getSessionKey() { 46 | return sessionKey; 47 | } 48 | 49 | public synchronized void setSessionKey(byte[] sessionKey) { 50 | this.sessionKey = sessionKey; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AccountRegistrationResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class AccountRegistrationResponse extends MediusMessage { 12 | 13 | private final byte[] messageId; 14 | 15 | public AccountRegistrationResponse(byte[] messageId) { 16 | super(MediusMessageType.AccountRegistrationResponse); 17 | 18 | this.messageId = messageId; 19 | } 20 | 21 | @Override 22 | public byte[] getPayload() { 23 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 24 | 25 | try { 26 | outputStream.write(messageId); 27 | outputStream.write(Utils.hexStringToByteArray("000000")); 28 | outputStream.write(Utils.intToBytesLittle(MediusCallbackStatus.SUCCESS.getValue())); 29 | outputStream.write(Utils.intToBytesLittle(1)); 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | 34 | return outputStream.toByteArray(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AccountUpdateStatsRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class AccountUpdateStatsRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private byte[] stats = new byte[MediusConstants.ACCOUNTSTATS_MAXLEN.value]; 15 | 16 | public AccountUpdateStatsRequest(byte[] data) { 17 | super(MediusMessageType.AccountUpdateStats, data); 18 | // Process the packet 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageID); 21 | buf.get(sessionKey); 22 | buf.get(stats); 23 | } 24 | 25 | public String toString() { 26 | return "AccountUpdateStatsRequest: \n" + 27 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 28 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 29 | "stats: " + Utils.bytesToHex(stats); 30 | } 31 | 32 | 33 | public synchronized byte[] getMessageID() { 34 | return messageID; 35 | } 36 | 37 | public synchronized void setMessageID(byte[] messageID) { 38 | this.messageID = messageID; 39 | } 40 | 41 | public synchronized byte[] getSessionKey() { 42 | return sessionKey; 43 | } 44 | 45 | public synchronized void setSessionKey(byte[] sessionKey) { 46 | this.sessionKey = sessionKey; 47 | } 48 | 49 | public synchronized byte[] getStats() { 50 | return stats; 51 | } 52 | 53 | public synchronized void setStats(byte[] stats) { 54 | this.stats = stats; 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AddToBuddyListRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class AddToBuddyListRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private byte[] accountID = new byte[4]; 15 | 16 | public AddToBuddyListRequest(byte[] data) { 17 | super(MediusMessageType.AddToBuddyList, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageID); 21 | buf.get(sessionKey); 22 | buf.getShort(); 23 | buf.get(accountID); 24 | } 25 | 26 | public String toString() { 27 | return "AddToBuddyListRequest: \n" + 28 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 29 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 30 | "accountID: " + Utils.bytesToHex(accountID); 31 | } 32 | 33 | public byte[] getMessageID() { 34 | return messageID; 35 | } 36 | 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/AddToBuddyListResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class AddToBuddyListResponse extends MediusMessage { 11 | 12 | private byte[] messageID; 13 | private byte[] callbackStatus; 14 | 15 | public AddToBuddyListResponse(byte[] messageID, byte[] callbackStatus) { 16 | super(MediusMessageType.AddToBuddyListResponse); 17 | 18 | this.messageID = messageID; 19 | this.callbackStatus = callbackStatus; 20 | } 21 | 22 | @Override 23 | public byte[] getPayload() { 24 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 25 | 26 | try { 27 | outputStream.write(messageID); 28 | outputStream.write(Utils.hexStringToByteArray("000000")); 29 | outputStream.write(callbackStatus); 30 | } catch (IOException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | return outputStream.toByteArray(); 35 | } 36 | 37 | 38 | public String toString() { 39 | return "AddToBuddyListResponse: \n" + 40 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 41 | "callbackStatus: " + Utils.bytesToHex(callbackStatus); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ChannelInfoRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ChannelInfoRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private byte[] worldID = new byte[4]; 15 | 16 | public ChannelInfoRequest(byte[] data) { 17 | super(MediusMessageType.ChannelInfo, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageID); 21 | buf.get(sessionKey); 22 | buf.getShort(); // buffer 23 | buf.get(worldID); 24 | } 25 | 26 | public String toString() { 27 | return "ChannelInfoRequest: \n" + 28 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 29 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 30 | "worldID: " + Utils.bytesToHex(worldID); 31 | } 32 | 33 | public synchronized byte[] getMessageID() { 34 | return messageID; 35 | } 36 | 37 | public synchronized void setMessageID(byte[] messageID) { 38 | this.messageID = messageID; 39 | } 40 | 41 | public synchronized byte[] getSessionKey() { 42 | return sessionKey; 43 | } 44 | 45 | public synchronized void setSessionKey(byte[] sessionKey) { 46 | this.sessionKey = sessionKey; 47 | } 48 | 49 | public synchronized byte[] getWorldID() { 50 | return worldID; 51 | } 52 | 53 | public synchronized void setWorldID(byte[] worldID) { 54 | this.worldID = worldID; 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ChannelListRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class ChannelListRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private short pageId; 14 | private short pageSize; 15 | 16 | public ChannelListRequest(byte[] data) { 17 | super(MediusMessageType.ChannelList, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageId); 21 | buf.get(sessionKey); 22 | buf.get(pageId); 23 | buf.get(pageSize); 24 | } 25 | 26 | public byte[] getMessageId() { 27 | return messageId; 28 | } 29 | 30 | public void setMessageId(byte[] messageId) { 31 | this.messageId = messageId; 32 | } 33 | 34 | public byte[] getSessionKey() { 35 | return sessionKey; 36 | } 37 | 38 | public void setSessionKey(byte[] sessionKey) { 39 | this.sessionKey = sessionKey; 40 | } 41 | 42 | public void setPageId(short pageId) { 43 | this.pageId = pageId; 44 | } 45 | 46 | public int getPageId() { 47 | return pageId; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ChannelList_ExtraInfoOneRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ChannelList_ExtraInfoOneRequest extends MediusMessage { 11 | 12 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] pageId = new byte[2]; 14 | private byte[] pageSize = new byte[2]; 15 | 16 | public ChannelList_ExtraInfoOneRequest(byte[] data) { 17 | super(MediusMessageType.ChannelList_ExtraInfo1, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageId); 21 | buf.get(pageId); 22 | buf.get(pageSize); 23 | } 24 | 25 | public String toString() { 26 | return "ChannelList_ExtraInfoOneRequest: \n" + 27 | "messageID: " + Utils.bytesToHex(messageId) + '\n' + 28 | "pageID: " + Utils.bytesToHex(pageId) + '\n' + 29 | "pageSize: " + Utils.bytesToHex(pageSize); 30 | } 31 | 32 | public byte[] getMessageId() { 33 | return messageId; 34 | } 35 | 36 | public byte[] getPageId() { 37 | return pageId; 38 | } 39 | 40 | public byte[] getPageSize() { 41 | return pageSize; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ChatToggleRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ChatToggleRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | 14 | 15 | public ChatToggleRequest(byte[] data) { 16 | super(MediusMessageType.ChatToggle, data); 17 | ByteBuffer buf = ByteBuffer.wrap(data); 18 | buf.get(messageID); 19 | } 20 | 21 | public String toString() { 22 | return "ChatToggleRequest: \n" + 23 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 24 | "rawData: " + Utils.bytesToHex(getPayload()); 25 | } 26 | 27 | public synchronized byte[] getMessageID() { 28 | return messageID; 29 | } 30 | 31 | public synchronized void setMessageID(byte[] messageID) { 32 | this.messageID = messageID; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ChatToggleResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ChatToggleResponse extends MediusMessage { 11 | 12 | private byte[] messageID; 13 | private byte[] callbackStatus; 14 | 15 | public ChatToggleResponse(byte[] messageID, byte[] callbackStatus) { 16 | super(MediusMessageType.ChatToggleResponse); 17 | 18 | this.messageID = messageID; 19 | this.callbackStatus = callbackStatus; 20 | } 21 | 22 | @Override 23 | public byte[] getPayload() { 24 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 25 | 26 | try { 27 | outputStream.write(messageID); 28 | outputStream.write(Utils.hexStringToByteArray("000000")); 29 | outputStream.write(callbackStatus); 30 | } catch (IOException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | return outputStream.toByteArray(); 35 | } 36 | 37 | 38 | public String toString() { 39 | return "ChatToggleResponse: \n" + 40 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 41 | "callbackStatus: " + Utils.bytesToHex(callbackStatus); 42 | } 43 | 44 | public synchronized byte[] getMessageID() { 45 | return messageID; 46 | } 47 | 48 | public synchronized void setMessageID(byte[] messageID) { 49 | this.messageID = messageID; 50 | } 51 | 52 | public synchronized byte[] getCallbackStatus() { 53 | return callbackStatus; 54 | } 55 | 56 | public synchronized void setCallbackStatus(byte[] callbackStatus) { 57 | this.callbackStatus = callbackStatus; 58 | } 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ClearGameListFilterResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ClearGameListFilterResponse extends MediusMessage { 11 | 12 | private byte[] messageID; 13 | private byte[] callbackStatus; 14 | 15 | public ClearGameListFilterResponse(byte[] messageID, byte[] callbackStatus) { 16 | super(MediusMessageType.ClearGameListFilterResponse); 17 | 18 | this.messageID = messageID; 19 | this.callbackStatus = callbackStatus; 20 | } 21 | 22 | @Override 23 | public byte[] getPayload() { 24 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 25 | try { 26 | outputStream.write(messageID); 27 | outputStream.write(Utils.hexStringToByteArray("000000")); // Padding 28 | outputStream.write(callbackStatus); 29 | } catch (IOException e) { 30 | // TODO Auto-generated catch block 31 | e.printStackTrace(); 32 | } 33 | return outputStream.toByteArray(); 34 | } 35 | 36 | 37 | public String toString() { 38 | return "ClearGameListFilterResponse: \n" + 39 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 40 | "callbackStatus: " + Utils.bytesToHex(callbackStatus); 41 | } 42 | 43 | public synchronized byte[] getMessageID() { 44 | return messageID; 45 | } 46 | 47 | public synchronized void setMessageID(byte[] messageID) { 48 | this.messageID = messageID; 49 | } 50 | 51 | public synchronized byte[] getCallbackStatus() { 52 | return callbackStatus; 53 | } 54 | 55 | public synchronized void setCallbackStatus(byte[] callbackStatus) { 56 | this.callbackStatus = callbackStatus; 57 | } 58 | 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ClearGameListFilterZeroRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ClearGameListFilterZeroRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | 14 | public ClearGameListFilterZeroRequest(byte[] data) { 15 | super(MediusMessageType.ClearGameListFilter0, data); 16 | 17 | ByteBuffer buf = ByteBuffer.wrap(data); 18 | 19 | buf.get(messageID); 20 | } 21 | 22 | public String toString() { 23 | return "ClearGameListFilterZeroRequest: \n" + 24 | "messageID: " + Utils.bytesToHex(messageID); 25 | } 26 | 27 | public synchronized byte[] getMessageID() { 28 | return messageID; 29 | } 30 | 31 | public synchronized void setMessageID(byte[] messageID) { 32 | this.messageID = messageID; 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/CreateClanRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.ByteOrder; 5 | 6 | import net.hashsploit.clank.server.medius.MediusConstants; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class CreateClanRequest extends MediusMessage { 12 | 13 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 14 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 15 | private int applicationId; 16 | private String clanName; 17 | 18 | public CreateClanRequest(byte[] data) { 19 | super(MediusMessageType.CreateClan, data); 20 | 21 | ByteBuffer buf = ByteBuffer.wrap(data); 22 | buf.order(ByteOrder.LITTLE_ENDIAN); 23 | buf.get(messageId); 24 | buf.get(sessionKey); 25 | applicationId = buf.getInt(); 26 | 27 | final byte[] clanNameBytes = new byte[MediusConstants.CLANNAME_MAXLEN.value]; 28 | buf.get(clanNameBytes); 29 | 30 | clanName = Utils.bytesToStringClean(clanNameBytes); 31 | } 32 | 33 | public byte[] getMessageId() { 34 | return messageId; 35 | } 36 | 37 | public byte[] getSessionKey() { 38 | return sessionKey; 39 | } 40 | 41 | public int getApplicationId() { 42 | return applicationId; 43 | } 44 | 45 | public String getClanName() { 46 | return clanName; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/CreateClanResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class CreateClanResponse extends MediusMessage { 12 | 13 | private byte[] messageId; 14 | private MediusCallbackStatus callbackStatus; 15 | private int clanId; 16 | 17 | public CreateClanResponse(byte[] messageId, MediusCallbackStatus callbackStatus, int clanId) { 18 | super(MediusMessageType.CreateClanResponse); 19 | 20 | this.messageId = messageId; 21 | this.callbackStatus = callbackStatus; 22 | this.clanId = clanId; 23 | } 24 | 25 | @Override 26 | public byte[] getPayload() { 27 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 28 | try { 29 | outputStream.write(messageId); 30 | outputStream.write(new byte[3]); // padding 31 | outputStream.write(Utils.intToBytesLittle(callbackStatus.getValue())); 32 | outputStream.write(Utils.intToBytesLittle(clanId)); 33 | } catch (IOException e) { 34 | e.printStackTrace(); 35 | } 36 | return outputStream.toByteArray(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/CreateGameResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class CreateGameResponse extends MediusMessage { 11 | 12 | private byte[] messageID; 13 | private byte[] callbackStatus; 14 | private byte[] newWorldID; 15 | 16 | public CreateGameResponse(byte[] messageID, byte[] callbackStatus, byte[] newWorldID) { 17 | super(MediusMessageType.CreateGameResponse); 18 | this.messageID = messageID; 19 | this.callbackStatus = callbackStatus; 20 | this.newWorldID = newWorldID; 21 | } 22 | 23 | @Override 24 | public byte[] getPayload() { 25 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 26 | try { 27 | outputStream.write(messageID); 28 | outputStream.write(Utils.hexStringToByteArray("000000")); // padding 29 | outputStream.write(callbackStatus); 30 | outputStream.write(newWorldID); 31 | } catch (IOException e) { 32 | // TODO Auto-generated catch block 33 | e.printStackTrace(); 34 | } 35 | 36 | return outputStream.toByteArray(); 37 | } 38 | 39 | 40 | public String toString() { 41 | return "CreateGameResponse: \n" + 42 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 43 | "callbackStatus: " + Utils.bytesToHex(callbackStatus) + '\n' + 44 | "newWorldID: " + Utils.bytesToHex(newWorldID); 45 | } 46 | 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/DnasSignaturePostRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class DnasSignaturePostRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | 15 | public DnasSignaturePostRequest(byte[] data) { 16 | super(MediusMessageType.DnasSignaturePost, data); 17 | 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageID); 20 | buf.get(sessionKey); 21 | } 22 | 23 | public String toString() { 24 | return "DnasSignaturePostRequest: \n" + 25 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 26 | "sessionKey: " + Utils.bytesToHex(sessionKey); 27 | } 28 | 29 | public synchronized byte[] getMessageID() { 30 | return messageID; 31 | } 32 | 33 | public synchronized void setMessageID(byte[] messageID) { 34 | this.messageID = messageID; 35 | } 36 | 37 | public synchronized byte[] getSessionKey() { 38 | return sessionKey; 39 | } 40 | 41 | public synchronized void setSessionKey(byte[] sessionKey) { 42 | this.sessionKey = sessionKey; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/FindPlayerRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class FindPlayerRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private byte[] searchType = new byte[4]; 15 | private byte[] accountId = new byte[4]; 16 | private byte[] accountName = new byte[MediusConstants.PLAYERNAME_MAXLEN.value]; 17 | 18 | public FindPlayerRequest(byte[] data) { 19 | super(MediusMessageType.FindPlayer, data); 20 | 21 | ByteBuffer buf = ByteBuffer.wrap(data); 22 | buf.get(messageID); 23 | buf.get(sessionKey); 24 | buf.get(new byte[2]); 25 | buf.get(searchType); 26 | buf.get(accountId); 27 | buf.get(accountName); 28 | } 29 | 30 | public String toString() { 31 | return "FindPlayerRequest: \n" + 32 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 33 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 34 | "searchType: " + Utils.bytesToHex(searchType) + '\n' + 35 | "accountId: " + Utils.bytesToHex(accountId) + '\n' + 36 | "accountName: " + Utils.bytesToHex(accountName); 37 | } 38 | 39 | public byte[] getAccountId() { 40 | return accountId; 41 | } 42 | 43 | public byte[] getMessageID() { 44 | return messageID; 45 | } 46 | 47 | public byte[] getAccountName() { 48 | return accountName; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/FindWorldByNameRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class FindWorldByNameRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private byte[] name = new byte[MediusConstants.WORLDNAME_MAXLEN.value]; 14 | private int worldType; 15 | 16 | public FindWorldByNameRequest(byte[] data) { 17 | super(MediusMessageType.FindWorldByName, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageId); 21 | buf.get(sessionKey); 22 | buf.get(name); 23 | buf.get(new byte[2]); 24 | 25 | // TODO: change to FindWorldType object 26 | buf.get(worldType); 27 | } 28 | 29 | public byte[] getMessageId() { 30 | return messageId; 31 | } 32 | 33 | public void setMessageId(byte[] messageId) { 34 | this.messageId = messageId; 35 | } 36 | 37 | public byte[] getSessionKey() { 38 | return sessionKey; 39 | } 40 | 41 | public void setSessionKey(byte[] sessionKey) { 42 | this.sessionKey = sessionKey; 43 | } 44 | 45 | public void setName(byte[] name) { 46 | this.name = name; 47 | } 48 | 49 | public byte[] getName() { 50 | return name; 51 | } 52 | 53 | public void setWorldType(int worldType) { 54 | this.worldType = worldType; 55 | } 56 | 57 | public int getWorldType() { 58 | return worldType; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GameInfoZeroRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.ByteOrder; 5 | 6 | import net.hashsploit.clank.server.medius.MediusConstants; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class GameInfoZeroRequest extends MediusMessage { 12 | 13 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 14 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 15 | private int worldId; 16 | 17 | public GameInfoZeroRequest(byte[] data) { 18 | super(MediusMessageType.GameInfo0, data); 19 | 20 | ByteBuffer buf = ByteBuffer.wrap(data); 21 | buf.order(ByteOrder.LITTLE_ENDIAN); 22 | 23 | buf.get(messageId); 24 | buf.get(sessionKey); 25 | buf.getShort(); // buffer 26 | worldId = buf.getInt(); 27 | } 28 | 29 | public String toString() { 30 | return "GameInfoZeroRequest: \n" + 31 | "messageID: " + Utils.bytesToHex(messageId) + '\n' + 32 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 33 | "worldID: " + worldId; 34 | } 35 | 36 | public byte[] getMessageID() { 37 | return messageId; 38 | } 39 | public byte[] getSessionKey() { 40 | return sessionKey; 41 | } 42 | 43 | public int getWorldId() { 44 | return worldId; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GameListRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class GameListRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private int applicationId; 14 | private short pageId; 15 | private short pageSize; 16 | 17 | public GameListRequest(byte[] data) { 18 | super(MediusMessageType.GameList, data); 19 | 20 | ByteBuffer buf = ByteBuffer.wrap(data); 21 | buf.get(messageId); 22 | buf.get(sessionKey); 23 | buf.get(new byte[2]); 24 | buf.get(applicationId); 25 | buf.get(pageId); 26 | buf.get(pageSize); 27 | } 28 | 29 | public byte[] getMessageId() { 30 | return messageId; 31 | } 32 | 33 | public void setMessageId(byte[] messageId) { 34 | this.messageId = messageId; 35 | } 36 | 37 | public byte[] getSessionKey() { 38 | return sessionKey; 39 | } 40 | 41 | public void setSessionKey(byte[] sessionKey) { 42 | this.sessionKey = sessionKey; 43 | } 44 | 45 | public void setApplicationId(int applicationId) { 46 | this.applicationId = applicationId; 47 | } 48 | 49 | public int getApplicationId() { 50 | return applicationId; 51 | } 52 | 53 | public void setPageId(short pageId) { 54 | this.pageId = pageId; 55 | } 56 | 57 | public int getPageId() { 58 | return pageId; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GameList_ExtraInfoZeroRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class GameList_ExtraInfoZeroRequest extends MediusMessage { 11 | 12 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] pageId = new byte[2]; 14 | private byte[] pageSize = new byte[2]; 15 | 16 | public GameList_ExtraInfoZeroRequest(byte[] data) { 17 | super(MediusMessageType.GameList_ExtraInfo0, data); 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageId); 20 | buf.get(pageId); 21 | buf.get(pageSize); 22 | } 23 | 24 | public String toString() { 25 | return "GameList_ExtraInfoZeroRequest: \n" + "messageId: " + Utils.bytesToHex(messageId) + '\n' + "pageId: " + Utils.bytesToHex(pageId) + '\n' + "pageSize: " + Utils.bytesToHex(pageSize); 26 | } 27 | 28 | public byte[] getMessageId() { 29 | return messageId; 30 | } 31 | 32 | public byte[] getPageId() { 33 | return pageId; 34 | } 35 | 36 | public byte[] getPageSize() { 37 | return pageSize; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GameWorldPlayerListRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class GameWorldPlayerListRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private byte[] worldID = new byte[4]; 15 | 16 | public GameWorldPlayerListRequest(byte[] data) { 17 | super(MediusMessageType.GameWorldPlayerList, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageID); 21 | buf.get(sessionKey); 22 | buf.getShort(); // buffer 23 | buf.get(worldID); 24 | } 25 | 26 | public String toString() { 27 | return "GameWorldPlayerListRequest: \n" + 28 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 29 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 30 | "worldID: " + Utils.bytesToHex(worldID); 31 | } 32 | 33 | public synchronized byte[] getMessageID() { 34 | return messageID; 35 | } 36 | 37 | public synchronized void setMessageID(byte[] messageID) { 38 | this.messageID = messageID; 39 | } 40 | 41 | public synchronized byte[] getSessionKey() { 42 | return sessionKey; 43 | } 44 | 45 | public synchronized void setSessionKey(byte[] sessionKey) { 46 | this.sessionKey = sessionKey; 47 | } 48 | 49 | public synchronized byte[] getWorldID() { 50 | return worldID; 51 | } 52 | 53 | public synchronized void setWorldID(byte[] worldID) { 54 | this.worldID = worldID; 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GetAllAnnouncementsRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class GetAllAnnouncementsRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | 15 | public GetAllAnnouncementsRequest(byte[] data) { 16 | super(MediusMessageType.GetAllAnnouncements, data); 17 | 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageID); 20 | buf.get(sessionKey); 21 | } 22 | 23 | public String toString() { 24 | return "GetAllAnnouncementsRequest: \n" + 25 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 26 | "sessionKey: " + Utils.bytesToHex(sessionKey); 27 | } 28 | 29 | public synchronized byte[] getMessageId() { 30 | return messageID; 31 | } 32 | 33 | public synchronized void setMessageID(byte[] messageID) { 34 | this.messageID = messageID; 35 | } 36 | 37 | public synchronized byte[] getSessionKey() { 38 | return sessionKey; 39 | } 40 | 41 | public synchronized void setSessionKey(byte[] sessionKey) { 42 | this.sessionKey = sessionKey; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GetAnnouncementsRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class GetAnnouncementsRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private int appId; 14 | 15 | public GetAnnouncementsRequest(byte[] data) { 16 | super(MediusMessageType.GetAnnouncements, data); 17 | 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageId); 20 | buf.get(sessionKey); 21 | buf.get(new byte[2]); 22 | buf.get(appId); 23 | } 24 | 25 | public byte[] getMessageId() { 26 | return messageId; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GetBuddyInvitationsRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class GetBuddyInvitationsRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | 13 | public GetBuddyInvitationsRequest(byte[] data) { 14 | super(MediusMessageType.GetBuddyInvitations, data); 15 | 16 | ByteBuffer buf = ByteBuffer.wrap(data); 17 | buf.get(messageId); 18 | } 19 | 20 | public byte[] getMessageId() { 21 | return messageId; 22 | } 23 | 24 | public void setMessageId(byte[] messageId) { 25 | this.messageId = messageId; 26 | } 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GetLobbyPlayerNames_ExtraInfoRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class GetLobbyPlayerNames_ExtraInfoRequest extends MediusMessage { 11 | 12 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] lobbyWorldId = new byte[4]; 14 | 15 | public GetLobbyPlayerNames_ExtraInfoRequest(byte[] data) { 16 | super(MediusMessageType.GetLobbyPlayerNames_ExtraInfo, data); 17 | 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageId); 20 | buf.get(new byte[3]); 21 | buf.get(lobbyWorldId); 22 | } 23 | 24 | public String toString() { 25 | return "GetLobbyPlayerNames_ExtraInfoRequest: \n" + 26 | "messageID: " + Utils.bytesToHex(messageId) + '\n' + 27 | "lobbyWorldID: " + Utils.bytesToHex(lobbyWorldId); 28 | } 29 | 30 | public synchronized byte[] getLobbyWorldId() { 31 | return lobbyWorldId; 32 | } 33 | 34 | public synchronized void setLobbyWorldID(byte[] lobbyWorldID) { 35 | this.lobbyWorldId = lobbyWorldID; 36 | } 37 | 38 | public synchronized byte[] getMessageID() { 39 | return messageId; 40 | } 41 | 42 | public synchronized void setMessageID(byte[] messageID) { 43 | this.messageId = messageID; 44 | } 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GetMyIPRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class GetMyIPRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | 14 | public GetMyIPRequest(byte[] data) { 15 | super(MediusMessageType.GetMyIP, data); 16 | 17 | ByteBuffer buf = ByteBuffer.wrap(data); 18 | buf.get(messageId); 19 | buf.get(sessionKey); 20 | } 21 | 22 | public byte[] getMessageId() { 23 | return messageId; 24 | } 25 | 26 | public void setMessageId(byte[] messageId) { 27 | this.messageId = messageId; 28 | } 29 | 30 | public byte[] getSessionKey() { 31 | return sessionKey; 32 | } 33 | 34 | public void setSessionKey(byte[] sessionKey) { 35 | this.sessionKey = sessionKey; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GetMyIPResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 7 | import net.hashsploit.clank.server.medius.MediusConstants; 8 | import net.hashsploit.clank.server.medius.MediusMessageType; 9 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 10 | import net.hashsploit.clank.utils.Utils; 11 | 12 | public class GetMyIPResponse extends MediusMessage { 13 | 14 | private byte[] messageId; 15 | private String ipAddress; 16 | private MediusCallbackStatus callbackStatus; 17 | 18 | public GetMyIPResponse(byte[] messageId, String ipAddress, int port, MediusCallbackStatus callbackStatus) { 19 | super(MediusMessageType.GetMyIPResponse); 20 | 21 | this.messageId = messageId; 22 | this.ipAddress = ipAddress; 23 | this.callbackStatus = callbackStatus; 24 | } 25 | 26 | @Override 27 | public byte[] getPayload() { 28 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 29 | try { 30 | outputStream.write(messageId); 31 | outputStream.write(Utils.buildByteArrayFromString(ipAddress, MediusConstants.IP_MAXLEN.value)); 32 | outputStream.write(Utils.hexStringToByteArray("000000")); // padding 33 | outputStream.write(Utils.intToBytesLittle(callbackStatus.getValue())); 34 | } catch (IOException e) { 35 | e.printStackTrace(); 36 | } 37 | return outputStream.toByteArray(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/GetUniverseInformationRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class GetUniverseInformationRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] infoType = new byte[4]; 13 | private byte[] mediusCharacterEncodingType = new byte[4]; 14 | private byte[] mediusLanguageType = new byte[4]; 15 | 16 | public GetUniverseInformationRequest(byte[] data) { 17 | super(MediusMessageType.GetUniverseInformation, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageId); 21 | buf.get(new byte[3]); 22 | buf.get(infoType); 23 | buf.get(mediusCharacterEncodingType); 24 | buf.get(mediusLanguageType); 25 | } 26 | 27 | public byte[] getMessageId() { 28 | return messageId; 29 | } 30 | 31 | public byte[] getInfoType() { 32 | return infoType; 33 | } 34 | 35 | public byte[] getMediusCharacterEncodingType() { 36 | return mediusCharacterEncodingType; 37 | } 38 | 39 | public byte[] getMediusLanguageType() { 40 | return mediusLanguageType; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/LadderList_ExtraInfoRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class LadderList_ExtraInfoRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] ladderStatIndex = new byte[4]; 14 | private byte[] mediusSortOrder = new byte[4]; 15 | private byte[] startPosition = new byte[4]; 16 | private byte[] pageSize = new byte[4]; 17 | 18 | public LadderList_ExtraInfoRequest(byte[] data) { 19 | super(MediusMessageType.LadderList_ExtraInfo, data); 20 | 21 | ByteBuffer buf = ByteBuffer.wrap(data); 22 | buf.get(messageID); 23 | buf.get(new byte[3]); 24 | buf.get(ladderStatIndex); 25 | buf.get(mediusSortOrder); 26 | buf.get(startPosition); 27 | buf.get(pageSize); 28 | } 29 | 30 | public String toString() { 31 | return "LadderList_ExtraInfoRequest (" + "messageId: " + Utils.bytesToHex(messageID) + ", " + "ladderStatIndex: " + Utils.bytesToHex(ladderStatIndex) + ", " + "mediusSortOrder: " + Utils.bytesToHex(mediusSortOrder) + "," + "startPosition: " + Utils.bytesToHex(startPosition) + "," 32 | + "pageSize: " + Utils.bytesToHex(pageSize) + ")"; 33 | } 34 | 35 | public byte[] getMessageId() { 36 | return messageID; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/LadderPositionRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.nio.ByteBuffer; 6 | 7 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 8 | import net.hashsploit.clank.server.medius.MediusConstants; 9 | import net.hashsploit.clank.server.medius.MediusMessageType; 10 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 11 | import net.hashsploit.clank.utils.Utils; 12 | 13 | public class LadderPositionRequest extends MediusMessage { 14 | 15 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 16 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 17 | 18 | public LadderPositionRequest(byte[] data) { 19 | super(MediusMessageType.LadderPosition); 20 | 21 | 22 | ByteBuffer buf = ByteBuffer.wrap(data); 23 | buf.get(messageId); 24 | buf.get(sessionKey); 25 | buf.get(new byte[2]); // padding 26 | buf.get(new byte[4]); // account id 27 | buf.get(new byte[4]); // start byte 28 | buf.get(new byte[4]); // end byte 29 | buf.get(new byte[4]); // medius sort order object 30 | } 31 | 32 | @Override 33 | public byte[] getPayload() { 34 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 35 | 36 | try { 37 | outputStream.write(messageId); 38 | outputStream.write(Utils.hexStringToByteArray("000000")); 39 | outputStream.write(Utils.intToBytesLittle(MediusCallbackStatus.SUCCESS.getValue())); 40 | outputStream.write(Utils.intToBytesLittle(1)); 41 | } catch (IOException e) { 42 | e.printStackTrace(); 43 | } 44 | 45 | return outputStream.toByteArray(); 46 | } 47 | 48 | public byte[] getMessageId() { 49 | return messageId; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/LadderPositionResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class LadderPositionResponse extends MediusMessage { 12 | 13 | private final byte[] messageId; 14 | 15 | public LadderPositionResponse(byte[] messageId) { 16 | super(MediusMessageType.LadderPositionResponse); 17 | 18 | this.messageId = messageId; 19 | } 20 | 21 | @Override 22 | public byte[] getPayload() { 23 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 24 | 25 | try { 26 | outputStream.write(messageId); 27 | outputStream.write(Utils.hexStringToByteArray("000000")); 28 | outputStream.write(Utils.intToBytesLittle(1)); 29 | outputStream.write(Utils.intToBytesLittle(MediusCallbackStatus.SUCCESS.getValue())); 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | 34 | return outputStream.toByteArray(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/LadderPosition_ExtraInfoRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class LadderPosition_ExtraInfoRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] accountId = new byte[4]; 14 | private byte[] ladderStatIndex = new byte[4]; 15 | private byte[] sortOrder = new byte[4]; 16 | 17 | public LadderPosition_ExtraInfoRequest(byte[] data) { 18 | super(MediusMessageType.LadderPosition_ExtraInfo, data); 19 | 20 | ByteBuffer buf = ByteBuffer.wrap(data); 21 | buf.get(messageID); 22 | buf.get(new byte[3]); 23 | buf.get(accountId); 24 | buf.get(ladderStatIndex); 25 | buf.get(sortOrder); 26 | } 27 | 28 | public String toString() { 29 | return "LadderPosition_ExtraInfoRequest: \n" + 30 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 31 | "accountId: " + Utils.bytesToHex(accountId) + '\n' + 32 | "ladderStatIndex: " + Utils.bytesToHex(ladderStatIndex) + '\n' + 33 | "sortOrder: " + Utils.bytesToHex(sortOrder); 34 | } 35 | 36 | public byte[] getAccountId() { 37 | return accountId; 38 | } 39 | 40 | public byte[] getMessageID() { 41 | return messageID; 42 | } 43 | 44 | public byte[] getLadderStatIndex() { 45 | return ladderStatIndex; 46 | } 47 | 48 | public byte[] getSortOrder() { 49 | return sortOrder; 50 | } 51 | 52 | 53 | } -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/LobbyWorldPlayerListRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class LobbyWorldPlayerListRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private int worldId; 14 | 15 | public LobbyWorldPlayerListRequest(byte[] data) { 16 | super(MediusMessageType.LobbyWorldPlayerList, data); 17 | 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageId); 20 | buf.get(sessionKey); 21 | buf.get(new byte[2]); 22 | buf.get(worldId); 23 | } 24 | 25 | public byte[] getMessageId() { 26 | return messageId; 27 | } 28 | 29 | public void setMessageId(byte[] messageId) { 30 | this.messageId = messageId; 31 | } 32 | 33 | public byte[] getSessionKey() { 34 | return sessionKey; 35 | } 36 | 37 | public void setSessionKey(byte[] sessionKey) { 38 | this.sessionKey = sessionKey; 39 | } 40 | 41 | public void setWorldId(int worldId) { 42 | this.worldId = worldId; 43 | } 44 | 45 | public int getWorldId() { 46 | return worldId; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/PickLocationRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class PickLocationRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private int locationId; 14 | 15 | public PickLocationRequest(byte[] data) { 16 | super(MediusMessageType.PickLocation, data); 17 | 18 | ByteBuffer buf = ByteBuffer.wrap(data); 19 | buf.get(messageId); 20 | buf.get(sessionKey); 21 | buf.get(new byte[2]); // padding 22 | buf.get(locationId); 23 | } 24 | 25 | public byte[] getMessageId() { 26 | return messageId; 27 | } 28 | 29 | public void setMessageId(byte[] messageId) { 30 | this.messageId = messageId; 31 | } 32 | 33 | public byte[] getSessionKey() { 34 | return sessionKey; 35 | } 36 | 37 | public void setSessionKey(byte[] sessionKey) { 38 | this.sessionKey = sessionKey; 39 | } 40 | 41 | public void setLocationId(int locationId) { 42 | this.locationId = locationId; 43 | } 44 | 45 | public int getLocationId() { 46 | return locationId; 47 | } 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/PickLocationResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class PickLocationResponse extends MediusMessage { 12 | 13 | private byte[] messageID; 14 | private MediusCallbackStatus callbackStatus; 15 | 16 | public PickLocationResponse(byte[] messageID, MediusCallbackStatus callbackStatus) { 17 | super(MediusMessageType.PickLocationResponse); 18 | 19 | this.messageID = messageID; 20 | this.callbackStatus = callbackStatus; 21 | } 22 | 23 | @Override 24 | public byte[] getPayload() { 25 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 26 | try { 27 | outputStream.write(messageID); 28 | outputStream.write(Utils.hexStringToByteArray("000000")); // padding 29 | outputStream.write(Utils.intToBytesLittle(callbackStatus.getValue())); 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | return outputStream.toByteArray(); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/PlayerInfoRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class PlayerInfoRequest extends MediusMessage { 11 | 12 | private byte[] messageID = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 14 | private byte[] accountID = new byte[4]; 15 | 16 | public PlayerInfoRequest(byte[] data) { 17 | super(MediusMessageType.PlayerInfo, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageID); 21 | buf.get(sessionKey); 22 | buf.getShort(); // buffer 23 | buf.get(accountID); 24 | } 25 | 26 | public String toString() { 27 | return "PlayerInfoRequest: \n" + 28 | "messageID: " + Utils.bytesToHex(messageID) + '\n' + 29 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 30 | "accountID: " + Utils.bytesToHex(accountID); 31 | } 32 | 33 | public synchronized byte[] getMessageID() { 34 | return messageID; 35 | } 36 | 37 | public synchronized void setMessageID(byte[] messageID) { 38 | this.messageID = messageID; 39 | } 40 | 41 | public synchronized byte[] getSessionKey() { 42 | return sessionKey; 43 | } 44 | 45 | public synchronized void setSessionKey(byte[] sessionKey) { 46 | this.sessionKey = sessionKey; 47 | } 48 | 49 | public synchronized byte[] getAccountID() { 50 | return accountID; 51 | } 52 | 53 | public synchronized void setAccountID(byte[] accountID) { 54 | this.accountID = accountID; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/PlayerReportRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class PlayerReportRequest extends MediusMessage { 11 | 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private byte[] mediusWorldID = new byte[4]; 14 | private byte[] stats = new byte[MediusConstants.ACCOUNTSTATS_MAXLEN.value]; 15 | 16 | 17 | public PlayerReportRequest(byte[] data) { 18 | super(MediusMessageType.PlayerReport, data); 19 | // Process the packet 20 | ByteBuffer buf = ByteBuffer.wrap(data); 21 | 22 | buf.get(sessionKey); 23 | buf.get(new byte[3]); // buffer 24 | buf.get(mediusWorldID); 25 | buf.get(stats); 26 | 27 | } 28 | 29 | public String toString() { 30 | return "PlayerReportRequest: \n" + 31 | "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 32 | "mediusWorldID: " + Utils.bytesToHex(mediusWorldID) + '\n' + 33 | "stats: " + Utils.bytesToHex(stats); 34 | } 35 | 36 | public synchronized byte[] getSessionKey() { 37 | return sessionKey; 38 | } 39 | 40 | public synchronized void setSessionKey(byte[] sessionKey) { 41 | this.sessionKey = sessionKey; 42 | } 43 | 44 | public synchronized byte[] getMediusWorldID() { 45 | return mediusWorldID; 46 | } 47 | 48 | public synchronized void setMediusWorldID(byte[] mediusWorldID) { 49 | this.mediusWorldID = mediusWorldID; 50 | } 51 | 52 | public synchronized byte[] getStats() { 53 | return stats; 54 | } 55 | 56 | public synchronized void setStats(byte[] stats) { 57 | this.stats = stats; 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ServerAuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ServerAuthenticationRequest extends MediusMessage { 11 | 12 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 13 | private byte[] trustLevel = new byte[4]; // int 14 | private byte[] addressList = new byte[48]; // NetAddressList 15 | 16 | public ServerAuthenticationRequest(byte[] data) { 17 | super(MediusMessageType.MediusServerAuthenticationRequest, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageId); 21 | buf.get(); // 1 byte padding 22 | buf.getShort(); // 2 byte padding 23 | buf.get(trustLevel); 24 | buf.get(addressList); 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "ServerAuthenticationRequest: \n" + 30 | "messageId: " + Utils.bytesToHex(messageId) + '\n' + 31 | "trustLevel: " + Utils.bytesToHex(trustLevel) + '\n' + 32 | "addressList: " + Utils.bytesToHex(addressList); 33 | } 34 | 35 | public byte[] getMessageId() { 36 | return messageId; 37 | } 38 | 39 | public byte[] getLocationId() { 40 | return trustLevel; 41 | } 42 | 43 | public byte[] getNetAddressList() { 44 | return addressList; 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ServerAuthenticationResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ServerAuthenticationResponse extends MediusMessage { 11 | 12 | private byte[] messageId; 13 | private byte confirmation; 14 | private byte[] connectInfo; 15 | 16 | 17 | public ServerAuthenticationResponse(byte[] messageId, byte confirmation, byte[] connectInfo) { 18 | super(MediusMessageType.MediusServerAuthenticationResponse); 19 | this.messageId = messageId; 20 | this.confirmation = confirmation; 21 | this.connectInfo = connectInfo; 22 | } 23 | 24 | @Override 25 | public byte[] getPayload() { 26 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 27 | 28 | try { 29 | outputStream.write(messageId); 30 | outputStream.write(confirmation); 31 | outputStream.write(Utils.hexStringToByteArray("0000")); 32 | outputStream.write(connectInfo); 33 | } catch (IOException e) { 34 | // TODO Auto-generated catch block 35 | e.printStackTrace(); 36 | } 37 | 38 | return outputStream.toByteArray(); 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "ServerSessionBeginResponse: \n" + 44 | "messageId: " + Utils.bytesToHex(messageId) + '\n' + 45 | "confirmation: " + Utils.byteToHex(confirmation) + '\n' + 46 | "connectInfo: " + Utils.bytesToHex(connectInfo); 47 | } 48 | 49 | public byte[] getMessageId() { 50 | return messageId; 51 | } 52 | 53 | public byte getConfirmation() { 54 | return confirmation; 55 | } 56 | 57 | public byte[] getConnectInfo() { 58 | return connectInfo; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/ServerSessionBeginResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | public class ServerSessionBeginResponse extends MediusMessage { 11 | 12 | private byte[] messageId; 13 | private byte confirmation; 14 | private byte[] connectInfo; 15 | 16 | 17 | public ServerSessionBeginResponse(byte[] messageId, byte confirmation, byte[] connectInfo) { 18 | super(MediusMessageType.MediusServerSessionBeginResponse); 19 | this.messageId = messageId; 20 | this.confirmation = confirmation; 21 | this.connectInfo = connectInfo; 22 | } 23 | 24 | @Override 25 | public byte[] getPayload() { 26 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 27 | 28 | try { 29 | outputStream.write(messageId); 30 | outputStream.write(confirmation); 31 | outputStream.write(Utils.hexStringToByteArray("0000")); 32 | outputStream.write(connectInfo); 33 | } catch (IOException e) { 34 | // TODO Auto-generated catch block 35 | e.printStackTrace(); 36 | } 37 | 38 | return outputStream.toByteArray(); 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "ServerSessionBeginResponse: \n" + 44 | "messageId: " + Utils.bytesToHex(messageId) + '\n' + 45 | "confirmation: " + Utils.byteToHex(confirmation) + '\n' + 46 | "connectInfo: " + Utils.bytesToHex(connectInfo); 47 | } 48 | 49 | public byte[] getMessageId() { 50 | return messageId; 51 | } 52 | 53 | public byte getConfirmation() { 54 | return confirmation; 55 | } 56 | 57 | public byte[] getConnectInfo() { 58 | return connectInfo; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/SessionEndRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class SessionEndRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | 14 | public SessionEndRequest(byte[] data) { 15 | super(MediusMessageType.SessionEnd, data); 16 | 17 | ByteBuffer buf = ByteBuffer.wrap(data); 18 | buf.get(messageId); 19 | buf.get(sessionKey); 20 | } 21 | 22 | public byte[] getMessageId() { 23 | return messageId; 24 | } 25 | 26 | public byte[] getSessionKey() { 27 | return sessionKey; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/SessionEndResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class SessionEndResponse extends MediusMessage { 12 | 13 | private byte[] messageId; 14 | private MediusCallbackStatus callbackStatus; 15 | 16 | public SessionEndResponse(byte[] messageId, MediusCallbackStatus callbackStatus) { 17 | super(MediusMessageType.SessionEndResponse); 18 | 19 | this.messageId = messageId; 20 | this.callbackStatus = callbackStatus; 21 | } 22 | 23 | @Override 24 | public byte[] getPayload() { 25 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 26 | try { 27 | outputStream.write(messageId); 28 | outputStream.write(new byte[3]); // padding 29 | outputStream.write(Utils.intToBytesLittle(callbackStatus.getValue())); 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | return outputStream.toByteArray(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/SetLocalizationParamsRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class SetLocalizationParamsRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | private int characterEncoding; 14 | private int languageType; 15 | 16 | public SetLocalizationParamsRequest(byte[] data) { 17 | super(MediusMessageType.SetLocalizationParams, data); 18 | 19 | ByteBuffer buf = ByteBuffer.wrap(data); 20 | buf.get(messageId); 21 | buf.get(sessionKey); 22 | buf.getShort(); // 2 byte padding 23 | buf.get(characterEncoding); 24 | buf.get(languageType); 25 | } 26 | 27 | // @Override 28 | // public String toString() { 29 | // return "SetLocalizationParamsRequest: \n" + 30 | // "messageId: " + Utils.bytesToHex(messageId) + '\n' + 31 | // "sessionKey: " + Utils.bytesToHex(sessionKey) + '\n' + 32 | // "characterEncoding: " + Utils.bytesToHex(characterEncoding) + '\n' + 33 | // "languageType: " + Utils.bytesToHex(languageType); 34 | // } 35 | 36 | public byte[] getMessageId() { 37 | return messageId; 38 | } 39 | 40 | public byte[] getSessionKey() { 41 | return sessionKey; 42 | } 43 | 44 | public int getLanguageType() { 45 | return languageType; 46 | } 47 | 48 | public int getCharacterEncoding() { 49 | return characterEncoding; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/SetLocalizationParamsResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusCallbackStatus; 7 | import net.hashsploit.clank.server.medius.MediusMessageType; 8 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 9 | import net.hashsploit.clank.utils.Utils; 10 | 11 | public class SetLocalizationParamsResponse extends MediusMessage { 12 | 13 | private byte[] messageId; 14 | private MediusCallbackStatus callbackStatus; 15 | 16 | 17 | public SetLocalizationParamsResponse(byte[] messageId, MediusCallbackStatus callbackStatus) { 18 | super(MediusMessageType.SetLocalizationParamsResponse); 19 | this.messageId = messageId; 20 | this.callbackStatus = callbackStatus; 21 | } 22 | 23 | @Override 24 | public byte[] getPayload() { 25 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 26 | 27 | try { 28 | outputStream.write(messageId); 29 | outputStream.write(Utils.hexStringToByteArray("000000")); 30 | outputStream.write(Utils.intToBytesLittle(callbackStatus.getValue())); 31 | } catch (IOException e) { 32 | // TODO Auto-generated catch block 33 | e.printStackTrace(); 34 | } 35 | 36 | return outputStream.toByteArray(); 37 | } 38 | 39 | // @Override 40 | // public String toString() { 41 | // return "ServerSessionBeginResponse: \n" + 42 | // "messageId: " + Utils.bytesToHex(messageId) + '\n' + 43 | // "callbackStatus: " + Utils.bytesToHex(callbackStatus.getValue()); 44 | // } 45 | 46 | // public byte[] getMessageId() { 47 | // return messageId; 48 | // } 49 | 50 | // public byte getCallbackStatus() { 51 | // return callbackStatus.getValue(); 52 | // } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/VersionServerRequest.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import net.hashsploit.clank.server.medius.MediusConstants; 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | 9 | public class VersionServerRequest extends MediusMessage { 10 | 11 | private byte[] messageId = new byte[MediusConstants.MESSAGEID_MAXLEN.value]; 12 | private byte[] sessionKey = new byte[MediusConstants.SESSIONKEY_MAXLEN.value]; 13 | 14 | public VersionServerRequest(byte[] data) { 15 | super(MediusMessageType.VersionServer, data); 16 | 17 | ByteBuffer buf = ByteBuffer.wrap(data); 18 | buf.get(messageId); 19 | buf.get(sessionKey); 20 | } 21 | 22 | public byte[] getMessageId() { 23 | return messageId; 24 | } 25 | 26 | public void setMessageId(byte[] messageId) { 27 | this.messageId = messageId; 28 | } 29 | 30 | public byte[] getSessionKey() { 31 | return sessionKey; 32 | } 33 | 34 | public void setSessionKey(byte[] sessionKey) { 35 | this.sessionKey = sessionKey; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/medius/serializers/VersionServerResponse.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.medius.serializers; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | 6 | import net.hashsploit.clank.server.medius.MediusMessageType; 7 | import net.hashsploit.clank.server.medius.objects.MediusMessage; 8 | import net.hashsploit.clank.utils.Utils; 9 | 10 | 11 | public class VersionServerResponse extends MediusMessage { 12 | 13 | private byte[] messageId; 14 | private String serverVersion; 15 | 16 | public VersionServerResponse(byte[] messageId, String serverVersion) { 17 | super(MediusMessageType.VersionServerResponse); 18 | 19 | this.messageId = messageId; 20 | this.serverVersion = serverVersion; 21 | } 22 | 23 | @Override 24 | public byte[] getPayload() { 25 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 26 | try { 27 | outputStream.write(messageId); 28 | outputStream.write(Utils.buildByteArrayFromString(serverVersion, 56)); 29 | } catch (IOException e) { 30 | e.printStackTrace(); 31 | } 32 | return outputStream.toByteArray(); 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/muis/MediusUniverseInformationServer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.muis; 2 | 3 | import net.hashsploit.clank.Clank; 4 | import net.hashsploit.clank.EmulationMode; 5 | import net.hashsploit.clank.config.configs.MuisConfig; 6 | import net.hashsploit.clank.server.medius.MediusServer; 7 | 8 | public class MediusUniverseInformationServer extends MediusServer { 9 | 10 | public MediusUniverseInformationServer(String address, int port, int parentThreads, int childThreads) { 11 | super(EmulationMode.MEDIUS_UNIVERSE_INFORMATION_SERVER, address, port, parentThreads, childThreads); 12 | 13 | if (Clank.getInstance().getConfig() instanceof MuisConfig) { 14 | final MuisConfig muisConfig = (MuisConfig) Clank.getInstance().getConfig(); 15 | for (UniverseInfo universe : muisConfig.getUniverseInformation()) { 16 | logger.finest("Universes: " + universe.toString()); 17 | } 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/muis/UniverseInfo.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.muis; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class UniverseInfo { 6 | 7 | @SerializedName("name") 8 | private String name; 9 | 10 | @SerializedName("description") 11 | private String description; 12 | 13 | @SerializedName("hostname") 14 | private String hostname; 15 | 16 | @SerializedName("port") 17 | private int port; 18 | 19 | @SerializedName("application_id") 20 | private int applicationId; 21 | 22 | @SerializedName("universe_id") 23 | private int universeId; 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public String getDescription() { 30 | return description; 31 | } 32 | 33 | public String getHostname() { 34 | return hostname; 35 | } 36 | 37 | public int getPort() { 38 | return port; 39 | } 40 | 41 | public int getApplicationId() { 42 | return applicationId; 43 | } 44 | 45 | public int getUniverseId() { 46 | return universeId; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "UniverseInfo{" + 52 | "name='" + name + '\'' + 53 | ", description='" + description + '\'' + 54 | ", hostname='" + hostname + '\'' + 55 | ", port=" + port + 56 | ", applicationId=" + applicationId + 57 | ", universeId=" + universeId + 58 | '}'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/nat/NatClient.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.nat; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import io.netty.channel.socket.DatagramChannel; 6 | import net.hashsploit.clank.server.ClientState; 7 | import net.hashsploit.clank.server.IClient; 8 | import net.hashsploit.clank.server.pipeline.NatHandler; 9 | 10 | public class NatClient implements IClient { 11 | 12 | private static final Logger logger = Logger.getLogger(NatClient.class.getName()); 13 | 14 | private final NatServer server; 15 | private final DatagramChannel channel; 16 | 17 | public NatClient(NatServer server, DatagramChannel ch) { 18 | this.server = server; 19 | this.channel = ch; 20 | 21 | channel.pipeline().addLast("NatPipelineHandler", new NatHandler(this)); 22 | } 23 | 24 | @Override 25 | public String getIPAddress() { 26 | return channel.remoteAddress().getAddress().getHostAddress(); 27 | } 28 | 29 | @Override 30 | public int getPort() { 31 | return channel.remoteAddress().getPort(); 32 | } 33 | 34 | @Override 35 | public ClientState getClientState() { 36 | return null; 37 | } 38 | 39 | @Override 40 | public void onDisconnect() { 41 | 42 | } 43 | 44 | public String getServerIPAddress() { 45 | return server.getPublicIp(); 46 | //return server.getAddress(); 47 | } 48 | 49 | public int getServerPort() { 50 | return server.getPort(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/nat/NatClientInitializer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.nat; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.ChannelInitializer; 5 | import io.netty.channel.FixedRecvByteBufAllocator; 6 | import io.netty.channel.socket.DatagramChannel; 7 | import io.netty.handler.timeout.ReadTimeoutException; 8 | import net.hashsploit.clank.Clank; 9 | 10 | public class NatClientInitializer extends ChannelInitializer { 11 | 12 | private final NatServer server; 13 | 14 | public NatClientInitializer(NatServer server) { 15 | super(); 16 | this.server = server; 17 | } 18 | 19 | @Override 20 | protected void initChannel(DatagramChannel ch) { 21 | 22 | // TODO: Pull bytebuffer allocator from config 23 | ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(2048)); 24 | 25 | 26 | final NatClient client = new NatClient(server, ch); 27 | server.addClient(client); 28 | } 29 | 30 | @Override 31 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) { 32 | 33 | if (!(e.getCause() instanceof ReadTimeoutException)) { 34 | Clank.getInstance().getTerminal().handleException(e); 35 | } 36 | 37 | ctx.channel().close().awaitUninterruptibly(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/nat/NatServer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.nat; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import net.hashsploit.clank.server.UdpServer; 6 | import net.hashsploit.clank.utils.Utils; 7 | 8 | public class NatServer extends UdpServer { 9 | 10 | private static final Logger logger = Logger.getLogger(NatServer.class.getName()); 11 | private String publicIp; 12 | 13 | public NatServer(String address, int port, int threads) { 14 | super(address, port, threads); 15 | setChannelInitializer(new NatClientInitializer(this)); 16 | publicIp = Utils.getPublicIpAddress(); 17 | } 18 | 19 | @Override 20 | public void start() { 21 | super.start(); 22 | } 23 | 24 | 25 | @Override 26 | public void stop() { 27 | super.stop(); 28 | } 29 | 30 | public String getPublicIp() { 31 | return publicIp; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/pipeline/RtFrameEncoderHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.pipeline; 2 | 3 | import java.util.List; 4 | import java.util.logging.Logger; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | import io.netty.channel.ChannelHandlerContext; 8 | import io.netty.handler.codec.MessageToByteEncoder; 9 | import net.hashsploit.clank.server.MediusClient; 10 | 11 | public class RtFrameEncoderHandler extends MessageToByteEncoder> { 12 | 13 | private static final Logger logger = Logger.getLogger(RtFrameEncoderHandler.class.getName()); 14 | private final MediusClient client; 15 | 16 | public RtFrameEncoderHandler(MediusClient client) { 17 | this.client = client; 18 | } 19 | 20 | @Override 21 | protected void encode(ChannelHandlerContext ctx, List msgs, ByteBuf out) throws Exception { 22 | for (ByteBuf msg : msgs) { 23 | out.writeBytes(msg); 24 | } 25 | } 26 | 27 | @Override 28 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { 29 | // Close the connection when an exception is raised. 30 | logger.warning(String.format("Exception in %s from %s: %s", RtFrameDecoderHandler.class.getName(), ctx.channel().remoteAddress().toString(), cause.getMessage())); 31 | cause.printStackTrace(); 32 | ctx.close(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/pipeline/TimeoutHandler.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.pipeline; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.handler.timeout.ReadTimeoutException; 5 | import io.netty.handler.timeout.ReadTimeoutHandler; 6 | import net.hashsploit.clank.server.IClient; 7 | 8 | public class TimeoutHandler extends ReadTimeoutHandler { 9 | 10 | private IClient client; 11 | 12 | public TimeoutHandler(IClient client, int timeoutSeconds) { 13 | super(timeoutSeconds); 14 | this.client = client; 15 | } 16 | 17 | @Override 18 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { 19 | if (cause instanceof ReadTimeoutException) { 20 | client.onDisconnect(); 21 | } else { 22 | super.exceptionCaught(ctx, cause); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/rpc/ClankMasRpcClient.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.rpc; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import io.grpc.ManagedChannel; 6 | import io.grpc.StatusRuntimeException; 7 | import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder; 8 | import net.hashsploit.clank.server.rpc.ClankMlsServiceGrpc.ClankMlsServiceBlockingStub; 9 | 10 | public class ClankMasRpcClient { 11 | 12 | private static final Logger logger = Logger.getLogger(ClankMasRpcClient.class.getName()); 13 | 14 | private final ManagedChannel grpcChannel; 15 | private ClankMlsServiceBlockingStub syncStub; 16 | 17 | public ClankMasRpcClient(String address, int port) { 18 | 19 | // FIXME: add support for encryption 20 | this.grpcChannel = NettyChannelBuilder.forTarget(String.format("%s:%s", address, Integer.toString(port))).usePlaintext().build(); 21 | this.syncStub = ClankMlsServiceGrpc.newBlockingStub(grpcChannel); 22 | 23 | } 24 | 25 | public PlayerLoginResponse loginPlayer(String username, String password, String sessionKey) { 26 | PlayerLoginRequest request = PlayerLoginRequest.newBuilder().setUsername(username).setPassword(password).setSessionKey(sessionKey).build(); 27 | PlayerLoginResponse response; 28 | try { 29 | response = syncStub.playerLogin(request); 30 | } catch (StatusRuntimeException e) { 31 | e.printStackTrace(); 32 | logger.warning("RPC failed: " + e.getStatus()); 33 | return null; 34 | } 35 | return response; 36 | } 37 | 38 | public String generateSessionKey() { 39 | SessionKeyRequest request = SessionKeyRequest.newBuilder().build(); 40 | SessionKeyResponse response; 41 | try { 42 | response = syncStub.generateSessionKey(request); 43 | } catch (StatusRuntimeException e) { 44 | e.printStackTrace(); 45 | logger.warning("RPC failed: " + e.getStatus()); 46 | return null; 47 | } 48 | return response.getSessionKey(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/rpc/RpcConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.rpc; 2 | 3 | public class RpcConfig { 4 | 5 | private final String address; 6 | private final int port; 7 | 8 | public RpcConfig(final String address, final int port) { 9 | this.address = address; 10 | this.port = port; 11 | } 12 | 13 | public String getAddress() { 14 | return address; 15 | } 16 | 17 | public int getPort() { 18 | return port; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/rpc/RpcServerConfig.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.rpc; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | import net.hashsploit.clank.config.objects.ServerInfo; 5 | 6 | public class RpcServerConfig extends ServerInfo { 7 | 8 | @SerializedName("encryption") 9 | private Encryption encryption = new Encryption(); 10 | 11 | public Encryption getEncryption() { 12 | return encryption; 13 | } 14 | 15 | public static class Encryption { 16 | 17 | @SerializedName("enabled") 18 | private boolean enabled = false; 19 | 20 | @SerializedName("cert_chain") 21 | private String certChainFile = null; 22 | 23 | @SerializedName("private_key") 24 | private String privateKeyFile = null; 25 | 26 | public boolean isEnabled() { 27 | return enabled; 28 | } 29 | 30 | public String getCertChainFile() { 31 | return certChainFile; 32 | } 33 | 34 | public String getPrivateKeyFile() { 35 | return privateKeyFile; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/scert/ISCERTObject.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.scert; 2 | 3 | public interface ISCERTObject { 4 | 5 | public byte[] serialize(); 6 | 7 | public void deserialize(byte[] data); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/scert/SCERTConstants.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.scert; 2 | 3 | public enum SCERTConstants { 4 | 5 | NET_MAX_NETADDRESS_LENGTH(16), 6 | 7 | NET_ADDRESS_LIST_COUNT(2); 8 | 9 | private final int value; 10 | 11 | private SCERTConstants(int value) { 12 | this.value = value; 13 | } 14 | 15 | public final int getValue() { 16 | return value; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/scert/SCERTObject.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.scert; 2 | 3 | public class SCERTObject implements ISCERTObject { 4 | 5 | public SCERTObject() { 6 | 7 | } 8 | 9 | @Override 10 | public byte[] serialize() { 11 | return null; 12 | } 13 | 14 | @Override 15 | public void deserialize(byte[] data) { 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/scert/objects/RTMsgEncodingType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.scert.objects; 2 | 3 | /** 4 | * This is the RT_MSG_ENCODING_TYPE variant used in the RT_MSG_SERVER_SYSTEM_MESSAGE (0x1c) packet. 5 | * 6 | * @author hashsploit 7 | * 8 | */ 9 | public enum RTMsgEncodingType { 10 | 11 | RT_MSG_ENCODING_NONE(0x00), 12 | 13 | RT_MSG_ENCODING_ISO_8859_1(0x01), 14 | 15 | RT_MSG_ENCODING_UTF8(0x02), 16 | 17 | RT_MSG_ENCODING_BINARY(0x03); 18 | 19 | private final byte value; 20 | 21 | private RTMsgEncodingType(int value) { 22 | this.value = (byte) value; 23 | } 24 | 25 | public final byte getValue() { 26 | return value; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/server/scert/objects/RTMsgLanguageType.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.server.scert.objects; 2 | 3 | /** 4 | * This is the RT_MSG_LANGUAGE_TYPE variant used in the RT_MSG_SERVER_SYSTEM_MESSAGE (0x1c) packet. 5 | * 6 | * @author hashsploit 7 | * 8 | */ 9 | public enum RTMsgLanguageType { 10 | 11 | RT_MSG_LANGUAGE_NONE(0x00), 12 | 13 | RT_MSG_LANGUAGE_US_ENGLISH(0x01), 14 | 15 | RT_MSG_LANGUAGE_UK_ENGLISH(0x02), 16 | 17 | RT_MSG_LANGUAGE_JAPANESE(0x03), 18 | 19 | RT_MSG_LANGUAGE_KOREAN(0x04), 20 | 21 | RT_MSG_LANGUAGE_ITALIAN(0x05), 22 | 23 | RT_MSG_LANGUAGE_SPANISH(0x06), 24 | 25 | RT_MSG_LANGUAGE_GERMAN(0x07), 26 | 27 | RT_MSG_LANGUAGE_FRENCH(0x08), 28 | 29 | RT_MSG_LANGUAGE_DUTCH(0x09), 30 | 31 | RT_MSG_LANGUAGE_PORTUGUESE(0x0a), 32 | 33 | RT_MSG_LANGUAGE_CHINESE(0x0b), 34 | 35 | RT_MSG_LANGUAGE_TAIWANESE(0x0c); 36 | 37 | private final byte value; 38 | 39 | private RTMsgLanguageType(int value) { 40 | this.value = (byte) value; 41 | } 42 | 43 | public final byte getValue() { 44 | return value; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/net/hashsploit/clank/utils/RtBuffer.java: -------------------------------------------------------------------------------- 1 | package net.hashsploit.clank.utils; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | 6 | public class RtBuffer { 7 | 8 | private byte[] buffer; 9 | private int cursor; 10 | private boolean encrypted; 11 | 12 | public RtBuffer() { 13 | buffer = new byte[1024]; 14 | clear(); 15 | } 16 | 17 | public void process(byte nextByte) { 18 | buffer[cursor] = nextByte; 19 | 20 | // Check encryption 21 | if (cursor == 0) { 22 | byte id = buffer[0]; 23 | // Check if encrypted or decrypted 24 | int idCheckInt = id & 0xFF; 25 | encrypted = idCheckInt >= 128; 26 | } 27 | 28 | cursor++; 29 | } 30 | 31 | public boolean isFull() { 32 | if (cursor < 3) { 33 | return false; 34 | } 35 | 36 | return getFullLength() == cursor; 37 | } 38 | 39 | private int getFullLength() { 40 | // 1 -> id, 2 -> len 41 | int totalLength = 1 + 2 + Utils.bytesToShortLittle(buffer[1], buffer[2]); 42 | 43 | // 4-> hash 44 | if (encrypted) { 45 | totalLength += 4; 46 | } 47 | 48 | return totalLength; 49 | } 50 | 51 | 52 | public ByteBuf toByteBuf() { 53 | ByteBuf b; 54 | int totalLength = getFullLength(); 55 | b = Unpooled.buffer(totalLength); 56 | b.writeBytes(buffer, 0, totalLength); 57 | b.resetReaderIndex(); 58 | return b; 59 | } 60 | 61 | public void clear() { 62 | cursor = 0; 63 | } 64 | 65 | } 66 | --------------------------------------------------------------------------------