Q2Admin 1.31 (NB: if enforcing q2ace, version 1.19 and above should be enforced because of changes in the q2ace responses).

A project originally written by KillerBee http://www.planetquake.com/q2admin/ and taken further to implement q2ace only servers plus detect more recent cheats after KillerBee went inactive.

This q2admin has all the features of q2admin 1.17 and as such you should initially ensure that you can download that version direct from the authors website and ensure that you get it working.  the provided binary is a straight swap for the q2admin 1.17 binary '.so' for linux or '.dll' for win32.


additional features on this special release are :

- Generic Speed Hack Detection (so far stops all known speed hacks even those designed for HL / CS)
- Optional Server side enforment for of the client side anti-cheating product - q2ace (www.savageservers.com/q2ace)
- Rcon password exploit fixed
- Vote map change exploit fixed
- q2admin cmd queue overflow plugged (prevents a server crash method)
- prevents certain wall hacks from being effective
- prevents overflow of teamname and team skins in tourney mod from crashing the server
- prevents userinfo overflow exploit in q2admin (in turn stops id3 proxy bot)
- gives some limited admin commands without the need for lrcon
- some other crap


CREDITS :
iD software
killerbee for the original q2admin http://www.planetquake.com/q2admin/ (also please see kb's web site for additional credit's for his original work)
pooy for most of the additional work since killerbee's version 1.17 (other work by pooy includes q2 jump mod @ http://www.q2jump.jolt.co.uk)
me, manic miner (http://www.jolt.co.uk quake2 head admin), for some bug fixes, linux work and production.



The variables settings i've used are what the defaults are if you don't set them yourself.

Speed Hack Detection
--------------------

The additional q2admin.txt config variables required for the new improved speed hack detection are :


;seconds for check
msec_interval "5" 

;msecs allowed (msec_interval*1000 = normal, so 10 interval = 10000 msec_max for a normal client. 
;setting msec_max to slightly higher will detect speed cheats of the percentage it is higher)
msec_max "6000"

;set to 0 to not kick
msec_kick_on_bad "5" 


Roughly speed hacks that use external programs just slow down the internal windows clock.  this causes programs that rely on it to speed up to compensate as they think it's an extreemly slow machine so are doing the player a favour.  The new q2admin routines basically count various things that are sent to the server and decides whether or not this is the normal amount that's sent to the server (as the variable names suggest, these are msec's).  A normal player will not send more that 6000 msecs to the server in 5 seconds.  A couple of false detects we have come across are for players with extreemly bad connections i.e. very warpy players as while they are lagged they don't send any msecs but once they are free they burst them all at once which can take their count over 6000 in < 5 seconds.  Because of this there is a third variable that says how many times must a player be caught out before they are kicked.

I've been using these settings on two servers for the entire week.  I've only had one false detect (for an AOL user surprise surprise).




Q2Ace Enforcement
-----------------

The additional q2admin.txt config variables you require to play with this option are :

;activate q2ace enforement
ace_check "Yes"

;activate valid p_way enforcement
;this makes sure that a q2ace client is connected direct to the server (the same way reconnect_address used to before it 
;was hacked in all the bots and exe's out there) and not a proxy.
ace_way_check "No"  // note i would recommend "Yes" here to make a more secure server


;how often to check the clients p_auth response that was generated when they joined the map
ace_check_interval "60"


;what version of q2ace to allow onto the server
ace_version_check "1.17"


;how many clients must be on the server before q2admin automatically starts
;checking p_auth repsonses with no admins required
;note this really must definately be at least 3, plus also the more the better
ace_min_clients "4"

;update.  you could actually set this to 2 for a duel server.  if a cheater joins and a q2ace player joins then one player will be kicked but not necessarily the correct player.  if you think about it, this doesn't matter.  it will mean that the cheater is always left to play by himself which will mean surely in the end they'll give up and go somewhere else.


;custom kick message for the client (%s client name, %d debug error code)
;you could add location of q2ace help forums etc here (max 256 chars).
ace_kick_msg "    ****    %s has been using a non standard exe, error %d.    ****    \n"

;kick players who use asus graphics drivers
;0 = don't kick but players spam to the server if they are using asus drivers and what level
;1 = kick any players who are using the definite cheat drivers and make players of other versions spam to the server
;2 = kick any players using any version of asus drivers (as all asus drivers can be hacked to give see through walls).
ace_asus_check "1"


*****************  NEW FILE q2adminace.txt ******************

an additional file is required for stage 3 q2ace checking.  please create a file called q2adminace.txt which should have the following layout :

the first line should just have the word 'q2ace113' on it.  the version number is irrelevent to anything else - this is just a marker.
the lines after should contain a username, password and q2ace admin level they have

and example file of q2adminace.txt would look like :

q2ace113
alex anexample 1
thresh removethis 7


this file only allows for 128 admins to be added.  this surely is enough ???



Q2ace detection works on three levels.

1. it checks the client repsonds correctly to p_modification.  if the client does not respond or fails any q2ace checks, then they are kicked.


2. when the amount of clients on the server reach ace_min_clients, q2admin will start to evaluate the p_auth repsonse that is stored against the client when they joined the map.  a p_auth command is only generated once during a map for each player so that the pause caused by q2ace will not lag players during gameplay.  if q2admin deems that the player has not provided a good p_auth repsonse then they will be kicked.


3. you can set trusted players to log onto q2admin as a q2ace admin.  a flag will be set against their username so that q2admin will check that other players p_auth response matches that of the first admin in the list.  if it doesn't match the admin p_auth response then the player will be kicked.

to log an admin it (best to have it in a config :) ) they need to type !admin username password i.e. for the above file

!admin alex anexample

would set my admin flag.

1.29 UPDATE: a new login system has been added so that you don't have to keep login on at each map change (this depends on the mod).  in you config set a user variable that the server can read.  for example, to recreate the above you would have the lines (or type) :

set q2adminuser alex
set q2adminpass anexample




a level 1 admin can do :

!boot <number>
- explains itself ?

level 2 admin can do :

everything a level 1 admin can

level 3 admin can do :

everything a level 2 admin can &
!changemap <mapname>
-explains itself 

level 4 admin can do :
everything a level 3 admin can &
!dumpuser <num>
- this will show the level1 admin what the p_auth response is for that user.  this can help with debug issues i.e. why is a player constantly kicked (probably a zip drive installed).

a level 5 admin can do :
everything a level 4 admin can &
!pauth

currently a player could connect to the server with q2ace, obtain a p_auth response and log it, then disconnect knowing what p_auth they should provide for that map.  they could then connect back to the server with a non valid quake2 exe which replies with the p_auth obtained earlier.  

issuing a !pauth command will force a new response to be required by all players within 30 seconds.  this command is really designed for league situations and should not be used within the first 30 seconds of a map change or within 30 seconds of last using it.  the feature is not fully tested so do not use it lightly.  as i say, it's only really for highly suspect players who regularly disconnect and reconnect to the server.

level 6 admin can do :
everything a level 5 admin can

level 7 admin can do :
everything a level 6 admin can &

!stuff <user> <message>
this is the q2admin stuff command and should not be given out lightly or without understanding how much control an admin can achieve with it.


if you wish to log admins logging in then add this to your q2adminlog.txt file :

added to q2adminlog.txt :
ADMINLOG: YES 1 "\"#m\" : Time \"#t\" *** Name \"#n\"  Ping \"#p\" IP \"#i\""

#m will be replaced with 'ADMIN - '


be warned, having a group of players on the server all using a fake q2ace could mean that your server is overtaken by cheats as it will start to kick legitimate players.  personally i can't see this happened as cheaters usually only pick on the weak and wouldn't actually want to play against a load of other cheaters on the same server.

second warning is that a rogue admin who has an issue with his p_auth will also cause all other players to be kick even though they maybe the genuine players.  having an admin logged in will override check 2 and kick players even if he is the only player on the server with a different p_auth response.



Q2Ace only server client bypass
-------------------------------
This functionality allows players to join a q2admin 1.29 server that has q2ace only activated without having to use q2ace.  This is primarily designed so that server admins can allow linux and mac users onto the server where a q2ace client doesn't exist.  I would urge server admins not to give out logins lightly and to ask for some sort of proof that they are a linux or mac user.  There are really very few linux and mac users out there - don't believe just anyone who asks you or tells you that they are.  also if at all possible, keep an eye on their playing.

IMPORTANT: any player logged on like this will spam a message to the server saying that they have done so.  You can not log onto a q2ace only server quietly, so players shouldn't worry that the server is full of non q2ace users because they will be informed.


This works in a very similar way to the q2admin ace logon system for admins above.  Infact the code was just copied and pasted and just the filename changed :)

the login file you need to add is called q2adminacebypass.txt.  it should have the same format as the q2adminace.txt file above for example :

q2ace113
alex anexample 1
thresh removethis 1

the '1's are just a left over from the admin login system, but they need to be there. the 'q2ace113' is also just a marker, the version number isn't relevent to anything else, but it does have to be there.

if the player just wishes to log in when they join the server then they need to type :

!q2ace username password

for example i would type

!q2ace alex anexample

this has a down fall as at the start of every map (depending on the mod's method of map changes) the server looses this info as you become a new client and you would have to type it in again.  also, obviously, the server will try and kick you within about 15 seconds for not having a q2ace client - so this method will mean you have to type super fast:).  therefore it's better to use the alternative method of setting a client side variable in your config that q2admin can read :

set q2aceuser alex
set q2acepass anexmaple


IMPORTANT: any player logged on like this will spam a message to the server saying that they have done so.  You can not log onto a q2ace only server quietly, so players shouldn't worry that the server is full of non q2ace users because they will be informed.


to log people using it add the following to the q2adminlog.txt file :

ADMINLOG: YES 1 "\"#m\" : Time \"#t\" *** Name \"#n\"  Ping \"#p\" IP \"#i\""


#m will be replaced with 'Q2ACE Bypass'



Wall hack prevention
--------------------

Some wall hacks are currently available that are not detected by q2ace (although we brought the methods they are employing and our prevention for it to the attention of the q2ace developers and they have figured out a way to stop them in q2ace 1.14).  I have found that a simple vid_restart done on the client machine will stop the wall hack working.  by adding the line

do_vid_restart "No"

into the q2admin.txt config file, it will force the client to do a vid_restart command when they first connect to the server rather than every single map change.

NOTE: this option is now out of date since the release of q2ace 1.25


Misc Server Exploit protection
------------------------------
there's an exploit in q2admin which means that if you send a lot of userinfo changes to it then it overflows it's command
queues and actually makes the player invisible to the q2admin but not the game or server.  this means none of q2admins checks will work.  don't worry it's not commonly used but we did see that it was being used in the id3 modified ratbot as another level of throwing q2admin.

this exploit can also be used to crash the server often with wierd messages like bad magic overflow (iirc).



;maximum amount of times a player can change their userinfo before being kicked for server flooding
userinfochange_count "40"


;amount of time in seconds a player can reach their maximum number of userinfo changes
userinfochange_time "60"


some players have some wierd binds that will cause them to be kicked for flooding the server.  for example the first one that came up was

alias +fire hand 1;+attack
alias -fire hand 2;-attack

why on earth they wanted that bind i've no idea.  but hand changes are part of the userinfo so everytime he fired, his userinfo changed and very quickly he was kicked.  amended the bind and he was fine.

if you have a player who swears blind he isn't cheating then enable the userinfo log (see changes for 1.22) and when he gets kicked, check his userinfo's and see what keeps changing so quickly.


Misc
----

;showfps
;all clients have the above command available to them which they can type into the console while playing on a q2admin 1.2x server.  ;when typed the server will continue to spam their true fps to their console.

client_map_cfg "0"
;a setting of 1 and the server will stuff 'set map_name mapname' to the client so that the variable can be used in scripts
;a setting of 2 and the server will stuff 'exec cfg/mapname.cfg' to the client on client begin so that specific configs can automatically be run by the players
;a setting of 4 and the server will stuff 'exec cfg/all.cfg' to the client before the map specific config.
; NOTE you can add these together like dmflags i.e. settings it to a value of "6" will mean that all three settings are performed.

private_command1
private_command2
.
.
private_command9
;this will stuff any command you choose to players at 60 second intervals.  if the player does not have the command you would expect
;them to spam the command to the server.  q2admin traps this and prevents it being spammed.
;if the player has the command then it won't be spammed, but q2admin records this and logs it.  add the following lines to the q2adminlog.txt file :
;LOGFILE: 6 MOD "q2admincommandtest.log"
;PRIVATELOG: YES 6 "Command Test: Time \"#t\" Name \"#n\"  Ping \"#p\" IP \"#i\" #m"
;
;for example you may like to test if a client has commands that belong in well known quake2 cheat exe
;fairly useless for most - i only implemented it for debugging and testing purposes


gl_driver_max_changes "3"
;restricts the amount of times a player can change their gl_driver

gl_driver_check "0"
;pretty redundant with the advent of q2ace1.17.  it log's gl_driver usage of the players to the console.  again in place just for debug, logging and testing purposes.
;anyway, the settings are :
;1 - do the check
;2 - dont spam the check
;4 - dump to console
;add them together to achieve the desired affect for example i used 5 so that the server did the check and quietly spammed the server console which i logged.



Straight to the point
---------------------

for those that cba to read all of the above the additional q2admin.txt variables and there settings that i am using on my servers at jolt are :

ace_check_interval "60"
ace_version_check "1.17"
ace_min_clients "4"
ace_check "Yes"
msec_interval "5"
msec_max "6500"
msec_kick_on_bad "5"
do_vid_restart "No"
ace_max_pmod_noreply "1"
fps_kick_msg "    ****    %s has been using an fps hacked exe.    ****    \n"
ace_asus_check "1"
userinfochange_time "60"
userinfochange_count "40"
ace_way_check "No"   // note i would recommend "Yes" here to make a more secure server
client_map_cfg "0"





you can just add them to the bottom of the file and all works ok.  you should read up though and learn why you need to create the file q2adminace.txt



Revsion Info
------------
1.31 :
Small bug fix in that a client doesn't get kicked and say i've been kick for failing p_modified as this causes all the other q2ace clients to do another p_modified :/
Added another value to client_map_cfg so that clients can run a generic config as well as map specific configs if the server admin so chooses.
Added some additional cheat protection ready for q2ace 1.19 updated responses.
Added some additional cheat protection that doesn't require q2ace enforcement yet still stops several current public and privately released cheats - these are enabled by default.


1.30 :
Fixed non kicking of clients using wrong q2ace version, if less than 4 players.  It now kicks and expains what version is required.
Fixed bug where p_custom could cause clients to be kicked
Added msec output to dumpuser
Made the admin dumpuser more secure, by not displaying first 4 characters of p_auths to non level 7 admins
Added a specific dumpmsec command for level 2 admins


1.29
public release
added ability to create login's for players so they can join a q2ace only server without q2ace - i.e. useful for the odd linux and mac clients out there if they know the server admin.
bug fixed map change exploit from 1.28

1.28
private release.  added the ability to see what graphics drivers a player was using which gave a good indication as to how many people were taking advantage of the 3dfx q2ace exploit - fortunately, very very few.
some additional admin commands for q2ace admins
ability to stuff exec cfg/mapname.cfg to players or set a variable name in their client so that they can assign it to a key


1.27
private release.  added the ability to see if the client has certain commands available to them on their client.


1.26
Bug fix for 1.25 which had a serious flaw in it which kinda meant that the default variable setting would mean that it doesn't do a fucking thing to stop cheaters - doh !!!.


1.25
protection built in against id3 proxy bot
protection against server exploit and possible server crashes by flooding userinfo extreemly quickly
p_way comaparison to work the same way as p_auth checks do (should stop all future proxy bots) note the default is No, i suggest changing it to Yes :)
userinfochange_time "60"
userinfochange_count "40"
ace_way_check "No"


1.24
added a new check when a player enters the server 'p_asus'.  this checks a player for asus drivers and acts on the rules specified by the admin via the variable ace_asus_check.
change the kick message so that when a player isn't using q2ace it tells them to download the version number specified in ace_version_check.


upto 1.23b
-you can assume individual release numbers were private releases for testing purposes.
-removed fps_kick_msg variable from config file as it's now redundant.
-reworked testing so that it's now done every 60 seconds (ace_check_interval).  this is so that a client can't join the server, get tested and then change their gl_driver or anything else that invalidates q2ace mid game and have no one notice.  that vortex for pointing out this slight flaw to me :)  p_auth isn't retested unless the !pauth command is issued by an admin so there should be no additional lag.  this loop hole is now publically known, i have seen it mentioned myself on cheat sites in relation to q2admin q2ace only servers.

added new q2admin.txt variable
ace_max_pmod_noreply "2"
this should allow clients the oportunity not to respond a couple of times just incase they are lagged or alt-tabbed briefly.  this setting has been working fine for me for some time.


-initial q2ace test now increased from 10 seconds to 15 seconds so that very slow clients can make it onto the server more easily where large maps are involved.
-clients can no longer say the words p_auth or p_modified.  this was causing problems especially now that the tests were being done every 60 seconds.  haven't done the work to stop people setting their names to p_auth or p_modified though, so either use the q2adminban.txt file and add it in there, or ban players who abuse this.  i will probably talk to q2ace team and ask them to implement it clientside.
-added a client command 'showfps' which shows the true fps that the client and server are comunicating at.  it's accurate to about +or-2fps
-redone the error messages when kicked by q2amind for q2ace violations - they now give a bit more info for the client.  also the error messages are now logged as reasons if you log kicks using q2admin.
-when being kicked for not using q2ace, you are no longer returned to windows but left in the q2ace console so that you can read what's going on a bit more.
-added motd to display after the vid_restart so that it just didn't disapear when the client joined the server.



1.22e - 1.22i
prevent some more skin and team name overflows under linux mainly for tourney mod - an exploit that can crash a server or render it useless
fixed bug so that you can mute by player number now (code provided by wayne gill)
fixed server crash method which overflows the command queue (only by extending the array though :( ).
prevented a certain cheat exe from becoming invisible to q2admin and thus invisible to all of q2admins tests.
added CLIENTUSERINFO as an option to log in q2adminlog.txt
	LOGFILE: 5 MOD "q2adminuserinfo.log"
	CLIENTUSERINFO: YES 5 "Userinfo: Time \"#t\" Name \"#n\"  Ping \"#p\" IP \"#i\" #m"
only really useful for debugging and trying to figure out wtf players are attempting to do to bypass q2admin

