Esempio n. 1
0
/*
===============
SVC_RemoteCommand

A client issued an rcon command.
Shift down the remaining args
Redirect all printfs
===============
*/
void SVC_RemoteCommand(void)
{
    int i;
    char remaining[1024];

    i = Rcon_Validate();

    if (i == 0)
        Com_Printf("Bad rcon from %s:\n%s\n", NET_AdrToString(net_from), net_message.data + 4);
    else
        Com_Printf("Rcon from %s:\n%s\n", NET_AdrToString(net_from), net_message.data + 4);

    Com_BeginRedirect(RD_PACKET, sv_outputbuf, SV_OUTPUTBUF_LENGTH, SV_FlushRedirect);

    if (!Rcon_Validate())
    {
        Com_Printf("Bad rcon_password.\n");
    }
    else
    {
        remaining[0] = 0;

        for (i = 2; i < Cmd_Argc(); i++)
        {
            strcat(remaining, Cmd_Argv(i));
            strcat(remaining, " ");
        }

        Cmd_ExecuteString(remaining);
    }

    Com_EndRedirect();
}
Esempio n. 2
0
/*
===============
SVC_RemoteCommand

A client issued an rcon command.
Shift down the remaining args
Redirect all printfs
===============
*/
static void SVC_RemoteCommand (void)
{
	int		i;
	char	remaining[1024];

	i = Rcon_Validate ();

	if (i == 0)
	{
		Con_Printf ("Bad rcon from %s:\n%s\n", NET_AdrToString(net_from), net_message.data + 4);
		SV_BeginRedirect (RD_PACKET);
		Con_Printf ("Bad rcon_password.\n");
	}
	else
	{
		Con_Printf ("Rcon from %s:\n%s\n", NET_AdrToString(net_from), net_message.data + 4);
		SV_BeginRedirect (RD_PACKET);
		remaining[0] = 0;

		for (i = 2; i < Cmd_Argc(); i++)
		{
			strcat (remaining, Cmd_Argv(i) );
			strcat (remaining, " ");
		}

		Cmd_ExecuteString (remaining, src_command);
	}

	SV_EndRedirect ();
}
Esempio n. 3
0
/**
 * @brief A client issued an rcon command. Shift down the remaining args. Redirect all printfs
 */
static void SVC_RemoteCommand (struct net_stream *stream)
{
	char buf[256];
	const char *peername = NET_StreamPeerToName(stream, buf, sizeof(buf), false);
	bool valid = Rcon_Validate(Cmd_Argv(1));

	if (!valid)
		Com_Printf("Bad rcon from %s:\n%s\n", peername, Cmd_Argv(1));
	else
		Com_Printf("Rcon from %s:\n%s\n", peername, Cmd_Argv(1));

	Com_BeginRedirect(stream, sv_outputbuf, SV_OUTPUTBUF_LENGTH);

	if (!valid)
		/* inform the client */
		Com_Printf("Bad rcon_password.\n");
	else {
		char remaining[1024] = "";
		int i;

		/* execute the rcon commands */
		for (i = 2; i < Cmd_Argc(); i++) {
			Q_strcat(remaining, Cmd_Argv(i), sizeof(remaining));
			Q_strcat(remaining, " ", sizeof(remaining));
		}

		/* execute the string */
		Cmd_ExecuteString(remaining);
	}

	Com_EndRedirect();
}
Esempio n. 4
0
/*
* SVC_RemoteCommand
* 
* A client issued an rcon command.
* Shift down the remaining args
* Redirect all printfs
*/
static void SVC_RemoteCommand( const socket_t *socket, const netadr_t *address )
{
	int i;
	char remaining[1024];
	flush_params_t extra;

	i = Rcon_Validate();

	if( i == 0 )
		Com_Printf( "Bad rcon from %s:\n%s\n", NET_AddressToString( address ), Cmd_Args() );
	else
		Com_Printf( "Rcon from %s:\n%s\n", NET_AddressToString( address ), Cmd_Args() );

	extra.socket = socket;
	extra.address = address;
	Com_BeginRedirect( RD_PACKET, sv_outputbuf, SV_OUTPUTBUF_LENGTH, SV_FlushRedirect, ( const void * )&extra );

	if( sv_showRcon->integer )
		Com_Printf( "Rcon Packet %s\n", NET_AddressToString( address ) );

	if( !Rcon_Validate() )
	{
		Com_Printf( "Bad rcon_password.\n" );
	}
	else
	{
		remaining[0] = 0;

		for( i = 2; i < Cmd_Argc(); i++ )
		{
			Q_strncatz( remaining, "\"", sizeof( remaining ) );
			Q_strncatz( remaining, Cmd_Argv( i ), sizeof( remaining ) );
			Q_strncatz( remaining, "\" ", sizeof( remaining ) );
		}

		Cmd_ExecuteString( remaining );
	}

	Com_EndRedirect();
}
Esempio n. 5
0
/*
===============
SVC_RemoteCommand

A client issued an rcon command.
Shift down the remaining args
Redirect all printfs
===============
*/
void SVC_RemoteCommand (void)
{
	if (!Rcon_Validate ()) {
		Com_Printf ("Bad rcon from %s:\n%s\n", NET_AdrToString (net_from), net_message.data+4);

		SV_BeginRedirect (RD_PACKET);
		Com_Printf ("Bad rcon_password\n");
	}
	else {
		Com_Printf ("Rcon from %s:\n%s\n", NET_AdrToString (net_from), net_message.data+4);

		SV_BeginRedirect (RD_PACKET);
		Cmd_ExecuteString (Cmd_MakeArgs(2));
	}

	SV_EndRedirect ();
}
Esempio n. 6
0
/**
 * @brief A client issued an rcon command. Shift down the remaining args. Redirect all printfs
 */
static void SVC_RemoteCommand (struct net_stream* stream)
{
    char buf[64];
    const char* peername = NET_StreamPeerToName(stream, buf, sizeof(buf), false);

    /* Prevent using rcon as an amplifier and make dictionary attacks impractical */
    if (SVC_RateLimitAddress(*stream)) {
        Com_DPrintf(DEBUG_SERVER, "SVC_RemoteCommand: rate limit from %s exceeded, dropping request\n", peername);
        return;
    }

    const bool valid = Rcon_Validate(Cmd_Argv(1));
    if (!valid) {
        static leakyBucket_t bucket;
        /* Make DoS via rcon impractical */
        if (SVC_RateLimit(&bucket, 10, 1000)) {
            Com_DPrintf(DEBUG_SERVER, "SVC_RemoteCommand: rate limit exceeded, dropping request\n");
            return;
        }

        Com_Printf("Bad rcon from %s with password: '******'\n", peername, Cmd_Argv(1));
    } else {
        Com_Printf("Rcon from %s\n", peername);
    }

    static char sv_outputbuf[1024];
    Com_BeginRedirect(stream, sv_outputbuf, sizeof(sv_outputbuf));

    if (!valid) {
        /* inform the client */
        Com_Printf(BAD_RCON_PASSWORD);
    } else {
        char remaining[1024] = "";
        int i;

        /* execute the rcon commands */
        for (i = 2; i < Cmd_Argc(); i++) {
            Q_strcat(remaining, sizeof(remaining), "%s ", Cmd_Argv(i));
        }

        /* execute the string */
        Cmd_ExecuteString("%s", remaining);
    }

    Com_EndRedirect();
}