1 00:00:00,000 --> 00:00:08,260 We've been working with Patrick, which is here, for about a year on reversing games and fuzzing games, online games particularly. 2 00:00:08,860 --> 00:00:12,080 And before I start, we have a bunch of questions for you guys. 3 00:00:12,440 --> 00:00:16,640 The first one would be, how many of you ever play online games? 4 00:00:16,860 --> 00:00:17,680 Please raise your hand. 5 00:00:18,240 --> 00:00:18,980 All right. 6 00:00:19,680 --> 00:00:21,040 Some people don't. 7 00:00:21,040 --> 00:00:21,380 Okay. 8 00:00:22,020 --> 00:00:23,060 Didn't expect that. 9 00:00:23,140 --> 00:00:24,940 How many of you ever thought of cheating? 10 00:00:25,580 --> 00:00:26,700 Come on, don't be shy. 11 00:00:27,000 --> 00:00:27,900 Don't be shy. 12 00:00:29,080 --> 00:00:29,740 All right. 13 00:00:30,340 --> 00:00:32,900 How many of you really succeeded in doing that? 14 00:00:35,240 --> 00:00:36,000 All right. 15 00:00:38,320 --> 00:00:50,480 Well, so all of you probably, everyone who tried to cheat at one game like Diablo 3 or League of Legends, which would be the focus of the talk today, realized quickly that it is very, very hard. 16 00:00:50,740 --> 00:00:55,940 And when we started to do the presentation for this talk, we had two options. 17 00:00:56,320 --> 00:00:59,700 The first option was, well, how about doing a talk? 18 00:00:59,700 --> 00:01:02,920 Where we show you a bunch of attacks or a bunch of how we crash games. 19 00:01:03,200 --> 00:01:08,220 And the second one was more into telling you how we did it. 20 00:01:08,540 --> 00:01:18,900 And we decided to take the later route because I've been, since I've been doing a lot of fuzzing and a lot of reversing on games for the last three years, I have been cruising a bunch of forums. 21 00:01:19,280 --> 00:01:26,000 And most of the things I read is, I know assembly code, I know C++, how do I do reversing games? 22 00:01:26,260 --> 00:01:29,680 And most of the skill sets that you need to do that are now... 23 00:01:32,660 --> 00:01:47,120 So what we hope you to get from this talk is ideas on how next time you want to test a game, not for cheating, of course, but for intellectual satisfaction, you have the right skill set, right? 24 00:01:47,600 --> 00:01:48,000 Yeah. 25 00:01:49,080 --> 00:01:53,320 By the way, if you start cheating at Diablo 3, I will be super angry because I'm still playing it. 26 00:01:53,420 --> 00:01:56,300 So please hold for a little while before you start doing that. 27 00:01:56,400 --> 00:01:56,760 Thank you. 28 00:01:58,880 --> 00:01:59,680 It's a very, very... 29 00:01:59,700 --> 00:02:00,660 It's a very tough place. 30 00:02:01,040 --> 00:02:03,700 And over the last year, we met a lot of incredible people. 31 00:02:04,060 --> 00:02:09,720 And before starting, we want to acknowledge them because they did some of the work and we want to take credit for it. 32 00:02:09,880 --> 00:02:12,720 So we want to thank particularly Drew. 33 00:02:14,400 --> 00:02:16,440 Moeziz, which did a lot of work on Diablo 3. 34 00:02:16,580 --> 00:02:19,620 And Inkline9, which did a lot of work on League of Legends. 35 00:02:19,820 --> 00:02:23,300 And we are building on what they did and we helped them along the way. 36 00:02:23,500 --> 00:02:29,580 And they helped us, so it's really like they should be there together with us, at least here in spirit, I guess. 37 00:02:29,700 --> 00:02:34,100 So why fuzzing online game is so hard? 38 00:02:34,420 --> 00:02:36,340 Well, in theory, it's super simple. 39 00:02:36,460 --> 00:02:41,540 You have a server and you have a game and nothing special in it except a few things. 40 00:02:41,880 --> 00:02:44,380 First, well, you don't have the server. 41 00:02:44,560 --> 00:02:50,080 When you try to fuzz, let's say, Apache or FTP server, you usually have the binary as a very least, 42 00:02:50,080 --> 00:02:53,700 so you can actually instrument it, look how it works, and you can relaunch it and stuff. 43 00:02:54,140 --> 00:02:56,580 When you are fuzzing games, you don't. 44 00:02:56,860 --> 00:02:58,420 You simply don't have the server. 45 00:02:58,520 --> 00:02:59,680 The server is something out of you. 46 00:02:59,680 --> 00:03:00,760 You don't know how it works. 47 00:03:00,800 --> 00:03:04,080 You don't know how it's run, on which platform it is run. 48 00:03:04,500 --> 00:03:06,980 It's completely obscure to you. 49 00:03:07,120 --> 00:03:10,120 And by the way, do not fuzz games server. 50 00:03:10,920 --> 00:03:13,520 Fuzzing games server is illegal and I have to put this disclaimer somewhere. 51 00:03:13,900 --> 00:03:15,480 Do not try to fuzz Diablo 3 server. 52 00:03:16,120 --> 00:03:17,180 I never tell you to do that. 53 00:03:17,360 --> 00:03:18,140 Do not do that. 54 00:03:18,520 --> 00:03:20,140 You can maybe fuzz the client. 55 00:03:20,260 --> 00:03:20,860 That may be illegal. 56 00:03:21,020 --> 00:03:24,580 I'm not a lawyer, but I'm pretty sure fuzzing server is illegal. 57 00:03:26,860 --> 00:03:28,200 So the second thing is, 58 00:03:28,200 --> 00:03:32,380 when you look at the protocol, over the times, it became more and more complicated. 59 00:03:32,640 --> 00:03:37,160 I'm going to tell you more about the one about Diablo 3 and the one on League of Legends, 60 00:03:37,360 --> 00:03:42,980 but most of them, maybe except Formville, are very, very complex and encrypted, 61 00:03:43,200 --> 00:03:45,200 and you don't really know what's inside. 62 00:03:45,360 --> 00:03:48,840 So it's really hard to just fire up a sniper and just look at packets. 63 00:03:48,920 --> 00:03:50,300 It won't give you much these days. 64 00:03:50,400 --> 00:03:52,420 You have to really work harder on that. 65 00:03:52,800 --> 00:03:57,840 And finally, well, games try to use the basic hands to prevent you 66 00:03:57,840 --> 00:04:02,980 from debugging the code, so they have anti-debugging techniques. 67 00:04:03,240 --> 00:04:04,780 They also have active security checks. 68 00:04:05,180 --> 00:04:06,820 The most well-known would be the Warden. 69 00:04:06,960 --> 00:04:09,540 I'm going to give you a few words on this in a few slides, 70 00:04:09,660 --> 00:04:12,620 which is Blizzard's active security checker, 71 00:04:12,640 --> 00:04:15,520 and they're a very, very, very complex piece of code. 72 00:04:15,780 --> 00:04:19,120 You're looking at huge binary with a ton of DLRs, 73 00:04:19,120 --> 00:04:21,440 so if you just say, well, I'm going to just reverse it, 74 00:04:21,480 --> 00:04:24,980 let's pop up ADA or any type of analysis, 75 00:04:25,180 --> 00:04:26,840 then you're going to fail because it's just too big. 76 00:04:27,840 --> 00:04:29,760 And then when you look at that, you're like this. 77 00:04:32,780 --> 00:04:36,780 That's actually my usual face, which is like, ooh, that hurts. 78 00:04:36,900 --> 00:04:38,860 It's really hard, and you make no progress. 79 00:04:39,500 --> 00:04:41,520 When Patrick joined me like six months ago, 80 00:04:41,620 --> 00:04:44,380 he spent probably like two months doing zero progress. 81 00:04:44,680 --> 00:04:49,220 It's like very frustrating, and we don't want you guys to feel the same, 82 00:04:49,280 --> 00:04:51,780 so we try to give you a point of how to not be stuck. 83 00:04:51,980 --> 00:04:55,220 It's possible, and most people are like this in the forum. 84 00:04:55,380 --> 00:04:56,380 I don't know what to do. 85 00:04:56,520 --> 00:04:57,480 How am I starting? 86 00:04:57,840 --> 00:05:00,040 What is the thing I need to know? 87 00:05:00,520 --> 00:05:03,260 Well, friends, there is hope. 88 00:05:03,920 --> 00:05:05,660 It is possible to first game. 89 00:05:05,840 --> 00:05:07,260 It is possible to have results. 90 00:05:07,760 --> 00:05:09,420 You just have to be very creative, 91 00:05:09,480 --> 00:05:11,560 and we really have to think out of the box 92 00:05:11,560 --> 00:05:14,460 and use some sort of technique that you might not feel 93 00:05:14,460 --> 00:05:17,460 like are linked to reverse, but actually are really useful. 94 00:05:17,940 --> 00:05:19,780 And yes, I'm going to give you statistics, 95 00:05:20,040 --> 00:05:22,720 and yes, we're going to do some mathematical analysis 96 00:05:22,720 --> 00:05:25,200 of packets because at some point, as you will see, 97 00:05:25,320 --> 00:05:27,540 there is no other way, and it actually 98 00:05:27,840 --> 00:05:29,880 will be faster than just reverse the thing. 99 00:05:30,180 --> 00:05:33,060 So what we really want you to take out from this talk 100 00:05:33,060 --> 00:05:37,820 is the new techniques or the techniques revamped 101 00:05:37,820 --> 00:05:41,760 to first games that we come across over the last year, 102 00:05:41,840 --> 00:05:44,180 and then you can take them home and try to play with them, 103 00:05:44,220 --> 00:05:47,140 and hopefully you will help a bunch of open source projects 104 00:05:47,140 --> 00:05:49,840 that are around games, and a lot of good come out of that. 105 00:05:50,160 --> 00:05:51,900 So here's our master plan for today. 106 00:05:53,120 --> 00:05:54,520 We have the game, we have the server, 107 00:05:54,680 --> 00:05:57,340 so what we try to do usually is we try to be 108 00:05:57,340 --> 00:05:58,380 in between. 109 00:05:58,760 --> 00:06:02,420 We want to have our tool to actually intercept the traffic 110 00:06:03,060 --> 00:06:07,340 and be able to see the packets, and here is our first twist, 111 00:06:07,420 --> 00:06:09,940 is we also want our tool to correlate that 112 00:06:09,940 --> 00:06:11,840 with memory offsets. 113 00:06:12,260 --> 00:06:14,420 One of the things which is very powerful is when you combine 114 00:06:14,420 --> 00:06:16,780 network traffic with memory analysis, 115 00:06:16,900 --> 00:06:19,420 because you know what packet affect which state, 116 00:06:19,540 --> 00:06:22,000 and then you can write things like if I see this packet, 117 00:06:22,240 --> 00:06:24,900 what are the packets I see when this value comes up 118 00:06:24,900 --> 00:06:26,660 or which value comes down and so forth. 119 00:06:27,340 --> 00:06:30,640 It's actually a very useful technique to combine both of them. 120 00:06:31,100 --> 00:06:33,240 So today we're going to show you four things. 121 00:06:33,720 --> 00:06:37,020 One is how do you intercept traffic, which is the first step. 122 00:06:37,160 --> 00:06:39,180 Then how you have to bypass encryption, 123 00:06:39,500 --> 00:06:43,080 so every game uses encryption so you have to do that 124 00:06:43,080 --> 00:06:44,460 before doing any works. 125 00:06:44,740 --> 00:06:47,280 Then how do you reverse the traffic? 126 00:06:47,380 --> 00:06:48,580 When you have decrypted your packets, 127 00:06:48,800 --> 00:06:52,580 how do you actually come up with an understanding 128 00:06:52,580 --> 00:06:56,700 of what it is, and then we finish by telling you a little bit of 129 00:06:56,700 --> 00:06:59,220 when you have the packet and you have the ability to do first 130 00:06:59,220 --> 00:07:00,620 and you sort of know what you want to do, 131 00:07:00,700 --> 00:07:03,060 how you monitor the results on the client side. 132 00:07:04,560 --> 00:07:05,740 So intercepting traffic. 133 00:07:07,520 --> 00:07:10,140 There is mainly three ways for intercepting traffic. 134 00:07:10,500 --> 00:07:13,920 The first one is you take your game and you do something 135 00:07:13,920 --> 00:07:16,000 which is well known, which is JL injections. 136 00:07:17,340 --> 00:07:20,820 I'm speaking of Windows games for Linux fans. 137 00:07:21,060 --> 00:07:23,820 It's more like an LD preload where you try to overwrite 138 00:07:23,820 --> 00:07:24,920 a specific set of functions. 139 00:07:26,700 --> 00:07:29,440 The second way is you work as the OS level and where you have 140 00:07:29,440 --> 00:07:33,600 to write the driver or you use a VM, you put your game into the VM, 141 00:07:33,720 --> 00:07:36,380 depending on how graphic intensive is your game, 142 00:07:36,440 --> 00:07:37,820 you might or might not be able to do that, 143 00:07:37,960 --> 00:07:40,700 and then you write a driver which is going to intercept 144 00:07:40,700 --> 00:07:43,340 the packets before they leave the box and before they hit 145 00:07:43,340 --> 00:07:46,840 the router, or the last way is to actually have the network 146 00:07:46,840 --> 00:07:49,980 or the IP advisor and just use this interception 147 00:07:49,980 --> 00:07:51,660 after the packets leave the box. 148 00:07:54,880 --> 00:07:55,280 Okay. 149 00:07:55,420 --> 00:07:55,800 So. 150 00:07:57,100 --> 00:07:57,920 Hooking Winsocks. 151 00:07:58,100 --> 00:08:00,340 So most of the games in Windows use Winsocks, 152 00:08:00,460 --> 00:08:02,860 which is a Windows socket API, which is a standard way 153 00:08:02,860 --> 00:08:03,840 to send and receive packets. 154 00:08:04,280 --> 00:08:06,920 I have yet to see a game which doesn't use it. 155 00:08:07,700 --> 00:08:10,480 And basically there is a couple of functions that you want 156 00:08:10,480 --> 00:08:11,580 to basically overwrite. 157 00:08:11,900 --> 00:08:14,380 The first one is connect, which allows you to manipulate 158 00:08:14,380 --> 00:08:15,320 where the game connects. 159 00:08:15,680 --> 00:08:18,400 The second one is receive when, for receiving packets, 160 00:08:18,580 --> 00:08:20,640 and the third one is obviously sending packets. 161 00:08:20,780 --> 00:08:22,600 These are the three functions that you want to hook, 162 00:08:22,720 --> 00:08:25,280 and there is two ways mainly to do that. 163 00:08:25,280 --> 00:08:27,980 The first one is to use Microsoft D2 libraries, 164 00:08:28,860 --> 00:08:31,980 which is a way for you to write a DLR, which says I want to 165 00:08:31,980 --> 00:08:34,560 intercept this, this, this, and this, and then it's going to 166 00:08:34,560 --> 00:08:38,360 inject a DLR into the game, and you would have like a bypass 167 00:08:38,360 --> 00:08:39,060 to these functions. 168 00:08:39,740 --> 00:08:42,220 The other one, if you don't want to use D2, and there is a lot 169 00:08:42,220 --> 00:08:45,440 of discussion in the communities on what is the best way to do, 170 00:08:45,500 --> 00:08:52,020 you can actually not use Microsoft D2, and use IAT 171 00:08:52,020 --> 00:08:55,120 hooking, which is basically you write the table of the front, 172 00:08:55,280 --> 00:08:58,080 the pointer directly by yourself, and then they're going to go 173 00:08:58,080 --> 00:09:00,640 to your function, and then you return to the real functions. 174 00:09:02,640 --> 00:09:06,060 That's where things become harder when you do a game. 175 00:09:06,220 --> 00:09:09,460 If you do that on a browser, like it works perfectly. 176 00:09:09,840 --> 00:09:13,380 If you do that on Diablo 3, you have to face a warden. 177 00:09:13,840 --> 00:09:15,060 So what is a warden? 178 00:09:15,360 --> 00:09:20,300 So a warden is the code name for Blizzard anti-chilling engine. 179 00:09:21,180 --> 00:09:23,620 It is meant basically to do three things. 180 00:09:23,960 --> 00:09:25,260 The first thing, which we know, 181 00:09:25,280 --> 00:09:29,040 most about is it reads a certain offset in the memory. 182 00:09:29,200 --> 00:09:31,980 So it looks at different offsets in the game and tries to see if 183 00:09:31,980 --> 00:09:34,160 these offsets have been modified in any ways. 184 00:09:34,440 --> 00:09:38,180 It also scans the list of processes you have run on your 185 00:09:38,180 --> 00:09:44,880 computer for known bots or known executable, like debuggers, 186 00:09:46,980 --> 00:09:49,080 packet interceptors, knifers, and so forth, 187 00:09:49,100 --> 00:09:50,140 and reports it to Blizzard. 188 00:09:50,420 --> 00:09:54,460 And last thing, it actually seems to be able to run a blob 189 00:09:54,460 --> 00:09:54,880 of code. 190 00:09:55,280 --> 00:09:57,400 Basically sometimes it fetches a blob of code and just runs it 191 00:09:57,400 --> 00:09:58,980 and returns the result to Blizzard. 192 00:10:00,280 --> 00:10:05,580 What it means for us is that if you use hooking, you will get code. 193 00:10:06,520 --> 00:10:07,040 You will. 194 00:10:07,220 --> 00:10:11,500 There is like no, you might not be code right away because you 195 00:10:11,500 --> 00:10:14,060 might inject or hook a little bit differently than the receive 196 00:10:14,060 --> 00:10:17,080 or send function and you can be upper this function, but 197 00:10:17,080 --> 00:10:20,080 sometimes it will figure this out and you get code because the 198 00:10:20,080 --> 00:10:23,540 wardens can, for every time, ways of injecting the allows. 199 00:10:26,240 --> 00:10:31,440 So the other options that we sort of work, we use for the last 200 00:10:31,440 --> 00:10:34,400 six months is use write a driver. 201 00:10:34,760 --> 00:10:39,160 Two years ago we were starting to do using LSP, which was the 202 00:10:39,160 --> 00:10:40,460 old way to do it by Microsoft. 203 00:10:40,780 --> 00:10:45,860 There was actually a talk at DEFCON 15 on that to tell you how 204 00:10:45,860 --> 00:10:47,780 old it is, like five or six years old. 205 00:10:48,060 --> 00:10:51,080 There is a new one that came out which is actually easier, so if 206 00:10:51,080 --> 00:10:54,280 you want to look at doing that, the easiest way to do it is to 207 00:10:54,280 --> 00:10:55,260 use the window. 208 00:10:55,280 --> 00:10:58,860 You can use the window filter platform, which make, basically 209 00:10:58,860 --> 00:11:01,740 you can tell I want to intercept TCP connection or I want to 210 00:11:01,740 --> 00:11:04,860 intercept the stream on top of it and make it easier for you 211 00:11:04,860 --> 00:11:08,140 because it's going to re-sync TCP counter for you and so forth, 212 00:11:08,220 --> 00:11:08,740 so it's pretty good. 213 00:11:09,820 --> 00:11:12,140 The thing you have to be careful when you write a driver is 214 00:11:12,140 --> 00:11:15,140 actually the driver, what you do is basically you stop the 215 00:11:15,140 --> 00:11:17,540 packets to go to the server and you re-inject them. 216 00:11:17,720 --> 00:11:20,380 The problem when you do that with a driver is your own packet 217 00:11:20,380 --> 00:11:23,260 are going to go back to your own driver, so you have to tag them. 218 00:11:23,600 --> 00:11:25,080 It seems easy to explain. 219 00:11:25,280 --> 00:11:29,440 When you implement it, it's sort of tricky and you might find weird 220 00:11:29,440 --> 00:11:32,040 bugs like having the same packet sent twice to the server and so 221 00:11:32,040 --> 00:11:33,360 forth, so you have to be careful. 222 00:11:35,260 --> 00:11:41,520 On a side note, you can't really redirect IPs, so I saw that a 223 00:11:41,520 --> 00:11:42,480 bunch of times in the forums. 224 00:11:42,660 --> 00:11:45,220 People say, well, but what you can do is simply tell Diablo 3 225 00:11:45,220 --> 00:11:48,460 to go and connect to your own IPs. 226 00:11:48,460 --> 00:11:49,860 There is like a common line option for that. 227 00:11:50,220 --> 00:11:52,420 The truth is it's used to work in beta. 228 00:11:53,200 --> 00:11:55,000 In release, you can't do that. 229 00:11:55,280 --> 00:11:59,880 Basically, the server sends a packet, a challenge packet to 230 00:11:59,880 --> 00:12:03,540 Diablo 3 with the IP of the server and if it actually doesn't 231 00:12:03,540 --> 00:12:06,900 match the list it has into a DLL, which is downloaded every 232 00:12:06,900 --> 00:12:10,200 time you launch a game, it's going to refuse to connect. 233 00:12:10,760 --> 00:12:15,500 So you actually have to, Diablo 3 has to believe that you 234 00:12:15,500 --> 00:12:18,000 connect to the right IP, otherwise you can't actually 235 00:12:19,540 --> 00:12:20,280 launch a game. 236 00:12:20,720 --> 00:12:23,060 And some people will say, well, but I can hook these functions. 237 00:12:23,400 --> 00:12:25,260 Well, if you hook these functions, the world is going to 238 00:12:25,280 --> 00:12:26,920 catch you, so you can't do that. 239 00:12:27,160 --> 00:12:31,080 You have to either reroute the IP to a different box or you have 240 00:12:31,080 --> 00:12:32,520 to do the driver interceptions. 241 00:12:32,980 --> 00:12:37,560 So to summarize this part, you can do DLL injections and it 242 00:12:37,560 --> 00:12:41,280 works fine on games which don't have like active checks, like 243 00:12:41,280 --> 00:12:41,960 League of Legends. 244 00:12:42,200 --> 00:12:44,400 That's probably the current way of doing it for League of 245 00:12:44,400 --> 00:12:44,700 Legends. 246 00:12:44,860 --> 00:12:48,320 When you deal with games which are really, really secure, like 247 00:12:48,320 --> 00:12:51,920 Diablo 3, you have to do something more fancy. 248 00:12:52,340 --> 00:12:54,480 We use driver for a very good reason. 249 00:12:54,540 --> 00:12:55,260 As I said, we use driver for a very good reason. 250 00:12:55,280 --> 00:12:58,120 As I said in my master plan, I want to be able to read the game 251 00:12:58,120 --> 00:12:58,360 state. 252 00:12:58,700 --> 00:13:02,020 I want to be able to collect packets with what is happening 253 00:13:02,020 --> 00:13:04,760 in the memory, and the only way for me to do that would be on 254 00:13:04,760 --> 00:13:05,420 the same computer. 255 00:13:05,720 --> 00:13:08,160 I might be able to do it with a second box, but I have to do 256 00:13:08,160 --> 00:13:10,600 socket and so forth, and there will be some latency, which 257 00:13:10,600 --> 00:13:16,860 might not be, which might seem trickier, so our current 258 00:13:16,860 --> 00:13:19,500 approach, what we recommend to do is actually use a driver and 259 00:13:19,500 --> 00:13:23,320 use the WPF way of doing it, just intercept packets. 260 00:13:23,560 --> 00:13:24,400 That's how we did it. 261 00:13:25,560 --> 00:13:26,000 Encryptions. 262 00:13:27,820 --> 00:13:30,080 Let's start with the easy one, League of Legends. 263 00:13:30,780 --> 00:13:32,560 So League of Legends use Blowfish. 264 00:13:33,000 --> 00:13:36,280 I have no idea why they choose Blowfish, which is slow, but 265 00:13:36,280 --> 00:13:39,320 somehow, someone, they must have read that Blowfish is great, 266 00:13:39,400 --> 00:13:40,720 so they implemented Blowfish. 267 00:13:41,300 --> 00:13:43,900 So League of Legends have two binary, one which is the 268 00:13:43,900 --> 00:13:46,480 launcher where you find your game, and then you click play, 269 00:13:46,680 --> 00:13:48,080 and it's launched your game. 270 00:13:48,700 --> 00:13:51,900 The interesting part of that is actually once you click on 271 00:13:51,900 --> 00:13:54,340 launch, the key, the Blowfish key appears. 272 00:13:54,340 --> 00:13:55,080 It appears in the command line. 273 00:13:58,360 --> 00:14:00,080 So they have some sort of encryption. 274 00:14:02,180 --> 00:14:03,160 Not a big deal. 275 00:14:04,340 --> 00:14:07,280 Let's go back to something way more complicated. 276 00:14:07,780 --> 00:14:08,820 Enter Diablo 3. 277 00:14:11,060 --> 00:14:11,720 All right. 278 00:14:11,940 --> 00:14:14,860 So you have the game, and you have the Battle.net server, 279 00:14:15,020 --> 00:14:16,720 which is the first server you connect to. 280 00:14:17,040 --> 00:14:20,620 The first thing you're going to do is what's called a SRP6 281 00:14:20,620 --> 00:14:24,320 challenge, which is basically a way for you to, you know, 282 00:14:24,340 --> 00:14:26,860 prove that you have the right login and password without 283 00:14:26,860 --> 00:14:30,060 transmitting it in clear. 284 00:14:30,280 --> 00:14:31,500 It's a six-step protocol. 285 00:14:31,880 --> 00:14:32,820 I'm not going into details. 286 00:14:33,460 --> 00:14:35,960 If you Google SRP6, you're going to find it. 287 00:14:36,240 --> 00:14:40,400 The basic idea is you hash your password with like a secret, 288 00:14:40,520 --> 00:14:44,120 with a nonce, and then you exchange that with some sort of 289 00:14:44,120 --> 00:14:49,140 DeFi crypto, and basically, the network attacker has no way to 290 00:14:49,140 --> 00:14:49,940 brute force your password. 291 00:14:50,080 --> 00:14:50,780 That's why it's pretty good. 292 00:14:50,920 --> 00:14:54,080 It's actually very, very, the right way to do that, and when 293 00:14:54,080 --> 00:14:58,460 you have done that, what you obtain is a secret key, which is 294 00:14:58,460 --> 00:15:01,360 shared between the Battle.net server and the game, and you 295 00:15:01,360 --> 00:15:03,260 change out every instance of the game, of course. 296 00:15:04,040 --> 00:15:06,220 And then you use that to start TLS. 297 00:15:06,520 --> 00:15:10,600 So you do TLS PS key, which is pressure at key, so basically 298 00:15:10,600 --> 00:15:13,800 they start to do TLS instead of using certificate to exchange 299 00:15:13,800 --> 00:15:17,100 the keys, actually use the keys they have used in SRP6. 300 00:15:18,180 --> 00:15:22,140 And when this is done, and you say, okay, I can do all of 301 00:15:22,140 --> 00:15:22,340 this. 302 00:15:22,500 --> 00:15:22,860 Ah! 303 00:15:24,080 --> 00:15:26,140 So you do the RSA challenge, and I'm going to explain you a 304 00:15:26,140 --> 00:15:29,820 little bit what is the RSA challenge is, and then after 305 00:15:29,820 --> 00:15:33,100 that, you actually connect to a second server, which is what we 306 00:15:33,100 --> 00:15:35,360 call the game server, where the actual game occur. 307 00:15:35,580 --> 00:15:37,720 You know, when you click play, actually you are moving to 308 00:15:37,720 --> 00:15:38,200 another server. 309 00:15:39,000 --> 00:15:42,160 And no, Blizzard do not put the key into the command line. 310 00:15:42,780 --> 00:15:43,560 Not this time. 311 00:15:44,060 --> 00:15:47,840 So why a RSA challenge? 312 00:15:48,120 --> 00:15:52,460 So TLS PS key is basically using SSL with a pressure key, 313 00:15:52,620 --> 00:15:54,060 which is the one you exchange it during the game. 314 00:15:54,060 --> 00:15:59,580 So you do the SRP6 challenge, and it should be perfectly fine 315 00:15:59,580 --> 00:16:03,280 for us, because, well, I know my password, so I can recreate the 316 00:16:03,280 --> 00:16:05,820 SRP6 challenge on my interception mechanism. 317 00:16:07,080 --> 00:16:09,680 And so there is no way for Blizzard to know that it's an 318 00:16:09,680 --> 00:16:13,160 end-to-end connection, so they use a RSA challenge, so the 319 00:16:13,820 --> 00:16:17,180 client expects a message which is signed with the private key 320 00:16:17,180 --> 00:16:21,960 of Blizzard, and if this is not showed by, if it's not valid, 321 00:16:22,140 --> 00:16:24,040 then, ah, it's not valid. 322 00:16:24,040 --> 00:16:25,560 The game will refuse to launch again. 323 00:16:25,800 --> 00:16:27,820 It's actually located into the password DLL. 324 00:16:28,960 --> 00:16:31,760 So basically what happened is, we don't know the key. 325 00:16:31,840 --> 00:16:34,180 We don't know the Blizzard private key, and the game expects 326 00:16:34,840 --> 00:16:37,740 you to have this challenge signed by the private key of 327 00:16:37,740 --> 00:16:40,080 Blizzard, otherwise it will refuse to launch, so it's a way 328 00:16:40,080 --> 00:16:41,280 for them to do authentications. 329 00:16:41,520 --> 00:16:44,860 And it's actually perfectly meant to be proven for exactly 330 00:16:44,860 --> 00:16:46,700 what we want to do, which is manage the middle attacks. 331 00:16:48,280 --> 00:16:50,360 So there is two ways to bypass the challenge. 332 00:16:50,840 --> 00:16:54,020 One is you're going to factor RSA key, which is, you know, 333 00:16:54,020 --> 00:16:55,480 as far as I can tell, impossible. 334 00:16:56,180 --> 00:16:57,660 Or you're going to patch the game. 335 00:16:58,440 --> 00:17:00,460 But if you patch the game, you know what happened? 336 00:17:01,700 --> 00:17:03,600 The warden is going to go after you. 337 00:17:03,640 --> 00:17:05,320 Remember, the warden, we should look at the offset. 338 00:17:05,500 --> 00:17:07,740 They actually look at the offset of the key, so if you try to 339 00:17:07,740 --> 00:17:10,000 change the key or change the task, they're going to catch 340 00:17:10,000 --> 00:17:10,180 you. 341 00:17:11,680 --> 00:17:13,940 So that's probably what's a happy face you make. 342 00:17:15,760 --> 00:17:17,880 And you're like, okay, that's become complicated. 343 00:17:18,100 --> 00:17:21,480 So you start to thinking, well, maybe I can do put into debug 344 00:17:21,480 --> 00:17:23,920 mode, swap when doing the challenge. 345 00:17:24,020 --> 00:17:26,040 And be very quick and remove the swap. 346 00:17:26,340 --> 00:17:29,400 Or I might intercept the warden and I might actually trick the 347 00:17:29,400 --> 00:17:30,840 warden into not getting the right offset. 348 00:17:32,440 --> 00:17:34,780 And then you look more and more. 349 00:17:35,980 --> 00:17:38,160 And then you realize something really deep. 350 00:17:40,160 --> 00:17:42,060 Traffic to the game server is not encrypted. 351 00:17:44,560 --> 00:17:45,040 . 352 00:17:51,700 --> 00:17:52,180 So. 353 00:17:54,220 --> 00:17:58,120 When you realize that, you're like, yes, I can't, so you 354 00:17:58,120 --> 00:18:02,140 can't, what it means is we can monitor the game by itself, but 355 00:18:02,140 --> 00:18:05,720 we can't do for auction, a house protocol is encrypted. 356 00:18:06,160 --> 00:18:08,940 So if you want to basically try to fuzz the auction out, and 357 00:18:08,940 --> 00:18:11,960 again, it's illegal, you might not be able to do that because 358 00:18:11,960 --> 00:18:15,220 these packets are encrypted, so they protect your login, the 359 00:18:15,220 --> 00:18:17,120 character selection, and the auction house. 360 00:18:17,460 --> 00:18:20,420 If you just want to be in the game, like bashing monster and 361 00:18:20,420 --> 00:18:23,420 doing quests, this is not encrypted, so that's the part 362 00:18:23,420 --> 00:18:24,140 we focus with. 363 00:18:24,640 --> 00:18:29,420 So at that point, we give up on everything and we just like let 364 00:18:29,420 --> 00:18:32,820 the game do all the authentication for itself and we 365 00:18:32,820 --> 00:18:37,300 pick up the connection after all this is done and we just give 366 00:18:37,300 --> 00:18:40,620 up on basically the auction and so forth. 367 00:18:41,460 --> 00:18:41,860 All right. 368 00:18:42,940 --> 00:18:43,620 Reversing protocol. 369 00:18:46,380 --> 00:18:49,500 Here's what a Diablo 3 game packets look like. 370 00:18:49,700 --> 00:18:50,520 So they use TCP. 371 00:18:51,520 --> 00:18:53,400 And on top of TCP, they use a 372 00:18:53,420 --> 00:18:55,880 RPC, which is remote procedure calls, so they send a lot of 373 00:18:55,880 --> 00:19:00,000 calls to the server, say do this, do that, for instance, I'm 374 00:19:00,000 --> 00:19:03,180 facing this, I'm going there, and then the server is going to 375 00:19:03,180 --> 00:19:08,040 say play this animation or I'm going to kill this monster, so 376 00:19:08,040 --> 00:19:11,140 basically you say I'm going to attack there and the server is 377 00:19:11,140 --> 00:19:17,060 going to send you back how much DPS you did because all the 378 00:19:17,060 --> 00:19:19,140 computation I've done on the server side to prevent cheating 379 00:19:19,140 --> 00:19:19,440 again. 380 00:19:20,160 --> 00:19:23,060 And then on top of that, they use what we call protobuf. 381 00:19:23,840 --> 00:19:29,080 Protobuf is a way to create a nested protocol which is 382 00:19:29,080 --> 00:19:31,880 developed by Google, there is an open source implementation of 383 00:19:31,880 --> 00:19:36,460 that, the community has created a C-sharp version of it, so you 384 00:19:36,460 --> 00:19:40,660 have it for Python, C++, Java and C-sharp currently available 385 00:19:42,200 --> 00:19:42,880 open source. 386 00:19:43,220 --> 00:19:46,840 And if you want to know what a Diablo 3 packets look like, this 387 00:19:46,840 --> 00:19:51,900 is a packet which is half reversed, so you have this is an 388 00:19:51,900 --> 00:19:52,420 attack packet. 389 00:19:52,420 --> 00:19:55,200 So when you attack packets, this is what we have been able to 390 00:19:55,200 --> 00:19:58,240 isolate, so you have something which is like an end target 391 00:19:58,240 --> 00:20:01,920 message where you have three fields, we believe it's actually 392 00:20:01,920 --> 00:20:04,840 five or six fields, we don't know exactly how to split it 393 00:20:04,840 --> 00:20:08,640 yet, and then you have the location where you want to eat 394 00:20:08,640 --> 00:20:10,980 which is like three coordinates which are at the bottom of the 395 00:20:10,980 --> 00:20:11,120 screen. 396 00:20:11,520 --> 00:20:13,980 This is the kind of stuff you're going to get and you can see 397 00:20:13,980 --> 00:20:18,180 it's a protobuf because it has a nested component and that's how 398 00:20:18,180 --> 00:20:20,900 they probably say they have like a bunch of components and 399 00:20:20,900 --> 00:20:22,640 you unlock them. 400 00:20:22,860 --> 00:20:26,400 On the other side, League of Legends use something completely 401 00:20:26,400 --> 00:20:29,920 different, they use UDP, and on top of that they use Inet which 402 00:20:29,920 --> 00:20:35,840 is a reliable connection on top of UDP, on top of that they have 403 00:20:35,840 --> 00:20:38,620 Blowfish, and on top of that they have a new protocol which is 404 00:20:38,620 --> 00:20:40,660 a League of Legends protocol which is their own custom 405 00:20:40,660 --> 00:20:44,000 protocol which is the thing you care deeply about, so Inet is 406 00:20:44,000 --> 00:20:48,820 just a way to multiplex, basically the League of Legends 407 00:20:48,820 --> 00:20:50,560 packet format is something like this. 408 00:20:50,900 --> 00:20:53,540 You have an opcode which tells you what the action is, followed 409 00:20:53,540 --> 00:20:59,800 by an ID which is an integer, 32 bits, little Indian, and then 410 00:20:59,800 --> 00:21:03,080 followed by some content, and then they are multiplexing across 411 00:21:03,440 --> 00:21:07,080 multiple channels, and each channel has a set of flags, so 412 00:21:07,080 --> 00:21:10,100 you usually have like four or five channels and one or two 413 00:21:10,100 --> 00:21:11,380 flags for this. 414 00:21:11,480 --> 00:21:14,500 Usually three is for sending information and one is for 415 00:21:14,500 --> 00:21:15,980 receiving information or something like that. 416 00:21:16,680 --> 00:21:19,240 And then you're like, at some point you feel pretty good, 417 00:21:19,320 --> 00:21:20,240 you're like, well, okay. 418 00:21:20,920 --> 00:21:26,140 I know the protocol, I'm able to manipulate it, I'm happy, I 419 00:21:26,140 --> 00:21:27,320 did all the hard work, right? 420 00:21:27,880 --> 00:21:30,460 And from now it should be done here. 421 00:21:30,900 --> 00:21:34,060 Well, let's take some check. 422 00:21:34,560 --> 00:21:40,640 We recorded a game which lasted 21 minutes, and in 21 minutes we 423 00:21:40,640 --> 00:21:41,740 get 60,000 packets. 424 00:21:42,820 --> 00:21:46,800 That's a lot of data as a process, and on average you get 425 00:21:46,800 --> 00:21:49,760 about 48 packets a second, so if you try to do that with a 426 00:21:49,760 --> 00:21:49,940 sniper. 427 00:21:50,900 --> 00:21:51,460 You won't see anything. 428 00:21:51,640 --> 00:21:54,560 If you try to process that with a sniper, well, it's going to 429 00:21:54,560 --> 00:21:59,160 take you a lot of time, and we have isolated 78 different op 430 00:21:59,160 --> 00:22:01,060 codes, so there's also a lot of different packets. 431 00:22:02,100 --> 00:22:06,960 So if you want to grab that, you have some birth to up to 80 432 00:22:06,960 --> 00:22:11,880 percent or 90 packets a second at some point, and then it's 433 00:22:11,880 --> 00:22:16,920 very, very, very oscillating, and it's not easy to do with 434 00:22:16,920 --> 00:22:17,500 that. 435 00:22:17,700 --> 00:22:19,280 And then, well. 436 00:22:21,300 --> 00:22:23,040 Yeah, there is too much stuff to process. 437 00:22:23,220 --> 00:22:25,460 You can't just look at it and just figure out what it is, 438 00:22:25,480 --> 00:22:26,820 because it's actually too much data. 439 00:22:28,020 --> 00:22:30,560 Well, there is no such thing as too much data, you know? 440 00:22:30,880 --> 00:22:34,000 Having a lot of data is good, because if we have a lot of 441 00:22:34,000 --> 00:22:35,860 data, we can start to do something like statistical 442 00:22:35,860 --> 00:22:39,280 analysis, and don't be afraid, it's pretty easy, to actually 443 00:22:39,280 --> 00:22:42,840 figure out a lot of things by themself, and then use that. 444 00:22:43,140 --> 00:22:46,420 So what I propose to do from there is first we're going to 445 00:22:46,420 --> 00:22:48,820 bucket, which is basically split the traffic by op code, 446 00:22:48,900 --> 00:22:50,700 because we know that each op code is some sort of 447 00:22:51,740 --> 00:22:54,800 separated, and then try to do some what I call differential 448 00:22:54,800 --> 00:22:57,600 analysis, and I'm going to show you how it works, then we're 449 00:22:57,600 --> 00:23:00,600 going to try to mutate this to do the fuzzing, and then we can 450 00:23:00,600 --> 00:23:03,380 inject the code and just look at the data and see how it's 451 00:23:03,380 --> 00:23:03,860 going to work. 452 00:23:04,180 --> 00:23:05,500 So bucketing is very simple. 453 00:23:05,640 --> 00:23:08,260 All you do is you look at the op code and you say, well, if it's 454 00:23:08,260 --> 00:23:13,080 op code A, I'm going to put it into the bucket A, and if it's B, 455 00:23:13,180 --> 00:23:15,460 I'm going to put it into bucket B, and that's all there is to it. 456 00:23:15,560 --> 00:23:19,680 So it's not hard, and it's going to be like four lines of Python 457 00:23:19,680 --> 00:23:20,160 or something. 458 00:23:20,900 --> 00:23:23,120 And then you have your bucket, and then you can work on each of 459 00:23:23,120 --> 00:23:23,860 them in those relations. 460 00:23:24,500 --> 00:23:27,100 When you have each bucket, what you do is you take each packet, 461 00:23:27,700 --> 00:23:30,260 and what you're going to do is you're going to do the first 462 00:23:30,260 --> 00:23:32,720 packet followed by the second packet, and you're going to 463 00:23:32,720 --> 00:23:35,780 look at how many of them are differences in the same offset. 464 00:23:35,960 --> 00:23:38,240 So you're going to compare offset by offset, which is like 465 00:23:38,240 --> 00:23:41,360 column by column, and you compare all of them, and for 466 00:23:41,360 --> 00:23:46,160 instance, you can see that for the first offset, the value is 467 00:23:46,160 --> 00:23:47,260 from two to nine. 468 00:23:47,340 --> 00:23:50,640 We have the range, because the lowest one is zero two, and the 469 00:23:50,640 --> 00:23:53,440 highest one is zero nine, and the second one hasn't moved, so 470 00:23:53,440 --> 00:23:55,860 it's basically some sort of static field, either an 471 00:23:55,860 --> 00:23:59,060 identifier or a split, a separator or something like 472 00:23:59,060 --> 00:24:02,220 that, and the third one is also separated. 473 00:24:02,820 --> 00:24:06,840 When you have that, you have to do a second step where what you 474 00:24:06,840 --> 00:24:10,260 do is you do differential analysis between traces. 475 00:24:10,540 --> 00:24:13,340 So you have one trace which might have this shape where the 476 00:24:13,340 --> 00:24:17,340 first offset is viable, the second one is fixed, the third 477 00:24:17,340 --> 00:24:19,980 one is fixed, and then you, for instance, look for the second 478 00:24:19,980 --> 00:24:20,560 player trace. 479 00:24:20,640 --> 00:24:21,660 And you compare those two. 480 00:24:22,060 --> 00:24:25,320 And what you can see from there is that, of course, the first 481 00:24:26,240 --> 00:24:29,840 offset have variations, the second one is fixed, but 482 00:24:29,840 --> 00:24:34,620 actually the third one is also viable because it's probably the 483 00:24:34,620 --> 00:24:37,820 ID of the user or ID of the player, so you can actually get 484 00:24:37,820 --> 00:24:38,200 more data. 485 00:24:39,740 --> 00:24:43,240 If you want all of this, I put all the differential analysis on 486 00:24:43,240 --> 00:24:46,440 the League of Legends protocol into the GitHub. 487 00:24:46,660 --> 00:24:50,480 If you look for League of Legends line, you're going to 488 00:24:50,480 --> 00:24:53,420 find them, and I have all of them in public, and when you 489 00:24:53,420 --> 00:24:55,220 have that, you can say, well, now I can fuzz everything. 490 00:24:55,900 --> 00:24:58,200 So now what I'm going to do is I'm going to take every range, 491 00:24:58,340 --> 00:25:03,300 and for each range, I'm going to just, you know, just mutate all 492 00:25:03,300 --> 00:25:03,620 of those. 493 00:25:04,760 --> 00:25:06,660 Well, the problem is it looks like this. 494 00:25:06,900 --> 00:25:09,080 It's what we call the curse of dimensionality. 495 00:25:10,360 --> 00:25:13,460 If you try to have one bucket which change, it's perfectly 496 00:25:13,460 --> 00:25:16,960 fine, if you have seven range which actually change, even if 497 00:25:16,960 --> 00:25:20,460 you try to do four mutation by range and combine all of them, 498 00:25:20,480 --> 00:25:22,440 you're going to end up with millions and millions of 499 00:25:22,440 --> 00:25:22,700 packets. 500 00:25:23,340 --> 00:25:27,440 To give you an idea, when we tried to generate all the 501 00:25:27,440 --> 00:25:34,320 fuzzing vectors for the League of Legends client, and we only 502 00:25:34,320 --> 00:25:37,360 used three value, which is minimum, maximum, and median 503 00:25:37,360 --> 00:25:40,280 value, we ended up with 1.5 million packets. 504 00:25:42,480 --> 00:25:45,520 And the problem is League of Legends is very brittle, the 505 00:25:45,520 --> 00:25:48,800 client, so most of the time we actually crash the client. 506 00:25:49,160 --> 00:25:50,460 So the problem is, I need to do this. 507 00:25:50,480 --> 00:25:53,920 And you have to click on, we know the game, reset the game, 508 00:25:56,200 --> 00:25:59,020 and then click, and then start, and even if you automate that 509 00:25:59,020 --> 00:26:01,440 with, let's say, auto it, then you have to do it in super slow, 510 00:26:01,580 --> 00:26:05,660 so, well, you have to take it to the next level. 511 00:26:06,040 --> 00:26:08,540 It's not good enough, even if you are to that point where you 512 00:26:08,540 --> 00:26:11,860 know what is fixed, what is not fixed, and you're able to try to 513 00:26:11,860 --> 00:26:13,860 do all the fuzzing, you're not good enough. 514 00:26:15,000 --> 00:26:17,640 You need something better, so you can start with something 515 00:26:17,640 --> 00:26:19,520 very simple, you can look at frequency analysis. 516 00:26:20,480 --> 00:26:21,040 This is the plot. 517 00:26:21,500 --> 00:26:25,160 What you can see here is by opcode, and it's a logarithmic 518 00:26:25,160 --> 00:26:28,960 scale, so the biggest bar are actually way higher than they 519 00:26:28,960 --> 00:26:30,520 look at here on the diagram. 520 00:26:31,640 --> 00:26:33,720 Some opcode are very, very frequent. 521 00:26:33,940 --> 00:26:37,960 There are mainly pings and update on location and stuff 522 00:26:37,960 --> 00:26:40,220 like that, which are not really what you are interested in. 523 00:26:40,420 --> 00:26:44,380 On the other hand, there is a handful opcode which are very, 524 00:26:44,440 --> 00:26:45,460 very, very rare. 525 00:26:45,860 --> 00:26:48,140 And these are the ones we actually care about. 526 00:26:48,400 --> 00:26:48,800 Why? 527 00:26:49,060 --> 00:26:50,460 Uh, because the source code is very, very, very rare. 528 00:26:50,480 --> 00:26:52,640 And the small stuff is usually the good stuff. 529 00:26:52,800 --> 00:26:55,680 For instance, when you do a level up, well, level up is not 530 00:26:55,680 --> 00:26:56,240 that often. 531 00:26:56,400 --> 00:26:58,960 You're not going to level up every second, so you might have 532 00:26:58,960 --> 00:27:00,760 like four or five of those into the trace. 533 00:27:01,220 --> 00:27:02,680 Same thing for buying items. 534 00:27:02,860 --> 00:27:05,540 You do not buy like 20 items or a million items. 535 00:27:05,680 --> 00:27:08,120 You buy maybe 10, 20 items, so it's very, very low. 536 00:27:08,380 --> 00:27:09,520 And same thing for attacking. 537 00:27:09,740 --> 00:27:12,320 You do not attack that often, so there is very, very few packets. 538 00:27:12,520 --> 00:27:15,680 So if you discard all the stuff which is very, very frequently 539 00:27:15,680 --> 00:27:19,240 updated, then you end up with a small chunk of opcode which are 540 00:27:19,240 --> 00:27:20,180 more manageable. 541 00:27:20,480 --> 00:27:20,580 That's what you do. 542 00:27:23,380 --> 00:27:27,080 That being said, remember, it's an online game, so when you send 543 00:27:27,080 --> 00:27:29,500 a comment, you also want to know what the answer is linked to it. 544 00:27:29,900 --> 00:27:32,660 So the problem is with League of Legends that I said, there is 545 00:27:32,660 --> 00:27:35,800 multiple packets that they sort of multiplex each other, so it's 546 00:27:35,800 --> 00:27:37,940 actually hard to know which one is related to one another. 547 00:27:38,360 --> 00:27:42,660 So you need to actually do correlations between opcodes. 548 00:27:43,060 --> 00:27:45,300 For instance, when you have an attack trigger, you want to 549 00:27:45,300 --> 00:27:47,860 know what is the response from the server for that. 550 00:27:48,000 --> 00:27:50,460 Or when you assign a new skill, what you want to know is what is 551 00:27:51,740 --> 00:27:54,560 the server referring to me and how I can play with that. 552 00:27:54,820 --> 00:27:57,980 So to do that, you do something which is fairly standard, which 553 00:27:57,980 --> 00:27:58,960 is called n-gram analysis. 554 00:27:59,260 --> 00:28:03,480 It's very, a big word for, I'm going to be grim, it's actually 555 00:28:03,480 --> 00:28:05,460 a big word for something that's that simple. 556 00:28:05,700 --> 00:28:09,700 What you do is you only take the opcode and then you take the 557 00:28:09,700 --> 00:28:12,540 first packet and then the second packet, and then you say, well, 558 00:28:12,640 --> 00:28:15,200 I see these two opcodes one after the other one time. 559 00:28:15,400 --> 00:28:17,760 And then you move and you say, well, I see these two opcodes 560 00:28:17,760 --> 00:28:19,440 one after the other one time, and so forth. 561 00:28:19,920 --> 00:28:20,440 And then you move, and then you say, well, I see these two opcodes 562 00:28:20,460 --> 00:28:26,100 the end, if you repeat across all the trace, you're going to get some of them which are 563 00:28:26,100 --> 00:28:30,840 more frequent than others. And it's going to get actually rid of the noise. So if you 564 00:28:30,840 --> 00:28:36,420 actually trigger something multiple times, it's likely that at some point the answer 565 00:28:36,420 --> 00:28:41,540 and the response which are related are going to appear close together more often than others. 566 00:28:42,000 --> 00:28:45,960 I'm simplifying a little bit because you need to be a little bit more fuzzy, but that's 567 00:28:45,960 --> 00:28:52,380 the essence of this. And there is one gotcha with that. If you try to do that, do not try to 568 00:28:52,380 --> 00:28:56,680 keep high frequency packets into it because you have some packets which are like ten times a 569 00:28:56,680 --> 00:29:00,520 second so they're going to mess up your analysis so you need to actually get rid of all the high 570 00:29:00,520 --> 00:29:06,040 frequency packets before inserting it into it. So let me give you a concrete example. So far 571 00:29:06,040 --> 00:29:13,960 we've been doing a lot of hand waving. Here is a League of Legends set skill packet. So every 572 00:29:13,960 --> 00:29:15,940 time you gain a level, you get a level and you get a level and you get a level and you get a 573 00:29:15,960 --> 00:29:19,840 level. So you have the ability to select a skill and say I want to increase this skill, this 574 00:29:19,840 --> 00:29:26,480 skill, or this skill. What you actually do is we pull out the trace for you and in blue there is 575 00:29:26,480 --> 00:29:32,100 the op code, 3E, and then you have 1B, 1C, 1A, 1B, which is the second column which is 576 00:29:32,100 --> 00:29:38,060 basically the player ID. How we know that, we know that because if you use, if you look at one 577 00:29:38,060 --> 00:29:42,100 trace, it's fixed. If you look at multiple trace with multiple players, it's actually become 578 00:29:42,100 --> 00:29:45,940 viable so we know it's actually linked to the player. And then at the end of the day, if you 579 00:29:45,940 --> 00:29:54,300 have 0, 0, 2, 0, 3, 0, et cetera, it's actually from 0, 0 to 0, 5 and then we took a deeper look at 580 00:29:54,300 --> 00:29:59,440 that by basically clicking on one of the slots and then looking at what packet we got by playing 581 00:29:59,440 --> 00:30:04,780 the game and looking at the output at the same time and it's actually the slot position. So what 582 00:30:04,780 --> 00:30:12,700 the packet says is I want to put the player ID X, I want to put one more point to this slot. And 583 00:30:12,700 --> 00:30:15,920 then you need the answer, right? And so we did this frequency analysis and then go back to the 584 00:30:15,940 --> 00:30:20,640 program and we get the answer and the answer is 18. And so 18 is the same thing. You have the 585 00:30:20,640 --> 00:30:25,340 player ID, followed by the slot position you actually said and then the server tells you how 586 00:30:25,340 --> 00:30:33,860 much you have. Right? So basically it tells you well for slot position 1, which is 0, 0, you get a 587 00:30:33,860 --> 00:30:41,880 skill between 0, 1 and 0, 6 which is the maximum you can get for a given skill. And you look at 588 00:30:46,860 --> 00:30:51,880 this and you're like yes, no, maybe. Yes. It seems to be there is a bug where you're like well, 589 00:30:52,040 --> 00:30:59,000 if the server sends me how much power I can get for a given slot, what happens if I rewrite 0, 1 590 00:30:59,000 --> 00:31:03,120 to let's say 0, 6. So I get like I said I'm going to assign one point and then I stop the 591 00:31:03,120 --> 00:31:07,080 packet from the server and I say well, no, in reality you don't get one more point, you get like 592 00:31:07,080 --> 00:31:15,920 six more points. It sort of works in the sense that your client is going to believe that you're 593 00:31:15,940 --> 00:31:20,760 actually have six. So your client is going to believe what the servers say and he's going to 594 00:31:20,760 --> 00:31:27,560 say yes, you have a spell of six. But when you try to use it, it won't work because actually the 595 00:31:27,560 --> 00:31:33,020 server keeps tab of how much DPS you do. So actually even you can pretend to have the skill 596 00:31:33,020 --> 00:31:38,300 but it's actually not going to do anything because they do the computation on the server. I 597 00:31:38,300 --> 00:31:45,920 don't know when they fixed it, but it's fixed. All right. Another way to do this is you can 598 00:31:45,940 --> 00:31:54,420 do it, we found very useful is binding a specific set of keystroke to our keyboard before we're 599 00:31:54,420 --> 00:32:01,740 doing an action. So we actually say we usually use control X. And so we press control X just 600 00:32:01,740 --> 00:32:08,500 before we want to the action we're interested in and then our software actually adds to the 601 00:32:08,500 --> 00:32:14,760 trace. So a click event into the trace. And after that what we do is we usually look at the 602 00:32:14,760 --> 00:32:15,920 end few packet after the end few packet. And then we have to go back and do the same thing. So 603 00:32:15,940 --> 00:32:21,200 after that, so it's actually helping basically the game and looking at the trace at the same 604 00:32:21,200 --> 00:32:26,360 time putting the click at that point is actually help us to isolate the packets we want to look 605 00:32:26,360 --> 00:32:30,000 at. If you don't want to do all the different analysis and stuff, the easiest way is just to 606 00:32:30,000 --> 00:32:34,880 record a specific sequence and say, well, I want you to know what are the packets from this 607 00:32:34,880 --> 00:32:39,940 particular point in time and then you can actually look at only these packets. Again, what we 608 00:32:39,940 --> 00:32:45,620 want to come across is don't try to reverse the entire protocol because most of the protocol 609 00:32:45,940 --> 00:32:50,820 are sort of independent. Just try to focus on the one you are really interested in like attacking 610 00:32:50,820 --> 00:32:56,680 or setting an item or removing an item and then just look at those packets. And if you look at 611 00:32:56,680 --> 00:33:01,800 enough of those packets, you're going to find a recurrence and then with this you can actually 612 00:33:01,800 --> 00:33:08,960 figure out how the protocol works. And then for the next part I'm going to let Patrick tell you a 613 00:33:08,960 --> 00:33:10,440 little bit more how we monitor the results. 614 00:33:18,020 --> 00:33:25,000 Okay. So what about monitoring the results? Remember the bigger picture is to build 615 00:33:25,000 --> 00:33:32,840 a fuzzer. So we kind of need some way to automate the monitoring of the results so that we can 616 00:33:32,840 --> 00:33:42,140 build some scripts, for example, that is going to check whether or not we succeeded. So how do I 617 00:33:42,140 --> 00:33:45,920 do that? As my packet affected the data, I'm going to have to do a little bit more of a 618 00:33:45,940 --> 00:33:55,780 look at the game state. To do that, we need to read the state of the game. We have a couple of 619 00:33:55,780 --> 00:34:04,080 ways to do that. The first one is to read the game memory. So we are going to inject a packet and 620 00:34:04,080 --> 00:34:11,100 then we need to find the memory of sets of the potential value that is going to be affected. And 621 00:34:11,100 --> 00:34:21,280 this value will give us an idea of how we succeeded in changing the state of the game. For example, 622 00:34:21,300 --> 00:34:31,740 if we take the health of the player of the number of gold pieces, we can say that I have 10 gold and 623 00:34:31,740 --> 00:34:41,080 now I'm trying to buy an item and I have 11 gold. So did my injection work? So I'm going to try to 624 00:34:41,100 --> 00:34:41,520 figure out how we can change all of these values to give us a better idea of how we can 625 00:34:41,520 --> 00:34:48,940 get the value of the other. So how do I find the upset in the memory? The idea is to start with the 626 00:34:48,940 --> 00:34:56,020 complete armor, for example, and take a snapshot of the memory. Then you remove one piece of 627 00:34:56,020 --> 00:35:10,160 armor and you do the same thing. You filter all the values that didn't change and you keep good stuff. And then you do it again. You change another piece of armor and you take another snapshot and filter the values. 628 00:35:11,100 --> 00:35:16,400 again and again. And at the end, it's likely that you will find 629 00:35:16,400 --> 00:35:25,760 the relevant value in a couple of iterations. What if the 630 00:35:25,760 --> 00:35:32,340 offset is encrypted or obfuscated? Usually not all the 631 00:35:32,340 --> 00:35:40,320 structure is encrypted. It's only the interesting values. So 632 00:35:40,320 --> 00:35:42,960 for example, the player structure that is not encrypted. 633 00:35:44,520 --> 00:35:50,480 The idea is, for instance, in Diablo 3, the goal value is not 634 00:35:50,480 --> 00:35:55,300 encrypted in the player structure. So it's actually a 635 00:35:55,300 --> 00:36:00,460 float. So you can find this value and then climb up or down 636 00:36:00,460 --> 00:36:05,140 in the structure to find the health value. And then you get 637 00:36:05,140 --> 00:36:08,780 the offset in the structure and you can get the actual memory 638 00:36:08,780 --> 00:36:09,160 address. 639 00:36:11,540 --> 00:36:17,620 Another option would be to do more set and unset on the value 640 00:36:18,330 --> 00:36:21,920 until you get only one value. But this can take a lot of time 641 00:36:21,920 --> 00:36:29,220 and a lot of iterations. If it's obfuscated, the thing that you 642 00:36:29,220 --> 00:36:34,280 can do is just look for a value that changes or changes and try 643 00:36:34,280 --> 00:36:40,300 to extract what is important for you. And then find out how it 644 00:36:40,320 --> 00:36:46,560 is obfuscated. Okay. So that's it for the game analysis. Thank 645 00:36:46,560 --> 00:36:50,920 you for coming. And you can follow us on Twitter or G+.