AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Convert STEAMID to Steam Community ID (https://forums.alliedmods.net/showthread.php?t=60899)

voogru 09-16-2007 00:09

Convert STEAMID to Steam Community ID
 
I figured I would share this little snippet, this will convert a STEAMID to the a players friendID which is used for steam community.

What could potentially be done with this, is to fetch data on a player, see what groups he is in, and basically gives you the flexibility to ban whole groups from your server without knowing all of their steamids.

At least, thats what I intend to do with it. You can also of course do the reverse, converting friend ID's to steamids.

PHP Code:

__int64 GetFriendID( const char *pszAuthID )
{
    if(!
pszAuthID)
        return 
0;

    
int iServer 0;
    
int iAuthID 0;

    
char szAuthID[64];
    
strcpy_s(szAuthID63pszAuthID);

    
char *szTmp strtok(szAuthID":");
    while(
szTmp strtok(NULL":"))
    {
        
char *szTmp2 strtok(NULL":");
        if(
szTmp2)
        {
            
iServer atoi(szTmp);
            
iAuthID atoi(szTmp2);
        }
    }

    if(
iAuthID == 0)
        return 
0;

    
__int64 i64friendID = (__int64)iAuthID 2;

    
//Friend ID's with even numbers are the 0 auth server.
    //Friend ID's with odd numbers are the 1 auth server.
    
i64friendID += 76561197960265728 iServer

    return 
i64friendID;


Have fun.

Edit: Using this a Pure MySQL was created

Nican 09-16-2007 00:22

Re: Convert STEAMID to Steam Community ID
 
Really interesting data...

I would never have thought there was a relation ship

+Karma for you

BAILOPAN 09-16-2007 10:36

Re: Convert STEAMID to Steam Community ID
 
That's pretty awesome, voogru. I'm curious as to how you discovered this -- observation with some trial and error?

out of boredom I went and looked up the first few steamids to see how many were definitely valve employees:
Code:

steam_0:0:1 (alfred)
steam_0:1:1 (ErikJ)
steam_0:1:2 (alfred)
steam_0:0:5 (greg coomer)
steam_0:0:6 (john cook)
steam_0:1:7 (taylor sherman)
steam_0:0:8 (chris bokitch)
steam_0:1:9 (lyncho?)
steam_0:1:10 (eric smith)


voogru 09-16-2007 13:10

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by BAILOPAN (Post 531878)
That's pretty awesome, voogru. I'm curious as to how you discovered this -- observation with some trial and error?

out of boredom I went and looked up the first few steamids to see how many were definitely valve employees:
Code:

steam_0:0:1 (alfred)
steam_0:1:1 (ErikJ)
steam_0:1:2 (alfred)
steam_0:0:5 (greg coomer)
steam_0:0:6 (john cook)
steam_0:1:7 (taylor sherman)
steam_0:0:8 (chris bokitch)
steam_0:1:9 (lyncho?)
steam_0:1:10 (eric smith)


A bit of trial and error.

I got the friendID for these two ID's:

STEAM_0:1:1182 (76561197960268093)
STEAM_0:1:30679 (76561197960327087)

I noticed that the 2 friend ID's were identicle up until 11th number.
76561197960 268093
76561197960 327087

Then I tried this:

76561197960327087 - 76561197960268093 = 58994

Result was higher than expected, so I cut it in half for giggles.

58994 / 2 = 29497

Hmm.. not too far from 30679..

29497 + 1182 = 30679 DING DING DING DING

and

30679 - 29497 = 1182 DING DING DING DING

:D

To get the first number, I then did:

76561197960268093 - (1182 * 2) = 76561197960265729

But, I use the 76561197960265728 number and then just increment it by what the auth server is.

There does not appear to be a STEAM_0:0:0 ID, but there is a STEAM_0:1:0 ID.

Now with this knowledge, I also have the option of storing steamid's as 64 bit ints rather than strings.

My question to valve is where the hell did they pull out a number like 76561197960265728.

A friend of mine pointed out when it's converted to hex it's 110000100000000, but no idea if that is significant or not.

M249-M4A1 09-16-2007 23:16

Re: Convert STEAMID to Steam Community ID
 
holy cow

Extreme_One 09-17-2007 18:34

Re: Convert STEAMID to Steam Community ID
 
Wow

That's really clever!

BAILOPAN 09-17-2007 19:00

Re: Convert STEAMID to Steam Community ID
 
voogru: thanks for the logic path behind that :)

Of course you could just store them as 32-bit integers if you wanted... if you just do the X*2 + 1, it will be a long time before they overflow. Nice idea either way for lookup algorithms.

voogru 09-17-2007 23:13

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by BAILOPAN (Post 532436)
voogru: thanks for the logic path behind that :)

Of course you could just store them as 32-but integers if you wanted... if you just do the X*2 + 1, it will be a long time before they overflow. Nice idea either way for lookup algorithms.

Yeah, I realized that, but what if someday valve takes over the world and has more than 4 billion steam accounts?

M249-M4A1 09-18-2007 22:06

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by voogru (Post 532495)
Yeah, I realized that, but what if someday valve takes over the world and has more than 4 billion steam accounts?

stop hacking the pentagon

Lee 11-17-2007 16:04

Re: Convert STEAMID to Steam Community ID
 
You should post this in the AMXX section too.

Roach 11-19-2007 17:53

Re: Convert STEAMID to Steam Community ID
 
Woah, thats really cool.

I am impressed. +karma.

API 11-24-2007 16:41

Re: Convert STEAMID to Steam Community ID
 
Wow, nice.

Grrrrrrrrrrrrrrrrrrr 11-28-2007 00:40

Re: Convert STEAMID to Steam Community ID
 
i think i just had a moment. this can be used to give admin to certain groups or special abilities and more. this is revolutionary. DAMN.

BigBaller 11-29-2007 10:30

Re: Convert STEAMID to Steam Community ID
 
Now my question is when would we see this implemented into a nice plugin for end users?

You could do a lot of interesting things with a plugin that used that, maybe even find steam community groups or something and join them from a server.

Twilight Suzuka 12-16-2007 21:32

Re: Convert STEAMID to Steam Community ID
 
Interesting. Bannage by user groups might be useful to implement into my PUG mod.

Roach now has power in this forum.

Seather 12-22-2007 19:15

Re: Convert STEAMID to Steam Community ID
 
2 Attachment(s)
I made a PHP script that batch converts both ways.

http://www.joe.to/moo/sid_convert.php

Source code attached.

you don't need to clean the input, you can paste your admins ini and have the output be the same as your input except for the links

Old attachment view count: 2814 views (1747 + 467 + 600)

flyeni6 12-25-2007 20:21

Re: Convert STEAMID to Steam Community ID
 
really nice :)

StevenT 12-29-2007 19:39

Re: Convert STEAMID to Steam Community ID
 
very nice thx

krod 12-30-2007 15:48

Re: Convert STEAMID to Steam Community ID
 
BRILLIANT!!!!!!
I need to integrate this on my forums!

Scuzzy 01-16-2008 12:06

Re: Convert STEAMID to Steam Community ID
 
I just wanted to pay homage and say thanks to Voogru for posting this, it's come in EXTREMELY handy. We use in our server administration and it helps greatly. Thanks!

http://www.oldtimersclan.com/post_img/scuztools1.jpg

Lee 01-16-2008 14:23

Re: Convert STEAMID to Steam Community ID
 
That administration panel looks pretty impressive. I like the idea of automatically banning previously banned players using a different account. Do you use set_user_info(), IP address or another method?

Scuzzy 01-16-2008 15:54

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by Lee (Post 574669)
That administration panel looks pretty impressive. I like the idea of automatically banning previously banned players using a different account. Do you use set_user_info(), IP address or another method?

Thank you. We have a perl process that watches the database and server for bans. It executes the following process once an account has been perm banned:

1) Get all IPs registered for the account, search for all steam-ids associated with that IP.
2) Ban all IDs associated with that IP. Check all IPs for each account banned for additional accounts, repeating the process.

This trees out and finds and removes all associated accounts in a recursive process.

We don't only run this process on accounts that have been banned though. If an account that was previously banned connects to the server we log the "denied" connection and save the IP. We then run that IP through the process above and nuke an previously undected new accounts of the "LLama".

But wait, there's more!

If an unbanned account connects to the server we check the IP of that account against the IPs of all previously banned accounts. If that player is playing from the same IP that a previously banned account has, they're immediately banned as well.

We don't like Llamas. We don't like it when they return. I also hate "cafe" accounts, we have more idiots play from steam cafes then I care to count. Nothing like total inaccountability to make someone as asshat in a server. This pretty much eliminates them.

Scuzzy

KMFrog 01-16-2008 19:19

Re: Convert STEAMID to Steam Community ID
 
And also eliminates anyone with a dynamic IP address on the same ISP as "the banned"?

Scuzzy 01-16-2008 22:05

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by KMFrog (Post 574808)
And also eliminates anyone with a dynamic IP address on the same ISP as "the banned"?

You mean it one guy gets banned, gives up his IP addr and another guy with the same game gets that IP and trys to connect to our server? Yes. We did think of that, but considering the requirements the statistical chances are pretty slim:

1) They both have to have the same ISP
2) They have to have Dynamic IPS.
3) One has to be banned.
4) The second has to get that bad IP.
5) They have to both play Steam Games, either TFC/FF/TF2 (Out of the hundreds of thousands of players)
6) They both have to choose our server (out of the 4000+ available in North America alone)

Scuzzy

KMFrog 01-17-2008 10:17

Re: Convert STEAMID to Steam Community ID
 
1) "big popular" ISPs are often filling multiple slots on any server
2) If they are on the same ISP, chances are they are both on dynamic addressing
3) A ban increases the chance your system will fail :p
4) Each ISP will have its own way of doing things, some rotate IP addresses automatically so the chances could be quite high
5) True, but hundreds of thousands of players only increases the chance your system will fail
6) If the ISP has a good route to your server, chances are people from the same ISP will join due to the lower pings

Plus, you will not be able to identify "false bans" as you could not have a method to verify the identity of the people banned. If we all had static IP addresses, this system would be great - but most domestic connections have a dynamic IP address. If you have lots of bans due to your IP tracking, then personally I would be a bit worried about who I'm banning :D

Also, you might want to keep in mind that most kids with a cafe account probably ritually change their IP address to avoid IP bans & mask their identity.

If I were in your place, I would only track multiple bans from the same IP address. Once an address has reached a pre-set limit only then would I wipe out the IP. Its far from perfect though, and the same problems still apply - just the chances of banning the wrong people are less due to the "ban limit" buffer.

I'm just picking holes anyway, don't mind me - I'm a system whore :]

Scuzzy 01-17-2008 12:20

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by KMFrog
If I were in your place, I would only track multiple bans from the same IP address. Once an address has reached a pre-set limit only then would I wipe out the IP. Its far from perfect though, and the same problems still apply - just the chances of banning the wrong people are less due to the "ban limit" buffer.

I'm just picking holes anyway, don't mind me - I'm a system whore :]

I understand the worry, but we've had the system for years and it's worked well. 99% of this type of ban are two people are playing from the same IP the same night. I'm not aware of how many people have dynamic IPs, most companys issue an IP and so long as the computer reconnects to the network in the next week they keep that IP (from what I've seen in the U.S.). Back in the days of dialup I'd completely agree with you. We've had 75228 unbanned people connect to our server over the last 3 years. Of those 75228 people:
74921 had 9 IPs or less
198 had between 10-19 IPs
79 had between 20 and 49 IPs
24 people had between 50 and 100
6 had above 100 IPs
It may untentionally ban one or two people out of a few hundred thousand, but I think the margin for error is pretty small. We've also received 0 complaints that a ban was incorrect because of this reason, and we get unban requests every day. We're more willing to crack a few eggs then deal with Llamas over and over again. There are plenty of good servers to play on, being limited away from ours doesn't really hurt anyone.

Scuzzy

[kirk]./musick` 01-17-2008 19:06

Re: Convert STEAMID to Steam Community ID
 
Wow, very nice find!

Maurice 01-18-2008 11:45

Re: Convert STEAMID to Steam Community ID
 
In the first posts of this topic i readed it would be possible to get the steamcommunity information from every desired steamID. If this is correct it would be the plugin or software i need because the player with STEAMID *********** discovered my rcon password due unknown reason. The same IP also hacked my website. To prevent this in the future i've to fix the leak and need to know how he did it. Therefor i need all the info i can get about the the STEAMID **********.

If possible i hope someone can help me to get more information about STEAMID ************.

Scuzzy 01-19-2008 21:42

Re: Convert STEAMID to Steam Community ID
 
BTW, for anyone interested in doing this strictly in mySQL, like a trigger to calculate this field when you create a player record... I found some issues getting mySQL to actually ADD the numbers together. I finally came up with this:

Code:


cast(mid(steam_id,9,1)  as unsigned) + cast('76561197960265728' as unsigned) + cast(mid(steam_id, 11,10)*2 as unsigned)

That did it appropriately. (but make sure you're not getting a false steam id, like "STEAM_ID_LAN")

Cheers,
Scuzzy

Maurice 01-21-2008 05:17

Re: Convert STEAMID to Steam Community ID
 
You are awesome Scuzzy! This is really the steamcommunity ID i was looking for and now i can get in touch witch the person that broke into my server. I've only one more question Scuzzy. Would it be possible that you remove the steamid out of my quoted reply because i don't want that this hacker know i'm looking for him. If you remove it i will remove it from my post to, if you don't want to remove it's fine to because you helped me already so much!

Scuzzy 01-22-2008 00:11

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by Maurice (Post 576607)
You are awesome Scuzzy! This is really the steamcommunity ID i was looking for and now i can get in touch witch the person that broke into my server. I've only one more question Scuzzy. Would it be possible that you remove the steamid out of my quoted reply because i don't want that this hacker know i'm looking for him. If you remove it i will remove it from my post to, if you don't want to remove it's fine to because you helped me already so much!

Done.

Maurice 01-22-2008 04:17

Re: Convert STEAMID to Steam Community ID
 
Thanks again Scuzzy! But i have already a new question. I tested with my own steamid aswell with some friends steamid and everything is works correct when i use the formule
steamcommunityID - (steamID * 2) = 76561197960265729

If i take for example the steamID's
STEAM_0:0:123456
STEAM_0:1:123456

They both reffer to that same steamcommunityID, how can i be sure to wich of the both steamID's belong the the calculated steamcommunutyID?

Scuzzy 01-22-2008 22:41

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by Maurice (Post 577044)
Thanks again Scuzzy! But i have already a new question. I tested with my own steamid aswell with some friends steamid and everything is works correct when i use the formule
steamcommunityID - (steamID * 2) = 76561197960265729

If i take for example the steamID's
STEAM_0:0:123456
STEAM_0:1:123456
They both reffer to that same steamcommunityID, how can i be sure to wich of the both steamID's belong the the calculated steamcommunutyID?

You didn't add the 1 to the second steam_id:

STEAM_0:0:123456 = 0 + 76561197960265728 + (123456*2)
STEAM_0:1:123456 = 1 + 76561197960265728 + (123456*2)

Scuzzy

theY4Kman 01-27-2008 01:45

Re: Convert STEAMID to Steam Community ID
 
1 Attachment(s)
I got a bit bored, so I made a Python script for it. It took me way longer than it should've...I spent most of the time on the fluff (options, about, etc).

StevenT 01-27-2008 15:41

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by Seather (Post 565979)
I made a PHP script that batch converts both ways.

http://www.joe.to/moo/sid_convert.php

Source code attached.

you don't need to clean the input, you can paste your admins ini and have the output be the same as your input except for the links

Code:

Fatal error:  Call to undefined function bcmul() in /usr/local/www/www.joe.to/moo/sid_convert.php on line 38
>.< now i need to find a new website that i can freely use T.T

Phoenix2 01-27-2008 19:37

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by theY4Kman (Post 578802)
I got a bit bored, so I made a Python script for it. It took me way longer than it should've...I spent most of the time on the fluff (options, about, etc).

Sorry if I sound stupid, but, does this go on a webserver? And if so, how do or what do I need to install it?

Thanks,
P2

Seather 01-28-2008 23:20

Re: Convert STEAMID to Steam Community ID
 
StevenT: fixed, after all these years we finally got a decent connection / OS for our site.
http://www.joe.to/moo/sid_convert.php

StevenT 01-29-2008 00:23

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by Seather (Post 579420)
StevenT: fixed, after all these years we finally got a decent connection / OS for our site.
http://www.joe.to/moo/sid_convert.php

thx i love you!

CShadowRun 02-02-2008 20:30

Re: Convert STEAMID to Steam Community ID
 
Should anyone want it, I made this into a little mIRC Script (So you can type /profile STEAMID or COMMUNITY ID to get the steamid or community url returned.

Just read the remarks to see how to install and use, pretty simple.

I also set this up in the SourceMod IRC Channel (#sourcemod on gamesurge) just type !profile STEAMID or COMMUNITY ID and if i'm online it'll reply for you :P

Code:

  ; Script to turn STEAM_IDs into Community page URLS and the other way around. Created by CShadowRun!
  ; Use is simple just type /profile STEAM_ID or Community ID (The very large number at the end of the URL)
  ; Just press alt + r in mIRC and paste this into your remotes and you  should be good to go!

alias profile {
  if ($regex($1-,^STEAM_\d:(\d):(\d+)$)) {
    var %n = $right(76561197960265728,$calc($len($regml(2) + 1)))
    var %id = $calc(($regml(2) * 2) + $regml(1) + %n)
    echo -a $+($1-,'s) Community page is: $+(http://steamcommunity.com/profiles/,$left(76561197960265728,$calc(13 - $len($regml(2)))),%id) 
  }
  else if ($regex($1-,^7656119\d+$)) {
    var %n = $right($1-,10)
    var %n = $calc(%n - 7960265728)
    if (. isin $calc(%n / 2)) { var %one = 1 | dec %n }
    var %n = $calc(%n / 2)
    echo -a Profile ID $1- Belongs to: $+(STEAM_0:,$iif(%one,1,0),:,%n)
  }
  else { echo -a $1- Does not appear to be a valid Community or Steam ID. }
}


theY4Kman 02-03-2008 00:16

Re: Convert STEAMID to Steam Community ID
 
Phoenix2, it's a Python script. After you've installed Python onto your computer, download the script, remove the .txt extension, and run the script from the command-line.


All times are GMT -4. The time now is 18:16.

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