Raised This Month: $12 Target: $400
 3% 

SM RCon (updated 2012-09-09)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
psychonic

BAFFLED
Join Date: May 2008
Old 09-28-2011 , 15:13   SM RCon (updated 2012-09-09)
Reply With Quote #1

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
Attached Files
File Type: zip smrcon.zip (1.10 MB, 3183 views)

Last edited by psychonic; 06-29-2016 at 16:10. Reason: updated source code link
psychonic is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 09-28-2011 , 16:22   Re: SM RCon
Reply With Quote #2

This should be very useful. Thanks!
KyleS is offline
napalm00
Veteran Member
Join Date: Jun 2011
Location: Italy, sadly
Old 09-28-2011 , 16:43   Re: SM RCon
Reply With Quote #3

This will come handy to get a list of people using the rcon.
Thanks a lot!
__________________
napalm00 is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 09-29-2011 , 00:25   Re: SM RCon
Reply With Quote #4

Holy sh*tsauce, thanks for those additional hooks Great Duck !
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-29-2011 , 00:40   Re: SM RCon
Reply With Quote #5

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 >.<

Last edited by psychonic; 09-29-2011 at 09:15.
psychonic is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-29-2011 , 11:10   Re: SM RCon
Reply With Quote #6

Quote:
Originally Posted by psychonic View Post
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.
psychonic is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 09-29-2011 , 12:48   Re: SM RCon (updated 2011-09-29)
Reply With Quote #7

Requesting a version for L4D2 if that isn't too much work.

#edit Doh, just saw the change log. Will test.
Mr. Zero is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-30-2011 , 10:13   Re: SM RCon (updated 2011-09-29)
Reply With Quote #8

Thank you again!
__________________
Peace-Maker is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 09-30-2011 , 11:34   Re: SM RCon
Reply With Quote #9

Quote:
Originally Posted by napalm00 View Post
This will come handy to get a list of people using the rcon.
Thanks a lot!
+1

Good stuff!
GoD-Tony is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 10-01-2011 , 10:30   Re: SM RCon (updated 2011-09-29)
Reply With Quote #10

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;

__________________
databomb is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:26.


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