1 00:00:13,560 --> 00:00:18,420 All right, thank you for coming to this presentation, Embedded Reverse Engineering Cracking Mobile 2 00:00:18,420 --> 00:00:25,020 Binaries. In short, I'll be showing you how to crack a mobile binary or an EXE on the 3 00:00:25,020 --> 00:00:31,580 Pocket PC platform. Although it is targeted more for the Microsoft side of things, the 4 00:00:31,580 --> 00:00:37,520 information I am presenting is also geared toward the ARM processor, which is multi-platform 5 00:00:37,520 --> 00:00:41,060 and multi-device. So you can use some of this knowledge with other things, too. 6 00:00:41,640 --> 00:00:48,820 Before I actually get started, I have some swag to give away. And this is kind of a self-promotional 7 00:00:48,820 --> 00:00:54,660 thing, too. I co-authored this. If you don't win, you can buy it. It's available. As I 8 00:00:54,660 --> 00:00:55,000 look around, I see a lot of people. I see a lot of people. I see a lot of people. I 9 00:00:55,020 --> 00:00:59,760 look around. This isn't as black of a crowd with the shirts as I expected. I've heard 10 00:00:59,760 --> 00:01:03,340 this referred to as an oil pit by some people with the number of black shirts in here. 11 00:01:03,700 --> 00:01:07,220 Anyway, I want to give this first book to the person wearing the brightest, most obnoxious 12 00:01:07,220 --> 00:01:11,720 shirt. And I think I can spot him from here, the tie-dye man right here. So I'll give 13 00:01:11,720 --> 00:01:12,500 you the first one. 14 00:01:18,040 --> 00:01:23,880 The second one, picking on another stereotype, most of us are probably 35 or under. So I 15 00:01:23,880 --> 00:01:28,300 want to give this to the oldest person in the crowd. So is there anybody 65 or older? 16 00:01:30,500 --> 00:01:42,100 Yeah. Is anybody going to admit to 55 or older? Come on up. Come on up. Very good. I want 17 00:01:42,100 --> 00:01:49,800 to be coming to DEF CON at your age. Now, the third one is kind of funny because I received 18 00:01:49,800 --> 00:01:53,860 two of these in the mail a couple of weeks ago. I don't know why they sent me two. It's 19 00:01:53,880 --> 00:01:58,100 in traditional Chinese. I can't read one of them. So why they sent me two is beyond 20 00:01:58,100 --> 00:02:12,080 me. Does anybody know traditional Chinese? Come on up. It's yours. And if you haven't 21 00:02:12,080 --> 00:02:18,660 seen one of these yet, you probably haven't been in a talk. Let's see. I'll just give 22 00:02:18,660 --> 00:02:23,200 it to the first person who can make it. Okay. Come on up. He's coming behind you, man. He 23 00:02:23,200 --> 00:02:23,560 beat you. 24 00:02:23,880 --> 00:02:31,220 There you go. All right. Now to get started on this. Who am I? What am I doing here? How 25 00:02:31,220 --> 00:02:37,140 many people got their way paid? Yeah. I had to basically come up here and speak to get 26 00:02:37,140 --> 00:02:42,040 my way paid. So for the rest of you, this is one way to get a free ticket to DEF CON 27 00:02:42,040 --> 00:02:45,200 if you can find a company to sponsor you. And Air Scanner is a company that sponsored 28 00:02:45,200 --> 00:02:49,780 me. They do mobile security software. And if you forget, there are little logos in the 29 00:02:49,780 --> 00:02:53,180 upper left-hand corner of every slide. So I don't think you'll forget very easily. 30 00:02:53,880 --> 00:02:59,960 Anyway, I have always been attracted to reverse engineering since I was a kid at the toaster 31 00:02:59,960 --> 00:03:04,520 and remote-controlled cars and whatever else. I'm sure many of you can share that. It's 32 00:03:04,520 --> 00:03:10,260 that same kind of feeling. To me, it's a tool, not a weapon. And with computers, it's 33 00:03:10,260 --> 00:03:15,080 all about knowing your computer. So this is why I targeted this particular subject. 34 00:03:15,960 --> 00:03:20,760 There is a darker side to reverse engineering. Most of us are familiar with cracking software. 35 00:03:22,980 --> 00:03:27,080 Payer programmers, especially in the US, programmers are already seeing a lot of their 36 00:03:27,080 --> 00:03:31,100 jobs outsourced. So they're losing money. And that's about all I'll say. 37 00:03:31,980 --> 00:03:38,540 Have to cover the legal issues. This is reverse engineering. And in some contents, it's illegal. 38 00:03:39,160 --> 00:03:44,220 I'll just read this verbatim. No person shall circumvent a technological measure that effectively 39 00:03:44,220 --> 00:03:49,400 controls access to a work protected under this title. And this title is the law it pertains 40 00:03:49,400 --> 00:03:50,740 to. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 00:03:51,300 --> 00:04:16,260 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 00:04:16,260 --> 00:04:17,300 It's just that it's not effective. 43 00:04:18,080 --> 00:04:18,520 What? 44 00:04:18,680 --> 00:04:21,100 If you're telling me it's not effective, it's not effective. 45 00:04:23,320 --> 00:04:24,040 It's not effective? 46 00:04:24,440 --> 00:04:24,860 Right. 47 00:04:27,380 --> 00:04:27,820 Okay. 48 00:04:32,940 --> 00:04:35,100 Yeah, I'll take questions again. 49 00:04:35,220 --> 00:04:35,880 Anyway, I've got to move on. 50 00:04:35,920 --> 00:04:37,260 This takes 50 minutes. 51 00:04:37,540 --> 00:04:39,300 I am going to show a serial protection. 52 00:04:39,540 --> 00:04:42,640 I'm going to show that basically you want to program your stuff right. 53 00:04:42,740 --> 00:04:46,060 If you program it simply and you look at the upper level languages, 54 00:04:46,260 --> 00:04:47,660 and you think your serial protection is secure, 55 00:04:48,740 --> 00:04:50,880 you're probably misled because at the bottom level, 56 00:04:51,020 --> 00:04:54,280 when you're dealing with an assembler, it's probably going to be flawed. 57 00:04:54,460 --> 00:04:55,840 Most serial protections are flawed. 58 00:04:56,760 --> 00:04:58,100 Okay, now get into it. 59 00:04:58,300 --> 00:04:59,680 I'm going to skip these because I don't have time. 60 00:05:00,380 --> 00:05:01,920 There are some memory issues. 61 00:05:02,060 --> 00:05:05,620 If you own one of these devices and you ever let the power run out on it, 62 00:05:05,680 --> 00:05:07,320 you'll know that you probably lost all your files, 63 00:05:07,740 --> 00:05:09,620 except for the stuff stored on the compact flash. 64 00:05:09,840 --> 00:05:11,060 That's because it's stored in RAM. 65 00:05:11,280 --> 00:05:12,920 We all know RAM needs power to survive. 66 00:05:13,240 --> 00:05:15,780 The OS files are stored on the ROM, 67 00:05:15,780 --> 00:05:16,840 so they don't get lost. 68 00:05:18,280 --> 00:05:22,780 There's a unique issue with the way the files are on here. 69 00:05:23,040 --> 00:05:25,980 The OS files are executable in place, 70 00:05:26,100 --> 00:05:29,340 so that means they don't need to be dumped to RAM to run, 71 00:05:29,440 --> 00:05:30,580 so it saves your RAM resources. 72 00:05:31,240 --> 00:05:33,740 Unless they're compressed, then they have to be decompressed to the RAM, 73 00:05:33,880 --> 00:05:36,880 which adds a little kind of an issue when you're debugging software 74 00:05:36,880 --> 00:05:38,560 because you can't debug it straight from the RAM. 75 00:05:38,820 --> 00:05:39,900 Something to keep in mind. 76 00:05:39,920 --> 00:05:41,480 We won't really see that here, 77 00:05:41,640 --> 00:05:44,340 but if you move on and run with this, keep that in mind. 78 00:05:46,560 --> 00:05:51,220 Moving on, there are some prerequisites to being able to reverse engineer. 79 00:05:51,420 --> 00:05:54,200 You've got to understand where assembly fits in the broad scheme of things, 80 00:05:54,380 --> 00:05:57,160 that it's a lower-level language, it's not an upper-level language. 81 00:05:58,020 --> 00:06:00,760 It's simply one step up from the machine code, the binary, 82 00:06:00,800 --> 00:06:02,080 that the actual processor reads. 83 00:06:02,280 --> 00:06:04,660 It's a way for us humans to understand it more easily. 84 00:06:04,940 --> 00:06:08,420 You've got to understand the conversions between hex to binary, ASCII to decimal. 85 00:06:09,320 --> 00:06:10,160 Enough said there. 86 00:06:10,300 --> 00:06:12,860 I hope you all know that, or at least are able to figure that out. 87 00:06:13,520 --> 00:06:15,760 However, the ARM processor has a lot of problems. 88 00:06:15,780 --> 00:06:18,220 It has a lot of specifics in it that you do need to understand. 89 00:06:18,540 --> 00:06:20,520 That is the registers and the opcodes, 90 00:06:20,740 --> 00:06:23,600 and how the registers work, and what the opcodes are, and how they work. 91 00:06:23,960 --> 00:06:25,660 We're going to be covering some of those here, 92 00:06:25,820 --> 00:06:28,460 not all of them because there will be more time than I'm allotted. 93 00:06:29,920 --> 00:06:31,400 To start, the registers. 94 00:06:31,640 --> 00:06:33,540 There are 37 total registers. 95 00:06:33,860 --> 00:06:35,700 The registers are used by the processor, 96 00:06:35,920 --> 00:06:38,780 so it doesn't have to keep writing back and forth in RAM. 97 00:06:38,960 --> 00:06:40,340 It basically speeds the process up. 98 00:06:41,520 --> 00:06:43,820 The register purpose changes depending on mode. 99 00:06:43,980 --> 00:06:44,800 You'll read about this. 100 00:06:44,860 --> 00:06:45,620 This is more of an upload. 101 00:06:45,780 --> 00:06:45,980 This is a level thing. 102 00:06:46,980 --> 00:06:50,320 However, there are some registers that we need to definitely pay attention to. 103 00:06:50,860 --> 00:06:53,560 Register 15 is the program counter. 104 00:06:53,700 --> 00:06:57,800 This is important to watch because it lets you know where in the program you are actually executing at. 105 00:06:58,440 --> 00:07:00,380 Register 14 is the link register. 106 00:07:00,740 --> 00:07:03,660 That's if a program is executing through and needs to go to a subroutine. 107 00:07:03,960 --> 00:07:06,880 It'll continue executing, but it has to know where to bounce back. 108 00:07:07,140 --> 00:07:08,320 That's what the link register is for. 109 00:07:08,380 --> 00:07:10,720 It points back to where you need to continue executing at. 110 00:07:11,400 --> 00:07:13,260 Register 13 points to the stack. 111 00:07:13,520 --> 00:07:15,480 Now, the stack, most of you are probably familiar with. 112 00:07:15,480 --> 00:07:19,140 The idea of a stack is simply is used to hold the temporary values 113 00:07:19,140 --> 00:07:20,940 and the variables that are used by your program, 114 00:07:22,280 --> 00:07:25,000 including register values when a subroutine is called. 115 00:07:25,160 --> 00:07:26,620 Those values will have to be put aside, 116 00:07:26,800 --> 00:07:30,260 so the subroutine can then use the registers, how the stack is used. 117 00:07:30,600 --> 00:07:36,260 There are four registers, 31 through 28, which are used as status flags. 118 00:07:36,460 --> 00:07:39,020 These control how your program flows. 119 00:07:39,360 --> 00:07:40,460 We'll get into that more. 120 00:07:40,940 --> 00:07:45,020 In particular, if you're starting out, you need to pay a lot of attention to register 31, 121 00:07:45,480 --> 00:07:46,420 and register 30. 122 00:07:46,800 --> 00:07:51,960 And these are used to, register 31 is a negative, or it's the less than. 123 00:07:52,120 --> 00:07:55,340 So these status flags can mean more than one thing. 124 00:07:55,560 --> 00:07:58,560 And you got to keep that in mind as you're watching the program execute. 125 00:07:58,840 --> 00:08:01,680 What am I actually using the status flag for at this point? 126 00:08:01,900 --> 00:08:05,740 And you'll understand as we get into how the status flags work, and we'll show this. 127 00:08:06,320 --> 00:08:07,960 The same thing about register 30. 128 00:08:08,100 --> 00:08:10,520 And this is a little bit confusing if you're new at this, 129 00:08:10,620 --> 00:08:15,220 because if a value is zero and it's checked, the zero flag 130 00:08:15,220 --> 00:08:16,240 will be updated to one. 131 00:08:16,580 --> 00:08:19,220 If the value is equal, it'll be updated to one. 132 00:08:19,520 --> 00:08:24,120 So, basically, just watch how the zero is working. 133 00:08:24,320 --> 00:08:25,460 You might kind of get confused. 134 00:08:25,560 --> 00:08:27,880 If it's zero, then it should be zero, and it's not really works that way. 135 00:08:29,800 --> 00:08:35,860 Here is a screenshot of the register window and the Microsoft debugger, 136 00:08:35,920 --> 00:08:36,560 which I will show you. 137 00:08:36,740 --> 00:08:39,460 I just want you to see how these, while we're talking about registers, 138 00:08:39,680 --> 00:08:43,400 you have registers zero through register 12 that are listed as they are. 139 00:08:43,540 --> 00:08:45,120 Now, the stack pointer is registered. 140 00:08:45,120 --> 00:08:49,180 Register 13, link register 14, program counter is 15. 141 00:08:50,320 --> 00:08:55,960 Here you can also see the negative, the status flags basically right listed here. 142 00:08:58,300 --> 00:09:02,020 Jumping on to the opcodes now, I'm going to touch on like eight of them 143 00:09:02,020 --> 00:09:03,260 or something like that that we'll be using. 144 00:09:03,520 --> 00:09:05,400 The first one is the move opcode. 145 00:09:05,560 --> 00:09:09,140 It simply moves a value from a register into another register 146 00:09:09,140 --> 00:09:12,420 or from a hard-coded value in the program into a register. 147 00:09:12,740 --> 00:09:14,520 And if you note over here, 148 00:09:14,520 --> 00:09:16,800 on the right where the hex is, 149 00:09:16,940 --> 00:09:19,420 I included that so you can kind of get a feeling for, 150 00:09:20,400 --> 00:09:23,380 you have to pay a lot of attention to detail when you're working with this. 151 00:09:23,500 --> 00:09:25,260 Because this, if you wanted to change a value, 152 00:09:25,420 --> 00:09:29,600 you have to make sure that you pay attention to all the characters in your hex. 153 00:09:31,340 --> 00:09:33,680 The compare opcode, this again, 154 00:09:33,840 --> 00:09:36,980 it'll just compare a value in a register to another register 155 00:09:37,460 --> 00:09:39,060 or a hard-coded value to a register. 156 00:09:39,300 --> 00:09:44,180 And again, I included the hex just so you can see that there's just a slight variation between the two, 157 00:09:44,180 --> 00:09:45,300 but it makes a big difference. 158 00:09:45,480 --> 00:09:49,240 If you forget that, your program, and you try and change something in your program, 159 00:09:49,800 --> 00:09:52,480 you'll probably get confused, you'll forget what you changed, 160 00:09:52,640 --> 00:09:54,160 and then you might as well start over. 161 00:09:56,800 --> 00:09:59,380 All right, status flags, talked a little bit about this. 162 00:09:59,540 --> 00:10:01,500 Here you can see how the status flags work. 163 00:10:01,860 --> 00:10:06,940 I have the compare status flag, the compare opcode comparing R1 to R0. 164 00:10:07,120 --> 00:10:12,200 Now the negative, the end status flag is updated according to which value is greater. 165 00:10:14,180 --> 00:10:17,260 If R0 is greater than R1, then the status flag will remain zero. 166 00:10:18,700 --> 00:10:22,040 If R1 is greater than R0, the status flag will be updated to one. 167 00:10:22,640 --> 00:10:27,340 The Z status flag with the compare opcode basically looks to see if the values are the same. 168 00:10:27,600 --> 00:10:31,380 The result determines whether or not the Z is set to one or the Z is set to zero. 169 00:10:31,580 --> 00:10:33,920 And the carry kind of works opposite of the negative. 170 00:10:34,300 --> 00:10:38,980 Now if you note, down here at the moves, that S, if you're familiar with x86 debugging, 171 00:10:39,340 --> 00:10:40,780 that does not mean move string. 172 00:10:41,020 --> 00:10:44,160 That means perform the move and then update the status flag. 173 00:10:44,700 --> 00:10:47,140 And here, the same thing with the ands opcode. 174 00:10:49,040 --> 00:10:53,580 Basically, when flags are updated, they're updated based on the resultant value. 175 00:10:54,240 --> 00:10:57,100 Now in the case of the move, both values are going to be the same, 176 00:10:57,180 --> 00:10:59,420 so it doesn't really make a difference which value you use. 177 00:10:59,580 --> 00:11:03,900 And the ands opcode, if you use, well, if you and R1 and FF together, 178 00:11:04,100 --> 00:11:06,800 then R0 is where the resultant value is written to. 179 00:11:08,340 --> 00:11:11,820 Your status flags are updated based on that value in R0. 180 00:11:12,520 --> 00:11:13,920 Here you can see how it works. 181 00:11:14,180 --> 00:11:16,680 The Z status flag isn't really updated with these two. 182 00:11:17,640 --> 00:11:19,020 Here are a list. 183 00:11:19,180 --> 00:11:20,120 This is a good reference. 184 00:11:20,220 --> 00:11:23,440 You need to be familiar with at least recognizing what they are 185 00:11:23,440 --> 00:11:24,880 and how they control the program flow. 186 00:11:26,180 --> 00:11:27,700 Here's a list of all the status flags. 187 00:11:28,600 --> 00:11:32,440 Primarily, we'll be looking at the equal, not equal, and greater than and less than. 188 00:11:32,560 --> 00:11:33,260 Pretty straightforward. 189 00:11:33,520 --> 00:11:34,820 Most people understand basic math. 190 00:11:36,000 --> 00:11:36,660 Moving on. 191 00:11:37,160 --> 00:11:41,820 Now the status flags are used by the opcodes to determine program flow. 192 00:11:42,160 --> 00:11:43,800 Now here I have the branch opcode. 193 00:11:44,180 --> 00:11:46,240 Which runs down through a program. 194 00:11:46,320 --> 00:11:50,300 If the branch opcode is in there, it'll bounce it out to another address. 195 00:11:50,580 --> 00:11:53,580 The branch of the link is used for subroutines. 196 00:11:53,660 --> 00:11:56,680 If you run that program through the program, you have a subroutine, 197 00:11:56,820 --> 00:11:58,920 it bounces out, and then it bounces back. 198 00:11:59,200 --> 00:12:02,880 Now the branch will only be executed in the case of the branch equal 199 00:12:03,320 --> 00:12:05,460 if the Z status flag is updated to one. 200 00:12:06,660 --> 00:12:09,360 And the not equal if the Z status flag is updated to zero. 201 00:12:09,500 --> 00:12:14,020 So you can see here again, I listed a part of the hex that you can see that changes. 202 00:12:16,800 --> 00:12:18,960 The load register and store register. 203 00:12:19,360 --> 00:12:24,080 These two are used to write values either to the memory from a register 204 00:12:24,080 --> 00:12:26,620 or pull memory into a register. 205 00:12:27,020 --> 00:12:31,080 And the load loads the value from the memory into the register 206 00:12:31,080 --> 00:12:32,860 and the store stores it into memory. 207 00:12:33,820 --> 00:12:37,320 Here you can see variations in how it's used. 208 00:12:37,540 --> 00:12:40,140 There are numerous ways that they can be combined. 209 00:12:40,400 --> 00:12:43,340 Values can be added, registers can be added, it can be stored back to itself 210 00:12:43,340 --> 00:12:44,600 or not stored back to itself. 211 00:12:45,300 --> 00:12:49,960 This is kind of like a second level if you want to continue looking at reverse engineering. 212 00:12:51,200 --> 00:12:54,640 However, at the bottom here, the load multiple and the store multiple, 213 00:12:54,880 --> 00:12:59,920 they are used particularly when there's a subroutine called. 214 00:13:00,120 --> 00:13:04,500 They said the program executes down through, the subroutine is called out, 215 00:13:04,540 --> 00:13:09,380 the values in the main program that are being used have to be stored on the stack, 216 00:13:09,560 --> 00:13:10,600 and that's what this is used for. 217 00:13:10,740 --> 00:13:11,740 You'll see this a lot. 218 00:13:12,000 --> 00:13:13,320 And it's important to recognize that. 219 00:13:13,340 --> 00:13:15,500 because that means there's probably a subroutine being called. 220 00:13:15,780 --> 00:13:19,080 And the load will then load the values back off the stack 221 00:13:19,080 --> 00:13:20,320 into your registers again. 222 00:13:22,680 --> 00:13:26,100 And I'll talk about logical shift right, logical shift left. 223 00:13:26,200 --> 00:13:28,140 These are just used to move, 224 00:13:28,340 --> 00:13:31,620 basically it moves the binary value of, 225 00:13:31,740 --> 00:13:35,560 or the binary representation padded left or right with zeros. 226 00:13:36,620 --> 00:13:38,820 They can be, you can also have arithmetic, 227 00:13:38,820 --> 00:13:42,460 which will keep your sign bit, 228 00:13:43,540 --> 00:13:45,740 which keeps things flowing right. 229 00:13:45,800 --> 00:13:47,500 This is kind of a second level, we won't use it here. 230 00:13:48,560 --> 00:13:51,000 But it's important to be able to recognize what they're used for, 231 00:13:51,100 --> 00:13:51,960 if you see them. 232 00:13:52,820 --> 00:13:56,500 Now there are three main tools that we use for reverse engineering. 233 00:13:56,760 --> 00:13:59,020 The hex editor, disassembler, and debugger. 234 00:14:00,020 --> 00:14:03,120 The hex editor basically is just used to look at a file in hex, 235 00:14:03,260 --> 00:14:06,160 and you can then update that file with the values that you need 236 00:14:06,160 --> 00:14:08,800 to make it do what you want. 237 00:14:08,820 --> 00:14:11,700 I use UltraEdit32 in this demonstration. 238 00:14:13,060 --> 00:14:14,880 You're probably all familiar with the hex editor, 239 00:14:15,060 --> 00:14:16,640 and you probably have your own preference. 240 00:14:16,860 --> 00:14:18,880 This one just works in Windows and works in a presentation. 241 00:14:21,080 --> 00:14:24,840 Disassembler, this converts your program file into its assembly code, 242 00:14:24,940 --> 00:14:26,580 so you can actually understand what's going on, 243 00:14:26,660 --> 00:14:28,260 and you can basically read it. 244 00:14:28,540 --> 00:14:31,700 I use IDA Pro, there again, there's numerous ones, 245 00:14:31,840 --> 00:14:34,400 but IDA is pretty much the industry recognized, 246 00:14:34,660 --> 00:14:35,880 especially with people like us. 247 00:14:37,120 --> 00:14:38,200 Then the debugger. 248 00:14:38,240 --> 00:14:38,800 Now the debugger, 249 00:14:38,820 --> 00:14:40,440 you don't really have too much choice, 250 00:14:40,540 --> 00:14:41,580 especially on the Windows platform. 251 00:14:42,000 --> 00:14:44,500 However, Microsoft does provide a free debugger, 252 00:14:45,040 --> 00:14:46,560 which is nice of them. 253 00:14:47,000 --> 00:14:48,840 If you use one of these devices, 254 00:14:49,140 --> 00:14:51,160 you probably are familiar with the active sync 255 00:14:51,160 --> 00:14:54,280 and connecting up to your laptop or whatever with a USB connection. 256 00:14:54,780 --> 00:14:58,200 You can debug over USB, but it's painstakingly slow. 257 00:14:58,460 --> 00:15:00,320 You will crawl, and you'll get frustrated. 258 00:15:00,580 --> 00:15:04,680 I recommend that you connect it up with a regular wired network 259 00:15:04,680 --> 00:15:05,640 or a wireless network. 260 00:15:05,880 --> 00:15:08,040 I wasn't going to use wireless here because, well, 261 00:15:08,040 --> 00:15:10,520 I don't want to get kicked off my own wireless demonstration or whatever. 262 00:15:11,020 --> 00:15:13,920 So I have a crossover cable plugged right into my computer, 263 00:15:14,100 --> 00:15:16,840 full 10 megabit connection, it works beautifully. 264 00:15:17,080 --> 00:15:19,720 And it's practically instantaneous debugging. 265 00:15:20,300 --> 00:15:23,220 So you will need a program called Pocket Hosts for this, 266 00:15:23,300 --> 00:15:26,820 which is basically just a host file for the Pocket PC platform. 267 00:15:30,060 --> 00:15:33,360 Okay, now I debated whether or not to use two laptops at this point, 268 00:15:33,380 --> 00:15:35,880 but I went with one so we can see the screens. 269 00:15:36,380 --> 00:15:37,520 I'm going to jump out. 270 00:15:37,520 --> 00:15:41,380 At this point, we're going to go into IDA and we're going to load the file in. 271 00:15:41,740 --> 00:15:44,920 And before you do anything, any reversing, 272 00:15:44,920 --> 00:15:48,940 you have to have the actual executable file on your local computer. 273 00:15:49,160 --> 00:15:53,600 So you can't reverse it directly from here as easily. 274 00:15:53,720 --> 00:15:58,720 IDA has a special, well, it works better as a reverser than the debugger, 275 00:15:58,780 --> 00:16:00,300 although you can reverse with a debugger. 276 00:16:00,380 --> 00:16:02,960 It's kind of difficult to follow what's going on sometimes. 277 00:16:05,120 --> 00:16:07,420 So when we pull, when we load up, 278 00:16:07,520 --> 00:16:10,220 IDA, we need a place to hook into the program. 279 00:16:10,380 --> 00:16:13,680 We've got to figure out where it's going or what it's doing 280 00:16:13,680 --> 00:16:19,260 and basically try and find some place that we can just figure out what's going on. 281 00:16:19,580 --> 00:16:20,840 And there are some options. 282 00:16:20,980 --> 00:16:22,760 The more you do this, the more you learn to recognize 283 00:16:22,760 --> 00:16:25,960 what these functions are for and how they're used. 284 00:16:26,760 --> 00:16:30,620 One of the primary ones that are used in serial protection is the string compare 285 00:16:31,220 --> 00:16:34,220 because it basically compares a serial string with another serial string. 286 00:16:35,740 --> 00:16:37,200 This is one of the, 287 00:16:37,520 --> 00:16:40,340 one of the biggest taboos that you should not do is use a string compare, 288 00:16:40,500 --> 00:16:41,920 but people are still doing it. 289 00:16:42,660 --> 00:16:44,200 You can also use a message box 290 00:16:44,200 --> 00:16:47,260 because what's the first thing that happens if you enter the wrong serial string? 291 00:16:47,560 --> 00:16:50,060 It's going to get a message box saying you entered the wrong serial string. 292 00:16:50,280 --> 00:16:52,540 And that's just another way to hook right into the program 293 00:16:52,540 --> 00:16:53,500 and figure out what's going on. 294 00:16:55,000 --> 00:16:56,740 Let's see, I'm going to escape out of here. 295 00:16:57,520 --> 00:16:58,700 Jump into IDA. 296 00:17:00,440 --> 00:17:03,260 And here you can see the best way to do this is with the names window. 297 00:17:04,540 --> 00:17:07,240 Now, I know my string compare is right here. 298 00:17:07,520 --> 00:17:09,300 And IDA makes it really easy. 299 00:17:09,340 --> 00:17:10,300 It points right to the address. 300 00:17:10,700 --> 00:17:13,800 All I have to do is double click on it and I'm right there. 301 00:17:15,560 --> 00:17:16,660 I'll close this window. 302 00:17:17,220 --> 00:17:18,200 Let's see, open up this. 303 00:17:21,500 --> 00:17:22,580 Go to this next screen. 304 00:17:22,800 --> 00:17:24,660 This is an illustration of what you do not do. 305 00:17:26,900 --> 00:17:30,700 I give you one guess what these functions will actually point you to. 306 00:17:31,440 --> 00:17:34,320 A registration check perhaps or maybe an invalid registration. 307 00:17:35,780 --> 00:17:37,160 So if you're programming, 308 00:17:37,520 --> 00:17:38,980 you kind of want to, I mean, 309 00:17:39,720 --> 00:17:40,900 obsecurity is not security, 310 00:17:41,200 --> 00:17:42,800 but if you don't want to make it too easy, 311 00:17:42,920 --> 00:17:44,340 don't use something obvious like this. 312 00:17:46,740 --> 00:17:49,300 Here is a screenshot of IDA. 313 00:17:49,360 --> 00:17:50,720 And this is where we're at in the program. 314 00:17:51,160 --> 00:17:52,920 You can see the circle points. 315 00:17:53,180 --> 00:17:56,580 This is where it references it to inside the program. 316 00:17:57,840 --> 00:17:59,580 If there are two points of reference, 317 00:17:59,700 --> 00:18:00,920 like the function is used twice, 318 00:18:01,000 --> 00:18:02,000 it will have two listings. 319 00:18:02,140 --> 00:18:04,140 If there are three or more, it will have a dot, dot, dot. 320 00:18:04,260 --> 00:18:06,340 You simply click on it and it will open up a nice window. 321 00:18:07,520 --> 00:18:07,800 This is where you want to go to. 322 00:18:08,060 --> 00:18:10,040 And you double click it again and you're there. 323 00:18:10,540 --> 00:18:12,780 You may have to hunt and peck for a while 324 00:18:12,780 --> 00:18:15,260 before you find the place that you actually are looking for. 325 00:18:16,060 --> 00:18:17,460 For our illustration though, 326 00:18:17,660 --> 00:18:18,400 we are, 327 00:18:20,520 --> 00:18:21,600 we only have one, 328 00:18:21,720 --> 00:18:22,700 so here we are. 329 00:18:23,260 --> 00:18:25,300 This is the point in our program 330 00:18:25,900 --> 00:18:28,580 that our serial check is being performed. 331 00:18:29,840 --> 00:18:31,620 I'm going to start up here at the top. 332 00:18:31,720 --> 00:18:32,540 Back over here. 333 00:18:35,060 --> 00:18:36,060 The point in the program. 334 00:18:37,520 --> 00:18:38,980 This is the code that we're looking at. 335 00:18:39,120 --> 00:18:40,360 I don't know if any of you have laptops 336 00:18:40,360 --> 00:18:41,060 and you're following along, 337 00:18:41,200 --> 00:18:42,680 but if you did, then you can see this. 338 00:18:42,800 --> 00:18:44,080 Or if you go through the presentation later, 339 00:18:44,180 --> 00:18:45,800 you can see this is the entire, 340 00:18:45,960 --> 00:18:47,380 basically the serial validation check 341 00:18:47,380 --> 00:18:48,080 that we're looking at. 342 00:18:50,260 --> 00:18:51,460 I use IDA. 343 00:18:52,420 --> 00:18:54,020 One important thing to keep in mind, 344 00:18:54,120 --> 00:18:55,880 well, a tip for you, 345 00:18:55,960 --> 00:18:59,000 is if you're using IDA Pro less than 4.5, 346 00:18:59,180 --> 00:19:01,620 you'll have some issues trying to figure out 347 00:19:01,620 --> 00:19:03,660 what's going on because your function calls 348 00:19:03,660 --> 00:19:05,700 will be labeled with some really cryptic stuff 349 00:19:05,700 --> 00:19:09,980 like MCE300 underscore 2445. 350 00:19:11,360 --> 00:19:13,280 You kind of have to figure out what's going on 351 00:19:13,280 --> 00:19:14,880 and how it's being used and it can get frustrating. 352 00:19:15,540 --> 00:19:17,360 Now, Data Worm, if you're familiar with him, 353 00:19:17,460 --> 00:19:19,280 he does a lot of work with reversing 354 00:19:19,280 --> 00:19:21,980 and he actually came up with the IDT files 355 00:19:21,980 --> 00:19:23,720 that convert those cryptic 356 00:19:23,720 --> 00:19:25,020 into something you can understand. 357 00:19:25,360 --> 00:19:27,220 And he has them available at his website 358 00:19:27,220 --> 00:19:31,000 and I hereby give him a public note of gratitude 359 00:19:31,000 --> 00:19:33,520 because he helped save me a lot of time working out 360 00:19:33,660 --> 00:19:34,680 some of what was going on. 361 00:19:36,640 --> 00:19:38,080 Jump back over to here. 362 00:19:38,920 --> 00:19:40,040 Now here is the program. 363 00:19:40,820 --> 00:19:41,900 You can see right here, 364 00:19:42,000 --> 00:19:43,060 we're setting up some strings 365 00:19:43,500 --> 00:19:45,520 and we're starting to load some values into the string. 366 00:19:45,840 --> 00:19:47,920 Now, because this is a simple illustration, 367 00:19:48,940 --> 00:19:49,900 my serial number 368 00:19:50,680 --> 00:19:51,800 is not really hidden. 369 00:19:51,920 --> 00:19:52,500 Here it is. 370 00:19:52,580 --> 00:19:54,100 1, 2, 3, 4, 5, 6, 7, 8. 371 00:19:54,340 --> 00:19:56,240 And I kind of start out giving you it 372 00:19:56,240 --> 00:19:58,840 but it shows you that we're working toward a goal. 373 00:19:58,980 --> 00:20:01,680 Now, this is a really sloppy code 374 00:20:01,680 --> 00:20:03,640 but it still happens to work. 375 00:20:03,660 --> 00:20:04,080 It happens quite a lot 376 00:20:04,080 --> 00:20:05,660 where the serial number is actually included 377 00:20:05,660 --> 00:20:06,400 right in the program. 378 00:20:06,580 --> 00:20:07,460 You can see it in the hex editor. 379 00:20:08,700 --> 00:20:10,240 We have another string being loaded. 380 00:20:10,540 --> 00:20:12,180 This is correct serial number. 381 00:20:14,640 --> 00:20:15,720 Thanks for registering. 382 00:20:16,300 --> 00:20:17,360 There it is, right in memory. 383 00:20:17,700 --> 00:20:18,780 And that happens a lot. 384 00:20:18,920 --> 00:20:21,900 That happens more often than it doesn't. 385 00:20:22,680 --> 00:20:23,720 Incorrect serial number. 386 00:20:24,580 --> 00:20:26,240 Please contact technical support. 387 00:20:26,640 --> 00:20:29,340 And we have a final value right here 388 00:20:29,340 --> 00:20:30,700 being loaded into the register. 389 00:20:31,600 --> 00:20:32,740 And correct serial number. 390 00:20:33,680 --> 00:20:34,860 It says, please 391 00:20:36,400 --> 00:20:37,660 verify something or another. 392 00:20:38,860 --> 00:20:39,740 Incorrect serial number. 393 00:20:39,840 --> 00:20:41,540 Please verify it was typed correctly. 394 00:20:41,720 --> 00:20:43,260 So we have two incorrect messages 395 00:20:43,260 --> 00:20:45,280 and a correct message and our serial are loaded 396 00:20:45,280 --> 00:20:46,620 into the memory and placed on the stack. 397 00:20:47,420 --> 00:20:48,940 Now, at this point, 398 00:20:49,580 --> 00:20:51,380 many of you might recognize 399 00:20:51,380 --> 00:20:53,560 this update data if you program in C++. 400 00:20:53,840 --> 00:20:55,200 It's the 401 00:20:56,180 --> 00:20:57,520 function that basically loads 402 00:20:57,520 --> 00:20:59,340 the value on the screen into your program 403 00:20:59,340 --> 00:21:00,560 so you can use it. 404 00:21:01,780 --> 00:21:03,540 Now, at this point, we're going to jump into 405 00:21:03,660 --> 00:21:04,620 the debugger side of it. 406 00:21:04,720 --> 00:21:06,540 Because this is at the point where we want to see 407 00:21:06,540 --> 00:21:07,360 what's going on. 408 00:21:09,060 --> 00:21:11,300 So, I'm in embedded Visual C++. 409 00:21:11,900 --> 00:21:13,080 Let me open up my file. 410 00:21:15,200 --> 00:21:16,700 Here it is, serial.exe. 411 00:21:18,120 --> 00:21:18,740 It's open. 412 00:21:19,600 --> 00:21:21,780 Now, as we get into here, 413 00:21:21,860 --> 00:21:23,080 the first thing you're going to want to do 414 00:21:23,080 --> 00:21:23,640 is 415 00:21:26,240 --> 00:21:27,320 again, copy the 416 00:21:27,320 --> 00:21:29,540 file over to your PC if you haven't already done so. 417 00:21:29,720 --> 00:21:30,840 And you're going to hit F11. 418 00:21:31,080 --> 00:21:33,400 And this basically just prompts the debugger 419 00:21:33,660 --> 00:21:35,720 to the first line of execution in the program. 420 00:21:36,120 --> 00:21:37,720 And you're going to want to set breakpoints. 421 00:21:38,040 --> 00:21:39,480 Breakpoints are very handy because 422 00:21:39,480 --> 00:21:41,120 especially if you're in a huge program 423 00:21:41,120 --> 00:21:43,540 with thousands and tens of thousands 424 00:21:43,540 --> 00:21:44,340 of lines of code, 425 00:21:44,860 --> 00:21:46,420 you want to be able to stop it at a point 426 00:21:46,420 --> 00:21:47,940 where you know what's going on. 427 00:21:50,420 --> 00:21:51,660 Now, we already determined 428 00:21:51,660 --> 00:21:53,680 in IDEA that we want to stop it 429 00:21:53,680 --> 00:21:55,160 right here. So, I'm going to stop it at 430 00:21:56,120 --> 00:21:57,340 11280. And you can see 431 00:21:57,340 --> 00:21:58,980 another little tip is that 432 00:21:58,980 --> 00:22:01,440 you see 00011280 433 00:22:01,440 --> 00:22:03,600 because it doesn't, it's a 434 00:22:04,960 --> 00:22:05,760 relative address 435 00:22:05,760 --> 00:22:07,160 not using a base address. 436 00:22:08,160 --> 00:22:09,520 So, you need to keep that in mind 437 00:22:09,520 --> 00:22:11,480 because in your debugger, you're going to have 438 00:22:11,480 --> 00:22:13,560 you hit F11 and it goes through 439 00:22:13,560 --> 00:22:15,040 a bunch of connections 440 00:22:16,480 --> 00:22:17,960 it'll ask you for some DLLs 441 00:22:17,960 --> 00:22:19,020 if you have a more complex program. 442 00:22:20,280 --> 00:22:20,680 And 443 00:22:21,340 --> 00:22:23,520 it'll also take about 30 seconds longer if you're using 444 00:22:23,520 --> 00:22:24,120 a USB connection. 445 00:22:26,480 --> 00:22:27,840 Right here, you can see 446 00:22:27,840 --> 00:22:28,920 back on the addressing 447 00:22:28,920 --> 00:22:31,260 we have 18. And this is just 448 00:22:31,260 --> 00:22:33,520 because it is the absolute address. It is looking at 449 00:22:33,660 --> 00:22:34,820 the real address inside the program. 450 00:22:36,500 --> 00:22:37,640 Now, I'm going to set my 451 00:22:37,640 --> 00:22:39,080 it's already pretty much set up. 452 00:22:39,180 --> 00:22:41,540 Alt F9. It's already set. It's already 453 00:22:41,540 --> 00:22:43,320 checked. I'm ready to go. Hit OK. 454 00:22:44,400 --> 00:22:45,620 Let me take a moment and talk about 455 00:22:45,620 --> 00:22:47,460 these screens here. These are probably two of your 456 00:22:47,460 --> 00:22:49,620 best buddies. This one shows you 457 00:22:49,620 --> 00:22:51,320 the register values that are currently in use. 458 00:22:51,560 --> 00:22:53,560 And this one shows you the memory address that 459 00:22:54,020 --> 00:22:55,580 you can then look up 460 00:22:55,580 --> 00:22:57,140 and see what's going on in your memory. 461 00:22:59,580 --> 00:23:01,780 Back to IDEA. Sorry, back to 462 00:23:01,780 --> 00:23:03,420 back to our program. 463 00:23:03,660 --> 00:23:05,940 Let me hit F5. 464 00:23:06,300 --> 00:23:07,560 The breakpoint set. 465 00:23:07,800 --> 00:23:09,140 I expect it to actually break. 466 00:23:10,100 --> 00:23:11,500 And it did. Well, I actually know 467 00:23:11,500 --> 00:23:13,460 the program is running. Now, this debugger includes a 468 00:23:13,460 --> 00:23:15,480 really nice tool that you can see 469 00:23:15,480 --> 00:23:17,160 what's going on on my Pocket PC. 470 00:23:18,320 --> 00:23:19,880 So, you don't get kept in the dark. 471 00:23:20,020 --> 00:23:21,620 Here's what my serial program looks like. 472 00:23:22,060 --> 00:23:23,200 Now, I'm going to enter a value. 473 00:23:29,040 --> 00:23:30,420 I hit submit and 474 00:23:32,140 --> 00:23:33,460 again, I'll update the screen. 475 00:23:33,660 --> 00:23:34,300 So, you can follow along. 476 00:23:35,020 --> 00:23:36,860 Here we go. This is the serial number I entered. 477 00:23:36,940 --> 00:23:39,660 If I have no clue what it is, I'm just going to enter a value and see what happens. 478 00:23:40,220 --> 00:23:41,620 My breakpoint is hit 479 00:23:41,620 --> 00:23:42,660 and it stops the program. 480 00:23:43,140 --> 00:23:45,680 Here we are at 11288. 481 00:23:45,780 --> 00:23:47,300 If we look in IDEA, 482 00:23:47,780 --> 00:23:49,100 11288 is the update data. 483 00:23:49,920 --> 00:23:51,500 So, let's start at that point 484 00:23:51,500 --> 00:23:53,520 and watch and see what happens in the program. 485 00:23:55,600 --> 00:23:57,580 And I move step by step. You hit F11. 486 00:23:57,800 --> 00:23:59,280 This will just move it to the next line of code. 487 00:23:59,420 --> 00:24:01,240 It's the best way to work through a program. 488 00:24:01,680 --> 00:24:03,640 One thing I should also mention is that 489 00:24:03,660 --> 00:24:05,780 you can see, I hope, that these are red. 490 00:24:06,000 --> 00:24:08,420 If it's red, then the value has just been changed. 491 00:24:08,640 --> 00:24:10,300 It's another important thing to keep an eye on 492 00:24:10,300 --> 00:24:11,740 so you can watch and see what's going on. 493 00:24:12,940 --> 00:24:14,040 I'm going to hit F11 here 494 00:24:14,040 --> 00:24:15,480 and it's going to load a value 495 00:24:16,640 --> 00:24:18,040 right into R1, 496 00:24:18,240 --> 00:24:18,820 the register 1. 497 00:24:19,360 --> 00:24:20,540 Now, you can take this value, 498 00:24:21,280 --> 00:24:23,220 copy it out of here, drop it right into your memory, 499 00:24:23,920 --> 00:24:25,280 hit enter, and there we go. 500 00:24:25,500 --> 00:24:27,180 My serial number is in the memory. 501 00:24:27,500 --> 00:24:29,440 It's part of the program. It's being used. 502 00:24:29,640 --> 00:24:30,900 We're watching what's going on. 503 00:24:32,360 --> 00:24:33,540 Now, here at the next line, 504 00:24:34,920 --> 00:24:36,180 basically what we're having 505 00:24:36,180 --> 00:24:37,480 is a string compare. 506 00:24:37,600 --> 00:24:38,880 It's checking the value of R0 507 00:24:40,140 --> 00:24:43,000 which, let me hit F11. 508 00:24:45,240 --> 00:24:46,780 It's checking the value of R0 509 00:24:46,780 --> 00:24:47,900 with the value 8. 510 00:24:48,580 --> 00:24:50,880 Now, anybody give me a guess 511 00:24:50,880 --> 00:24:52,720 what the value in register 0 is? 512 00:24:52,980 --> 00:24:53,860 Just yell it out. 513 00:24:56,600 --> 00:24:57,920 It's the length of our string. 514 00:24:58,440 --> 00:24:59,360 Four characters? 515 00:24:59,600 --> 00:25:01,100 We have a four character string right here. 516 00:25:02,120 --> 00:25:02,600 Alright? 517 00:25:03,660 --> 00:25:04,880 Now, let's see a little bit what's going on. 518 00:25:05,020 --> 00:25:06,900 And you'll get the idea of what's going on here 519 00:25:06,900 --> 00:25:08,440 the more you work with it. 520 00:25:09,000 --> 00:25:10,560 Here we have a compare opcode. 521 00:25:10,760 --> 00:25:12,980 We talked about this. It compares the value in R0 522 00:25:12,980 --> 00:25:14,740 with the hardcoded value of number 8. 523 00:25:15,580 --> 00:25:17,700 R0 is 4, 8 is 8. 524 00:25:17,780 --> 00:25:19,560 If we hit F11, our flags 525 00:25:19,560 --> 00:25:21,160 down here should be updated accordingly. 526 00:25:21,520 --> 00:25:22,580 Which is not equal. 527 00:25:22,940 --> 00:25:25,880 So our 0 status flag is updated to the not equal status. 528 00:25:26,200 --> 00:25:27,120 And it's less than. 529 00:25:27,300 --> 00:25:29,600 So our negative status flag will be updated to 1. 530 00:25:30,160 --> 00:25:31,020 I'll hit F11. 531 00:25:31,020 --> 00:25:33,760 And you can see that that is what actually happened. 532 00:25:33,900 --> 00:25:34,240 I hope. 533 00:25:35,740 --> 00:25:37,380 Now we have a branch of less than 534 00:25:37,380 --> 00:25:38,640 and a branch of greater than. 535 00:25:40,080 --> 00:25:41,700 Now, the condition is met 536 00:25:41,700 --> 00:25:42,740 with a less than. 537 00:25:42,820 --> 00:25:44,600 So if I hit F11, it should bypass 538 00:25:44,600 --> 00:25:45,860 the rest of my serial validation. 539 00:25:46,460 --> 00:25:47,960 And I'm just going to hit F5 here. 540 00:25:49,120 --> 00:25:50,780 And I'm going to update the screen. 541 00:25:51,180 --> 00:25:52,460 And you can see that 542 00:25:52,980 --> 00:25:55,140 it gave us an error message right off the bat. 543 00:25:55,500 --> 00:25:57,380 So it's not long enough. 544 00:25:57,540 --> 00:25:58,240 Something's going on. 545 00:25:58,480 --> 00:25:59,980 Let's go back into the program. 546 00:26:02,380 --> 00:26:03,360 And start again. 547 00:26:03,480 --> 00:26:05,000 Now we know we want to 548 00:26:05,000 --> 00:26:06,480 come down to this point to compare. 549 00:26:07,180 --> 00:26:08,660 And the nice thing about a debugger 550 00:26:08,660 --> 00:26:10,460 is you can change the values in your register. 551 00:26:10,700 --> 00:26:12,260 So you can change the flow of the program 552 00:26:12,260 --> 00:26:13,340 as it is executing. 553 00:26:13,600 --> 00:26:16,580 It's a very useful tool to try and figure out how a program works. 554 00:26:17,160 --> 00:26:18,600 I'm going to change this value to 8. 555 00:26:18,700 --> 00:26:20,780 So now we have R0 equal to 8. 556 00:26:20,880 --> 00:26:22,380 And the value 8 being compared 557 00:26:22,880 --> 00:26:24,120 is going to come out in our favor. 558 00:26:24,540 --> 00:26:26,260 I hit F11. You can see 559 00:26:26,260 --> 00:26:27,780 the equal status flag is set. 560 00:26:27,940 --> 00:26:30,740 So these next two lines are going to be jumped right over. 561 00:26:31,260 --> 00:26:32,940 Now we have another load register. 562 00:26:33,420 --> 00:26:34,640 And this is loading a value 563 00:26:34,640 --> 00:26:36,120 into R0 from the stack. 564 00:26:36,960 --> 00:26:38,960 I hit the F11. 565 00:26:39,380 --> 00:26:40,420 And I check my memory. 566 00:26:42,460 --> 00:26:44,020 1, 2, 3, 4, 5, 6, 7, 8. 567 00:26:44,180 --> 00:26:46,160 So here's our value. 568 00:26:46,260 --> 00:26:48,400 Even if I didn't catch it in the IDA, 569 00:26:48,440 --> 00:26:50,500 I can now catch it. There's my serial number. 570 00:26:50,600 --> 00:26:51,080 It's right in memory. 571 00:26:52,060 --> 00:26:54,240 Now this next line, 2A4, 572 00:26:54,480 --> 00:26:55,720 just so you can see what's going on, 573 00:26:56,500 --> 00:26:58,300 is right here. This is our string compare. 574 00:26:58,660 --> 00:26:59,600 1, 1, 2, A4. 575 00:27:02,320 --> 00:27:03,380 I hit F11. 576 00:27:04,780 --> 00:27:05,860 And you can see 577 00:27:05,860 --> 00:27:06,920 that our status flags are updated. 578 00:27:07,200 --> 00:27:08,920 Now 1 equals fail. 579 00:27:09,120 --> 00:27:10,480 0 equals 1 in this case. 580 00:27:10,700 --> 00:27:11,760 Here we have a value. 581 00:27:11,900 --> 00:27:14,480 Another memory value. 582 00:27:15,100 --> 00:27:16,180 1, 1, 2, 2. 583 00:27:16,240 --> 00:27:17,360 So it's part of our serial number. 584 00:27:17,620 --> 00:27:18,700 If you work through this enough, 585 00:27:18,780 --> 00:27:21,180 you would see that this R1 equals 586 00:27:21,180 --> 00:27:23,740 the address of the character that failed. 587 00:27:24,440 --> 00:27:26,340 And then R2 equals the character 588 00:27:26,340 --> 00:27:27,180 that did fail. 589 00:27:27,340 --> 00:27:29,720 And R3 equals the character it should have been. 590 00:27:31,020 --> 00:27:32,000 So we don't use the string compare 591 00:27:32,000 --> 00:27:33,640 in any kind of serial check. 592 00:27:33,800 --> 00:27:35,400 Because I could simply work through this 593 00:27:35,400 --> 00:27:38,080 one character at a time, learning the serial number 594 00:27:38,080 --> 00:27:39,620 as I went and simply loop through it. 595 00:27:39,720 --> 00:27:40,760 And I have the serial number. 596 00:27:41,020 --> 00:27:43,240 Then it ends up on deluxe serials or something like that 597 00:27:43,240 --> 00:27:44,320 and not everybody has a serial number. 598 00:27:47,880 --> 00:27:48,680 Moving on, 599 00:27:49,760 --> 00:27:51,420 we overwrite R2 with a 0. 600 00:27:51,620 --> 00:27:52,960 Now we're moving R0 value, 601 00:27:53,180 --> 00:27:53,780 which is the 1, 602 00:27:53,920 --> 00:27:56,560 it's the status that was passed back from the string compare 603 00:27:56,560 --> 00:27:57,780 into R3. 604 00:27:57,900 --> 00:28:00,220 But we're updating the status flag after we do this. 605 00:28:01,020 --> 00:28:02,200 To control the rest of our program's flow. 606 00:28:03,100 --> 00:28:04,000 I hit F11. 607 00:28:04,200 --> 00:28:07,440 You can see that the value is 1. 608 00:28:07,580 --> 00:28:09,580 So the 0 flag is set to 0 609 00:28:09,580 --> 00:28:10,700 because it did not equal 0. 610 00:28:11,160 --> 00:28:12,600 And the negative was left alone. 611 00:28:13,400 --> 00:28:15,060 Now the next two lines of code here 612 00:28:15,060 --> 00:28:16,520 are interesting because if you look at them, 613 00:28:16,560 --> 00:28:18,820 you can see that regardless of what happens, 614 00:28:19,040 --> 00:28:20,120 the value 1 615 00:28:20,820 --> 00:28:22,760 or 0 is going to end up in R0. 616 00:28:23,600 --> 00:28:25,220 Now we've got to work through it 617 00:28:25,220 --> 00:28:27,300 and figure out what is controlling the program flow 618 00:28:27,300 --> 00:28:29,840 and why this R0 is so important. 619 00:28:30,200 --> 00:28:31,000 We hit F11. 620 00:28:31,020 --> 00:28:32,100 Hit F11 again. 621 00:28:32,260 --> 00:28:35,060 You can see now that R0 is used 622 00:28:35,060 --> 00:28:36,620 in the AND instruction. 623 00:28:37,400 --> 00:28:39,220 FF is being ANDed 624 00:28:39,720 --> 00:28:41,080 with the value in R0, 625 00:28:41,180 --> 00:28:42,160 which in this case is 0. 626 00:28:43,000 --> 00:28:44,660 So if it fails, 627 00:28:44,860 --> 00:28:45,760 if the string compare fails, 628 00:28:46,080 --> 00:28:47,940 the value 0 will end up in R0. 629 00:28:49,240 --> 00:28:52,660 That result ends up in R3. 630 00:28:53,060 --> 00:28:54,060 R3 equals 0. 631 00:28:54,180 --> 00:28:55,480 The status flags are updated 632 00:28:55,480 --> 00:28:57,060 because of that little S on the end 633 00:28:57,060 --> 00:28:58,300 to update the status flag. 634 00:28:58,980 --> 00:29:00,180 Hit F11 again. 635 00:29:01,160 --> 00:29:02,960 Now it's doing a load 636 00:29:02,960 --> 00:29:04,920 if the non-equal status 637 00:29:04,920 --> 00:29:06,260 is set. 638 00:29:06,600 --> 00:29:08,720 Our status flag is set 639 00:29:08,720 --> 00:29:10,660 because the equal status flag is set. 640 00:29:10,800 --> 00:29:12,200 So it's going to bypass this line. 641 00:29:12,480 --> 00:29:14,400 Hit F11, hit F5 642 00:29:14,800 --> 00:29:15,980 just for convenience sake. 643 00:29:16,600 --> 00:29:18,620 Update the screen and now we have 644 00:29:18,620 --> 00:29:19,780 a different error message. 645 00:29:20,020 --> 00:29:21,820 So it looks like if we enter 646 00:29:21,820 --> 00:29:23,400 the wrong length serial number, 647 00:29:23,540 --> 00:29:24,380 we get one error message. 648 00:29:24,520 --> 00:29:25,880 If we enter the wrong serial number 649 00:29:25,880 --> 00:29:28,160 and it's the right length, we get a different error message. 650 00:29:31,020 --> 00:29:33,220 So that's a variation in the program. 651 00:29:34,620 --> 00:29:35,220 Hit OK. 652 00:29:35,420 --> 00:29:35,860 Hit submit. 653 00:29:36,040 --> 00:29:37,560 Now we're back into the beginning of the program again. 654 00:29:37,880 --> 00:29:39,860 Now I'm going to jump immediately down to compare. 655 00:29:40,600 --> 00:29:42,380 Except this time I'm going to show you something else 656 00:29:42,380 --> 00:29:42,920 that we can do. 657 00:29:43,440 --> 00:29:45,720 I'm going to let the compare update the status flags 658 00:29:45,720 --> 00:29:46,960 with the failed 659 00:29:47,860 --> 00:29:49,220 basically it's going to say less than. 660 00:29:49,380 --> 00:29:51,380 So I can overwrite these status flags too. 661 00:29:52,120 --> 00:29:53,740 I overwrite my negative status flag. 662 00:29:54,620 --> 00:29:56,260 I overwrite my 0 status flag. 663 00:29:56,440 --> 00:29:57,540 Now I have an equal status. 664 00:29:57,880 --> 00:29:59,960 So the next line of code to execute is going to look at 665 00:30:01,020 --> 00:30:02,640 oh it's equal, I don't need to execute. 666 00:30:03,000 --> 00:30:04,420 Hit F11, hit F11 667 00:30:04,420 --> 00:30:05,740 and you can see it didn't jump. 668 00:30:06,140 --> 00:30:08,680 So again I just redirected the program flow on the fly. 669 00:30:09,400 --> 00:30:10,980 I'm going to bounce down to this point. 670 00:30:11,180 --> 00:30:12,060 As I discussed, 671 00:30:12,280 --> 00:30:14,220 the value in R0 controls 672 00:30:14,220 --> 00:30:16,500 what's going to happen here at the ands instruction. 673 00:30:19,540 --> 00:30:19,960 So 674 00:30:19,960 --> 00:30:23,180 since R0, I don't want it to equal 0 675 00:30:23,180 --> 00:30:24,260 I want it to equal 1 676 00:30:24,260 --> 00:30:26,500 because I want FF to be anded to 1 677 00:30:26,850 --> 00:30:29,280 and then the resultant value 1 be written in R3 678 00:30:29,280 --> 00:30:30,900 the status flags will be updated 679 00:30:31,020 --> 00:30:32,020 based on the 1 value. 680 00:30:33,480 --> 00:30:34,600 I hit F11 681 00:30:34,600 --> 00:30:35,860 and that happens. 682 00:30:36,200 --> 00:30:38,280 Now the non-equal status is set. 683 00:30:38,440 --> 00:30:41,280 So I know that the value on the stack 684 00:30:41,280 --> 00:30:42,940 is going to be loaded into R1. 685 00:30:43,700 --> 00:30:44,900 I hit F11 again. 686 00:30:45,420 --> 00:30:46,880 Let's see what R1 687 00:30:46,880 --> 00:30:48,660 well, you know what, I'll just hit F5. 688 00:30:48,900 --> 00:30:50,300 And you can see what R1 says. 689 00:30:53,640 --> 00:30:54,540 Correct serial number. 690 00:30:54,620 --> 00:30:55,400 Thank you for registering. 691 00:30:55,640 --> 00:30:57,520 So I just manually bypassed my serial check. 692 00:30:57,780 --> 00:30:59,100 And I could stop here 693 00:31:01,020 --> 00:31:02,200 because I just wanted to do it for myself. 694 00:31:03,860 --> 00:31:04,600 But now 695 00:31:04,600 --> 00:31:06,020 comes the point of a cracker 696 00:31:06,020 --> 00:31:07,220 where they're going to write a program 697 00:31:07,220 --> 00:31:08,580 and they're just going to automate this 698 00:31:08,580 --> 00:31:10,760 or they're just going to patch the program in the first place 699 00:31:10,760 --> 00:31:12,540 and just distribute that as the patched 700 00:31:13,180 --> 00:31:13,820 serial check. 701 00:31:13,980 --> 00:31:18,820 So let me see where I'm at here 702 00:31:18,820 --> 00:31:20,100 quick, catch you up. 703 00:31:21,460 --> 00:31:22,080 Here we do 704 00:31:22,080 --> 00:31:23,960 this is slides talking about 705 00:31:23,960 --> 00:31:25,080 what we just went through. 706 00:31:25,680 --> 00:31:28,480 The first crack, I'm just labeling it the sleight of hand 707 00:31:28,480 --> 00:31:29,740 because we're just going to trick the program 708 00:31:31,020 --> 00:31:31,120 because it's not true. 709 00:31:31,800 --> 00:31:34,020 And you can see that back in the compare 710 00:31:35,760 --> 00:31:36,880 in IDA right here 711 00:31:38,040 --> 00:31:39,200 right in this line 712 00:31:39,200 --> 00:31:40,200 we're comparing a value. 713 00:31:40,360 --> 00:31:42,080 Now how can we make this permanently 714 00:31:42,740 --> 00:31:43,520 in our favor? 715 00:31:45,560 --> 00:31:46,600 Well, R0, R0. 716 00:31:46,760 --> 00:31:47,740 Correct, here you go. 717 00:31:47,800 --> 00:31:48,440 Come up and get a CD. 718 00:31:50,120 --> 00:31:51,740 And I have a couple more things up here too 719 00:31:51,740 --> 00:31:52,260 if you do answer. 720 00:31:53,980 --> 00:31:55,040 Right, R0, R0. 721 00:31:55,180 --> 00:31:56,500 So you're comparing a value with itself. 722 00:31:56,860 --> 00:31:58,100 It's always going to be in our favor. 723 00:32:01,020 --> 00:32:01,900 That's the point of the code right here. 724 00:32:02,060 --> 00:32:03,180 I know you can't answer again. 725 00:32:03,320 --> 00:32:04,100 I'm only giving you one thing. 726 00:32:06,420 --> 00:32:08,120 We know that the value R0 727 00:32:08,120 --> 00:32:09,460 if it's a 0 728 00:32:09,460 --> 00:32:12,480 will end up basically controlling the program 729 00:32:12,860 --> 00:32:14,360 against our favor at this point. 730 00:32:14,440 --> 00:32:15,300 I'm sorry, if it's a 1 731 00:32:15,300 --> 00:32:16,500 it will control the program 732 00:32:17,140 --> 00:32:19,120 against our favor at this point. 733 00:32:20,380 --> 00:32:21,800 So, we want to control 734 00:32:23,040 --> 00:32:24,080 this value right here. 735 00:32:24,180 --> 00:32:26,900 We want 1 to be moved into R0. 736 00:32:27,980 --> 00:32:28,860 And it's 737 00:32:28,860 --> 00:32:29,520 moved in here 738 00:32:31,020 --> 00:32:31,660 and it can be moved in here 739 00:32:31,660 --> 00:32:33,480 if we simply change this value to a 1. 740 00:32:34,020 --> 00:32:35,080 So to do that, 741 00:32:35,100 --> 00:32:36,400 let's start with the compare. 742 00:32:36,640 --> 00:32:38,360 We need to load up our hex editor. 743 00:32:39,700 --> 00:32:40,680 Here's the serial program. 744 00:32:41,520 --> 00:32:42,660 Load it up in UltraEdit. 745 00:32:46,080 --> 00:32:46,880 Page down. 746 00:32:47,160 --> 00:32:49,000 Now the point in IDA 747 00:32:49,000 --> 00:32:50,800 that we need to go to 748 00:32:51,700 --> 00:32:52,100 294 749 00:32:52,100 --> 00:32:53,480 This is the address 750 00:32:54,820 --> 00:32:55,620 in IDA. 751 00:32:55,700 --> 00:32:57,000 Now in the file itself 752 00:32:57,000 --> 00:32:58,600 it points to a different location. 753 00:33:01,020 --> 00:33:02,020 This is the value we actually need to 754 00:33:02,020 --> 00:33:03,580 This is the address line we need to locate. 755 00:33:03,840 --> 00:33:06,480 So 694, we need to change this compare 756 00:33:06,840 --> 00:33:09,260 from an 8 to an R0. 757 00:33:09,480 --> 00:33:10,800 And also change that 758 00:33:10,800 --> 00:33:12,780 one last hex character on the end 759 00:33:12,780 --> 00:33:14,620 because now we're moving a register 760 00:33:14,620 --> 00:33:16,640 into a register, not a hard-coded into a register. 761 00:33:17,220 --> 00:33:18,920 Open up UltraEdit 762 00:33:18,920 --> 00:33:20,360 and I think it was 694 763 00:33:25,480 --> 00:33:27,260 694 is this line right here. 764 00:33:27,380 --> 00:33:28,260 You can see 8 765 00:33:28,260 --> 00:33:29,800 once you get familiar with 766 00:33:31,020 --> 00:33:32,540 how the hex looks. 767 00:33:33,220 --> 00:33:34,700 You can kind of even figure 768 00:33:34,700 --> 00:33:35,980 you can read through a program like this. 769 00:33:36,400 --> 00:33:38,660 But 8's moved into R0 and this is to compare. 770 00:33:38,980 --> 00:33:41,140 So we need to change this 8 to a 0. 771 00:33:41,600 --> 00:33:42,580 And we need to change 772 00:33:42,580 --> 00:33:45,000 the fact that it's moving a hard-coded 773 00:33:45,000 --> 00:33:47,100 value into a register from a register 774 00:33:47,100 --> 00:33:48,260 into a register, so that's a 1. 775 00:33:48,540 --> 00:33:50,420 It takes care of our first point. 776 00:33:50,740 --> 00:33:52,820 Come down to this point in the program 777 00:33:52,820 --> 00:33:54,980 2B4. We want to make this a 1. 778 00:33:55,300 --> 00:33:57,460 So at 2B4 or 6B4 779 00:33:59,420 --> 00:34:01,000 right at this point 780 00:34:01,020 --> 00:34:01,840 this is a 781 00:34:02,600 --> 00:34:03,960 the move not equal. 782 00:34:04,320 --> 00:34:05,580 Make this value a 1. 783 00:34:06,620 --> 00:34:08,020 File, save as. 784 00:34:08,440 --> 00:34:10,280 I'm going to say this is serial number 1. 785 00:34:11,400 --> 00:34:12,260 Hit save. 786 00:34:12,680 --> 00:34:14,620 Copy it from my local file 787 00:34:15,460 --> 00:34:15,980 directory. 788 00:34:17,480 --> 00:34:18,960 Over to the start 789 00:34:18,960 --> 00:34:20,340 menu on my Pocket PC. 790 00:34:20,940 --> 00:34:22,820 Open it up on my Pocket PC 791 00:34:22,820 --> 00:34:24,360 so you know I'm not full of crap. 792 00:34:25,080 --> 00:34:26,620 Hit submit and 793 00:34:28,040 --> 00:34:28,900 update the screen. 794 00:34:29,560 --> 00:34:30,900 No serial number entered. 795 00:34:31,020 --> 00:34:31,940 Thank you for registering. 796 00:34:32,160 --> 00:34:34,580 So here's one way that you can crack a program. 797 00:34:35,000 --> 00:34:35,440 Now 798 00:34:35,440 --> 00:34:38,400 just like there are many ways to program 799 00:34:38,400 --> 00:34:39,960 there are many weaknesses 800 00:34:40,620 --> 00:34:42,720 in a program that can be exploited. 801 00:34:42,980 --> 00:34:44,320 And I'm going to show you a couple more. 802 00:34:46,300 --> 00:34:47,000 Right here 803 00:34:47,000 --> 00:34:48,760 we have the compare. We already looked at that. 804 00:34:49,160 --> 00:34:50,660 How about these two lines right here? 805 00:34:51,900 --> 00:34:52,780 Let's simply 806 00:34:52,780 --> 00:34:54,840 overwrite those lines so we don't have to worry about 807 00:34:54,840 --> 00:34:55,620 what happens at the compare. 808 00:34:56,100 --> 00:34:56,820 I'm going to jump 809 00:34:58,640 --> 00:34:59,700 back into this point. 810 00:35:02,820 --> 00:35:03,900 Here you updated the hex. 811 00:35:04,020 --> 00:35:05,320 This is kind of like a slide. 812 00:35:05,480 --> 00:35:06,520 You're basically nopping it. 813 00:35:06,600 --> 00:35:08,640 You're basically putting a non-operation in there. 814 00:35:08,960 --> 00:35:10,760 However, there is no nop 815 00:35:11,760 --> 00:35:13,680 instruction on the ARM processor. 816 00:35:13,980 --> 00:35:15,420 You have to kind of do a virtual nop. 817 00:35:15,720 --> 00:35:16,620 So to do that 818 00:35:17,660 --> 00:35:18,460 we simply 819 00:35:19,120 --> 00:35:20,960 just move a value into itself. 820 00:35:21,080 --> 00:35:22,320 Move a register value into itself. 821 00:35:22,500 --> 00:35:25,100 It won't do anything. It won't update the status flags. 822 00:35:25,620 --> 00:35:26,820 It's the perfect way to do it. 823 00:35:27,760 --> 00:35:28,940 Just for curiosity 824 00:35:28,940 --> 00:35:30,940 I put the 9-0 in there to see what happened. 825 00:35:31,020 --> 00:35:32,440 Because that's how you do a nop on an x86. 826 00:35:32,980 --> 00:35:34,120 And it came up with 827 00:35:34,520 --> 00:35:35,980 probably the opposite of a nop. 828 00:35:37,340 --> 00:35:38,800 Umololol's s blah blah blah. 829 00:35:38,900 --> 00:35:40,920 And that basically stands for unsigned multiple 830 00:35:40,920 --> 00:35:43,200 long if the LS status flag is set 831 00:35:43,200 --> 00:35:45,040 and then it updates the status flags with the result 832 00:35:45,040 --> 00:35:46,520 and value. Not a nop. 833 00:35:49,020 --> 00:35:50,620 So what do we have to do? 834 00:35:54,720 --> 00:35:57,000 Here we are. We're going to overwrite 835 00:36:01,020 --> 00:36:02,820 these values right here with our 836 00:36:02,820 --> 00:36:04,300 basically our virtual nop. 837 00:36:04,520 --> 00:36:06,780 So I'm going to jump over to my 838 00:36:06,780 --> 00:36:09,160 hex editor. I'm going to go to that point in the program 839 00:36:09,160 --> 00:36:10,400 which is 298 840 00:36:12,360 --> 00:36:13,920 and that's 698. 841 00:36:15,100 --> 00:36:16,500 And right here we are. 842 00:36:16,620 --> 00:36:18,460 These two lines right here need to be changed. 843 00:36:18,860 --> 00:36:20,840 I'm going to make this a 0110 844 00:36:22,120 --> 00:36:23,080 a 0 845 00:36:23,080 --> 00:36:23,860 e 1 846 00:36:23,860 --> 00:36:26,460 and that next line is the same thing. 847 00:36:26,520 --> 00:36:28,480 10 a 0 848 00:36:28,800 --> 00:36:31,000 e 1. Now I still need to 849 00:36:31,020 --> 00:36:32,580 patch this point down here. 850 00:36:33,080 --> 00:36:34,480 So I still need to go to 851 00:36:34,480 --> 00:36:36,740 6 b 4 and change this 0 to a 1. 852 00:36:41,460 --> 00:36:42,260 6 b 853 00:36:42,260 --> 00:36:44,860 Ah crud. You know what? I got to start with 854 00:36:44,860 --> 00:36:45,380 a fresh one. 855 00:36:54,460 --> 00:36:56,320 6 9 4. Here we go. 856 00:36:57,540 --> 00:36:57,940 0110 857 00:36:58,360 --> 00:36:59,940 a 0 e 1 858 00:37:01,020 --> 00:37:02,160 0 1 1 0 859 00:37:03,000 --> 00:37:04,660 a 0 e 1 860 00:37:04,660 --> 00:37:06,380 Come down to 6 b 4 861 00:37:06,380 --> 00:37:08,980 and change this value right here 862 00:37:08,980 --> 00:37:09,500 to a 1. 863 00:37:10,260 --> 00:37:10,780 File 864 00:37:13,000 --> 00:37:13,880 Save as 865 00:37:15,080 --> 00:37:16,020 Sale number 2. 866 00:37:16,260 --> 00:37:16,720 Save. 867 00:37:17,900 --> 00:37:20,180 Copy it from our local over to our other side. 868 00:37:23,120 --> 00:37:24,900 And somebody's car alarm is going off. 869 00:37:31,240 --> 00:37:33,580 Update the screen so you can see it worked. 870 00:37:33,840 --> 00:37:34,540 Here we are. 871 00:37:34,640 --> 00:37:36,200 Sale number 2. Thank you for registering. 872 00:37:36,940 --> 00:37:38,580 Third one I'm going to show you. 873 00:37:39,680 --> 00:37:41,100 Since the rest of these 874 00:37:41,100 --> 00:37:41,860 have been kind of like 875 00:37:42,780 --> 00:37:44,660 after the fact, so if we could actually 876 00:37:44,660 --> 00:37:46,100 find the correct sale number before 877 00:37:46,100 --> 00:37:48,000 and use it for our validation 878 00:37:48,560 --> 00:37:50,440 without knowing it, that would be really handy. 879 00:37:50,520 --> 00:37:52,700 It's kind of like preventative maintenance so you don't have to patch 880 00:37:52,700 --> 00:37:53,260 anything else. 881 00:37:53,640 --> 00:37:55,780 And you can do that because right here at the 882 00:37:56,580 --> 00:37:58,460 string compare, we know that our correct 883 00:37:58,460 --> 00:37:59,880 sale is loaded into R0 884 00:38:00,820 --> 00:38:01,260 and 885 00:38:06,360 --> 00:38:06,800 Okay. 886 00:38:11,320 --> 00:38:12,140 Okay, so 887 00:38:12,140 --> 00:38:14,440 here we are. We know our correct sale 888 00:38:14,440 --> 00:38:15,600 is loaded into R0. 889 00:38:16,480 --> 00:38:18,460 We know our value 890 00:38:18,460 --> 00:38:20,360 is loaded into R1, so why don't we just take 891 00:38:20,360 --> 00:38:22,540 this value right off the stack and load it 892 00:38:22,700 --> 00:38:23,560 right into register 1. 893 00:38:24,440 --> 00:38:26,400 That'll save us all the trouble of trying to patch anything 894 00:38:26,400 --> 00:38:28,440 because we'll have the correct sale number right from the get-go. 895 00:38:29,820 --> 00:38:30,860 To do that, 896 00:38:30,860 --> 00:38:32,360 that's at 68C. 897 00:38:33,980 --> 00:38:34,680 Open up 898 00:38:34,680 --> 00:38:36,240 my blank serial again. 899 00:38:36,800 --> 00:38:38,320 Jump down to 68C. 900 00:38:40,920 --> 00:38:41,780 Right here we are. 901 00:38:42,240 --> 00:38:44,140 Now we're loading the value C 902 00:38:45,240 --> 00:38:46,080 into our 903 00:38:46,510 --> 00:38:48,820 loading it from our stack pointer. Now this is register 4. 904 00:38:48,920 --> 00:38:50,560 I'm changing to the stack pointer 905 00:38:50,560 --> 00:38:52,680 or the rank, yeah the stack pointer 906 00:38:52,700 --> 00:38:53,540 which is actually 907 00:38:54,380 --> 00:38:56,340 13 and that's represented by 908 00:38:56,340 --> 00:38:58,800 hex character D. So you don't have to change two characters. 909 00:38:59,440 --> 00:39:00,640 Hit file, save 910 00:39:00,640 --> 00:39:02,040 as, sale number 3. 911 00:39:03,220 --> 00:39:03,720 Save. 912 00:39:05,360 --> 00:39:06,200 From local. 913 00:39:15,340 --> 00:39:16,220 Update the screen. 914 00:39:16,920 --> 00:39:18,580 And there we go. Three different ways 915 00:39:18,580 --> 00:39:20,320 to crack the program in what? 916 00:39:20,460 --> 00:39:21,640 A whole ten minutes. 917 00:39:22,760 --> 00:39:24,340 I'm going to jump back to my slides now. 918 00:39:26,260 --> 00:39:26,940 Catch this up. 919 00:39:28,160 --> 00:39:30,100 Here is the actual code that I used. 920 00:39:30,260 --> 00:39:32,200 And I just included this so you can understand 921 00:39:32,200 --> 00:39:34,540 what not to do. The string is simply dumped 922 00:39:34,540 --> 00:39:36,100 into a string character. 923 00:39:36,240 --> 00:39:37,500 The serial number is dumped into a 924 00:39:38,280 --> 00:39:40,020 variable and so are the error messages. 925 00:39:40,280 --> 00:39:42,080 The update data is performed like we saw. 926 00:39:42,300 --> 00:39:44,540 And we have our little get length. And it just basically 927 00:39:44,540 --> 00:39:46,500 compares that value to 8 and that compare 928 00:39:46,500 --> 00:39:48,780 instruction where we're comparing our 0 to 8. 929 00:39:49,220 --> 00:39:49,880 The incorrect 930 00:39:50,540 --> 00:39:52,480 message length box is shown. 931 00:39:52,700 --> 00:39:54,500 If the serial is at least 932 00:39:54,500 --> 00:39:55,960 8 characters, it's then validated. 933 00:39:56,220 --> 00:39:58,320 And you have another set of 934 00:39:58,320 --> 00:40:00,140 boxes that are 935 00:40:00,520 --> 00:40:01,700 shown depending on what you entered. 936 00:40:03,740 --> 00:40:04,400 There are 937 00:40:04,400 --> 00:40:06,600 again, the tools that we need to use are 938 00:40:06,600 --> 00:40:08,880 the disassembler, debugger, and hex editor. 939 00:40:09,160 --> 00:40:10,660 You've got to understand the ARM processor 940 00:40:10,660 --> 00:40:11,720 and the opcodes and registers. 941 00:40:12,100 --> 00:40:14,080 And to reverse it, you've got to find a point in. 942 00:40:14,300 --> 00:40:15,640 You've got to be able to watch execution, 943 00:40:16,060 --> 00:40:18,580 figure out what's going on, and then patch it if you prefer. 944 00:40:19,080 --> 00:40:19,520 Now, 945 00:40:19,580 --> 00:40:22,280 the spin on this is not always 946 00:40:22,700 --> 00:40:23,880 something like cracking a program. 947 00:40:24,160 --> 00:40:26,300 Earlier this week, I wanted to use my 948 00:40:27,120 --> 00:40:28,760 terminal services client on my 949 00:40:28,760 --> 00:40:30,620 Dell and I wanted to connect to 950 00:40:30,620 --> 00:40:32,680 a port other than the default 3389. 951 00:40:33,080 --> 00:40:34,720 If you ever looked that up on the internet, 952 00:40:34,860 --> 00:40:35,740 I don't think anybody really cared, 953 00:40:37,680 --> 00:40:38,480 you can't 954 00:40:38,480 --> 00:40:40,620 supposedly do it. And I'm like, that's bogus. 955 00:40:40,700 --> 00:40:41,960 I've got to be able to do it. 956 00:40:42,080 --> 00:40:44,480 So I went in, I found a point in the program 957 00:40:44,480 --> 00:40:46,720 where 3389 is actually hard coded 958 00:40:46,720 --> 00:40:48,040 into the terminal services client. 959 00:40:48,320 --> 00:40:49,980 I changed it to the port I wanted to, 960 00:40:50,140 --> 00:40:52,220 at which point I then discovered that 961 00:40:52,700 --> 00:40:55,000 the program actually writes a register key in 962 00:40:55,000 --> 00:40:55,700 and then 963 00:40:56,220 --> 00:40:58,780 through that, it's just as simple as adding a register key 964 00:40:58,780 --> 00:41:00,660 into your pocket PC 965 00:41:00,660 --> 00:41:02,360 and you can connect to any port. 966 00:41:02,580 --> 00:41:04,640 It's undocumented, I haven't found 967 00:41:04,640 --> 00:41:06,800 any other place online that it can be done, 968 00:41:06,960 --> 00:41:08,440 but you can use 969 00:41:08,440 --> 00:41:09,920 reverse engineering for things like that. 970 00:41:10,080 --> 00:41:12,680 Make a program better, change something that you don't like, 971 00:41:12,860 --> 00:41:14,580 get rid of timers, get rid of 972 00:41:14,580 --> 00:41:16,280 various things that you may not 973 00:41:16,280 --> 00:41:17,500 like to see in a program. 974 00:41:20,020 --> 00:41:20,860 Lots of sites, 975 00:41:21,220 --> 00:41:22,680 not a whole lot, but there are 976 00:41:22,700 --> 00:41:23,600 several sites out there. 977 00:41:23,700 --> 00:41:26,060 Chaos.net is one of the 978 00:41:27,140 --> 00:41:28,480 it's more the cracking 979 00:41:28,480 --> 00:41:30,300 side of things, but that's usually where 980 00:41:31,940 --> 00:41:32,340 technology 981 00:41:32,340 --> 00:41:34,320 is innovated and people 982 00:41:34,320 --> 00:41:36,120 start figuring stuff out as if they're 983 00:41:36,600 --> 00:41:38,660 the hackers. They get a lot of the stuff 984 00:41:38,660 --> 00:41:40,120 moving. DataWorm, again, 985 00:41:40,260 --> 00:41:42,280 he's got a lot of information 986 00:41:42,280 --> 00:41:44,480 and he did the IDT files, so he knows 987 00:41:44,480 --> 00:41:44,860 this stuff. 988 00:41:46,220 --> 00:41:48,560 The third line here, this is a great PDF. 989 00:41:48,780 --> 00:41:50,680 If you want a great intro 990 00:41:50,680 --> 00:41:52,680 and an understanding of how the op codes work, 991 00:41:52,700 --> 00:41:54,600 read this PDF because it has 992 00:41:54,600 --> 00:41:56,000 a lot of valid information in it. 993 00:41:56,540 --> 00:41:57,480 The rest of these 994 00:41:57,480 --> 00:42:01,120 have various importance. The armref.pdf 995 00:42:01,120 --> 00:42:02,520 that's a great reference sheet 996 00:42:02,520 --> 00:42:04,580 that gives you a list of the op codes and some of their 997 00:42:04,580 --> 00:42:06,700 hex comparisons and so on. 998 00:42:07,140 --> 00:42:08,300 And, of course, Arm 999 00:42:08,300 --> 00:42:10,400 has a lot of manuals and AirScanner. 1000 00:42:10,840 --> 00:42:11,980 Anyway, I guess 1001 00:42:11,980 --> 00:42:13,700 I am done early. 1002 00:42:14,820 --> 00:42:16,660 I'm opposed to tell you that 1003 00:42:18,300 --> 00:42:20,440 you have to clear out because the next line is already 1004 00:42:20,440 --> 00:42:22,560 really long and that's really all I have 1005 00:42:22,700 --> 00:42:24,420 to say. If you have questions, I'm going to go out 1006 00:42:24,420 --> 00:42:26,260 by the pool so the next crowd can get in here a while. 1007 00:42:26,920 --> 00:42:27,880 So, thank you for your time.