| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/Dmfc/dmfcremote.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003/08/26 03:57:21 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * Remote administration |
| 26 | * |
| 27 | * $Log: dmfcremote.cpp,v $ |
| 28 | * Revision 1.1.1.1 2003/08/26 03:57:21 kevinb |
| 29 | * initial 1.5 import |
| 30 | * |
| 31 | * |
| 32 | * 6 7/14/99 11:48a Jeff |
| 33 | * localized text for patch fixes |
| 34 | * |
| 35 | * 5 7/09/99 6:18p Jeff |
| 36 | * added $remoteadminlogout and $wait commands |
| 37 | * |
| 38 | * 4 7/08/99 6:25p Jeff |
| 39 | * remote admin in and working |
| 40 | * |
| 41 | * 3 7/08/99 2:38a Jeff |
| 42 | * rough implementation of remote administration checked in. Still needs |
| 43 | * some polishing, but should work basically. |
| 44 | * |
| 45 | * 2 7/07/99 7:07p Jeff |
| 46 | * created dmfcremote.cpp |
| 47 | * |
| 48 | * $NoKeywords: $ |
| 49 | */ |
| 50 | |
| 51 | #include "gamedll_header.h"cxx . . $ `<file>/netgames/includes/gamedll_header.h`/ |
| 52 | #include "DMFC.h"cxx . . $ `<file>/netgames/includes/DMFC.h`/ |
| 53 | #include "dmfcinternal.h"cxx . . $ `<file>/netgames/dmfc/dmfcinternal.h`/ |
| 54 | #include "encryption.h"cxx . . $ `<file>/netgames/dmfc/encryption.h`/ |
| 55 | |
| 56 | #include <stdlib.h> |
| 57 | #include <memory.h> |
| 58 | |
| 59 | extern DMFCBasecxx . . $ DMFCBase# *basethiscxx . . $ basethis.; |
| 60 | |
| 61 | struct tRemotePlayerDatacxx . . $ tRemotePlayerData# { |
| 62 | bool authorizedcxx . . $ tRemotePlayerData#authorized.; // whether the player is authorized |
| 63 | uint8_tcxx . . $ uint8_t# curr_keycxx . . $ tRemotePlayerData#curr_key.[8]; // current encryption key |
| 64 | }; |
| 65 | |
| 66 | static tRemotePlayerDatacxx . . $ tRemotePlayerData# Authorized_playerscxx . . $ Authorized_players.[MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!]; |
| 67 | static char Remote_Admin_passcxx . . $ Remote_Admin_pass.[64]; |
| 68 | bool Use_remote_admincxx . . $ Use_remote_admin. = false; |
| 69 | static bool IAmAnAdmincxx . . $ IAmAnAdmin. = false; |
| 70 | |
| 71 | static void Remote_encryptcxx . . $ Remote_encrypt(3392f5e93f1a7d2c).(uint8_tcxx . . $ uint8_t# key[8], int size_buffer, uint8_tcxx . . $ uint8_t# *buffer, int *new_size, uint8_tcxx . . $ uint8_t# **new_buffer); |
| 72 | static void Remote_decryptcxx . . $ Remote_decrypt(3392f5e93f1a7d2c).(uint8_tcxx . . $ uint8_t# key[8], int size_buffer, uint8_tcxx . . $ uint8_t# *buffer, int *new_size, uint8_tcxx . . $ uint8_t# **new_buffer); |
| 73 | |
| 74 | // Sends a string to the server (function encrypts it before sending) |
| 75 | void Remote_SendStringToServercxx . . $ Remote_SendStringToServer(85c52e162fed56f9).(const char *string); |
| 76 | // Recieves a string from the server (function decrypts it) |
| 77 | void Remote_RecieveStringFromServercxx . . $ Remote_RecieveStringFromServer(499bb2d0b2f85908).(uint8_tcxx . . $ uint8_t# *data, char *buffer, int size); |
| 78 | // Sends a string to a client (function encrypts it before sending) |
| 79 | void Remote_SendStringToClientcxx . . $ Remote_SendStringToClient(66835f578de1bcb3).(int client, const char *string); |
| 80 | // Recieves a string from a client (function decrypts it) |
| 81 | int Remote_RecieveStringFromClientcxx . . $ Remote_RecieveStringFromClient(df91c54bbe867e1).(uint8_tcxx . . $ uint8_t# *data, char *buffer, int size); |
| 82 | // Handles remote admin packets from a client |
| 83 | void Remote_HandleClientPacketcxx . . $ Remote_HandleClientPacket(f25546b61a629de7).(uint8_tcxx . . $ uint8_t# *data); |
| 84 | // Handles remote admin packets from a client |
| 85 | void Remote_HandleServerPacketcxx . . $ Remote_HandleServerPacket(f25546b61a629de7).(uint8_tcxx . . $ uint8_t# *data); |
| 86 | |
| 87 | // Sends a message from the server to a client |
| 88 | void Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(int client, const char *message); |
| 89 | // Receives a message from the server |
| 90 | void Remote_GetMessagecxx . . $ Remote_GetMessage(f25546b61a629de7).(uint8_tcxx . . $ uint8_t# *data); |
| 91 | |
| 92 | // Logs a player out from being an administrator |
| 93 | void Remote_Logoutcxx . . $ Remote_Logout(d4f767463ce0a6b3).(int precnum); |
| 94 | |
| 95 | // filters any remote commands not allowed to be executed remotely |
| 96 | // -1 : not found |
| 97 | // 0 : can't call |
| 98 | // 1 : can call |
| 99 | int FilterNonRemoteCommandscxx . . $ FilterNonRemoteCommands(1ef8e6ec083aabb9).(char *command); |
| 100 | |
| 101 | // Initializes the remote administration system |
| 102 | void Remote_Initializecxx . . $ Remote_Initialize(49f6e7a06ebc5aa8).(void) { |
| 103 | // initialize encryption keys |
| 104 | srandcxx . . $ srand(6bab9b75950d6f3).((uint32_tcxx . . $ uint32_t#)time(0)); |
| 105 | |
| 106 | int i, j; |
| 107 | for (i = 0; i < MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!; i++) { |
| 108 | Authorized_playerscxx . . $ Authorized_players.[i].authorizedcxx . . $ tRemotePlayerData#authorized. = false; |
| 109 | |
| 110 | for (j = 0; j < 8; j++) { |
| 111 | Authorized_playerscxx . . $ Authorized_players.[i].curr_keycxx . . $ tRemotePlayerData#curr_key.[j] = randcxx . . $ rand(9efc7249d839d30e).() % 255; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | memset(Remote_Admin_passcxx . . $ Remote_Admin_pass., 0, 64); |
| 116 | |
| 117 | // setup packet recievers |
| 118 | #ifdef WIN32 |
| 119 | basethis->RegisterPacketReceiver(SPID_REMOTETOSERVER, Remote_HandleClientPacket); |
| 120 | basethis->RegisterPacketReceiver(SPID_REMOTETOCLIENT, Remote_HandleServerPacket); |
| 121 | basethis->RegisterPacketReceiver(SPID_SERVERREMOTEMSG, Remote_GetMessage); |
| 122 | #else |
| 123 | basethiscxx . . $ basethis.->RegisterPacketReceivercxx . . $ DMFCBase#RegisterPacketReceiver(6efe5766e3bef270).(SPID_REMOTETOSERVERcxx . . $ `netgames/dmfc/dmfcinternal.h:2770:9`!, &Remote_HandleClientPacketcxx . . $ Remote_HandleClientPacket(f25546b61a629de7).); |
| 124 | basethiscxx . . $ basethis.->RegisterPacketReceivercxx . . $ DMFCBase#RegisterPacketReceiver(6efe5766e3bef270).(SPID_REMOTETOCLIENTcxx . . $ `netgames/dmfc/dmfcinternal.h:2771:9`!, &Remote_HandleServerPacketcxx . . $ Remote_HandleServerPacket(f25546b61a629de7).); |
| 125 | basethiscxx . . $ basethis.->RegisterPacketReceivercxx . . $ DMFCBase#RegisterPacketReceiver(6efe5766e3bef270).(SPID_SERVERREMOTEMSGcxx . . $ `netgames/dmfc/dmfcinternal.h:2772:9`!, &Remote_GetMessagecxx . . $ Remote_GetMessage(f25546b61a629de7).); |
| 126 | #endif |
| 127 | |
| 128 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 129 | bool bTemp; |
| 130 | int pass_len = 64; |
| 131 | DatabaseRead1("DMFCRemoteAdminPass", Remote_Admin_passcxx . . $ Remote_Admin_pass., &pass_len); |
| 132 | if (DatabaseRead3("DMFCRemoteAdmin", &bTemp)) { |
| 133 | Remote_Enablecxx . . $ Remote_Enable(b45ddcbc8423892c).(bTemp); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // Processes remote administration for the frame |
| 139 | void Remote_ProcessFramecxx . . $ Remote_ProcessFrame(49f6e7a06ebc5aa8).(void) { |
| 140 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() != LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) |
| 141 | return; |
| 142 | |
| 143 | // go through all the players, and update their state (whether |
| 144 | // they are in the game or not) |
| 145 | int p; |
| 146 | for (p = 0; p < MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!; p++) { |
| 147 | player_recordcxx . . $ player_record# *pr = PRec_GetPRecordcxx . . $ PRec_GetPRecord(6359c6f28dd028ae).(p); |
| 148 | |
| 149 | if (Authorized_playerscxx . . $ Authorized_players.[p].authorizedcxx . . $ tRemotePlayerData#authorized.) { |
| 150 | // this is an authorized player, update them |
| 151 | |
| 152 | // make sure they are in the game |
| 153 | if (!pr || pr->statecxx . . $ player_record#state. != STATE_INGAMEcxx . . $ STATE_INGAME.) { |
| 154 | // the player is no longer in the game |
| 155 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "REMOTE: Removing authorization for %s\n", (pr->callsign) ? (pr->callsign) : "<UNKNOWN>"); |
| 156 | Remote_Logoutcxx . . $ Remote_Logout(d4f767463ce0a6b3).(p); |
| 157 | |
| 158 | // change the key for the slot |
| 159 | int j; |
| 160 | for (j = 0; j < 8; j++) { |
| 161 | Authorized_playerscxx . . $ Authorized_players.[p].curr_keycxx . . $ tRemotePlayerData#curr_key.[j] = randcxx . . $ rand(9efc7249d839d30e).() % 255; |
| 162 | } |
| 163 | |
| 164 | } else { |
| 165 | // the player is authorized and in the game |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // Gets the key for the given player record |
| 172 | uint8_tcxx . . $ uint8_t# *Remote_GetKeycxx . . $ Remote_GetKey(f18dc31a6ecbac56).(int prec) { |
| 173 | ASSERTcxx . . $ `netgames/includes/DMFC.h:370:9`!(prec >= 0 && prec < MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!); |
| 174 | return Authorized_playerscxx . . $ Authorized_players.[prec].curr_keycxx . . $ tRemotePlayerData#curr_key.; |
| 175 | } |
| 176 | |
| 177 | // Enables/Disables remote administration |
| 178 | void Remote_Enablecxx . . $ Remote_Enable(b45ddcbc8423892c).(bool enable) { |
| 179 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() != LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) |
| 180 | return; |
| 181 | |
| 182 | Use_remote_admincxx . . $ Use_remote_admin. = enable; |
| 183 | |
| 184 | if (*Remote_Admin_passcxx . . $ Remote_Admin_pass. == '\0' && enable) { |
| 185 | Use_remote_admincxx . . $ Use_remote_admin. = false; |
| 186 | } |
| 187 | |
| 188 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Remote Administration: %s\n", (Use_remote_admin) ? "On" : "Off"); |
| 189 | |
| 190 | if (!Use_remote_admincxx . . $ Use_remote_admin.) { |
| 191 | // log out all the logged in players |
| 192 | int p; |
| 193 | for (p = 0; p < MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!; p++) { |
| 194 | if (Authorized_playerscxx . . $ Authorized_players.[p].authorizedcxx . . $ tRemotePlayerData#authorized.) { |
| 195 | // log the player out |
| 196 | Remote_Logoutcxx . . $ Remote_Logout(d4f767463ce0a6b3).(p); |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | DatabaseWrite2("DMFCRemoteAdmin", Use_remote_admincxx . . $ Use_remote_admin.); |
| 202 | } |
| 203 | |
| 204 | // sets the administration password for the server |
| 205 | // pass in an unencrypted password |
| 206 | void Remote_SetPasswordcxx . . $ Remote_SetPassword(fda57c8427c60377).(char *password) { |
| 207 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() != LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) |
| 208 | return; |
| 209 | strncpy(Remote_Admin_passcxx . . $ Remote_Admin_pass., password, 63); |
| 210 | Remote_Admin_passcxx . . $ Remote_Admin_pass.[63] = '\0'; |
| 211 | DatabaseWrite1("DMFCRemoteAdminPass", Remote_Admin_passcxx . . $ Remote_Admin_pass., strlen(Remote_Admin_passcxx . . $ Remote_Admin_pass.)); |
| 212 | } |
| 213 | |
| 214 | // Logs a player record in as an administrator |
| 215 | bool Remote_Logincxx . . $ Remote_Login(ceb9eed3194142b2).(int precnum, char *pass) { |
| 216 | if (precnum < 0 || precnum >= MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!) |
| 217 | return false; |
| 218 | |
| 219 | player_recordcxx . . $ player_record# *pr = PRec_GetPRecordcxx . . $ PRec_GetPRecord(6359c6f28dd028ae).(precnum); |
| 220 | if (!pr || pr->statecxx . . $ player_record#state. != STATE_INGAMEcxx . . $ STATE_INGAME.) { |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | if (Authorized_playerscxx . . $ Authorized_players.[precnum].authorizedcxx . . $ tRemotePlayerData#authorized.) |
| 225 | return true; |
| 226 | |
| 227 | if (strcmp(pass, Remote_Admin_passcxx . . $ Remote_Admin_pass.) == 0) { |
| 228 | Authorized_playerscxx . . $ Authorized_players.[precnum].authorizedcxx . . $ tRemotePlayerData#authorized. = true; |
| 229 | } |
| 230 | |
| 231 | return Authorized_playerscxx . . $ Authorized_players.[precnum].authorizedcxx . . $ tRemotePlayerData#authorized.; |
| 232 | } |
| 233 | |
| 234 | // Logs a player out from being an administrator |
| 235 | void Remote_Logoutcxx . . $ Remote_Logout(d4f767463ce0a6b3).(int precnum) { |
| 236 | if (precnum < 0 || precnum >= MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!) |
| 237 | return; |
| 238 | |
| 239 | if (!Authorized_playerscxx . . $ Authorized_players.[precnum].authorizedcxx . . $ tRemotePlayerData#authorized.) |
| 240 | return; |
| 241 | |
| 242 | player_recordcxx . . $ player_record# *pr = PRec_GetPRecordcxx . . $ PRec_GetPRecord(6359c6f28dd028ae).(precnum); |
| 243 | if (!pr) |
| 244 | return; |
| 245 | if (pr->statecxx . . $ player_record#state. == STATE_INGAMEcxx . . $ STATE_INGAME.) { |
| 246 | Remote_SendStringToClientcxx . . $ Remote_SendStringToClient(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., "LOGOUTSUCCESS"); |
| 247 | Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., DTXT_REMOTELOGGEDOUTcxx . . $ `netgames/dmfc/dmfcinternal.h:2719:9`!); |
| 248 | } |
| 249 | Authorized_playerscxx . . $ Authorized_players.[precnum].authorizedcxx . . $ tRemotePlayerData#authorized. = false; |
| 250 | |
| 251 | DLLAddColoredHUDMessage(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(200, 200, 40), DTXT_HUDMSGLOGGEDOUTcxx . . $ `netgames/dmfc/dmfcinternal.h:2720:9`!, pr->callsigncxx . . $ player_record#callsign.); |
| 252 | } |
| 253 | |
| 254 | // Lists the players logged in |
| 255 | void Remote_ListLoginscxx . . $ Remote_ListLogins(49f6e7a06ebc5aa8).(void) { |
| 256 | int prec; |
| 257 | player_recordcxx . . $ player_record# *pr; |
| 258 | |
| 259 | char buffer[512]; |
| 260 | char temp[64]; |
| 261 | int len, curlen; |
| 262 | |
| 263 | curlen = 0; |
| 264 | *buffer = '\0'; |
| 265 | |
| 266 | for (prec = 0; prec < MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!; prec++) { |
| 267 | if (Authorized_playerscxx . . $ Authorized_players.[prec].authorizedcxx . . $ tRemotePlayerData#authorized.) { |
| 268 | pr = PRec_GetPRecordcxx . . $ PRec_GetPRecord(6359c6f28dd028ae).(prec); |
| 269 | if (pr && pr->statecxx . . $ player_record#state. != STATE_EMPTYcxx . . $ STATE_EMPTY.) { |
| 270 | len = strlen(pr->callsigncxx . . $ player_record#callsign.); |
| 271 | if (curlen + len > 500) { |
| 272 | // output the hudmessage |
| 273 | DLLAddColoredHUDMessage(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(200, 200, 40), buffer); |
| 274 | *buffer = '\0'; |
| 275 | curlen = 0; |
| 276 | } |
| 277 | if (*buffer != '\0') { |
| 278 | strncat(buffer, ":", sizeof(buffer) - strlen(buffer) - 1); |
| 279 | } |
| 280 | snprintf(temp, sizeof(temp), "%s[%d]", pr->callsigncxx . . $ player_record#callsign., prec); |
| 281 | strncat(buffer, temp, sizeof(buffer) - strlen(buffer) - 1); |
| 282 | curlen = strlen(buffer); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | if (*buffer != '\0') { |
| 288 | DLLAddColoredHUDMessage(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(200, 200, 40), buffer); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | extern player_recordcxx . . $ player_record# Player_recordscxx . . $ Player_records.[MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!]; |
| 293 | int translate_precptr_to_indexcxx . . $ translate_precptr_to_index(94a7156e227b3396).(player_recordcxx . . $ player_record# *pr) { |
| 294 | int index = (pr - Player_recordscxx . . $ Player_records.); |
| 295 | if (index < 0 || index >= MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!) |
| 296 | index = -1; |
| 297 | return index; |
| 298 | } |
| 299 | |
| 300 | // Sets a clients key |
| 301 | void Remote_SetMyKeycxx . . $ Remote_SetMyKey(f25546b61a629de7).(uint8_tcxx . . $ uint8_t# key[8]) { |
| 302 | player_recordcxx . . $ player_record# *pr; |
| 303 | pr = PRec_GetPRecordByPnumcxx . . $ PRec_GetPRecordByPnum(6359c6f28dd028ae).(basethiscxx . . $ basethis.->GetPlayerNumcxx . . $ DMFCBase#GetPlayerNum(b126dc7c1de90089).()); |
| 304 | int prec = translate_precptr_to_indexcxx . . $ translate_precptr_to_index(94a7156e227b3396).(pr); |
| 305 | if (prec == -1) { |
| 306 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "INVALID PREC!\n"); |
| 307 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 308 | return; |
| 309 | } |
| 310 | |
| 311 | memcpy(Authorized_playerscxx . . $ Authorized_players.[prec].curr_keycxx . . $ tRemotePlayerData#curr_key., key, 8); |
| 312 | } |
| 313 | |
| 314 | // handles a remote command (client side) |
| 315 | void Remote_ClientProcesscxx . . $ Remote_ClientProcess(85c52e162fed56f9).(const char *command) { |
| 316 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) |
| 317 | return; |
| 318 | if (!IAmAnAdmincxx . . $ IAmAnAdmin.) { |
| 319 | // only let "login" go through |
| 320 | if (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!(command, "login", strlen("login"))) { |
| 321 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Sending login attempt for remote administration\n"); |
| 322 | } else { |
| 323 | return; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | const char *ptr = command; |
| 328 | while (*ptr == ' ') |
| 329 | ptr++; |
| 330 | if (*ptr) { |
| 331 | Remote_SendStringToServercxx . . $ Remote_SendStringToServer(85c52e162fed56f9).(ptr); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | // handles a remote command (server side) |
| 336 | void Remote_ServerProcesscxx . . $ Remote_ServerProcess(577809987ad7a468).(int precnum, char *command) { |
| 337 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() != LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) |
| 338 | return; |
| 339 | if (precnum < 0 || precnum >= MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!) |
| 340 | return; |
| 341 | if (!Use_remote_admincxx . . $ Use_remote_admin.) |
| 342 | return; |
| 343 | |
| 344 | if (!Authorized_playerscxx . . $ Authorized_players.[precnum].authorizedcxx . . $ tRemotePlayerData#authorized.) { |
| 345 | // check to see if the player is trying to login |
| 346 | int loginlen = strlen("login "); |
| 347 | if (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!(command, "login ", loginlen)) { |
| 348 | char *ptr = &command[loginlen - 1]; |
| 349 | while (*ptr == ' ') |
| 350 | ptr++; |
| 351 | if (Remote_Logincxx . . $ Remote_Login(ceb9eed3194142b2).(precnum, ptr)) { |
| 352 | // successful login |
| 353 | player_recordcxx . . $ player_record# *pr = PRec_GetPRecordcxx . . $ PRec_GetPRecord(6359c6f28dd028ae).(precnum); |
| 354 | DLLAddColoredHUDMessage(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(200, 200, 40), DTXT_HUDMSGLOGGEDINcxx . . $ `netgames/dmfc/dmfcinternal.h:2721:9`!, pr->callsigncxx . . $ player_record#callsign.); |
| 355 | Remote_SendStringToClientcxx . . $ Remote_SendStringToClient(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., "LOGINSUCCESS"); |
| 356 | Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., DTXT_REMOTELOGGEDINcxx . . $ `netgames/dmfc/dmfcinternal.h:2722:9`!); |
| 357 | } |
| 358 | return; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | player_recordcxx . . $ player_record# *pr = PRec_GetPRecordcxx . . $ PRec_GetPRecord(6359c6f28dd028ae).(precnum); |
| 363 | |
| 364 | // check to see if they are logging out |
| 365 | if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "logout")) { |
| 366 | // log the player out |
| 367 | Remote_Logoutcxx . . $ Remote_Logout(d4f767463ce0a6b3).(precnum); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | // process the command |
| 372 | if (command[0] == '$') { |
| 373 | switch (FilterNonRemoteCommandscxx . . $ FilterNonRemoteCommands(1ef8e6ec083aabb9).(command)) { |
| 374 | case 1: { |
| 375 | DLLAddColoredHUDMessage(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(200, 200, 40), DTXT_REMOTEEXECUTEcxx . . $ `netgames/dmfc/dmfcinternal.h:2723:9`!, pr->callsigncxx . . $ player_record#callsign., command); |
| 376 | |
| 377 | if (basethiscxx . . $ basethis.->InputCommandHandlecxx . . $ DMFCBase#InputCommandHandle(c6b7e35ff6de5671).(command)) { |
| 378 | // command handled |
| 379 | Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., DTXT_REMOTESUCCESScxx . . $ `netgames/dmfc/dmfcinternal.h:2724:9`!); |
| 380 | } else { |
| 381 | // command not handled |
| 382 | Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., DTXT_REMOTENOTSUCCESScxx . . $ `netgames/dmfc/dmfcinternal.h:2725:9`!); |
| 383 | } |
| 384 | } break; |
| 385 | case 0: { |
| 386 | // command not handled |
| 387 | Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., DTXT_REMOTENOTALLOWEDcxx . . $ `netgames/dmfc/dmfcinternal.h:2726:9`!); |
| 388 | } break; |
| 389 | default: { |
| 390 | // command not handled |
| 391 | Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., DTXT_REMOTENOTFOUNDcxx . . $ `netgames/dmfc/dmfcinternal.h:2727:9`!); |
| 392 | } break; |
| 393 | } |
| 394 | } else { |
| 395 | // command not handled |
| 396 | Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(pr->pnumcxx . . $ player_record#pnum., DTXT_REMOTENOTFOUNDcxx . . $ `netgames/dmfc/dmfcinternal.h:2727:9`!); |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | // filters any remote commands not allowed to be executed remotely |
| 401 | int FilterNonRemoteCommandscxx . . $ FilterNonRemoteCommands(1ef8e6ec083aabb9).(char *command) { |
| 402 | // cut off whats after the first word (the command) |
| 403 | char cmd[64]; |
| 404 | strncpy(cmd, command, 63); |
| 405 | cmd[63] = '\0'; |
| 406 | char *ptr = cmd; |
| 407 | while (*ptr != ' ' && *ptr != '\0') |
| 408 | ptr++; |
| 409 | *ptr = '\0'; |
| 410 | |
| 411 | return basethiscxx . . $ basethis.->CanInputCommandBeUsedRemotelycxx . . $ DMFCBase#CanInputCommandBeUsedRemotely(1ef8e6ec083aabb9).((*cmd == '$') ? cmd + 1 : cmd); |
| 412 | } |
| 413 | |
| 414 | // Sends a message from the server to a client |
| 415 | void Remote_SendMessagecxx . . $ Remote_SendMessage(66835f578de1bcb3).(int client, const char *message) { |
| 416 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() != LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) |
| 417 | return; |
| 418 | |
| 419 | char *allocated = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 420 | int len = strlen(message); |
| 421 | const int maxlen = ((MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`! - 5) < 511) ? (MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`! - 5) : 511; |
| 422 | if (len > maxlen) { |
| 423 | allocated = new char[maxlen + 1]; |
| 424 | memcpy(allocated, message, maxlen); |
| 425 | allocated[maxlen] = '\0'; |
| 426 | message = allocated; |
| 427 | len = maxlen; |
| 428 | } |
| 429 | |
| 430 | int count = 0; |
| 431 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 432 | basethiscxx . . $ basethis.->StartPacketcxx . . $ DMFCBase#StartPacket(261852a8f74abaa0).(data, SPID_SERVERREMOTEMSGcxx . . $ `netgames/dmfc/dmfcinternal.h:2772:9`!, &count); |
| 433 | |
| 434 | MultiAddStringcxx . . $ MultiAddString(ac7a41cf4c80e28).(message, data, &count); |
| 435 | |
| 436 | basethiscxx . . $ basethis.->SendPacketcxx . . $ DMFCBase#SendPacket(49a5bbab55ea8abc).(data, count, client); |
| 437 | delete[] allocated; |
| 438 | } |
| 439 | |
| 440 | // Receives a message from the server |
| 441 | void Remote_GetMessagecxx . . $ Remote_GetMessage(f25546b61a629de7).(uint8_tcxx . . $ uint8_t# *data) { |
| 442 | int count = 0; |
| 443 | char buffer[512]; |
| 444 | |
| 445 | MultiGetStringcxx . . $ MultiGetString(e054694168e1d38e).(buffer, data, &count); |
| 446 | |
| 447 | DLLAddColoredHUDMessage(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(200, 200, 40), "==%s==", buffer); |
| 448 | } |
| 449 | |
| 450 | // Sends a string to the server (function encrypts it before sending) |
| 451 | void Remote_SendStringToServercxx . . $ Remote_SendStringToServer(85c52e162fed56f9).(const char *string) { |
| 452 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 453 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 454 | return; |
| 455 | } |
| 456 | |
| 457 | int slen; |
| 458 | int new_strlen; |
| 459 | uint8_tcxx . . $ uint8_t# *packet_data; |
| 460 | |
| 461 | slen = strlen(string); |
| 462 | player_recordcxx . . $ player_record# *pr; |
| 463 | pr = PRec_GetPRecordByPnumcxx . . $ PRec_GetPRecordByPnum(6359c6f28dd028ae).(basethiscxx . . $ basethis.->GetPlayerNumcxx . . $ DMFCBase#GetPlayerNum(b126dc7c1de90089).()); |
| 464 | int prec = translate_precptr_to_indexcxx . . $ translate_precptr_to_index(94a7156e227b3396).(pr); |
| 465 | if (prec == -1) { |
| 466 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "INVALID PREC!\n"); |
| 467 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | Remote_encryptcxx . . $ Remote_encrypt(3392f5e93f1a7d2c).(Authorized_playerscxx . . $ Authorized_players.[prec].curr_keycxx . . $ tRemotePlayerData#curr_key., slen, (uint8_tcxx . . $ uint8_t# *)string, &new_strlen, &packet_data); |
| 472 | |
| 473 | if (new_strlen == 0) { |
| 474 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "COULDN'T ENCRYPT\n"); |
| 475 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 476 | return; |
| 477 | } |
| 478 | |
| 479 | // now we can send off the packet |
| 480 | int count = 0; |
| 481 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 482 | basethiscxx . . $ basethis.->StartPacketcxx . . $ DMFCBase#StartPacket(261852a8f74abaa0).(data, SPID_REMOTETOSERVERcxx . . $ `netgames/dmfc/dmfcinternal.h:2770:9`!, &count); |
| 483 | |
| 484 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(prec, data, &count); |
| 485 | MultiAddIntcxx . . $ MultiAddInt(49f79918a3afee3).(new_strlen, data, &count); |
| 486 | memcpy(&data[count], packet_data, new_strlen); |
| 487 | count += new_strlen; |
| 488 | |
| 489 | basethiscxx . . $ basethis.->SendPacketcxx . . $ DMFCBase#SendPacket(49a5bbab55ea8abc).(data, count, SP_SERVERcxx . . $ `netgames/includes/DMFC.h:436:9`!); |
| 490 | freecxx . . $ free(bd21765a0afc8e3c).(packet_data); |
| 491 | } |
| 492 | |
| 493 | // Handles remote admin packets from a client |
| 494 | void Remote_HandleServerPacketcxx . . $ Remote_HandleServerPacket(f25546b61a629de7).(uint8_tcxx . . $ uint8_t# *data) { |
| 495 | char buffer[512]; |
| 496 | Remote_RecieveStringFromServercxx . . $ Remote_RecieveStringFromServer(499bb2d0b2f85908).(data, buffer, 512); |
| 497 | |
| 498 | if (!strcmp(buffer, "LOGOUTSUCCESS")) { |
| 499 | // we logged out |
| 500 | IAmAnAdmincxx . . $ IAmAnAdmin. = false; |
| 501 | } else if (!strcmp(buffer, "LOGINSUCCESS")) { |
| 502 | // we logged in |
| 503 | IAmAnAdmincxx . . $ IAmAnAdmin. = true; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | // Recieves a string from the server (function decrypts it) |
| 508 | void Remote_RecieveStringFromServercxx . . $ Remote_RecieveStringFromServer(499bb2d0b2f85908).(uint8_tcxx . . $ uint8_t# *data, char *buffer, int size) { |
| 509 | int count = 0; |
| 510 | int len = MultiGetIntcxx . . $ MultiGetInt(7337501fe74387bd).(data, &count); |
| 511 | |
| 512 | player_recordcxx . . $ player_record# *pr; |
| 513 | pr = PRec_GetPRecordByPnumcxx . . $ PRec_GetPRecordByPnum(6359c6f28dd028ae).(basethiscxx . . $ basethis.->GetPlayerNumcxx . . $ DMFCBase#GetPlayerNum(b126dc7c1de90089).()); |
| 514 | int prec = translate_precptr_to_indexcxx . . $ translate_precptr_to_index(94a7156e227b3396).(pr); |
| 515 | if (prec == -1) { |
| 516 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "INVALID PREC!\n"); |
| 517 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 518 | return; |
| 519 | } |
| 520 | |
| 521 | ASSERTcxx . . $ `netgames/includes/DMFC.h:370:9`!(len > 0); |
| 522 | if (len <= 0) |
| 523 | return; |
| 524 | |
| 525 | uint8_tcxx . . $ uint8_t# *packet; |
| 526 | packet = (uint8_tcxx . . $ uint8_t# *)malloccxx . . $ malloc(9f008b2a9698428b).(len); |
| 527 | memcpy(packet, &data[count], len); |
| 528 | count += len; |
| 529 | |
| 530 | int new_size; |
| 531 | uint8_tcxx . . $ uint8_t# *new_buffer; |
| 532 | Remote_decryptcxx . . $ Remote_decrypt(3392f5e93f1a7d2c).(Authorized_playerscxx . . $ Authorized_players.[prec].curr_keycxx . . $ tRemotePlayerData#curr_key., len, packet, &new_size, &new_buffer); |
| 533 | if (new_buffer) { |
| 534 | strncpy(buffer, (char *)new_buffer, size - 1); |
| 535 | buffer[size - 1] = '\0'; |
| 536 | freecxx . . $ free(bd21765a0afc8e3c).(new_buffer); |
| 537 | } else { |
| 538 | *buffer = '\0'; |
| 539 | } |
| 540 | |
| 541 | freecxx . . $ free(bd21765a0afc8e3c).(packet); |
| 542 | } |
| 543 | |
| 544 | // Sends a string to a client (function encrypts it before sending) |
| 545 | void Remote_SendStringToClientcxx . . $ Remote_SendStringToClient(66835f578de1bcb3).(int client, const char *string) { |
| 546 | if (basethiscxx . . $ basethis.->GetLocalRolecxx . . $ DMFCBase#GetLocalRole(b126dc7c1de90089).() != LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 547 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 548 | return; |
| 549 | } |
| 550 | |
| 551 | int slen; |
| 552 | int new_strlen; |
| 553 | uint8_tcxx . . $ uint8_t# *packet_data; |
| 554 | |
| 555 | slen = strlen(string); |
| 556 | player_recordcxx . . $ player_record# *pr; |
| 557 | pr = PRec_GetPRecordByPnumcxx . . $ PRec_GetPRecordByPnum(6359c6f28dd028ae).(client); |
| 558 | int prec = translate_precptr_to_indexcxx . . $ translate_precptr_to_index(94a7156e227b3396).(pr); |
| 559 | if (prec == -1) { |
| 560 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "INVALID PREC!\n"); |
| 561 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 562 | return; |
| 563 | } |
| 564 | |
| 565 | // check to make sure the player is authorized before sending |
| 566 | if (!Authorized_playerscxx . . $ Authorized_players.[prec].authorizedcxx . . $ tRemotePlayerData#authorized.) { |
| 567 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 568 | return; |
| 569 | } |
| 570 | |
| 571 | Remote_encryptcxx . . $ Remote_encrypt(3392f5e93f1a7d2c).(Authorized_playerscxx . . $ Authorized_players.[prec].curr_keycxx . . $ tRemotePlayerData#curr_key., slen, (uint8_tcxx . . $ uint8_t# *)string, &new_strlen, &packet_data); |
| 572 | |
| 573 | if (new_strlen == 0) { |
| 574 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "COULDN'T ENCRYPT\n"); |
| 575 | Int3cxx . . $ `netgames/includes/DMFC.h:378:9`!(); |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | // now we can send off the packet |
| 580 | int count = 0; |
| 581 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 582 | basethiscxx . . $ basethis.->StartPacketcxx . . $ DMFCBase#StartPacket(261852a8f74abaa0).(data, SPID_REMOTETOCLIENTcxx . . $ `netgames/dmfc/dmfcinternal.h:2771:9`!, &count); |
| 583 | |
| 584 | MultiAddIntcxx . . $ MultiAddInt(49f79918a3afee3).(new_strlen, data, &count); |
| 585 | memcpy(&data[count], packet_data, new_strlen); |
| 586 | count += new_strlen; |
| 587 | |
| 588 | basethiscxx . . $ basethis.->SendPacketcxx . . $ DMFCBase#SendPacket(49a5bbab55ea8abc).(data, count, client); |
| 589 | freecxx . . $ free(bd21765a0afc8e3c).(packet_data); |
| 590 | } |
| 591 | |
| 592 | // Handles remote admin packets from a client |
| 593 | void Remote_HandleClientPacketcxx . . $ Remote_HandleClientPacket(f25546b61a629de7).(uint8_tcxx . . $ uint8_t# *data) { |
| 594 | char buffer[512]; |
| 595 | int prec = Remote_RecieveStringFromClientcxx . . $ Remote_RecieveStringFromClient(df91c54bbe867e1).(data, buffer, 512); |
| 596 | if (prec == -1) |
| 597 | return; |
| 598 | |
| 599 | Remote_ServerProcesscxx . . $ Remote_ServerProcess(577809987ad7a468).(prec, buffer); |
| 600 | } |
| 601 | |
| 602 | // Recieves a string from a client (function decrypts it) |
| 603 | int Remote_RecieveStringFromClientcxx . . $ Remote_RecieveStringFromClient(df91c54bbe867e1).(uint8_tcxx . . $ uint8_t# *data, char *buffer, int size) { |
| 604 | int count = 0; |
| 605 | int prec = MultiGetBytecxx . . $ MultiGetByte(96e36f15bd3e0281).(data, &count); |
| 606 | int len = MultiGetIntcxx . . $ MultiGetInt(7337501fe74387bd).(data, &count); |
| 607 | |
| 608 | ASSERTcxx . . $ `netgames/includes/DMFC.h:370:9`!(len > 0); |
| 609 | ASSERTcxx . . $ `netgames/includes/DMFC.h:370:9`!(prec >= 0 && prec < MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!); |
| 610 | if (prec < 0 || prec >= MAX_PLAYER_RECORDScxx . . $ `netgames/includes/DMFC.h:526:9`!) |
| 611 | return -1; |
| 612 | if (len <= 0) |
| 613 | return -1; |
| 614 | |
| 615 | uint8_tcxx . . $ uint8_t# *packet; |
| 616 | packet = (uint8_tcxx . . $ uint8_t# *)malloccxx . . $ malloc(9f008b2a9698428b).(len); |
| 617 | memcpy(packet, &data[count], len); |
| 618 | count += len; |
| 619 | |
| 620 | int new_size; |
| 621 | uint8_tcxx . . $ uint8_t# *new_buffer; |
| 622 | Remote_decryptcxx . . $ Remote_decrypt(3392f5e93f1a7d2c).(Authorized_playerscxx . . $ Authorized_players.[prec].curr_keycxx . . $ tRemotePlayerData#curr_key., len, packet, &new_size, &new_buffer); |
| 623 | if (new_buffer) { |
| 624 | size = (len < size) ? len + 1 : size; |
| 625 | strncpy(buffer, (char *)new_buffer, size - 1); |
| 626 | buffer[size - 1] = '\0'; |
| 627 | freecxx . . $ free(bd21765a0afc8e3c).(new_buffer); |
| 628 | } else { |
| 629 | *buffer = '\0'; |
| 630 | } |
| 631 | |
| 632 | freecxx . . $ free(bd21765a0afc8e3c).(packet); |
| 633 | return prec; |
| 634 | } |
| 635 | |
| 636 | void Remote_pad_buffercxx . . $ Remote_pad_buffer(84e2fd16514268c).(int orig_size, const uint8_tcxx . . $ uint8_t# *orig_buffer, int *new_size, uint8_tcxx . . $ uint8_t# **new_buffer) { |
| 637 | // bump buffer up to size of mod 8 |
| 638 | *new_size = orig_size; |
| 639 | if (orig_size < 8 || (orig_size % 8) != 0) { |
| 640 | // we need to pad up |
| 641 | int chunks = orig_size / 8; |
| 642 | *new_size = (chunks + 1) * 8; |
| 643 | } |
| 644 | |
| 645 | *new_buffer = (uint8_tcxx . . $ uint8_t# *)malloccxx . . $ malloc(9f008b2a9698428b).(*new_size); |
| 646 | if (!(*new_buffer)) { |
| 647 | *new_size = 0; |
| 648 | return; |
| 649 | } |
| 650 | memset(*new_buffer, 0, *new_size); |
| 651 | memcpy(*new_buffer, orig_buffer, orig_size); |
| 652 | } |
| 653 | |
| 654 | static void Remote_encryptcxx . . $ Remote_encrypt(3392f5e93f1a7d2c).(uint8_tcxx . . $ uint8_t# key[8], int size_buffer, uint8_tcxx . . $ uint8_t# *buffer, int *new_size, uint8_tcxx . . $ uint8_t# **new_buffer) { |
| 655 | *new_buffer = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 656 | |
| 657 | uint8_tcxx . . $ uint8_t# *buff; |
| 658 | Remote_pad_buffercxx . . $ Remote_pad_buffer(84e2fd16514268c).(size_buffer, buffer, new_size, &buff); |
| 659 | if (*new_size == 0) |
| 660 | return; |
| 661 | |
| 662 | IceKeycxx . . $ IceKey# icecxx . . $ IceKey#IceKey(d4f767463ce0a6b3).(0); |
| 663 | |
| 664 | ice.setcxx . . $ IceKey#set(28caea9380bfac8a).((uint8_tcxx . . $ uint8_t# *)key); |
| 665 | |
| 666 | int i, num_chunks = 0; |
| 667 | int chunk_offset = 0; |
| 668 | uint8_tcxx . . $ uint8_t# *cipher; |
| 669 | cipher = (uint8_tcxx . . $ uint8_t# *)malloccxx . . $ malloc(9f008b2a9698428b).(*new_size); |
| 670 | if (!cipher) |
| 671 | return; |
| 672 | |
| 673 | num_chunks = (*new_size) / 8; |
| 674 | for (i = 0; i < num_chunks; i++) { |
| 675 | ice.encryptcxx . . $ IceKey#encrypt(a18788b04e8c2902).(&buff[chunk_offset], &cipher[chunk_offset]); |
| 676 | chunk_offset += 8; |
| 677 | } |
| 678 | |
| 679 | freecxx . . $ free(bd21765a0afc8e3c).(buff); |
| 680 | *new_buffer = cipher; |
| 681 | } |
| 682 | |
| 683 | static void Remote_decryptcxx . . $ Remote_decrypt(3392f5e93f1a7d2c).(uint8_tcxx . . $ uint8_t# key[8], int size_buffer, uint8_tcxx . . $ uint8_t# *buffer, int *new_size, uint8_tcxx . . $ uint8_t# **new_buffer) { |
| 684 | *new_buffer = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 685 | |
| 686 | uint8_tcxx . . $ uint8_t# *buff; |
| 687 | Remote_pad_buffercxx . . $ Remote_pad_buffer(84e2fd16514268c).(size_buffer, buffer, new_size, &buff); |
| 688 | if (*new_size == 0) |
| 689 | return; |
| 690 | |
| 691 | IceKeycxx . . $ IceKey# icecxx . . $ IceKey#IceKey(d4f767463ce0a6b3).(0); |
| 692 | |
| 693 | ice.setcxx . . $ IceKey#set(28caea9380bfac8a).((uint8_tcxx . . $ uint8_t# *)key); |
| 694 | |
| 695 | int i, num_chunks = 0; |
| 696 | int chunk_offset = 0; |
| 697 | uint8_tcxx . . $ uint8_t# *cipher; |
| 698 | cipher = (uint8_tcxx . . $ uint8_t# *)malloccxx . . $ malloc(9f008b2a9698428b).(*new_size); |
| 699 | if (!cipher) |
| 700 | return; |
| 701 | |
| 702 | num_chunks = (*new_size) / 8; |
| 703 | for (i = 0; i < num_chunks; i++) { |
| 704 | ice.decryptcxx . . $ IceKey#decrypt(a18788b04e8c2902).(&buff[chunk_offset], &cipher[chunk_offset]); |
| 705 | chunk_offset += 8; |
| 706 | } |
| 707 | |
| 708 | freecxx . . $ free(bd21765a0afc8e3c).(buff); |
| 709 | *new_buffer = cipher; |
| 710 | } |