Now, see, these guys were bugging me last night at the conference. We were having this party over at Pure, and they said I had to tape a 40-ouncer to my hand. Duct-tape it. But see, I didn't get home until about 6 in the morning, and I went to bed, and I woke up at 10, and I was still drunk. So what I decided to do is I slammed a couple Bloody Marys before I got here, and I'm feeling kind of jiggy. So I don't think I want to tempt fate by having a 40-ouncer taped to my hand. So for all you guys that knew that was the deal, I'm sorry. I'm not going to do it. All right, so now that we got that out of the way, welcome to my talk, Exploding Online Games for Cash. I've been doing some World of Warcraft hacking, so we're going to pick on Blizzard software. But these techniques could be used for all kinds of different things. I have 125 slides. There's no way in hell I'm going to get through them all. So I'm going to go really fucking fast. So I hope you don't mind. I have one video of a PvP bot that I will show you towards the end. So let's get started. Why am I hacking games? Well, because it's really fun. That's why. People are way more interested in games than they are in firewalls. As I found out in my book. It was completely sold out in pre-orders into September, and that was the first printing. So I was realizing, wow, this game is really cool. They're really complex. World of Warcraft, for example, is probably one of the most complex targets I've ever had to reverse engineer in my life. There's a healthy community of game hackers that are not the same community as the security community, but they're equally as skilled in reverse engineering, probably more so in some ways. And the real reason we're having this talk today is because computer gaming is a big business. It's growing. There's some kind of tracking by mores. There's law almost going on with MMOs at this time. Microsoft reports that gaming is the third most common activity on the platform, right behind web and email. So that's a pretty big deal. It's measured in billions. Why do we cheat? Why do I cheat? I cheat because I suck at games. That's why I cheat. I like having an unfair advantage over people, and I especially like doing that with a six-pack of beer. Cheating makes it more fun for me to play the game. And with games like World of Warcraft, there's a lot of grinding involved, a lot of repetitious things. And what I discovered is I can't compete with 15-year-old kids when their moms make them dinner and bring it in to them. I have a real job, and I can't have my level 70 guy leveled up in 15 days like they can. So, hey, I want to do something to kind of give me a little bit of an edge. There's another reason you might be considering doing this. So you can actually make money. So this is sort of like a miniature business plan. What I'm going to show you is how to farm gold in World of Warcraft and make things. $350,000 a year. I'm going to show you the numbers. We already know what MMOs are. I don't need to talk about that. MMOs and money, most of you probably know this, but there's actually an exchange rate between in-game currency, play money, and real money. Right now, that's about 3 cents per 100 gold in a wholesale market if you're going through an affiliate program. If you're on a retail site like IGE.com, that's about 10 cents of gold they're charging you. You can actually go retail. If you want to go retail, you can go retail. If you want to, but then you've got to deal with all the marketing of your site and stuff. So it's actually just easier to wholesale your gold through a reseller or affiliate program. The secondary market in virtual items is probably close to a billion dollars. It was 600 million in 2005, so I assume it's only getting larger. That's an aftermarket traded in virtual items that don't exist anywhere except in a SQL database. Here's a screenshot, and I have a link here. Here's a screenshot, and I have a link here for a YouTube video that you can watch talking about Chinese farming. And it's just a little documentary showing the sweatshops in China and the Philippines and how they basically slave all day long. But you'd think this is a bad job, but no, these guys like doing this. They'd prefer to have this job than to work in the Nike factory down the road. They make about $6 a day doing this job. Now, if you make a bot, this is current standards. I'm familiar with several bots that are currently being used commercially. These are not bots that Blizzard is aware of, otherwise the warden would have already banned them. These bots are private, and they're sold commercially to Chinese farmers. They farm about 400 gold per character in every eight-hour shift. They run two shifts a day. Each admin, that's the guy making $6 an hour, can manage about 15 of these bots. The better the bot, the more you can manage. It scales your operation. Two shifts a day, two bots per computer, usually running Windows 2000, because Windows 2000 runs better than Windows XP. It doesn't take a lot of time. It doesn't take up as much memory, and they can use these cheap, old computers and get two WoW accounts running at a time. At any given time, some of the largest farmers in China are running 1,000 simultaneous WoW accounts logged in at that moment in time. To give you an idea of the scale of the operation. Four admins, 30 computers, 60 bots at 1,600 gold per day per computer. That means that your farming operation on 30 computers is generating 48,000 WoW gold per day output. That is a standard, and that's normal. Wholesale that for $3 for every 100 gold. That's approximately $1,400 a day in gross income. You pay your expenses. You can see I have a little break out there. Rent, bandwidth, et cetera. Assume, basically, you got $1,000 a day in profit. Times that by 365, and now you know how you're making $365,000 a year farming gold and WoW. Now, I haven't counted something in here that's really important. There is an attrition rate due to banning. If your bot is undetected, which it needs to be to even do this business, then, hopefully, you're going to be able to do it. Hopefully, that attrition rate is not too much of a problem, but it does happen, and I actually don't know what the figures are on the attrition rate. Now, let's talk about the current design of the farming bots. Everything is waypoint driven. You put it in record mode, and you run your character through what's called a patrol path. Then you connect that patrol path to the vendors through a vendor path, and you also go to the graveyard, and you record one path that goes from the graveyard out to your patrol path. So, if you die, your ghost lives. You'll run back, find the body, and resurrect. The bot will actually run all the way back into town, and it will automatically repair all the items when it needs to be repaired. It'll dump off all the loot. It has a loot filter. Gray items, for example, won't be picked up unless you want them to. Green or above goes to a mule account. Those get muled in the mailbox. This is all occurring completely and totally automatically. The mule account picks up the green items, and the admin goes and dumps those on the auction house. Total output, 400 gold per day. Now, most of these farming bots are private variants of systems like WowSharp. Has anybody ever seen or heard of WowSharp before? Okay. You know the open source. The guy that wrote this open sourced it and released it. So, a bunch of guys went out and made private versions of this thing, compiled differently, that the warden couldn't detect, and they're still in operation. That's one of the ways that the Chinese farmers work. Here's some different features. I already talked about this. Oh, auto detection. This is kind of cool. It can detect if somebody's following your character. So, this is one of the admin's jobs. He has to watch not only the bot's fouling, that is, getting stuck on something, but also make sure that it's not alerting him that there's a GM present in the chat channel, or there's a particular NPC or, I'm sorry, PC that's been following him for a given amount of time. So, there's these features built in to help you from being called out and detected. It takes a lot of money to make a level 70 character in World of Warcraft. It's over $100 in investment per level 70. So, it costs a lot to lose them. Plus, it takes about 15 days. 15 days of leveling with the bot in order to reach level 70 in the first place. So, the nice thing about that is you can buy the game and use the free first month that comes with the game to level up to 70. The next thing you do is you drop that level 70 character on something like eBay and try to sell it for $500, and then you use it as a farming account until you sell it. That's the basic idea. Oops, I went up instead of down. Alright, here's some things not to do. Don't use ISX1. Wow. A whole bunch of people in the botting industry over the last three months have been banned, banned, and banned again. We're talking like really hardcore hits. Their business is probably going to go down. Bans are so bad. All of them based on ISX. Wow. Don't believe anything you read on their websites about how it's stealthy. It's not. Because I'm seeing it, they're getting banned over and over again. That is not a private bot. Don't use WowGlider. How many people here have had a WowGlider account? How many people have been banned? How many people have been banned? At least once. Come on. Two? That's it? I've lost over $400 in banned Wow accounts at this point in time. Don't use WowSharp, even though I just mentioned it is being used. It's being used with a lot of changes. So unless you're prepared to make those changes yourself, you'll probably get caught. Don't transfer a thousand gold of your own to some level one IGE mule account. Guaranteed banning next day. And don't do what I did and accidentally realize or forget that you're not supposed to be an old Ironforge. So when you ask in chat, how do I get out of here? GM comes online and bans you. So I'm basically making the point that public botting is dead. Even hardcore Ring Zero tricks like I was presenting last year in my Hacking World of Warcraft talk at Black Hat. That's a lot of money. Basically money and time that you can invest. If you release that as a public tool, even if Warden isn't going to Ring Zero, there's probably something we missed and they'll figure out a way to detect you. God knows how, but then boom, all your investment's lost. And the other thing is, Blizzard doesn't always use Warden to detect people. It uses accounting forensics to detect people too. Those are very simple SQL queries being taken place in their database and they just go through there and they can find all kinds of interesting things. Things that are very unnatural about a normal player. So every public bot so far has been detected. History has shown this. Mass bannings have occurred. Learn and don't do it. So what is forensics accounting? Just ask Darius Kazemi and give him a copy of GraphViz and a couple of SQL queries and he'll tell you how it works. He will go in there and tell you who transacts with who. If there's an IGE account, level of one, and he knows it's a mule and you talk to that account or move some gold to it, he knows that. Same quest, completed 150 times in four days. Okay, that's probably a problem. Large numbers of accounts all to the same credit card. Bad idea. And everything's really about gold. You transfer a large amount of gold between accounts, that's going to stick out. If you have a large amount of gold above the median average for that character, class, and level that you're at, that's going to stick out. You might be a guild leader and you get by because you're supposed to be the accountant and you have all the gold, that's fine. But if you hold on to gold for a very short time, you move it between accounts, those are the things that are going to stick out. And those things you can't hide from with ward insurance. Those are things that are just going to be in your database no matter what. You can pull off some interesting tricks. You can try to move things through the auction house, sell a really dumb item like a piece of linen for 10,000 gold, try to move it across the auction house. But that stuff's all tracked too. Gold acquisition records mark where every piece of gold comes from and where it goes. And those are stored. They do not throw it out. Now, why doesn't Blizzard actually ban people? They say they ban people, but that's like a public image. They actually like botting. If they ban people, they would lose 6 million of their 10 million accounts. Because their 10 million players is kind of a big lie. Something like 6 million of those are in China. In China, the game is played by the hour. You pay for every hour you're logged in. It's unlike the way they do it here in the West. So they want to keep people logged in as much as possible. There are only about 2 million people here in the U.S. that play WoW, according to the records that I have. And there's a link to the article in case you want to check it out. What is a ban all about? A ban isn't done because they want to get rid of players. A ban is done because they want to make more money in the next couple of weeks for their balance sheet. When they ban people, everyone they ban goes out and buys new accounts. There's a direct, measurable influx of cash immediately after every ban. And if you don't believe me, ask yourself, why don't they ban by IP address range? I've been banned so many times that they've never used my credit card as a banning tool. Every time I make a new account, I use the same credit card. Why don't they just immediately ban me? Oh, there's Greg again. Kill him. No, they want my money. Here's what a ban does. Approximately 50% of the banned accounts are repurchased shortly afterwards. You can measure that at about a half million to two million dollars in income. When they need the money on the balance sheet, time to do a ban. Boom. Now think about that. Public image and what really happens in the boardroom behind the scenes. All right, so that's that. That's a little influx there about how the gaming thing came to be. Let's talk about some DMCA stuff. Hey, when is my talk over, by the way? Ten of? Okay, I'm going to go pretty fast here. Now, I don't like the DMCA. Most of you probably don't like it either. Let's talk about this because it has legal ramifications for our business plan. You know that Blizzard likes to sue people. All right, they go and they threaten people all the time. So that would probably happen if you had a public bot and they were aware of it. If you do this kind of business, you will be violating the end user license agreement in terms of service. You need to avoid getting hit with the DMCA bat. Even though botting has nothing to do with copyright violations, Son and Shine, Wrath and Rosenfall, or whatever the hell their name is, is going to try to figure out how to make the DMCA apply to your bot because they do it. That's their job. They're doing it right now to Michael Donnelly and they'll do it to you. EULAs are not laws, so breaking a EULA does not mean you're breaking the law. It might be a misconception that you have. A EULA is only a contract. The best they can do is take you to court and try to sue you for violation of that contract. Now, Son and Shine, they've become experts of trying to make copyrights apply to pretty much everything. Their latest trick, I'm aware of, is they're trying to make the launching of the WoW.exe executable a violation of the DMCA. Because launching DMCA... Launching WoW is the same to them as making a copy of the CD, because it's the same bits. So launching the program is a violation of the DMCA. And that's what they're pulled on Michael Donnelly. You're going to have to actually do some reverse engineering in order to make a bot. For example, you'll have to locate the XYZ coordinates in memory, maximum hit points, what spell is currently active, the structure of the player character class, etc. Alright, so you are going to break the EULA when you do that. But nothing about XYZ coordinates has anything to do with making an illegal copy of WoW. But they're going to try to make that stick somehow. It's really ridiculous. So, with the WoW glider case and Michael Donnelly, they're trying to protect RAM as if it were actually a copy of the CD. And there's a link to the RuKit article that talks more about that. And we just talked about that too. Oh, but there's an interesting side note. How does Microsoft not violate the DMCA when explorer.exe launches WoW when you double-click it on the desktop then? They call this the copyrighted WoW gaming environment. You can read that in the documentation that they have out. Here's some common stuff that EULAs will throw out to you. Don't criticize in the public about this product. Don't reverse engineer, obviously. If you use this product, you will be remotely monitored, hence Worden. Don't use this product with other vendors' products. By signing this contract, you also agree to every future version of it. That's my personal favorite. They're going to send new versions of the EULA that you're not even aware of yet, and you've already agreed to it. Just because you agreed to the first one. And of course, they're never responsible if anything bad happens to your computer. So here's Blizzard's EULA. Your computer's RAM is monitored and will communicate information back to Blizzard. Here's Gator Corporation's EULA. Gator is a piece of spyware, by the way, and they have a 63-page EULA in their spyware. And it says that it is illegal for you to uninstall it. This is also on their Gator EULA. It's also illegal for you to sniff the traffic going back to its server. In other words, it's illegal for you to run Ethereum to determine what it's stealing from you. Microsoft FrontPage has a funny one. You can use FrontPage, but you can't use FrontPage to build a website that talks bad about Microsoft. This one's funny because this is a virus. And the virus came with a EULA that you actually would pop up. And you know how typically a user doesn't pay attention. They just click through. If you said yes, it would actually go through your email contacts and mail a copy of itself to all your friends. And the EULA specifically allowed that if you had hit OK. So they didn't break the law. And this is my personal favorite. My favorite, iTunes. At any time, we may modify this agreement. And it will be effective immediately and incorporated into this agreement. And your continued use of iTunes will be deemed your agreement and acceptance of the new EULA that you didn't yet agree to. Yeah, I really don't like Apple. So here's some ideas. First of all, obviously, don't release your public bot. Don't make a public bot. Don't put yourself downstream. Don't put yourself downstream of a DMCA lawsuit. And then here's some other crazy ideas. Make sure that you add to your bot some sort of strange packing system that does a challenge response with an authentication of some kind. So that in order to unpack the software, you have to have an authenticated account with some server that you control. So if Blizzard's engineers grab it and reverse engineer it, they're not going to have an account. And they're going to have to bypass an authentication scheme. Therefore, directly violating the DMCA. In order to reverse engineer your bot. And put them downstream of your own lawsuit. This one's kind of an obvious one, probably. But if someone in China has got this bot, and they're working for $6 a day, don't you think Blizzard would pay them $1,000 to get a copy of the bot so they could just go and ban everybody? I don't know if these guys have figured it out. They can walk out the front door and probably sell this thing on the black market. So you want to probably try this. You want to try to protect your bot in some way, in your farming organization, so that your employees don't basically do some insider threat on you. Alright, let's change subjects here and talk about some technology. How are bots built? There's different ways we build bots. There's kind of schools of thought here. And I'm going to go through the various ones. There's first and foremost the GUI-based macroing system. This is the most popular because it's the easiest for people to do. You sample pixels at defined XY coordinates. For example, when you're at maximum health, you know there's going to be red right here on the screen. When you're not, and you're at half health, it won't be red, but it will be red there. You can do sampling like that to determine where you are. It works really well, and it's really easy. I can build a bot like this in a couple of hours because it's just so easy to interact with it. And there's a couple of programs out there for you that will do it, make it very easy. I've used something called AC Tool before that works pretty well. It's essentially a QA tool designed to interact with the UI. Another way to do it is DLL injection. That is convenient because when you grab a structure in memory, you can directly dereference the pointers because you are in the memory space of the game. You're not outside of it, so you don't have to do any translations, making it very convenient, and therefore the most popular form of botting technology. Another one is debugger-based. You connect as a debugger, and you can use read and write process memory and breakpoints. It's just a different way to do it. It's slightly more of a pain in the ass, though, because you have to actually translate all the memory to the remote process space address coordinates. You can't just get a copy of something and then follow the pointer because it's not going to work. If it is in your local bot, that's not going to point to anything. And then, finally, client replacement. That's an interesting one where you actually don't even use wow.exe. You make your own gaming client from scratch that interacts with the target. That one's slightly hard, though, because when the warden comes down to do a check, it's going to fail all over the place. So you have to proxy the warden calls out to an actual running copy of wow just for the warden so that it finds the right hashes in memory at the right locations. Here's a screenshot of a GUI-based MacroIn bot. This is my character, Zanier, shortly before he got banned. I'll show you how this is working. He's actually backed up into a tent. He doesn't move. The tent protects him from someone coming in from behind, which, as you know from playing wow, you can't attack somebody who's behind you. So that's why he stands this way. He can't be killed from behind. And these guys, these deafiest messengers, or whatever the hell they are, they run up there, and they're within the aggro radius where he stands, and he just swings over and over and over again. The bodies just pile up. And I also added a feature where it would click on the screen within a matrix, and it would auto-loot everything that was down there in front of him. This could run for hours, no problem. So this took almost no time to build. This shows you the kinds of things you can do for botting that don't require a lot of reverse engineering skill or programming skill. They just take a little bit of your time and testing. You know, you've got to get the kinks worked out. And you've got to also find a good spot to do it. Like here, I've got this nice tent. Not everywhere is going to work well. You've got to find a spot in the world where this type of bot would work really well. Here are some snippets of code to show you how this works if you wanted to write your own macro win system. Here's how to get a color or pixel on the screen. All this, by the way, is in my book. I'm just throwing these on the slides just so I have some source code to show. So you can get the color or the pixel and determine if it's like red or blue. I have mana, I have energy, whatever. Here's how to post a left mouse click to the screen. Now, it's worth noting that if you're... This is a normal mouse click that would go as if you had done it right off the mouse, and you could do this for keystrokes. If you're using direct input, some games might do that. You can just do a Google search for DIK left and DIK right, and you'll find the same equivalent code but for direct input as opposed to the way I'm showing here. It's all the same stuff. You can also use send message and post a Windows message right into the target. That works really well with, like, Lord of the Rings Online, which I just made a bot for, by the way. And so you can actually minimize the window in that case and not even have it up on the screen, which is kind of nice. Here's an old, old hacking program which you wouldn't use anymore, but back in the day, this is actually an injected DOL that had its own Lua script associated with it, so it had a UI component called Bubba's Warcraft Hack, and these are all the locations that I have hot-keyed in there. This was a telehack. I could actually go directly to any of these locations just by clicking it. It would just change my X, Y, Z coordinates, and I was instantly there. It worked really well. There's a real good exploit in Gadgetazan, and there's this guy, a goblin, will give you this quest for going and collecting hippogriff eggs, and I had all the X, Y, Z coordinates for all the nests already in there, and I would go to him. It's a repeatable quest. Go to the eggs, pick it up, go back. I was making 1,500 experience every 30 seconds. My guild had me. I was at level 40. Three days later, I was level 55. I'm sitting there like this, you know. It's like over and over again, but here I am, level 55, and they're like, how did you do that? So it was really easy, just going around all the egg baskets, essentially. I've got to take a snippet of source code from this thing. This is kind of cool. It's template-based scanning. What the guy did is he wrote this. He actually, instead of reverse engineering a particular location in WoW, he found a location in WoW and then made the opcodes for it and then masked out some of them so whenever they patch, it would actually scan the binary and find the new location so with every patch, even though the stuff was moving around, he didn't need to release a new version of the bot. It worked pretty well. Here's a complete client replacement. This is a standalone program that logs directly into the WoW server and plays. It's got a number of interesting features, complete reverse engineering, of everything around you. These are the data structures being showed. I've redacted some of the data here. And here's a map. It's two-dimensional overhead. The black square represents you and then characters are shown in the other colors. And so this is directly communicating with the server and it's its own standalone client. This is another type of approach. This is actually called WoW Sniffer that you're seeing a screenshot of. It actually proxies or sniffs the packet stream going in and out. It's actually, in my book, I've had to redact all the decryption routines. But if you just go out and look for WoW Sniffer on the net, you get a nice clean copy of source code that will show all the decryption routines for WoW. And you can build your own sniffer of this type. And that could be used as a proxy system perhaps to control your character in the network stream. Here's another type of bot. I'm just putting this in because it is a common trick. It's not used with World of Warcraft type of botting but it is used for aim botting. You have a direct 3D library, OpenGL. You stand in front of that and you hook it and you can do all kinds of interesting things with the stream as it goes out to the video card. Some of you may have played Counter Strike and used aim bots in the past. This is a similar technique used there. You may recognize this screenshot. This is called a wall hack. And what's happening is the information being streamed to the video card is being modified on the fly so the video card renders it differently. Very simple to do out at the video card layer. And now you can see through the walls and actually see here there's a guy who's bisected by a wall and makes it very easy to aim at the blue part and shoot him where you'll hit him. Here's the proxy system in a little more detail. The game client runs normally but you pass it through the proxy that's doing the encrypted and decrypted packets and only when you need to grab data such as the positions of characters around your character you grab it out of the network stream. And you can also forge or inject messages into the network stream when you need to in order to automate the movement of your character to interact with the environment. This is very superior to the other ones because the proxy can't be detected by the warding client. Because it's not even running on the same machine as well. So this is actually a superior system. I don't have a working one but this is a nice idea and I hope somebody actually works on this and comes up with something. Even though I've told you not to release it to the public if you do come up with one can you give me a copy? This is a case for the proxy. It allows the client to handle all the state. So you don't have to reorganize and reimplement any of the state management which is very expensive. It lessens your chance from detection because we're not co-existing on the same machine as the warding client. There's less chance of change. Now this is an interesting one. Because the network stream requires changes anything in that protocol requires changes in both the client and the server it's much less likely that Blizzard will perform a patch on that protocol. It's much more likely that the class structures within the game itself will change. So the amount of overhead you have to reverse engineer patches should go down if you're using a proxy system. Alright, let's talk about the ultimate farming bot and what my ideal design would be. First of all you probably don't have contacts in China and you can't afford to go over there and find somebody in Shanghai to work for six bucks an hour. So what you'd like to do is go and put this in your garage. Now to do it in your garage you're going to need to scale the operation a bit better. Your farming bot's going to have to be able to handle at least 100 simultaneous running accounts without fouling up. You have to also be able to handle the auction house preferably automatically because you just don't have the time to manage all those green items up there on the auction house. It'll swamp you. You also have to be able to quest. The reason you have to be able to quest is because you also need to use this bot to auto-level all your characters. Grinding isn't enough. In order to get from level 1 to 70 in such a short time you have to quest. And you have to pre-script the entire system so that you don't have any setup required. There's a lot of the current botting technology that takes a lot of time where the admin's just dinking around trying to get everything running. You want to eliminate all that overhead as well. So that's the ideal. The screen that manages it will have a series of postage stamps. These things are actually used in a VNC-style protocol to give you a remote desktop view of each of the running WoW instances. This is a mock-up, by the way. This is not real. I just made this for the slide. The games run on slave machines within VMware. You have a bunch of those running in your garage on the farm. And then you have all these little postage stamps on your monitoring app and you can click on any one of those and bring up a UI where you can configure and control the bot itself, like which script it's running, et cetera, what account it's using. And you could also interact directly with the particular WoW if you want to at that time. How the system works is pre-recorded WayPaths again. We're not doing anything weird like trying to figure out the 3D world and do A-star pathfinding, none of that. What we do is we simply record WayPaths so you're going to spend a lot of time recording WayPaths for the whole world. It's a skeleton and branch approach and you're going to need several things on your skeleton and branch WayPaths. Here's how it looks. We'll have a WayPath between every major town center. That's the black line. Notice these are labeled. Now, every single spawning location for your corpse and the graveyard will have to be connected from the graveyard down to the main black WayPath. Now, even if you're not connected to the black WayPath, your corpse would run to the black WayPath first, then traverse that, and then traverse one of the branches that comes off that to get back to your body. Now, you also have a patrol path. That's the little gray one on the bottom. That's where you're going to go hunt for different things. And then finally, you have a link to every NPC that matters. And all these paths are stored in your small database. Proximity hunting is how you kill things. You're on the WayPath. In your proximity, you detect a target that you can kill, and you leave the WayPath temporarily to go kill it. All the bots work that way now, so this is not a problem. Now, here's something that bots don't do that they should. They need to record everything they do when they come off the WayPath, because otherwise, when they run into something like a cave chasing after things, they're not going to be able to get back, and they stick on walls. So if you record every step you take as you leave the primary WayPath, you just retract your steps, and you can get back to the main WayPath without getting stuck. As you can see in this mocked-up screenshot here, the toon goes back through the red dots to the main WayPath. Now, questing. What you need to do is go pick up these two guides. I shall say they are available on P2P networks if you are a scooge and don't want to pay the 30 bucks. But these things are excellent. I've looked at, not Jonah's, but I've looked at the other one, and it works really well. So what you want to do is quest, build scripts to do the questing. Not all the quests in these guides are things that you can completely solo. So throw out all the stuff you can't solo. But what they do is they say, pick up this drop quest, pick up this kill quest, run to this area, and it optimizes the positions that you're in in the game so you don't spend a lot of time running back and forth. Works pretty well. So you then can prescript all your leveling, and some of the things that you can do, for example, is a collection or drop or kill quest. You would pick it up from the NPC pre-recorded path, and you go out on the main, do the patrol, come back, and talk to the NPC, and that's how you finish that quest. Delivery quests, similar deal. We just go from one NPC to another. Everything's connected, so that's not a problem. The bots run... A farming bot runs as a state machine. Here we see a small state diagram. So essentially, at any given time, your bot will be in one of these states, and the transitions are marked by edges here. So for example, if I have a target mob, I move to a new state where I'm attacking. If I'm low on health, I move to a state where I'm healing. That's the state machine approach. So, level 70 in about 20 days. You get gold while you're leveling. As soon as the account hits level 70, you put it up for auction at $500 an account, and until it's sold, you use it as a farming account. All right, let's talk about some technical stuff. Player position. Everything in the world has an XYZ coordinate. If it's instantiated, that's part of its data structure. You can find that in memory. Go to the proper offsets, and you have the XYZ floats for its location. You have that for yourself. You have that for the target. You can do geometry calculations and post keystrokes and move to the target. Until recently, you could also telehack, so you could just put yourself anywhere you wanted to be. That doesn't work in WoW anymore. They made a change recently. It's a client-side integrity check. I have yet to crack that one, so I haven't been able to telehack for a while. But once you've reverse engineered one of these data structures, all the other ones are derivations of that type, and so it becomes very easy to figure out the rest of the structures. Player movement can be injected via Windows messages, or you can make internal function calls. There's actually an internal function call for player movement that you can just call directly from the main thread if you've hijacked the main thread. You can also use KBDEVENT, et cetera, in order to inject the mouse or keyboard input. The world database can be captured directly from the video card. If you want to do it that way, you could actually catch the structures as they're put out to the card for rendering. You could also look on... What is that called? WoW Map View, I think. There's a project on SourceForge, and it actually renders the entire world in 3D, so you could actually do A-star path mining if you were so inclined. The database of all the things in the world are collected at runtime in my bots, and I just simply put them up in a hash table, and I actually can reference them from the hash table. Detecting mobs and NPCs. We go through the world... Okay, so here I'll explain this. There's something they changed recently. They used thread local storage, the TLS value, to store an object pointer. That object's called the object manager. From the object manager is a linked list. There's a series of hash buckets that each have a linked list of objects. I'm going to show you the source code and how that works in just a moment here. Once you have all that, you have the position of every single object that's relative to your character in the visible world around you. Behind you, in front of you, behind walls doesn't make any difference. All the data comes down from the server. Here's the code. Okay, so on the top we actually have the hash bucket, and on the bottom we have the object manager. The object manager has a pointer at 1C to the hash bucket array. You go to that... Okay, first of all you get the object manager from the TLS value. From that, you go down to the hash bucket, and you parse through the hash bucket, and you follow each of those hash buckets through an array of linked lists. I'm sorry, a linked list. And here's the linked list. That's not the linked list, hold on. TLS index, D87F38. That's actually in the last patch of WOW. You probably don't need this TLS index. In my experience, it's always been 0. So you can just hard code it to 0. Here's the assembly language to grab the object manager base out of the TLS. So you move that up, and you can see into EBX. We call off the FS register, offset 2C. Offset 2C is the object manager. We have that now, and we can begin parsing through the hash buckets and the linked lists. Here's some more screenshots of code. Here we have the object manager. We get the array base, the size of the bucket array, and we go through them one at a time as a linked list. There's actually this funny little line of code here. It looks like, and I'm not sure why this happens. It might be something that Blizzard put in on purpose. They'll actually make an odd address on the last object in the linked list. I think it's actually like an end sentinel. It actually is there to indicate the end of the list. Now that's what I've witnessed in the assembly language when I reverse engineered this thing in IDA Pro. So I just go ahead and put it here. If you don't, you walk right off the end of the list. So that's how they do it. That's how I do it. There's probably some kind of macro in their source code they use for that. All right. Now every object that we grab has a GUID, a 64-bit GUID, that identifies it uniquely in the world. It has a type. It has a position. And so what I'm doing here is I'm just putting all the objects into a GUID to unit hash table in my local bot. Okay. What is this a screenshot of? Oh, we're going through all the linked lists here. The linked list going through each one one at a time. I'm using assembly language to do that. We're following, it's essentially a list entry pointer. So we go to that and then go next. So it's like from one to the next to the next to the next to the next until we hit the 01. Again, you can see that at the bottom in the while loop. When we get the 01 on the end, we know we hit the end sentinel. Here's the structure for a WOW object. 30 and 34 hex offsets are the GUID. We also have a type. The type is actually very important because the type tells us what it is. Container, item, unit, game object, corpse. And this is how we can detect if we're looking at an enemy that we can kill. Here's also a nice picture of how it works. The next pointer points to the beginning of the next object. But oddly enough, the previous pointer doesn't point to the beginning of the previous object. The previous pointer points to the last list entry record in the previous object. And you can see how the arrow actually points into the middle there. So that was the little thing that got me at first. But once I figured that out, it makes sense. Here's the coordinates. These are the current offsets that are working as of the last patch. B8, essentially there you have XYZ and heading. And that's enough to do all your vectoring in the game. Point towards the target, run towards the target, kill the target. Measure your distance from the target, et cetera. Yeah, I'm going to go a little faster. I'm running behind. All right, so we parse the database to the near objects. We get the player position. We find a suitable target. We set the PC's target GUID. There's actually a target field. You set it to the GUID of the thing you want to kill. What that does is immediately on the screen, a wow, boom, you have that target. Then if you hit one or something, you're going to attack that target, right? So you find the suitable target and you set that GUID. And then you have the target position. And you use some geometry to vector towards the target. You know your range. Once you're within 30 yards, you start slamming on your dots or whatever you're doing, sticking your pet on the target, and you're going. Now, one of the things that's really cool is the facing value. You can actually set that directly. You don't have to use arrow keys in order to, like, turn. You can directly set your facing and your pointing towards the target. So that helps out a lot. You can use a macro-based system with read and write process memory. That's, like I said before, we could, you know, read screen pixels and then post stuff into the target. We could use an injected DLL. We talked about that's one of the schools. And we can, you know, directly post keystrokes or use the send message function, actually post Windows messages in there to drive the character. We can inject a DLL and use thread hijacking off of the render world call so that we can actually make internal game function calls without having any thread safety issues. And that's actually a really cool trick. Here's a screenshot of how that works. Main thread of the application is running. We hit render world. There's a detour patch there. It jumps into our injected DLL. Once we're in the injected DLL, we can make calls directly into WoW. Cast spell by ID, for example, is a call we can make and just instantly cast a spell. And then when we're done, we're back at render world, and we continually loop around. Render world gets called hundreds of times a second, so we get plenty of processing time. Now, I did make a kernel mode version of that, and it has the benefit of not having any of these problems, which expose it to Worden. And I'll show you how that works. We're going to use a trick called shadow branching. So let me see if I have a good screenshot of that. The main thread runs. We hit a breakpoint. And then the supervisor code, which is running in the kernel, uncloaks a page of memory into the user mode space, jumps to it directly by hijacking the main thread using the context structure for that thread, changes the EIP right in the context structure in the kernel. So when it comes back into user mode, it's hyperspaced right into our code. It executes that code. Once the code is complete, it freezes the thread again, recloaks the memory, removes it out of the user mode process space, and changes the EIP back to what it was, hyperspacing it directly back to render world. And because Worden executes in the main thread, it'll never be exposed. This memory will never be exposed to a Worden query. We actually do release some of this source code, by the way, in our rootkit training class. So here's kind of a different picture of that. We allocate memory in the supervisor. We then have that over in user mode. We inject code into that. We branch to it. When it's done, we cloak it. By cloaking, we fill the original memory with capital A characters and move what was there up into kernel mode into a non-paged pool area. And then when we want it back again, when the hook fires, we uncloak by moving it back out over the capital As, branch to it again, and this process just repeats over and over and over again. So yes, this is code right here in OLLI debug. In OLLI debug, you can actually, if you drag the window fast enough, for a split second, sometimes you can actually see the code appear before the As come back. This is the injected code right here. It's actually much like a shellcode for a buffer overflow payload. It's position independent. It jumps to itself to find its location in memory. It does a fixup on a little data jump table, so it has access to all the function calls in kernel 32. It's very, very similar to shellcode, except in this case it's a little miniature. Virtual machine executing in the WoW environment. Now, how do we set hardware breakpoints? We're not going to detour render world directly. Rather, we're going to use hardware breakpoints. Doing that from the kernel is a real pain in the ass, I found out. You can't just set context on the thread. I had to hunt down some structures. But here's how we're going to do it. We set DR breakpoint on render world, and that's a protected breakpoint. If the warden tries to detect that the DR breakpoint is set, we will hijack that and give it a false answer. So we can actually control that from the kernel. So that's very little visibility to warden in this case. And then we pull off the trick I just described where we jump to the injected code page whenever we hit the render world call. Now, NTSet context thread does not work with the context debug register's enumerated type. That is our blue screen. We don't want to go there, so I had to figure out a new way. Let me show you how that works. We go to the kernel trap frame for the thread. So here's the structure. In the kernel, FS0 points to the KPCR structure. You go to that. Follow PR. CRCB down to the current thread. That points to an E thread. Once you're in the E thread, you follow the initial stack pointer to the top of the kernel stack. You go down to the bottom and subtract off the size of the K trap frame. Within that K trap frame structure are the DR breakpoint register values. You set them directly, and as soon as that thread goes back into user mode, the DR breakpoints are set. Everybody get that? All right. Yeah, okay, so we control the DR from there. In order to do that, we have to schedule a kernel mode APC, so this will run in the context of the target thread, but in kernel mode. There are different kinds of APCs, so just suffice it to say, this is a documented method. You schedule a kernel mode APC for the target, and then once you're in the target thread, you perform the following. You go through that little diagram that I just showed. Now, if you want to know those data structures, go up on the net and look for React OS. Google for React OS. The guy that wrote React OS clearly stole the source code to Windows. So now you can read the source code to Windows without reading the source code to Windows by using React OS. And he'll have all those structures up there. It's a very valuable resource. Multi-processor safe interrupt hooking is another problem we have to solve. That dual core systems, anything like that, we'll have to deal with that. So how many interrupt tables are on a dual CPU system? Come on, guys. Oh, come on. Someone knows. How many interrupt tables on a two CPU system? Two. Two. Thank you. One for every processor. So we have to schedule a deferred procedure call for each processor. The deferred procedure calls allow us to specify which processor the code should run on. So by doing that, a callback will be fired on the processor in question. We disable interrupts, patch interrupt table, and then re-enable interrupts. We then wait on a waitable object. We do that one for each processor, and we now have multi-CPU safe interrupt hooking. There's code for that on rootkit.com, by the way. Okay. Now, I only have a couple minutes left, and I want to cover PvP botting. It doesn't have anything to do with the farming stuff I was just talking about, but it is a new area I've been exploring. Who here likes to play PvP? Who here has an undead warlock that melts people's faces? Yeah. Okay. PvP botting. Let's talk about the idea. Every single thing you can do in PvP can be countered by a logical phrase or sequence of attacks or dots or buffs or debuffs. It's set up that way in WoW to be played that way, and if you're a really good player, you already have muscle memory figured out for a lot of your targets. But every single target's different. They may be wearing a different kind of armor set, for example, that you have to counter, or they may be carrying certain buffs. You can't think of all the things, but you can build a bot that knows everything to do. You pre-script every possible scenario into the bot, and it knows what to cast on yourself and your target to maximize your DPS and kill your target as quickly as possible. That's the idea of a PvP in a WoW-type universe. Now, unlike the farming bot, this is not... I actually struggled with this. I tried to make a PvP bot that was based on a state machine. It doesn't work. The state machine takes too much time to pick up and carry the events. So I made this event-based. As soon as an event rolls in of any kind, you immediately respond to it. So the PvP script I'm going to show you is a pseudocode designed for level 60+, undead, warlock, and WoW. There's an on-event handler. There's many different types of events. One of the types, for example, is hostile event. That would be if someone tried to come up and punk you, or some rogue came up and zapped you, or something like that. So you can immediately get an event hostile type. There's also a timer event. The timer event I had to throw in. It's the most similar to a state-based approach that we can get, but it's not actually state-based. In the timer event, we just check for things like mana and health, eat food, drink water, all that stuff. If we have a target, we'll then call into the combat handler. And hostile events, I'll give you an example. If we just got charmed or feared, we immediately call the break fear, etc. subroutine. Just to give you an example of one thing we would be responding to. And our fear breaker simply casts Will of the Forsaken, and if that doesn't work, it uses the insignia of the Horde, Trinket. Pretty simple. So now the guy that just tried to fear me or sheep me, whatever, I've now countered immediately and I'm ready to attack. Then the combat script runs. I fix my pet on the target. I'll cast Death Coil in order to prevent myself from being interrupted on my next fear spell. The fear will then fire, so your target's now feared and running away. If I have the Voidwalker, I'll immediately sacrifice him, giving myself a nice bubble. And then I'll call Fel Domination, which reduced the casting time for my Felguard to almost nil, and I basically get instant Felguard. So the guy that just came up to try to sap me, just got me, I countered his sap, instantly got a bubble, and now there's a Felguard chasing around and beating on him. And, by the way, I'm slapping a couple dots on him as well. Manage dots. Gets called. So we call our friend Curse of Agony in this course. We're checking our mana percentage, so we're doing some amount of management here. We call Corruption. Something to notice about this, though, we actually pause in this script at this point in time until the casting is complete. We don't queue them and run them. My first version was queuing, but it turns out I had a lot of multi-threaded, kind of overlapping issues occurring. So what we do is we actually halt on there until Curse of Agony is finished, then Corruption is finished, and then finally, if we can pull one off, we'll cast Annihilate as well. We have to stop moving temporarily while we cast Annihilate. That's what the code's doing at the bottom there. Okay. So here's just a summary of how it works. Timer events don't queue. If you're already in the timer taking your time, and another timer event fires, it just gets thrown in the trash bucket, because you don't want to get cascaded of those happening. Any kind of status update or hostile event all queues up, because you want to process all of those no matter what, because they change the state of your script. Multiple callbacks do not occur at the same time. They queue up. This is a single-threaded system. Now I want to show you back-sticking. This is one trick that I've been working on. You know that if you're facing your target, you can hit them, but a lot of times if you're not facing your target, you can't hit the target. So my trick is to move my character behind the target at all times, so no matter which way he turns, he can't face me. That would be really good for a back-stabbing rogue. Now, tele-hacking would be the best way to do that, but since they patched tele-hacking, until I get that working again, I actually have to use keystrokes. I'm going to show you a short movie of a PvP bot using back-sticking. Here's a diagram of how it works. My target is in red. Blue runs up. All right, I've got to go real fast here. Blue guy runs up, faces the same direction as the red guy, and then backs up a couple of steps. Red guy tries to move. I do it again. And there's sort of this humping action going on. So let me go ahead and show the movie for that, because we're out of time. Okay, I'll go quick here. Here's the star of our show. Now, I'm clicking on targets. You can see she immediately faces NPCs, players, and pets. Notice the immediate heading changes. That's just illustrating the heading control. Let me show that on NPC, this dude here walking. You can see she's auto-correcting her heading. I'll click on her now. Instantly fixes on her as she walks by. Now let's pick on a target that actually moves, and we'll turn on the movement. Okay, this guy's walking around, and now we have the kind of humping action, although it doesn't actually show up too well here, because he's actually moving. If he were to stop moving, you'd see it a lot more clearly. So he's turning a corner, and you can see she's tracking right back. Right behind him. So the tracking works quite well. Okay. Here's a player. He's going to try to turn around in a minute, because I'm really annoying him. Now, she noticed she keeps running up and backing up. Now, he's going to try to turn and face me. All right. Sorry, the movie's a little choppy. Now, there he goes. He tried to turn, and I immediately corrected. Now, he's turning again, and he still can't face me. And he's going to turn again, and again, I autocorrected. There he goes again. Sorry, mister. Look at me. I know you want to look at me, but you can't look at me. Okay. So this shows you how the back sticking kind of works. Now, this guy, I pick on him for a while. He's standing there. He actually kind of gets a little pissed off and runs away. But he can't get away. That's the problem. So he actually is going to run into a building here shortly. Off he goes. He's going to go into the weapon vendor. Okay. Now, I actually cut the film here to save time. She's running and just backing up. Now, this actually, I cut the film here. This goes on for about, I got to finish this video. I got to finish this video. Two more minutes. He's actually talking to me down there, and he's getting really mad. So he's going to run out of the building and try to get away. And again, I'm still following him. And right here, he finally has it, and he logs off. Boom. All right. So just to show you again how that works, here's another guy I'm following around. He's running around inside of one of the buildings, and you can see the tracking is working very well. Up the stairs, around the stairs, and there's no problem. She follows him all the way around. He's going to stand here for a moment. This movie is only about one minute more, so it's almost done. She's doing this backup thing again, and he's not really paying attention to me at the time, but now I've been following him for like 20 minutes. Okay. And he's done. He's about had it. Now watch. He's going to try to run away around this. Just again, the tracking shows off really well here. He's going to run around the tree, and she'll follow him very nicely around the tree. He's going to try to jump over the fence, and we're going to follow him. There he goes. He's going to run around a pillar. Again, he's not able to get away, no matter all these obstacles and things. So the trick works pretty well. I think I have one more example, very short, in here. He's going to run away. I think I have a picture of some NPC action here. I actually let him get away. Oh yeah, this is the end of the movie. Just wanted to show you, you can also click on animals, and so she's going to eat horse butt. Thank you. There's some Q&A. You can come talk to me more about this stuff.