Countermeasures
For obvious reasons, gaming companies are most interested in keeping bots out of games. Scientists have even begun to study the problem and publish work about it. For example, the paper "Preventing Bots from Playing Online Games" by Philippe Golle and Nicolas Ducheneaut appears in ACM Computers in Entertainment.17
One clever idea suggested for ensuring that humans (rather than bots) are playing games has been used successfully to combat spam. It's called a reverse Turing test. The Turing test is a test from the AI field meant to determine whether the entity at one end of a conversation is a human. A reverse Turing test works by asking questions to ensure that the answering target (in this case, a gamer) is a human. In many cases, this involves displaying a convoluted picture that only a human can properly decode (Figure 2-6). This technique is often referred to as captcha, short for Completely Automated Public Turing Test to Tell Computers and Humans Apart.
Figure 2-6 A classic reverse Turing test based on human perception. (From <http://www.brianpautsch.com/Blog/2005/12/1/Captcha>; used by permission.)
Often, gamers self-police and try to ferret out and expose bots among themselves. This can happen through the invocation of a game's chat function (something that game masters also employ as a tactic to find bots). The chat countermeasure works in many games, from MMORPGs to online poker. Poker bots are not very good at small talk!
Monitoring in real time (possibly using chat) is often accompanied by monitoring history as well. Looking for behavior that is nonhuman in nature—maybe superhuman aim, or maybe obsessive behavior such as killing monsters over and over in the same spot—is often a tip-off that a bot may be involved. Game masters make use of history to uncover cheating as a standard tactic.
Spyware
Anticheat tools have been around almost as long as game servers have. Public outcry on open servers led to the first such tools. Game companies running private servers carry on the tradition to this day.
The first service devoted to this is called PunkBuster, run by a Texas company named Even Balance, Inc. The PunkBuster service started in 2000. The first versions relied on simple techniques such as variable checking and process validation authorized through a server. This was followed by a number of server-based checks. Today, PunkBuster is integrated into a number of online games.
The PunkBuster Web site lists the following "features" of the product.18
- Real-time scanning of memory by PB Client on players' computers searching for known hacks/cheats
- Throttled two-tiered background auto-update system using multiple Internet Master Servers to provide end-user security ensuring that no false or corrupted updates can be installed on players' computers
- Frequent status reports (highly encrypted) are sent to the PB Server by all players and the PB Server raises a violation when necessary which causes the offending player to be removed from the game and all other players are informed of the violation
- PB Admins can also manually remove players from the game for a specified number of minutes or permanently ban if desired
- PB Servers can optionally be configured to randomly check player settings looking for known exploits of the game engine
- PB Admins can request actual screenshot samples from specific players and/or can configure the PB Server to randomly grab screenshot samples from players during gameplay
- An optional "bad name" facility is provided so that PB Admins can prevent players from using offensive player names containing unwanted profanity or racial slurs
- Search functions are provided for PB Admins who wish to search player's keybindings and scripts for anything that may be known to exploit the game
- The PunkBuster Player Power facility can be configured to allow players to self-administer game servers when the Server Administrator is not present entirely without the need for passwords
- PB Servers have an optional built-in mini http web server interface that allows the game server to be remotely administered via a web browser from anywhere over the Internet
Note that some of these features are extremely invasive, such as the one that scans client PCs! This kind of scanning often involves the installation of spyware on a gamer's PC.
PunkBuster was originally conceived as a way to stop client-side hacks in Counter-Strike. But today PunkBuster concentrates on helping to protect and police other games.
As it turns out, PunkBuster was a harbinger of invasive techniques to come.
The Warden: Defeating Cheaters by Crossing the Line
Today, WoW has a two-pronged strategy to defeat cheaters. The first approach is to make rules against cheating and ban those characters caught cheating. This is carried out by publishing the terms of use, which are administered according to the legally binding EULA. Nothing is wrong with that.19 (For more on the legal situation, see Chapter 4.) The second approach is to keep an eye on every PC running the WoW client and try to determine whether it is being used to cheat. This spying thing is a problem.
If monitoring someone's PC sounds like spying to you, that's because it is. WoW's embedded Warden reads all sorts of data from the gamer's PC. Hoglund's Warden discovery in fall 2005 set off a controversy over privacy, security, and just what lengths security measures should go to in order to stop cheating. And it's part of the reason that we decided to write Exploiting Online Games.
Besides monitoring the WoW process space and keeping track of DLLs running in that space, the Warden pokes around into other processes, doing things like reading the window text in the title bar of every window and doing a scan of the code loaded for every process running on your computer (which it then compares against known cheat code). Blizzard claims not to have any designs to use the data it digs up for purposes other than security, but nothing is really stopping the company from doing whatever it wants on a gamer's PC, and it has already crossed the invisible line by poking around outside the game's process area. We don't trust them.
This is a clear invasion of privacy. So much so that the Electronic Frontier Foundation (EFF) has even weighed in with an opinion <http://www.eff.org/deeplinks/archives/004076.php>. Though the EULA does call out that Blizzard may monitor PC activities with the Warden (without specifying what the Warden actually does), this information is buried in the small print that almost nobody ever reads. In informal conversations with WoW players, we have found that none of them were aware that they had agreed to such monitoring. Some of them were concerned enough to stop playing.
Worldwide, 8 million people play WoW (usually about 500,000 at any one time). And every single one of these players has granted Blizzard the right to scan their computer programs and memory—which Blizzard does.
The Warden process scans for an arbitrary list of things such as open processes, URLs, and so on, controlled at Blizzard's discretion, and mails the information it finds back to Blizzard any time the game program is running. Figure 2-7 shows an example of content being sent back to Blizzard by the Warden as determined by a program we wrote called the Governor. You can think of the Warden as 8 million copies of what the game companies call "legitimate spyware." We think the term spyware is apt without a modifier.
Figure 2-7 The Governor program, which we created, reports on the activities of the WoW Warden. The Warden acts as a spy for Blizzard and keeps an eye on your PC by calling into open processes and reading memory to see what it finds, then reporting that information back to Blizzard for analysis.
Of course, Blizzard isn't the only company that does monitoring like this—many other game companies do it, too. Sony even tried to install a monitor when music CDs were inserted into a PC but did it so poorly that the company landed in hot water. Reaction to the unmasking of programs like the WoW Warden and Sony's rootkit has been intense.
The Black Hat Corner reprints a blog entry outing the Warden as spyware. This story spread worldwide.
The Governor
Hoglund was upset enough by the Warden to write a program called the Governor that gamers can use to determine exactly what the Warden is doing.
We believe that having the Governor around is useful, especially if you're interested in what WoW software might be doing on your PC. A listing of part of the Governor is included here. You may download a copy of the software and the libraries required to build it from the book's Web site or at <http://www.rootkit.com/vault/hoglund/Governor.zip>. As we did earlier, we have interspersed the code with commentary to make it easier to understand.
// The Governor // Oct 16, 2005 - Greg Hoglund // www.rootkit.com #include "stdafx.h" #include "GovernorDLL.h" #include <windows.h> #include <stdio.h> #include <stdarg.h> #include <process.h> HANDLE g_hPipe = 0; CRITICAL_SECTION g_pipe_protector; void PatchFunctions();
The code here is used in a DLL—a type of code object that can be loaded directly into a program. In this case, the WoW program is forced to load this DLL via a process known in software security parlance as DLL injection. The injected DLL is actually just a normal DLL, but it is forced to load after the WoW game client has already started and logged into the WoW server.
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: InitializeCriticalSection(&g_pipe_protector); g_hPipe = StartPipe("\\\\.\\pipe\\wow_hooker"); SendText(g_hPipe, "GovernorDLL Loaded."); PatchFunctions(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: SendText(g_hPipe, "GovernorDLL Unloaded."); ShutdownPipe(g_hPipe); break; } return TRUE; }
The DLL opens a named pipe—a form of communication port—when it is loaded. Later, the named pipe will be used to report on the Warden's activity.
// // Send text down the pipe // void SendText (HANDLE hPipe, char *szText) { if(!hPipe) return; char *c; DWORD dwWritten; DWORD len = strlen(szText); DWORD lenh = 4; EnterCriticalSection(&g_pipe_protector); // send length first c = (char *)&len; while(lenh) { //char _g[255]; //_snprintf(_g, 252, "sending header %d", lenh); //OutputDebugString(_g); if (!WriteFile (hPipe, c, lenh, &dwWritten, NULL)) { LeaveCriticalSection(&g_pipe_protector); ShutdownPipe(hPipe); return; } lenh -= dwWritten; c += dwWritten; } // then string c = szText; while(len) { //char _g[255]; //_snprintf(_g, 252, "sending string %d", len); //OutputDebugString(_g); if (!WriteFile (hPipe, c, len, &dwWritten, NULL)) { LeaveCriticalSection(&g_pipe_protector); ShutdownPipe(hPipe); return; } len -= dwWritten; c += dwWritten; } LeaveCriticalSection(&g_pipe_protector); } HANDLE StartPipe(char *szPipeName) { HANDLE hPipe; TCHAR szBuffer[300]; // // Open the output pipe // hPipe = CreateFile (szPipeName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL); if (hPipe == INVALID_HANDLE_VALUE) { _snprintf (szBuffer, sizeof (szBuffer), "Failed to open output pipe(%s): %d\n", szPipeName, GetLastError ()); OutputDebugString(szBuffer); return NULL; } return hPipe; } void ShutdownPipe(HANDLE hPipe) { //cleanup if (hPipe) { FlushFileBuffers (hPipe); CloseHandle (hPipe); } // make sure it stops being used g_hPipe = 0; }
Some of the Warden hooking files are displayed below in order to enhance your understanding of what's going on. Remember, we're only showing you the essential parts of the Governor system here.
// The Governor // Oct 16, 2005 - Greg Hoglund // www.rootkit.com #include "stdafx.h" #include <windows.h> #include <stdio.h> #include <string.h> #include <winsock2.h> #include "GovernorDLL.h" #include "detours.h" #include <psapi.h> ////////////////////////////////////////////////////////////////// // These are functions used by the Warden to spy on other processes ///////////////////////////////////////////////////////////////////
The functions below are all used by the WoW Warden. Here, we use the public Microsoft Detours library to intercept calls made to these functions.20 This move allows us to report on any program that attempts to use these calls, including the Warden, through our named pipe.
DETOUR_TRAMPOLINE(BOOL __stdcall Real_GetWindowTextA( HWND hWnd, LPSTR lpString, int nMaxCount), GetWindowTextA); BOOL __stdcall Mine_GetWindowTextA( HWND hWnd, LPSTR lpString, int nMaxCount) { int len = Real_GetWindowTextA( hWnd, lpString, nMaxCount); if( len != 0) { // WoW found some window text, let's report it char _t[255]; _snprintf(_t, 252, "GetWindowTextA called from WoW, returned %d bytes, %s ", len, lpString); SendText(g_hPipe, _t); } return len; } DETOUR_TRAMPOLINE(BOOL __stdcall Real_GetWindowTextW( HWND hWnd, LPWSTR lpString, int nMaxCount), GetWindowTextW); BOOL __stdcall Mine_GetWindowTextW( HWND hWnd, LPWSTR lpString, int nMaxCount) { int len = Real_GetWindowTextW( hWnd, lpString, nMaxCount); if( len != 0) { // WoW found some window text, let's report it char _t[255]; _snprintf(_t, 252, "GetWindowTextW called from WoW, returned %d bytes", len); SendText(g_hPipe, _t); } return len; }
Now we can identify when the Warden is opening windows on the computer, even windows that belong to other programs (e.g., your instant messaging program). The Governor reports not only which window the Warden opened but also what text it read. This technique has been used to watch the Warden program read sensitive and presumably private information, including the e-mail addresses of the contacts in your instant messenger program.
DETOUR_TRAMPOLINE(int __stdcall Real_WSARecv( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine), WSARecv); int __stdcall Mine_WSARecv( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) { int res = Real_WSARecv(s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd,lpFlags, lpOverlapped,lpCompletionRoutine ); char _t[255]; _snprintf(_t, 252, "WSARecv returned %d, %d bytes received", res, *lpNumberOfBytesRecvd); SendText(g_hPipe, _t); return res; } DETOUR_TRAMPOLINE(DWORD __stdcall Real_CharUpperBuffA( LPTSTR lpString, DWORD cchLength), CharUpperBuffA); DWORD __stdcall Mine_CharUpperBuffA( LPTSTR lpString, DWORD cchLength) { DWORD len = Real_CharUpperBuffA( lpString, cchLength ); if( len != 0) { // WoW is processing some text, let's report it char _t[255]; _snprintf(_t, 252, "CharUpperBuffA called from WoW, string %s", lpString); SendText(g_hPipe, _t); } return len; } DETOUR_TRAMPOLINE(HANDLE __stdcall Real_OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId ), OpenProcess); HANDLE __stdcall Mine_OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId ) { HANDLE h = Real_OpenProcess( dwDesiredAccess, bInheritHandle, dwProcessId ); if( h != 0) { // WoW is opening a process, let's report it char _t[255]; _snprintf(_t, 252, "OpenProcess called from WoW, pid %d, returned handle 0x%08X", dwProcessId, (DWORD)h); SendText(g_hPipe, _t); } return h; } DETOUR_TRAMPOLINE(BOOL __stdcall Real_ReadProcessMemory( HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead ), ReadProcessMemory ); BOOL __stdcall Mine_ReadProcessMemory( HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead ) { BOOL ret = Real_ReadProcessMemory( hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead ); if( ret && ((DWORD)hProcess != -1) ) { // WoW is reading a process, let's report it char szProcessName[MAX_PATH] = "unknown"; GetProcessImageFileName(hProcess, szProcessName, MAX_PATH); char _t[255]; _snprintf(_t, 252, "ReadProcessMemory called from WoW, handle 0x%08X, process %s, read from address 0x%08X, %d bytes", hProcess, szProcessName, lpBaseAddress, nSize); SendText(g_hPipe, _t); } return ret; }
The last two functions above leave no guesswork as to Warden activity. They clearly report whenever the Warden opens another process and it reads the memory of that process. Our spy versus spy system is complete.
void PatchFunctions() { DetourFunctionWithTrampoline( (PBYTE)Real_GetWindowTextA, (PBYTE)Mine_GetWindowTextA); DetourFunctionWithTrampoline( (PBYTE)Real_GetWindowTextW, (PBYTE)Mine_GetWindowTextW); DetourFunctionWithTrampoline( (PBYTE)Real_CharUpperBuffA, (PBYTE)Mine_CharUpperBuffA); DetourFunctionWithTrampoline( (PBYTE)Real_OpenProcess, (PBYTE)Mine_OpenProcess); DetourFunctionWithTrampoline( (PBYTE)Real_ReadProcessMemory, (PBYTE)Mine_ReadProcessMemory); //DetourFunctionWithTrampoline( (PBYTE)Real_WSARecv, (PBYTE)Mine_WSARecv); }
This last part of the code actually installs the "detours" we defined against the selected functions. You can easily modify the source code to monitor additional calls, and you can apply this code against any program you want, including other games. We encourage you to experiment with this functionality. Perhaps you will discover other games and applications that are spying on users.
Where Do You Stand?
Online MMORPG forums and Web sites have been abuzz with the spyware controversy ever since Hoglund described the Warden. Some people believe that complaining about such spyware is silly and that if someone is so worried about it, he or she can just choose not to play. We disagree. We've also heard the opinion that maybe the blame belongs to Microsoft since its operating system allows arbitrary programs to collect the kind of information the Warden collects. What we worry about is the intention here. Regardless of whether you can invade privacy, should you?
What Blizzard is doing in the name of security is unacceptable, and it needs to stop. The tradeoff between personal liberty and security is an essential tradeoff that must be carefully negotiated. Citizens in a free society must guard their freedoms vigilantly or risk tyranny in the name of security. Historically, monitoring activities lead very quickly to abuse and present an unacceptably slippery slope. Blizzard does not need to read our e-mail, surf our URLs, or look into our non-Blizzard processes. Allowing the company to do so gives up too much ground for not enough return. Once everyone is doing this, there will be no more privacy on a "personal" computer.
Hoglund says it best in an open message to Blizzard posted at <http://www.rootkit.com/newsread.php?newsid=371>:
- Blizzard, it is within your right to attempt to make your computer game the way you wish it to be, and to attempt to catch cheaters. But, reading the memory of other processes and windows that are not part of the World of Warcraft game client is a violation of privacy. Making a violation of privacy legal in your EULA and TOS does not make it also moral. It remains a violation of privacy. Please refactor your policy in regards to scanning memory, and limit the warden to integrity checking of the game client's memory space, and please stop opening other processes and reading windows that do not belong to you.
If we stand by and let a game company poke around on our PCs in the name of security, what do you suppose they will do next?
Cheating
As we have shown in this chapter, there are many widespread ways to cheat in online games. Some of the techniques we describe are several years old. As more and more money is at stake, more gamers are likely to be tempted to cheat. Cheating is bad. Cheating technology is improving.
Big questions remain regarding anticheating technology, though. Are back door programs, rootkits, and invasive scanners really necessary for piracy detection? When does such a countermeasure cross the line between legitimate copy protection and invasion of privacy? What rights to your computer must you give up in order to play an online game?
Consider, for example, that Blizzard's Warden scanning program isn't really used to detect pirates—it's really used to detect cheaters. Blizzard, of course, gets to define precisely what it means by cheating—it is their game, after all. Among other things, cheating in this case means any use of software automation tools like the WoW_Agro macro we showed in this chapter to play the game.
It seems that the war on cheating has led to collateral damage in the form of privacy. Yet we have only begun to describe what's happening in the gaming world.