AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   SM RCon (updated 2012-09-09) (https://forums.alliedmods.net/showthread.php?t=168403)

psychonic 09-28-2011 15:13

SM RCon (updated 2012-09-09)
 
2 Attachment(s)
Provides forwards for handling RCon auth and commands from within SourceMod plugins.
This extension borrows some knowledge from the former gmsv_rcon extension for gmod, and expands on it with more functionality reversed.

Currently, only the Source 2007, Source 2009, L4D and L4D2 engines are supported. This includes:
  • CS:GO
  • CS:S
  • TF2
  • DOD:S
  • HL2DM
  • Left 4 Dead
  • Left 4 Dead 2
  • Ep2 / 2007 Mods

Support for more engines can (probably) be added if there is interest.

PHP Code:

/**
 * @brief Called when an RCon session auth is processed
 *
 * @param rconId    RCon listener ID, unique per session.
 * @param address    Originating IP address.
 * @param password    Password sent by RCon client.
 * @param allow        True to grant auth, false otherwise.
 * @return             Plugin_Changed to use given allow value, Plugin_Continue to let engine process.
 */
forward Action SMRCon_OnAuth(int rconId, const char[] address, const char[] passwordbool &allow);

/**
 * @brief Called when an RCon command is processed.
 *
 * @note Rejection here does not count as a bad password attempt;
 *       however, the RCon log line will be annotated in the form
 *       of 'command (rejected) "%s"' rather than just 'command "%s"'
 *
 * @param rconId    RCon listener ID, unique per session.
 * @param address    Originating IP address.
 * @param command    Command sent by RCon client.
 * @param allow        True to allow command to be processed, false otherwise.
 * @return             Plugin_Changed to use given allow value, Plugin_Continue to let engine process.
 */
forward Action SMRCon_OnCommand(int rconId, const char[] address, const char[] commandbool &allow);

/**
 * @brief Called when an RCon session is disconnected.
 *
 * @param rconId    RCon listener ID, unique per session.
 */
forward void SMRCon_OnDisconnect(int rconId);

/**
 * @brief Called when an RCon log line is written
 *
 * @param rconId    RCon listener ID, unique per session.
 * @param address    Originating IP address.
 * @param logdata    Log data (usually either "Bad Password" or "command"
 *                  followed by the command.
 * @return            Plugin_Continue to log, Plugin_Handled to block.
 */
forward Action SMRCon_OnLog(int rconId, const char[] address, const char[] logdata);

/**
 * @brief Determines whether current server command originated from an RCon session.
 *
 * @return             True if command originated from RCon session, false if from console or not in server command callback.
 */
native bool SMRCon_IsCmdFromRCon(); 


Unlike this extension, linux builds are available, RCon listeners' unique id is passed through so SM, RCon disconnections are passed, server command callbacks can be identified as from RCon, extended rcon logging support is available, and most importantly, unauthed RCon commands are not passed to SM.

Source code: https://github.com/psychonic/smrcon

KyleS 09-28-2011 16:22

Re: SM RCon
 
This should be very useful. Thanks!

napalm00 09-28-2011 16:43

Re: SM RCon
 
This will come handy to get a list of people using the rcon.
Thanks a lot!

RedSword 09-29-2011 00:25

Re: SM RCon
 
Holy sh*tsauce, thanks for those additional hooks Great Duck !

psychonic 09-29-2011 00:40

Re: SM RCon
 
I have an update mostly ready that I'll package/post tomorrow which adds a forward for when an RCon log line is being written (since this is in the engine, it bypasses SM's log hook).

This will allow easy blocking of "spammy" RCon by IP, such as from stats pollers, without sacrifising the rest of your RCon logs.

In addition, authed RCon commands that are manually blocked in SMRCon_OnCommand will log with the tag " (rejected)" added to the end. Right now, manually blocked ones are not logged at all due to being blocked altogether.

Edit: it will also have a linux version that actually loads >.<

psychonic 09-29-2011 11:10

Re: SM RCon
 
Quote:

Originally Posted by psychonic (Post 1565095)
I have an update mostly ready that I'll package/post tomorrow which adds a forward for when an RCon log line is being written (since this is in the engine, it bypasses SM's log hook).

This will allow easy blocking of "spammy" RCon by IP, such as from stats pollers, without sacrifising the rest of your RCon logs.

In addition, authed RCon commands that are manually blocked in SMRCon_OnCommand will log with the tag " (rejected)" added to the end. Right now, manually blocked ones are not logged at all due to being blocked altogether.

Edit: it will also have a linux version that actually loads >.<

Posted.

Shouldn't be anymore changes for a bit unless any issues are reported (though it worksforme) or unless more engine support is requested (which won't affect existing versions). So, glhf.

Mr. Zero 09-29-2011 12:48

Re: SM RCon (updated 2011-09-29)
 
Requesting a version for L4D2 if that isn't too much work.

#edit Doh, just saw the change log. Will test.

Peace-Maker 09-30-2011 10:13

Re: SM RCon (updated 2011-09-29)
 
Thank you again!

GoD-Tony 09-30-2011 11:34

Re: SM RCon
 
Quote:

Originally Posted by napalm00 (Post 1564942)
This will come handy to get a list of people using the rcon.
Thanks a lot!

+1

Good stuff!

databomb 10-01-2011 10:30

Re: SM RCon (updated 2011-09-29)
 
thanks for Linux support :)

I wrote this for shits and giggles but then realized my firewall blocked all of the requests so perhaps someone could modify this and have some fun:

PHP Code:

#include <sourcemod>
#include <smrcon>

#define VERSION "1.0.0"

new String:g_sIPs[MAXPLAYERS+1][18];

public 
OnClientConnected(client)
{
    
GetClientIP(clientg_sIPs[client], 18);
}

public 
OnClientDisconnect(client)
{
    
Format(g_sIPs[client], 18"");
}

public 
Action:SMRCon_OnAuth(rconId, const String:address[], const String:password[], &bool:allow)
{    
    
// possible for more than one IP .. grab all affected
    
for (new client 1client <= MaxClientsclient++)
    {
        if (!
strcmp(addressg_sIPs[client]))
        {
            
// player is currently connected
            
if (!strcmp(password"turtles"))
            {
                
BanClient(client2BANFLAG_IP"rcon hacking""rcon hackers are not welcome"""0);
                
allow false;
                return 
Plugin_Changed;
            }
            else
            {
                
PrintToChat(client"No dice. You should give up now.. the password definitely isn't turtles");
                
PrintToConsole(client"No dice. You should give up now.. the password definitely isn't turtles");
            }
        }
    }
    
    return 
Plugin_Continue;




All times are GMT -4. The time now is 10:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.