PazerOP / tf2_bot_detector

Automatically detects and votekicks cheaters/bots in TF2 casual.
MIT License
403 stars 55 forks source link

Mark People with a similar name #218

Closed SammCheese closed 1 year ago

SammCheese commented 3 years ago

An Enhancement to the Program would be a Highlight (like the Cheater highlight) of people with similar names (e.g same in-game name but one extra character)

ClusterConsultant commented 3 years ago

Using the steam api in conjunction with some regex and simple logic it is very possible to create a rule set that allows for very high specificity and sensitivity detection of generic name stealing. Terrible pseudo code: If ((steamName != inGameName) && otherPlayerName.find(inGameName))

SammCheese commented 3 years ago

Yeah, thats what i meant. It might be worth implementing that, to make detecting bots that arent in the lists already, easier.

cyrusParvereshi commented 3 years ago

So this would help to prevent real players from being kicked whose names have been copied by the bots?

ClusterConsultant commented 3 years ago

Kind of. From a tool perspective its just automating something most users (at least I assume based on how myself and friends use it) have been doing by hand. It would also future proof against new name stealing characters since it is acting based on the same metrics we are instead of just looking for one character. This would allow for the tool to more quickly identify and kick users with stolen names. Effectively reducing the likelihood that another non-tool user would kick the legitimate user sharing a name with the newly joined bot/cheater. This doesn't address the issue of communication to non-tf2bd users. See #203 and #189 as potential solutions to that problem.

SammCheese commented 3 years ago

Additionally you could make the program print the command to kick the bot to chat e.g "A cheater with the name GenericNameCopy is on the other team. Please kick them or paste this command into your Console to initiate a vote on the bot 'callvote kick {client id}' "

ClusterConsultant commented 3 years ago

There has been discussion of commands in chat in general. We don't want to train players into entering commands from chat into their console. Further talk of this should be done over on #203

SammCheese commented 3 years ago

seems like this has been done in the recent rule update?

PazerOP commented 3 years ago

Not exactly, I just added another zero-width character.

SammCheese commented 3 years ago

Alright, good to know.

Once it has been implemented, a chat message warning that the Bot is Imposting a Legit Player would be nice to further avoid conflicts.

Thank you for your Hard work pepelove (555793769035726849)

andy013 commented 3 years ago

Is there any legit reason why your steamName != inGameName? I don't even know if that's possible for legit players to do. That might be a good way to at least flag someone as suspicious and warn the user that they might be a bot. You might not even need to compare their name to the other players.

Kenajcrap commented 3 years ago

Is there any legit reason why your steamName != inGameName? I don't even know if that's possible for legit players to do.

Yes, it's pretty easy to do even by accident. If you change your name twice in a small enough window of time (say... 15 minutes) the second change will only happen in game if you rematch. So your name becomes different.

Also, if you use certain, very common, characters like ~ that the in-game name doesn't like, the game will omit those when setting the in-game name

All-in-all, noticing a person has a different in-game name is just one thing to consider when trying to know if someone is cheating, but it's pretty easy to happen to legit players too.

SammCheese commented 3 years ago

I think the best approach to this would be an Additional Color Category.

i.e 2 different People with almost Matching name, both get Marked as "Possible Imposter", rules like "If Possible imposter has nickname, mark as Imposter" to find the true Imposter and sending an Appropriate Chat Message like: "Attention! There is an Imposter Bot on the Enemy Team that goes by the name [name]! Make sure you kick the Bot!"

As soon as one of them leaves, both "Possible Imposter" Marked people get Unmarked and the Imposter marked as Cheater or Suspicious.

Kenajcrap commented 3 years ago

I think the best approach to this would be an Additional Color Category.

I disagree, I think that is unnecessarily complicated for a simple issue.

Just create a logic for looking for names that are the same once a list of characters (stored in a JSON) gets subtracted from both, and mark the one that has been in the match for the least amount of time as cheater (iirc, lobby returns the player time in the current server reliably).

A custom chat command MAY be implemented to curb people voting yes without looking amidst the voice spam. But it wouldn't be too useful since asking people to paste commands in console is not a good idea, and normal players can't discern between the impostor and the original to properly create a vote. It would be something like: "Attention: A bot/cheater is stealing the name of a player, be careful not to vote the wrong person off!"

andy013 commented 3 years ago

Just create a logic for looking for names that are the same once a list of characters (stored in a JSON) gets subtracted from both

This would fail because of all the characters in unicode that look the same.

Example:

"Kenajcrap" and "Kenajcrap" might show up the same in TF2 but be considered different when comparing the strings.

There are also a whole bunch of substitutions that can be used that look very similar like α in place of a. If you just delete these "special" characters then the strings will appear to be different when you compare them. You need to use a library that is designed to compare strings that could be visually confused with one another.

Kenajcrap commented 3 years ago

yea, after reading the other issue I understand it's not as straight forward as I initially thought. The suggestion I made there still stands though

SammCheese commented 3 years ago

Would it really be that hard?

id imagine that if that list of unicode character gets subtracted, the strings either are the same, or not. That can be used to Detect the Imposter.

(imagine the ? is the unicode character) "Kenajcr?ap" and "Kenajcrap" - With unicode char, they are not the same. "Kenajcrap" and "Kenajcrap" - Without Unicode char, they are the same. You could use the Before and After unicode removal string to compare it.

If ( (postRemovalPlayer1 != preRemovalPlayer1) && (preRemovalPlayer1 != preRemovalPlayer2) && playerTimeInMatch < playerTimeInMatchOfOtherPerson) { MarkasCheater }

Edit. Special Characters could be defined by every non Numerical or Alphabetical symbol. Lists of those Can be found on the Internet. Simple rules for O != 0 could be added manually.

andy013 commented 3 years ago

Look at the example I gave.

You have "Kenajcrap" and "Kenajcrap" if you remove the Kelvin symbol (K) which looks identical in TF2 to a capital K then you have "enajcrap" which is not the same as "Kenajcrap" so your check fails. The same applies for lots of characters. You can't just remove them because they are substitutes for letters.

Yes, if they just insert a zero width character you could remove it, but there are lots of other unicode characters that they can use.

SammCheese commented 3 years ago

in TF2 they might look the same but im sure the program can differenciate the unicode U+039A from U+004B which would be the Kelvin Symbol and the Latin Letter K.

As i said, a list of non-alphabetical and default numbers (their code), and remove those Accordingly, leaving only the standard alphabetical and numerical ones, which then can be used to do the thing in my comment.

ClusterConsultant commented 3 years ago

Out of interest of sanity comparing to steam name is still of value. Especially considering some work is being done on that already.

We are less concerned about actual Unicode replacements at this time since that method has not been seen in the wild. Not to mention the tf2 font does make Unicode lettering stick out.

Also the addition of categories will likely not be a thing given the goal is for user defined categories and the current set is a good enough base.

andy013 commented 3 years ago

I agree, I think comparing the steam name could be useful if most of the time it's a bot and only sometimes a real player. You could perhaps even have a variety of different checks like steam name, avatar the same as someone else in the game etc. and if a player failed all of them you would have a higher confidence that it's a bot.

I think you should be concerned about Unicode replacement as it is very easy to lookup characters that look the same as letters in someone's name and then create a table of the ones that actually display the same or very similar in TF2. I found a bunch just testing for a few minutes that look identical to the Latin letters that most people use in their name.

It seems obvious to me that if the bot detector was able to filter out zero-width characters and diacritic marks then character replacement is what the bots would start using next. Just like how they changed the characters they were using recently once this tool was updated to flag them.

I also think it's possible that the bots might update to change their steam name as well if this tool starts flagging differences. In the long term I think normalizing and comparing the strings might be the hardest for them to overcome.

[EDIT] Just wanted to add that I have now seen unicode replacement in the wild at least once.

astability commented 3 years ago

Unicode has technical standard 39 which talks about how to compare strings with confusables (identical chars): http://unicode.org/reports/tr39/#Confusable_Detection. You essentially convert things look the same are converted to the same codepoint, after which you can compare them like you usually do.

Im not sure if you could somehow use the fonts tf2 uses to check what becomes what.

Either way, it sounds easier to use the unicode method at first (which has implementations) rather than trying to disectect ttf files.

There are still some quirks that can't be removed this way, like (if i remember correctly) vv looking like M in one font.

andy013 commented 3 years ago

@astability I tried to implement this here: https://github.com/PazerOP/tf2_bot_detector/issues/138#issuecomment-797767597 If you have Visual Studio you can run the code and see if you can find a string that looks the same in TF2 but doesn't get detected.