Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Hack Detection notes from Deluxe Pacman 2

This thread is locked; no one can reply to it. rss feed Print
Hack Detection notes from Deluxe Pacman 2
Neil Roy
Member #2,229
April 2002
avatar

This section needs a new post, so I thought I would share some of my notes on how I implemented some hack detection and what not into my Deluxe Pacman 2 game.

The current version has these disabled, but at one time someone was hacking the game a lot (why, I don't know!). So I thought I would have some fun messing with them. Here are some notes I took. If anyone is curious.

~ Detecting Hacks ~

When a player gets a free life, I store their score into a variable "oldscore", I then compare oldscore to current score the next time they get a free life and if the difference doesn't warrant a free life, hack detected.

I store the current energy level into a variable (oldenergy) before I depleat it when it is being used. I then check later to see if the two match after I depleat it, and if they do, than hack detected.

If the player dies, I store their current number of lives before I decrease them into a variable (oldlives). I then compare the stored lives (oldlives) they used to have, with the current lives after they lost one, and if they match, than someone hacked the game.

I stored the total size of my game's data file (PAK file for my Deluxe Pacman 2) inside the game itself, I then check the game's current data file size with the stored value to help detecting a hack. And for good measure, I used the stored value in other areas of the game along with a checksum to make certain it wasn't altered either. :)
I have an ini settings command to disable the data file check so a user can alter it (it's just a renamed ZIP file anyhow). But they have to know that command, and I haven't told many people what that is. If you knew what it was for my Deluxe Pacman 2 game, you would laugh.

~ Hack penalties :) ~

If a hack is detected, I DO NOT LET THE PLAYER KNOW I DETECTED IT. Instead, I make subtle changes to the game they will not notice right away. This makes it harder for them to figure out if their hacks were successful or not and exactly what triggered their detection. Plus it's fun for me! :P

In this game, I shortened the length of time my ghosts stay blue by 25%.
I also increased the radius of the collision circle around my ghosts so it is easier to collide with one.
I also made ghosts move a bit faster. :)
I allowed them to enter their high score, but I don't bother to save the high score file at all, so the next time they play the game, the high scores won't be there. :)

~ Additional notes ~

Add a warning: "The use of modified game files is not recommended or supported. If you run into problems you may need to reinstall the program. Hacks could also contain viruses which could put your entire computer at risk!" (I try and deter people from using them)

Also throw in random variables into your game, and have your game check them at specific locations. These would be dummy variables that do absolutely nothing, but if placed in key locations, they can really throw people off that are using programs to scan your game in memory to hack it. You can change the dummies etc... perhaps at key locations where you don't want them being able to easily figure out where you store lives, where the score etc... is.

Someone who is determined, can figure it out, but I won't make it easy for them and most amateurs will give up as a game like mine, is hardly worth the effort.

--
Deluxe Pacman
"I am not ashamed of my belief in God."

Eric Johnson
Member #14,841
January 2013
avatar

That's pretty cool. :) I really enjoy "behind the scenes" sorts of posts like this. How did you know someone was hacking your game though? Does the game save high scores to a Web site?

I remember using Cheat Engine on some racing game on Steam after I finished it and was surprised to find that the game knew when I was cheating! :o It'd just end the race or whatever early, and wouldn't register my score. I just did it for fun though, not to ruin any leader boards or anything.

Pretty funny that you don't let on to the hacker though. ;D

Neil Roy
Member #2,229
April 2002
avatar

I made a small error in those notes. I don't check the executable size at all, I check the data file size (as that is what was being altered, new graphics, levels etc.). I actually have a method to allow players to alter it, but they have to be told from me personally (as I did one person who helped me with ideas while I developed it).

My game just saves the high scores to normal files on the drive, but they are in binary format, so difficult to edit manually.

There's lots you can check as those "Cheat Engines" will alter values in memory, so it will prevent lives from going down giving you infinite lives once you know where the lives variable is stored in memory. The only problem with that scheme is, a programmer like myself can put in safeguards to double check if I reduce the lives, to make certain the variable went down. Cheat Machine will keep it at max which is a sure indicator of a hack as when my game lowers your lives... the variable... should be lower, not the same. An unchanged value is a value that is being altered externally. :) I do the same for other values and because I know people are using cheat machine to monitor for changing variables, I threw in a bunch of dummy variables that do NOTHING, but I change them when I change lives, energy etc... just extra stuff to look for and not know what is going on with these cheat programs. :)

I don't let the user know I detected them as if I were to say, shut the game down as soon as a cheat was detected, you could easily trace where that happened in memory and then fix it so that doesn't happen. So most games that protect against cheats will not let you know it detected you but let you play, but change some conditions, not save your score etc... and you won't have a clue where it detected you or how. :)

It is actually a lot more fun to program as a programmer. It brings a smile to my face knowing some cheater is frustrated out of beating someone's high score unfairly ;D

I actually keep detailed journals of my development in my games. I find it can really help sometimes to go back and read something from the past. And just for nostalgia I will sometimes read though. Helps remind me of some ideas I had too that never got done, as I mention all ideas in them as well.

This was from a separate hacking journal I made notes in. I cleaned it up for in here. The original also had some code in it.

Edit: update my original post, corrected it so it mentions the data file, not the executable.

Edit2: OH, I didn't answer your question on how I knew. You're going to love this... THEY TOLD ME. ;D Yeah, not the brightest person... even told me their Facebook page, so I was able to check how they hacked it. Bwahahahahah!

--
Deluxe Pacman
"I am not ashamed of my belief in God."

amarillion
Member #940
January 2001
avatar

I can see the fun in this. Annoying a player who is trying to cheat. Like "iddqd" results in instant death in heretic.

But on the other hand, it seems kind of overkill. For something a single player does on their own computer, well, it wouldn't matter much to me.

--
Martijn van Iersel | My Blog | Sin & Cos | Tegel tilemap editor | TINS 2017

Neil Roy
Member #2,229
April 2002
avatar

Except they were creating these hacks, and the distributing them online. Given that this effects the high score and cheating means you could beat someone else's high score that played fairly, I like to do something to help prevent it.

There are separate built in programmer's cheat code in my game that works, stuff I coded in to help me test the game. There's really no NEED for hacks to be honest.

--
Deluxe Pacman
"I am not ashamed of my belief in God."

amarillion
Member #940
January 2001
avatar

In that case, I agree. If the cheating affects other players, then there is a reason to do something about it.

--
Martijn van Iersel | My Blog | Sin & Cos | Tegel tilemap editor | TINS 2017

Neil Roy
Member #2,229
April 2002
avatar

Do a search on Youtube for the Diablo Port Mortem some time. It's a good case for protecting against cheating right from the get go. They didn't bother protecting against it at all in that game and they didn't really care. They felt that if it's just you playing it, what will it really matter. Well, that is, until they made the game multiplayer and added in Battlenet. Then all of a sudden cheating was rampant and it effected other players. They then realized it was a mistake to not deal with cheating earlier.

It's a great video to watch. Heck, all of the postmortems, from the GDC youtube page are awesome as they show some of the development problems etc.

--
Deluxe Pacman
"I am not ashamed of my belief in God."

LennyLen
Member #5,313
December 2004
avatar

Neil Roy said:

Then all of a sudden cheating was rampant and it effected other players.

The amount of cheating in public Diablo games was ridiculous. The only way to have decent games was to stick to private channels. I ended up getting my own bnetd server for the community I was involved with so that we could avoid cheaters.

Kompromaus
Member #16,649
March 2017

Longtime lurker!

I'm on the other side of the battle! Trying to cheat in an online game. Not easy, lots of work. But been successful thus far.

I have a custom OpenGL shim library that sits between Mesa and the target. The goal is to no-op drawing entirely and rely on running dozens of instances on headless servers.

One interesting tactic I used was generating a collision map of the world with ODE, so I know where I can walk and where I can't. It's broken into a couple stages:

1) I shoot rays down in equal distance units and collide with the terrain.
2) I then create a virtual 'token', offset a little bit off the values from step 1 and as big as the player (in render units).
3) For every so many units, I check to see if the token collides with any static geometry. If there's a collision, I mark it impassable; if not, I mark it passable. I also do some optimizations to check for walls by offsetting a smaller token.

I can then cache the collision data and then do things like path-finding across the world. Nifty!

Good day.

Go to: