Raised This Month: $ Target: $400
 0% 

[EXTENSION] Query Cache (AS2_INFO DoS protection)


Post New Thread Reply   
 
Thread Tools Display Modes
Afronanny
Veteran Member
Join Date: Aug 2009
Old 04-06-2010 , 22:28   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #121

Quote:
Originally Posted by pheadxdll View Post
It's in the engine. You probably want CVEngineServer::GetGameServerSteamID(void) It's a virtual function so it should be easy to call.
Even better

I was talking to Mana, owner of the LotusClan.com servers and he provided some information regarding server SteamIds:

Code:
15:57:06 Server's SteamID: 90078665405217792
         <TAB>Type: k_EAccountTypeAnonGameServer
         <TAB>ID: 2773597184
Not sure what it is, or what it does, but he had a command on his server to fetch the steamid, it's type and another ID.
Afronanny is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-07-2010 , 05:18   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #122

That's just the basic info from the CSteamID class, both of the functions named previously should return a CSteamID.

Quote:
Server's SteamID: 90078665405217792
The full 64-bit ID
Quote:
Type: k_EAccountTypeAnonGameServer
Code:
...
k_EAccountTypeAnonGameServer = 4,       // anonymous game server account
...
Quote:
ID: 2773597184
This is the AccountID portion, this is the part that is unique.

The universe used is most likely public.

There is a full implementation here.
EAccountType and EUniverse enums, just in case you want them for reference.
__________________
asherkin is offline
recon0
Veteran Member
Join Date: Sep 2007
Location: US
Old 04-07-2010 , 14:37   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #123

That looks very useful.

I think with that, and the virtual function, you can probably take it from here Afronanny.
__________________
recon0 is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 04-07-2010 , 20:05   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #124

Quote:
Originally Posted by recon0 View Post
That looks very useful.

I think with that, and the virtual function, you can probably take it from here Afronanny.
I sure hope so.

One problem, I'm not sure how to call virtual functions. I know how to hook them, but calling one is something I've never done before.

Last edited by Afronanny; 04-07-2010 at 22:19.
Afronanny is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-08-2010 , 05:06   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #125

It should probably be done using bintools, or even looking up the code yourself (it's quite easy to find out how to call them, I can't remember offhand), but just for testing you can SH_DECL_(MANUAL)HOOK and then SH_CALL, this is probably not great for final code as it bypasses any hooks, but it's really fast to write when looking for a func that does what you want.

http://wiki.alliedmods.net/SourceHoo...ypassing_Hooks

An alternative solution that AzuiSleet sugested on IRC after reading the thread is to use Steam_GSGetSteamID, this is a C export from steamclient and will not break on updates.
__________________

Last edited by asherkin; 04-08-2010 at 05:29.
asherkin is offline
recon0
Veteran Member
Join Date: Sep 2007
Location: US
Old 04-08-2010 , 05:23   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #126

Quote:
Originally Posted by Afronanny View Post
One problem, I'm not sure how to call virtual functions. I know how to hook them, but calling one is something I've never done before.
It's one of the simplest function types to call. If you take a look at the SDKTools extension (part of SM), it will probably show you how to get from an offset to a function call. You could also look at the C++ source for the SP natives that let you call virtual functions.
__________________
recon0 is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 04-08-2010 , 06:22   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #127

Quote:
Originally Posted by asherkin View Post
It should probably be done using bintools, or even looking up the code yourself (it's quite easy to find out how to call them, I can't remember offhand), but just for testing you can SH_DECL_(MANUAL)HOOK and then SH_CALL, this is probably not great for final code as it bypasses any hooks, but it's really fast to write when looking for a func that does what you want.

http://wiki.alliedmods.net/SourceHoo...ypassing_Hooks

An alternative solution that AzuiSleet sugested on IRC after reading the thread is to use Steam_GSGetSteamID, this is a C export from steamclient and will not break on updates.
Quote:
Originally Posted by recon0 View Post
It's one of the simplest function types to call. If you take a look at the SDKTools extension (part of SM), it will probably show you how to get from an offset to a function call. You could also look at the C++ source for the SP natives that let you call virtual functions.
Thanks. I'll try it later today when I get home.
Afronanny is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-08-2010 , 06:40   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #128

I wasn't going to post this as it only works on the EP2/OB engine, but I just re-read the OP and noticed that Query Cache only works on there as well.

Code:
typedef HSteamPipe (*GetPipeFn)();
typedef HSteamUser (*GetUserFn)();
typedef void * (*GetHandleFn)(HSteamUser, HSteamPipe);
typedef uint64 (*GetCSteamIDFn)(void *);

GetPipeFn g_GameServerSteamPipe;
GetUserFn g_GameServerSteamUser;
GetHandleFn g_GameServerHandle;
GetCSteamIDFn g_GameServerSteamID;

CON_COMMAND(printid, "") {
	g_GameServerSteamUser = (GetUserFn)GetProcAddress(GetModuleHandleA("steam_api.dll"), "SteamGameServer_GetHSteamUser");
	g_GameServerSteamPipe = (GetPipeFn)GetProcAddress(GetModuleHandleA("steam_api.dll"), "SteamGameServer_GetHSteamPipe");
	g_GameServerHandle = (GetHandleFn)GetProcAddress(GetModuleHandleA("steamclient.dll"), "Steam_GetGSHandle");
	g_GameServerSteamID = (GetCSteamIDFn)GetProcAddress(GetModuleHandleA("steamclient.dll"), "Steam_GSGetSteamID");

	CSteamID steamID = CSteamID(g_GameServerSteamID(g_GameServerHandle(g_GameServerSteamUser(), g_GameServerSteamPipe())));
	g_pSM->LogMessage(myself, "SteamID: %s", steamID.Render());
};
Of course, a lot of that can be moved to make it more efficient, but bear in mind the server doesn't have it's steam id yet on start.

EDIT: HSteamPipe and HSteamUser are both int32. I missed it since the typedef is already in OpenSteamWorks
__________________

Last edited by asherkin; 04-08-2010 at 06:45.
asherkin is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 04-12-2010 , 14:06   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #129

Quote:
Originally Posted by asherkin View Post
I wasn't going to post this as it only works on the EP2/OB engine, but I just re-read the OP and noticed that Query Cache only works on there as well.

Code:
typedef HSteamPipe (*GetPipeFn)();
typedef HSteamUser (*GetUserFn)();
typedef void * (*GetHandleFn)(HSteamUser, HSteamPipe);
typedef uint64 (*GetCSteamIDFn)(void *);
 
GetPipeFn g_GameServerSteamPipe;
GetUserFn g_GameServerSteamUser;
GetHandleFn g_GameServerHandle;
GetCSteamIDFn g_GameServerSteamID;
 
CON_COMMAND(printid, "") {
    g_GameServerSteamUser = (GetUserFn)GetProcAddress(GetModuleHandleA("steam_api.dll"), "SteamGameServer_GetHSteamUser");
    g_GameServerSteamPipe = (GetPipeFn)GetProcAddress(GetModuleHandleA("steam_api.dll"), "SteamGameServer_GetHSteamPipe");
    g_GameServerHandle = (GetHandleFn)GetProcAddress(GetModuleHandleA("steamclient.dll"), "Steam_GetGSHandle");
    g_GameServerSteamID = (GetCSteamIDFn)GetProcAddress(GetModuleHandleA("steamclient.dll"), "Steam_GSGetSteamID");
 
    CSteamID steamID = CSteamID(g_GameServerSteamID(g_GameServerHandle(g_GameServerSteamUser(), g_GameServerSteamPipe())));
    g_pSM->LogMessage(myself, "SteamID: %s", steamID.Render());
};


Of course, a lot of that can be moved to make it more efficient, but bear in mind the server doesn't have it's steam id yet on start.

EDIT: HSteamPipe and HSteamUser are both int32. I missed it since the typedef is already in OpenSteamWorks
I'm using Linux, no Windows server. I believe the Linux equivalent is dlopen and dlsym, correct?

Quote:
Originally Posted by asherkin View Post
It should probably be done using bintools, or even looking up the code yourself (it's quite easy to find out how to call them, I can't remember offhand), but just for testing you can SH_DECL_(MANUAL)HOOK and then SH_CALL, this is probably not great for final code as it bypasses any hooks, but it's really fast to write when looking for a func that does what you want.

http://wiki.alliedmods.net/SourceHoo...ypassing_Hooks

An alternative solution that AzuiSleet sugested on IRC after reading the thread is to use Steam_GSGetSteamID, this is a C export from steamclient and will not break on updates.
I tried putting this into code, but I'm not sure how to get the return value when using SH_CALL.
Afronanny is offline
WebNoob
Senior Member
Join Date: Jul 2008
Old 04-13-2010 , 09:54   Re: [EXTENSION] Query Cache (AS2_INFO DoS protection)
Reply With Quote #130

As we've been getting DDOS's of late, I tried to isntall this last night.

Installation went fine, and it loaded without a hitch, but all the (TF2) servers disappeared from the server browser/favorites.

I had the following placed in the server.cfg:

Code:
//qcache settings

qcache_gameversion 1.0.8.4
Did I miss something?
WebNoob is offline
Reply



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 06:43.


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