Skip to content

Commit

Permalink
Fix Exploitable getCSR() checks
Browse files Browse the repository at this point in the history
  • Loading branch information
AconiteX committed Jun 17, 2021
1 parent b3d51a7 commit 23c8f34
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ void CommandCppFuncsNamespace::commandFuncNotepad(Command const & , NetworkId co

void CommandCppFuncsNamespace::commandFuncSetScale (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & params)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
if(target == NetworkId::cms_invalid)
{
Expand All @@ -1568,7 +1568,7 @@ void CommandCppFuncsNamespace::commandFuncSetScale (Command const & , NetworkId

void CommandCppFuncsNamespace::commandFuncSetYaw (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & params)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
if(target == NetworkId::cms_invalid)
{
Expand All @@ -1587,7 +1587,7 @@ void CommandCppFuncsNamespace::commandFuncSetYaw (Command const & , NetworkId co

void CommandCppFuncsNamespace::commandFuncHideMe (Command const &, NetworkId const &, NetworkId const &, Unicode::String const &params)
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
bool hide = false;

Expand Down Expand Up @@ -1624,7 +1624,7 @@ void CommandCppFuncsNamespace::commandFuncHideMe (Command const &, NetworkId con

void CommandCppFuncsNamespace::commandFuncReloadAdminTable (Command const & , NetworkId const & , NetworkId const & , Unicode::String const & )
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
const std::string reloadCommand = "/remote server reloadAdminTable";
IGNORE_RETURN(CuiMessageQueueManager::executeCommandByString(reloadCommand, true));
Expand All @@ -1635,7 +1635,7 @@ void CommandCppFuncsNamespace::commandFuncReloadAdminTable (Command const & , Ne

void CommandCppFuncsNamespace::commandFuncSkills (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & )
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
if(target == NetworkId::cms_invalid)
{
Expand All @@ -1654,7 +1654,7 @@ void CommandCppFuncsNamespace::commandFuncSkills (Command const & , NetworkId co

void CommandCppFuncsNamespace::commandFuncSpawn (Command const & , NetworkId const & , NetworkId const & , Unicode::String const & params)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
const std::string spawnCommand = "/remote object spawn ";

Expand All @@ -1670,7 +1670,7 @@ void CommandCppFuncsNamespace::commandFuncSpawn (Command const & , NetworkId con

void CommandCppFuncsNamespace::commandFuncDestroy (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & )
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
if(target == NetworkId::cms_invalid)
{
Expand All @@ -1689,7 +1689,7 @@ void CommandCppFuncsNamespace::commandFuncDestroy (Command const & , NetworkId c

void CommandCppFuncsNamespace::commandFuncEditBank (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & )
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
if (target == NetworkId::cms_invalid)
{
Expand All @@ -1713,7 +1713,7 @@ void CommandCppFuncsNamespace::commandFuncEditBank (Command const & , NetworkId

void CommandCppFuncsNamespace::commandFuncEditInventory (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & )
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
if (target == NetworkId::cms_invalid)
{
Expand All @@ -1737,7 +1737,7 @@ void CommandCppFuncsNamespace::commandFuncEditInventory (Command const & , Netwo

void CommandCppFuncsNamespace::commandFuncEditDatapad (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & )
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
if (target == NetworkId::cms_invalid)
{
Expand All @@ -1760,7 +1760,7 @@ void CommandCppFuncsNamespace::commandFuncEditDatapad (Command const & , Network
//----------------------------------------------------------------------
void CommandCppFuncsNamespace::commandFuncExamineObjVars (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & params)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
const std::string objvarCommand = "/remote objvar list ";

Expand All @@ -1775,7 +1775,7 @@ void CommandCppFuncsNamespace::commandFuncExamineObjVars (Command const & , Netw

void CommandCppFuncsNamespace::commandFuncRenamePlayer (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & params)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
if(target == NetworkId::cms_invalid)
{
Expand Down Expand Up @@ -1803,7 +1803,7 @@ void CommandCppFuncsNamespace::commandFuncRenamePlayer (Command const & ,

void CommandCppFuncsNamespace::commandFuncDraw (Command const & , NetworkId const & , NetworkId const & , Unicode::String const & params)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
size_t pos = 0;
int value = nextIntParm (params, pos);
Expand All @@ -1815,7 +1815,7 @@ void CommandCppFuncsNamespace::commandFuncDraw (Command const & , NetworkId cons

void CommandCppFuncsNamespace::commandFuncUiDebugExamine (Command const & , NetworkId const & , NetworkId const & , Unicode::String const & params)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
const std::string debugExamineCommand = "/ui debugexamine ";
std::string command = debugExamineCommand + Unicode::wideToUTF8(params);
Expand All @@ -1827,7 +1827,7 @@ void CommandCppFuncsNamespace::commandFuncUiDebugExamine (Command const & , Netw

void CommandCppFuncsNamespace::commandFuncUnload (Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & )
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
if(target == NetworkId::cms_invalid)
{
Expand All @@ -1854,7 +1854,7 @@ void CommandCppFuncsNamespace::commandFuncEmptyMail(Command const & , NetworkId

void CommandCppFuncsNamespace::commandFuncEditBiography(Command const & , NetworkId const & , NetworkId const & target, Unicode::String const & str)
{
if(ConfigClientGame::getCSR())
if(Game::getPlayerObject()->isAdmin())
{
NetworkId editTarget(target);

Expand Down Expand Up @@ -2012,7 +2012,7 @@ void CommandCppFuncsNamespace::commandFuncTarget (Command const & , NetworkId co

void CommandCppFuncsNamespace::commandFuncTargetPilot(Command const &, NetworkId const &, NetworkId const &target, Unicode::String const &)
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
CreatureObject * const player = Game::getPlayerCreature();
if (player)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,18 @@ float ConfigClientGame::getConnectionTimeout()

//-----------------------------------------------------------------------

/**
*>>>>>>>> WARNING READ THIS <<<<<<<<<<
*
* This is not a secure or reliable way to validate who is/is not a CSR.
* This only checks for the obfuscation code in the client-side config
* which anyone can add. This should ONLY be used to flag for the command
* parser that admin commands are available.
*
* If you need to validate if someone is/is not a CSR (isGod) then you
* should use Game::getPlayerObject->isAdmin() only!! But MORE importantly,
* anything being done should also be validated server-side!!!
*/
bool ConfigClientGame::getCSR()
{
return ms_0fd345d9;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ SwgCuiBiographyEdit::~SwgCuiBiographyEdit()

void SwgCuiBiographyEdit::performActivate()
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
CuiManager::requestPointer(true);
setIsUpdating(true);
Expand All @@ -127,7 +127,7 @@ void SwgCuiBiographyEdit::performActivate()

void SwgCuiBiographyEdit::performDeactivate()
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
setIsUpdating(false);
CuiManager::requestPointer(false);
Expand All @@ -139,7 +139,7 @@ void SwgCuiBiographyEdit::performDeactivate()

void SwgCuiBiographyEdit::onBiographyRetrieved(PlayerCreatureController::Messages::BiographyRetrieved::BiographyOwner const & msg)
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
if (m_biographyStatus == BES_waiting)
{
Expand All @@ -160,7 +160,7 @@ void SwgCuiBiographyEdit::onBiographyRetrieved(PlayerCreatureController::Message

void SwgCuiBiographyEdit::OnButtonPressed(UIWidget *context)
{
if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
if (context == m_saveButton)
{
Expand Down Expand Up @@ -198,7 +198,7 @@ void SwgCuiBiographyEdit::update(float deltaTimeSecs)
{
CuiMediator::update(deltaTimeSecs);

if (ConfigClientGame::getCSR())
if (Game::getPlayerObject()->isAdmin())
{
// Out of range check...
bool const isInRange = m_player != CachedNetworkId::cms_cachedInvalid && m_player.isValid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "clientGame/CreatureObject.h"
#include "clientGame/Game.h"
#include "clientGame/GameNetwork.h"
#include "clientGame/PlayerObject.h"
#include "clientGraphics/Graphics.h"
#include "clientUserInterface/CuiInventoryManager.h"
#include "clientUserInterface/CuiManager.h"
Expand Down Expand Up @@ -734,7 +735,7 @@ void SwgCuiInventory::update (float deltaTimeSecs)

m_timeSinceLastRangeCheck += deltaTimeSecs;

if (m_timeSinceLastRangeCheck > 3.3f && !ConfigClientGame::getCSR())
if (m_timeSinceLastRangeCheck > 3.3f && !Game::getPlayerObject()->isAdmin())
{
m_timeSinceLastRangeCheck = 0.0f;

Expand Down

0 comments on commit 23c8f34

Please sign in to comment.