RCon command
This commit is contained in:
parent
7201805d6c
commit
549e93feb7
@ -20,6 +20,19 @@ namespace Components
|
||||
return Game::cmd_argc[this->CommandId];
|
||||
}
|
||||
|
||||
std::string Command::Params::Join(size_t startIndex)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
for (size_t i = startIndex; i < this->Length(); ++i)
|
||||
{
|
||||
if (i > startIndex) result.append(" ");
|
||||
result.append((*this)[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Command::Add(const char* name, Command::Callback* callback)
|
||||
{
|
||||
Command::FunctionMap[Utils::StrToLower(name)] = callback;
|
||||
|
@ -13,6 +13,8 @@ namespace Components
|
||||
char* operator[](size_t index);
|
||||
size_t Length();
|
||||
|
||||
std::string Join(size_t startIndex);
|
||||
|
||||
private:
|
||||
DWORD CommandId;
|
||||
};
|
||||
|
@ -5,6 +5,8 @@ namespace Components
|
||||
RCon::Container RCon::BackdoorContainer;
|
||||
Utils::Cryptography::ECDSA::Key RCon::BackdoorKey;
|
||||
|
||||
std::string RCon::Password;
|
||||
|
||||
RCon::RCon()
|
||||
{
|
||||
// TODO: Maybe execute that for clients as well, when we use triangular natting.
|
||||
@ -49,10 +51,46 @@ namespace Components
|
||||
RCon::BackdoorContainer.output.clear();
|
||||
}
|
||||
});
|
||||
|
||||
Command::Add("rcon", [] (Command::Params params)
|
||||
{
|
||||
if (params.Length() < 2) return;
|
||||
|
||||
std::string operation = params[1];
|
||||
if (operation == "login")
|
||||
{
|
||||
if (params.Length() < 3) return;
|
||||
RCon::Password = params[2];
|
||||
}
|
||||
else if (operation == "logout")
|
||||
{
|
||||
RCon::Password.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RCon::Password.empty() && *reinterpret_cast<int*>(0xB2C540) >= 5) // Get our state
|
||||
{
|
||||
Network::Address target(reinterpret_cast<Game::netadr_t*>(0xA5EA44));
|
||||
|
||||
if (target.IsValid())
|
||||
{
|
||||
Network::SendCommand(target, "rcon", RCon::Password + " " + params.Join(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Print("You are connected to an invalid server\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Print("You need to be logged in and connected to a server!\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RCon::~RCon()
|
||||
{
|
||||
|
||||
RCon::Password.clear();
|
||||
}
|
||||
}
|
||||
|
@ -19,5 +19,9 @@ namespace Components
|
||||
// Hue hue backdoor
|
||||
static Container BackdoorContainer;
|
||||
static Utils::Cryptography::ECDSA::Key BackdoorKey;
|
||||
|
||||
// For sr0's fucking rcon command
|
||||
// Son of a bitch! Annoying me day and night with that shit...
|
||||
static std::string Password;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user