This Free Tool Decodes Game Boy ROM From a Photograph
Transcript
Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.
What that's actually doing is it's making sure that this Nintendo logo that you see on page 221 is included in the cartridge. You can make a cartridge with any logo you like, but it will only boot if it is a Nintendo logo. >> So, some kind of copyright thing. >> Trademark. Actually, >> a trademark. Cool. >> Um, the other systems of that era used copyright where they used really advanced copy protection mechanisms. In the Game Boy, Nintendo decided to save some money by using trademark law instead. Okay, >> this is the least significant bit of the first [music] address. >> Wow, man. Just a picture.
>> Yeah. And then after you know the tricks, after you've solved it, this is something that you could do with graph paper if you had enough time. >> Everyone, David Bumble back with a very special guest, Travis, great to have you on the show. >> Howdy. Thanks for having me. >> So, Travis, you have just released a book. I don't has Has it been released yet from with no start? >> Yes, this is released. This is available wherever fine books are sold. uh type in the ISBN number or uh Amazon, Google,
all the bookstores have it. >> So for everyone watching, I've put this on screen. So microcontroller exploit. So Travis, tell us a bit about yourself and then tell us about this book because I know you got a really cool demo to share. So give us an overview of your background, overview of what you did in the book and then we you know hopefully you can show us the demo. >> So I'm an embedded systems reverse engineer. Very cool. And that's a high flutin way to say that I take apart small computers. >> Love that. >> As a reverse engineer, I like reading the binary code inside of a device. I disassemble it. I decompile it. I understand it. And then I change it and I put it back. The big limitation on this is that for copy protection, a lot of devices don't allow you to read the software out. And it's not like a desktop computer where you just have a file of it or a CDROM or Y >> I spent a number of years studying how to take the software out of a microchip
when the microchip designer does not want you to. I do this with voltage glitching where I like scramble the voltage that goes to the chip and make it do the wrong thing. I do this with memory corruption exploits like you would hack a desktop computer. >> And I also do this through photography. I have a chemistry lab and microscopes at home and I take pictures of microchips in order to see what they do inside. And that's what we're going to do today. We're going to take a very very microscopic picture of a small piece of the Game Boy chip. And from that picture, we're going to get the software that has the Nintendo logo come in from the top of the screen and plays that little chime when you put in a cartridge.
>> The reason you're doing this, I believe, is cuz it's simpler than some of like the more modern stuff. Is that right? >> Yeah. Here in the States, we can just buy crazy chemicals online and um boil them at home and as long as we're not making drugs or explosives, it's our own business. Um in other countries, like you said that you're coming from the UK. >> Um it's a lot harder to buy these things. >> So this particular chip is the bits are
surface visible and you don't need any crazy chemicals. Um do you have any friends who play the violin? >> I don't, but tell us. >> Well, you should. Musicians have fun. >> I should. I'm sorry. Um, so if you take the um, coponium, they call it the pine
resin that you rub on a violin bow and you boil that and you boil a microchip in it, it takes all the plastic off. Takes a while. It's very messy. Um, but if you take a broken Game Boy and you take the chip out and you boil it in pine resin at home, you can expose the
pictures that we're looking at now. >> It's amazing. Yeah, cuz I mean this looks cool. Sorry to interrupt you. Before you get into the demo, just tell us a quick or give us a quick overview of the book cuz I'm assuming this is covered in the book and more. >> Yeah, so this is one chapter of the book. Um, I also explain u some other
chips are harder to photograph. You need different chemicals sometimes, uh, rather dangerous ones. There are also chips that I hack into electrically or by software. Um, like there's one where if you hold a pin low when you turn it on, it just forgets that it's protected. >> Oh wow. Um, if anybody from Free Scale is watching, I'm sorry. [laughter] Uh, it was a very lovely chip. So, this book is almost an encyclopedia of all the different ways to do it and it it cites all of the original papers. So, the chip that I'm showing you is from the Game Boy, but I'm not the first one to dump this chip. Uh, John McMaster is a good friend of mine. He used this as an example of the technology. And then when I was writing my own software to do this, the software that I'll demo de demo for you later, um I I built upon
his ideas and his techniques. So I'm not reusing his software, but I'm compatible with it and with the the principles behind it. He had some very clever ideas that were worth holding around. >> So is this for beginners or is it you have to have some knowledge before you start reading this? >> So this book is not a book for beginners. Um but the nice thing about it is that you can bounce around in it. Um, if you're very good at software, for example, you will understand the software chapters even though you might not understand the hardware chapters. Uh, and in the same way, if you're very good at hardware, but you're not very good at programming, you might understand the hardware chapters. And then the example that I'm showing you today is available on um on GitHub as a
public project. >> Oh, great. >> Uh with a complete step-by-step tutorial to so that your viewers can download this and do it themselves. Nothing more frustrating than seeing something cool that you're not able to reproduce yourself because some parts are kept secret or some details are missing. And I was very careful to include all the details so that you can reproduce the experiments in the book. >> Brilliant. Something that may seem slightly ridiculous about online security is that we constantly told to use unique complex passwords for every account. We told don't reuse passwords. Don't write them down. Don't make them easy to guess. Use a combination of uppercase letters or lowerase letters, numbers, and special characters. Okay.
Now, try doing that for [snorts] 30 different accounts or 50 different accounts depending on how many websites you have accounts with. It's impossible. At least for me. And this is exactly why people end up reusing passwords. It's not necessarily because they careless. It's because they've been given security advice they just can't keep up with. And that's why you need Proton Pass. It generates strong unique passwords for every account and stores them in an end toend encrypted vault. That's really important. That means because of its zero knowledge encryption. Not even Proton can access what's inside your vault. Now when you actually need to log into a website, Proton Pass autofills the credentials for you across your devices, browsers, and apps. Now maybe you already use a password manager and think it's going to be too much of a hassle to switch to Proton Pass. And that's where you'd be wrong. Proton Pass has an import feature that makes it very easy for you to switch from other password managers to Proton Pass. You don't have to choose between convenience and good security. Proton Pass gives you both. Now, I have two options for you.
Take your password security to the next level by signing up to Proton Pass for free using my link proton.me me/davidbombble. Or option two, again, take your password security to the next level and sign up to Proton Pass for free using the link in the video description. Security doesn't always have to be a total inconvenience. You can use Proton Pass
to make sure that you and your family are more secure and are using unique passwords for every website that you have an account with. So Travis, I love hearing the background, but I think most people watching and me included want to see the demo. So perhaps you can jump straight into that if we'll follow along in the book. Um, >> so we [clears throat] can open this up to the bookmarked page. This is page 220. This is a picture of the Game Boy
CPU. And the Game Boy CPU is um one
self-contained chip. It has the RAM. It has the C the compute power. >> Uh it has the video frame buffer. And it also has a tiny little program in it called uh the bootloadader. And this runs first. And when you turn on a Game Boy, if you have a cartridge in it, it will show you the Nintendo logo. Comes down from the top of the screen. And then it makes a little chime and the game begins. >> Yeah. >> What that's actually doing is it's making sure that this Nintendo logo that you see on page 221 is included in the cartridge. You can make a cartridge with any logo you like, but it will only boot if it is a Nintendo logo.
>> So, some kind of copyright thing, >> trademark, actually, a trademark. Cool. >> Um, the other systems of that era used copyright or they used um really advanced copy protection mechanisms in the Game Boy. Nintendo decided to save some money by using trademark law instead. >> Okay. >> And so this program makes sure that the right logo is shown. If you show the wrong logo, it won't boot. If you lie with a Nintendo logo, that's a trademark violation and they can sue you. >> Yeah, that's very clever. >> Now, the piece of this that we're looking at is on page 223. And if you have good eyesight or if you zoom in a bit, you can see that I've got all these ones and zeros at the bottom.
>> And the first thing that we're going to do today is we're going to get all the ones and the zeros out. And then we're going to figure out um first knowing their positions, we're going to figure out uh what color is which. The dark ones are ones or maybe I have it backward and the dark ones are zeros, but one way or the other. >> And then the next thing that we have to do is we have to search through this in order to find the uh the right ordering cuz natural languages like a lot of them are left to right like English. >> Some are right to left like Hebrew.
Yeah. Um, a few were like top to bottom or bottom to top. In inside of the microchip, the bits of significance are spread apart. So, your most significant bit is all in the left. >> Okay. Interesting. Yeah. >> And this kind of spreads out a word. And at the end of this, we'll be able to visualize that and kind of like highlight just the first three bytes to see where they are. All right. So, should we jump in? >> Yeah, go for it. >> All right. So, here on my screen, we have the microchip. Specifically, we have just the readonly memory inside of it. This is the program uh that is read
out and these things on the left and on the bottom here are called the row and the column decoders. So we have the row decoders here on the left and the column decoders here on the bottom. What they do is they select which 8 bits we're going to read and that becomes a bite or a word. If you do computer programming, you might think of a word as 32 or 64 bits. When we're dealing with readonly memory, it's whatever the native size of that memory is. uh how much you read at one time. So, if I zoom in a bit, um and
for those of you following along in the tutorial, I'm just pinch zooming on my laptop. So, as I zoom in, there are these things called VAS. Uh do you see this one here? >> Yep. Yep. >> Um and each via looks as a dark brown circle. What that is physically is it's a connection between layers of the microchip. >> So, this via here, for example, do you see how there's a faint line >> kind of running vertically and the horizontal ones are are more visible. the horizontal >> and the via wire on the top of the chip to a wire that's lower. Now this via and this one these are used
for uh power rails. This is to provide either high voltage or ground. These little ones here though in these eight vertical lines that you see you notice how some of them are missing. Like there's one here, one here, one here, and then this is missing and this is present and that's missing. >> Different colors. Yeah. >> Right. So when it's missing, that's a broken transistor. >> See? Oh, okay. >> A working transistor is a one. A broken transistor is a zero. >> Interesting. >> And this is how the microchip reads the memory out. Uh the first thing I'm going to do is I'm going to click to the left of the line.
>> Yep. >> And then I'm going to move my mouse to the right, but I'm not going to click. And I'm going to hit the R key. Oh, I see. Yeah. >> And you see that green line pops up? >> Y. >> So, that green line is um a a row and
it's a rather short one. I'm only marking eight bits on it. And whenever I hit the space bar, the software drops a new row with the exact same length and angle. >> Are you using a special kind of software or is it just like some kind of like visual program or something? Uh >> I am using special software. This is called mask ROM tool. >> Okay. This is an open- source program that I wrote in QT6 and C++. This is
available for Mac, Windows, and Linux. And um this is the most advanced freely
available software for reverse engineering a ROM. >> Well, thanks so much for making it available. >> Oh, no problem. Um if anybody in your audience has a commercial software for doing this, please send me a copy. I'd very much like a free license. Um, now as I move down and I keep hitting the space bar, it keeps dropping more rows.
And at the end of this, I'm going to mark a row line for every row in this chip. There are 16 of them, I think. And for all of the columns in the chip, I think there's like 128. And that will give me all of the bits of this ROM. And then I can begin decoding it. So now that just in this little region, now that I have the um the rows marked, I'm going to mark some columns. So, I click just above where the the line will be, and then I move my mouse lower >> and I hit the C key to drop a column.
>> Y >> and you'll notice that my uh my crosshair kind of shows that it's going to be off. >> Yeah, it's a bit all center, right? >> So, the crosshair updates whenever a line is dropped. >> Nice. >> And that's because these rows are pretty correct to like right angles, >> but they're not perfectly correct. And so the crosshair tilts in order to adjust to it. And you'll also note that as I I drop these repeated columns, the
um these little blue squares are appearing and they're appearing just over the locations where the bits are. >> And that could be maybe a one or a zero or something. Is that right? >> That could be. The software does not know which yet. >> Okay. >> So I go to my edit menu and I choose bit threshold. And you see that I've got this cool little um histogram. It's a
little jagged because I have very few samples. Um like I've only marked a couple dozen bits at this point. You can see that in um in each of the colors in
red, in green, and in blue, I have this uh separation. I have like some on the left and some on the right. Um scientists call this a biodal distribution cuz they like statistics more than I do. So the idea is that you're trying to pick a color position between the two hills. Now, as you look at it, you see in blue how there's a very small gap. >> Yes. Yep. >> And in red, you see how like there's a vertical line on the right? Like everything is either really bright in red or kind of dim. >> Y >> and green, you see how there are two hills and they're very far apart from each other. So, we're going to choose green. And I want you to watch the bits on the left. As I move this slide over.
So, as I move it, all the other colors disappear. And just as I pass that first hill, half of my bits turn red. So, the software now knows the difference between a one and a zero. We can also uh export this. So if I go to the view menu and I type bits, it gives me as art of all the different bits in order. You can move this into a Python program and then you can do the rest of the solving in Python if you like. >> So I'm I'm a bit slow, right? >> So we we've got an image of a Game Boy
chip that we're looking at. Yes. >> And just based on sort of the colors and what you've done, some clever software here, we know what the binary is. Is that right? >> Yes. >> That's amazing. >> Um >> because it's visual on that chip, right? >> Because it's visual. Now, so far we've only marked 64 bits. >> Yeah. >> Um, in order to get the whole thing, we need to mark all of them. >> Yeah. >> So, >> but you're proving the point. >> Proving the point. I'm gonna quickly run through and I'm going to mark all of them. >> Okay.
>> So, what I'm doing now is I'm marking all of the columns. And this feels a little bit tedious, but remember that I only need to do one line for each row and one line for each column. And I'm only marking the ends of them because I I'm repeating the same length and the same angle. And so at the end of it, you're only doing like the square root of the work of the image. Another important thing to notice is I'm not marking this one here where the VAS do not mark up on the lines. That's because this is a power rail and not a bit line.
Part of the tricky part about this is that you need to figure out what the memory designer was doing. How did you find that out? Is it just like trial and error or did you get like schematics or something? >> So there are couple ways to find it out. Uh one way is that sometimes schematics are published or they fall off of a truck or uh >> yeah magically appear online, >> right? Um unfortunately that doesn't happen often enough to rely on it. So another thing that you can do is you can just think really hard about it and there are only so many different technologies that you can make a memory in. This works only for readon memory.
It does not work for RAM. It does not work for EP ROM or flash. It does it
almost works for antifuses, but it's very hard there. In in terms of how you might make a ROM, there are three different say patents for it. This type is called a via ROM because the bits are encoded in VAS that connect between different layers. >> What's a VIA? Sorry for a dumb question. Um, a via on say a circuit board is one of those little circles that has metal in it that connects the front side to the back side. >> Y >> in a microchip it's the same thing. It's just microscopic and it's connecting in this case a top copper layer to um
polyilicon or diffusion beneath it. Uh sometimes it connects two metal layers to one another. Another way that you can do this is something called a diffusion ROM. You'll see those in a lot of older chips like from the late 70s and those are not surface visible. So on those you need to use hydrofluoric acid um to
dissolve the glass and it dissolves all glasses. So you can't use a glass beaker for this. You have to use a plastic one. And then >> so your lab at home must be really interesting with a bunch of like interesting chemicals and all kinds of chips lying around. >> Yeah. Yeah. It's like um >> mad scientist. I don't want to say it that way, but it sounds like really cool. >> A gentleman scientist, I'm told, is the most polite way to say a bum. So, in order to write this book, I had to build up the lab. Um, I spent a good 3 years
assembling the equipment. Oh, wow. >> Um, all of the X-rays in the book I took in my own laboratory. Actually, in order to finish the book, my digital X-ray machines at the time couldn't give me pictures that were large enough. >> Oh, wow. >> Um, X-rays don't have lensing. >> Yeah. So, your picture is as big as your sensor, one to one. >> Yeah. >> So, I called up um a buddy of mine, Alexander Nicolich, and I said, "Hey, man. Um I my digital sensor isn't big enough for this. I have too much parallax to stitch the images together. How hard would it be to do this on film?" And so, um Alex and his wife came
to visit me and brought along a dark room. >> Oh, wow. >> And we converted a bathroom in my house to be a dark room. And almost all of the X-rays in the book were taken on film rather than digitally. >> Oh, wow. That's amazing. Wow. >> Just in order to get that extra surface area, you know, to make the uh the picture big enough to see. >> Yeah. So, analog one in this case. >> The other part of the chemistry lab, of course, is that you need very good ventilation. You need a fume hood. You need filtering. Uh you need um >> Is this what you do full-time, right? Or is this like is this a side thing?
>> Uh no, this was a nights and weekends project that took me three or four years. Yeah. So this is sort of a continuation of what I was doing in grad school. If I had finished my doctorate, this would have been my uh dissertation.
So at this point, I've marked all of the bits and we can see most of them. But uh when I hit the V key, I'm doing what's called a design rule check. Um have you ever worked with computerated design? >> No, I'm I'm dumb. So you you you explain it to us. So, when you're using AutoCAD, for example, to make um a widget for a 3D printer, you might make a mistake or you might do something dumb. Uh so, here you're going to do something dumb as well. You're marking um48
bits. They're all very small. You're at the very limits of your resolution. You're going to have a problem somewhere. And so, what the V key does is it searches through the entire image
and it tells me where I made a mistake. In this case, I have four ambiguous bits. And you remember from the um the color histogram that we were trying to find a borderline between the colors and it looked like a good one, but we only had 16 bits marked. So what did we know? So now if I go and I view the bit threshold again, you can see that I'm actually on the border of the rightmost grouping. If I zoom in on my image and I
double click on any one of these bits, it will jump to it and you'll see that they're all correctly identified. So this bit is blue, meaning that it's um a
zero. The red above it is a one. And you see that it's correctly a blue, but it's got this um yellow square around it. And that tells me that it's not saying it's wrong, but it's saying it's untrustworthy because it's too close to my threshold. So what I can do is I can adjust the threshold. And if I drop it to the middle here and then I hit the V key again, it runs again and there are zero violations and the yellow square goes away. >> So in other words, your reading of zeros and ones will be good now. >> Right? And um that that's one method that I have of error correction. I anything near the threshold I don't trust. Another thing that I can do uh which we won't do in this demo, but I I do I always do in larger projects.
>> I error correct one chip against another. >> Okay? >> So I'll do the whole project twice. And the idea is that if I get a zero both times or I get a one both times, it's probably correct. >> But if I get a zero in one and a one in the other, one of them has to be wrong. And by comparing the two, I can highlight the mistakes. >> I mean, from from looking at this from the outside, this looks like a lot of work. >> It is, but I mean, we we've been here and this only took me 10 minutes to mark up. Um, I've done chips as large as a million bits. Uh, I did a an NSA chip from the 1990s called the Clipper chip and I was able to read the program out of it by doing this technique.
>> So you reverse engineered it basically and able to read it. That's so cool. >> Yeah, that was a diffusion ROM. So you need to boil the glass away in a second acid. Um, but after you do that, if you have good photos, it's the exact same procedure as here. >> I just think it's amazing that you can just from a photograph, I mean, okay, it's not just a photograph, but like a really high-res photograph that you can work this out. >> Yeah. Um, the the resolution is the limit though. >> Yeah. I do a lot of retro chips because I can do that at home on my own microscope. If I need to use an electron microscope, I have to go to the local university and I have to beg them or pay them or uh it's actually a lot of fun though using electron microscope because you can see an image like this and you can just say could you enhance there and just like uh CSI you know just enhance.
Okay, so at this point we have all of the bits marked and if I go to view and bits I have all the ones and the zeros here. This is all of them. This is the whole program, but you can't read this. There's no um >> Yeah, it's just a bunch of binary. Yeah. >> Right. So, the next thing we need to do is we need to figure out what order the bits go in. And the way that we do that is um first I'm going to pop up a couple of windows here. I'm going to pop up the hex window. And this will show me the hexodimal decoding where uh a bite appears as two letters between zero and f. So, I'm going to have that one open.
The other thing I'm going to do is I'm going to have the disassembler open. And this is giving me a a message that I have no bits to disassemble yet. And then I go to edit and I go to decoding. And these are all of my settings for how I want to decode the image. Calls left looks like this. Calls right, you know, these are all of the different orderings. So um basically you begin at
either the left or the right like you would in a natural language. You're doing either the column first or you do the row first. And then sometimes you have to do something weird like uh flip around it like a mirror. And this supports all of those different types. I can also rotate the image. >> I just want to say it's really cool that you actually wrote the software to do all of this. I mean that >> can you imagine doing this with graph paper? >> Wow, dude. >> This would take forever. >> That's amazing. >> Um, so if I go to the disassembly end,
um, these are all of the different uh, disassemblers that I support. Um, the one at the top I wrote myself. It's called good ASM and it has a module called SM83 right here. And as soon as I
select that, you see how the uh disassembly on the right pops up. >> Yep. >> So if I have the bits in the right order, that program will make sense. So the next thing to do is to figure out the order for this. I go to um view and I choose solver. And um I'm going to do bytes here. And I'm going to type 0 col 31. And I'm cheating a little here. Um,
one of the things in John McMaster's writings about this chip is that the chip does not have what's called a stack pointer reset. So you have a stack pointer just like just like you would on a desktop computer, but that stack pointer is not reset when you reboot the computer. You have to do it manually. So the very first instruction resets the stack pointer and the op code for that is 31. So what I'm saying here is that at address zero I expect the bite 31 and
then I hit solve and it gives me three solutions. And as I double click on each of these solutions you'll notice that the hex view and the disassembly on the right move. And you'll also note that the um the settings in the decoder view they also update. There are only three possible decodings for every rotation of the image, for flipping it on the x-axis or the y- axis, for inverting the bits. There are only three different combinations of settings that give you 31 as the very first bite. And if we look in the disassembly here, um, in this decoding, uh, which is the third, you'll see that the first instruction is LDSP0x3E47.
And what that means is that we're loading 3E47 into the stack pointer. And
if I choose the first one, it's loading 4711. And the second one is the winner. This is loading FFE. And to a reverse engineer, this looks right because FFE is the last even bite at the very end of RAM. And so it's counting downward from almost the end of RAM. And um you have
to build intuition for this. But after a while, that's how you recognize that you have a correct decoding. And all of the other instructions here and all of the bytes on the right, they're now correct. And because we have the correct ordering, we go to the file menu and we can um export the ROM bytes, right? We can just dump this out as a bin file and boot it in the Game Boy emulator. The other thing that we can do is we can um select some of these bytes. So let's take that first instruction 31 FE FFF
that you can see in the upper right and I just hit show selected bytes. And you remember earlier the yellow boxes were showing us errors or mistakes. Well, what they're doing now, if I zoom in, these are showing me the bits of the first four bytes. And if I select it just a little bit better, it'll drop to be only the three bytes. And so if I hover over it, it'll even tell me which bit. So this is the 0x4 bit um at
address zero. And if I move my mouse down a little bit, I get a tool tip telling me that it's the same thing at address one and the same thing at address 2. So if you did have to reverse engineer this chip with graph paper, what you do is for every group of 16
columns, that is one bit of significance. And you start at the top left one and you keep counting downward until you hit the bottom. And then you move one column over and back to the top. And you keep going again. And the most significant bit is the one on the left. Move 16 to the right of that, you get the next bit of significance all the way to the least significant bit over here on the right hand side of the chip. Um, this is the least significant bit of the first address. >> Wow, man. Just off picture. >> Yeah. And then after you know the tricks, after you solved it, this is something that you could do with graph paper if you had enough time.
>> So, I want to ask some dumb questions because I'm not I'm I'm a that's my job. Does these the zeros and ones change position, right? Is this just at a point in time or is this like static? So in RAM, a random access memory. A zero and a one can change and they change all the time. That's why we call it random access. >> In flash memory, a one can change to a zero pretty easily, but if you want to change a zero to a one, you have to do it for a whole page. That's why um flash
memory is sometimes really fast and other times kind of slow. Yeah. because the eraser takes a lot more time than the writes do. >> Okay. >> Here we're looking at readonly memory. >> Okay. >> And this is made this is a particular type of read only memory called a mask ROM. >> Okay. >> Hence the name of the tool. Mask ROM tool. >> Yeah. >> The mask here refers to the lithography masks at the manufacturing plant. >> Yeah. >> So the the fab that made this microchip had um a mask with a little hole cut out for all of the ones and no hole for the zeros. And so at manufacturing time, this got locked into every Game Boy. And every single Game Boy on Earth of this model has exactly the same ones and zeros.
>> And so you said you could export this and then boot it basically boot it into a emulator, right? >> Yeah. And when you boot a Game Boy, this is the program that slides a Nintendo logo down the screen and um does a little chime if it's right. And the reason why you see a black square if you have no uh cartridge in the slot >> y >> is that the logo that it shows you is the one in the cartridge. The one in the ROM is only used for comparison. Now uh if your audience would like to try this, I've got the GitHub link to the GBROM tutorial.
>> Brilliant. >> And you can step through and do every single one of these steps yourself. All using the free software and the free images. Nothing commercial required, no special experience, and you don't need your own Chem Lab because you can use the photographs for mine. >> I love that. So, once you've done this, what have you accomplished? You can you basically can duplicate this, boot it in an emulator, right? If you were doing this on other chips, you could read stuff and find out exactly how that chip works or what are you trying to accomplish? >> So, imagine that we had a time machine to the late 1980s >> and you and I decide that we're going to make fake Nintendo cartridges and we're going to make a boatload of money.
>> Y >> and somehow Nintendo is not going to sue us for it. The problem is that we want to show a different logo than the Nintendo logo. In order to figure out how to do that, we would need to know every little detail of how they check the logo. >> Yeah. >> And that's what this ROM gives us. This is for the original Game Boy because it's easiest to photograph. On the Game Boy Color, they needed a little bit of extra space for programming. So, they don't check the whole logo. Oh, well. They check the top of it and they check that the check some of it is right, but they don't check every bite of it. So, in the Game Boy Color, if you reverse engineer this program, you can figure out that you might make a different logo that still passes the check. Uh, I believe there were some uh counterfeit cartridges that used that trick.
>> You mentioned something in your book, right? Someone copied this and was able to bypass it, I think, if I if I remember correctly. >> Yeah. Um, and other chips were copied in
this way. The most popular was um a division of Atari called Tangen. And Tangen and Nintendo had both paid the Soviet Union for the license to Tetris. And they had both bought an exclusive license. It turns out that you can't trust communists in a business agreement. Y >> who knew? >> Yeah. >> Um so Nintendo refused to sell Tenan the
licensing chips. Here, there's only a logo on the Game Boy, but on the Nintendo NES, you need to have a special microchip, and that special microchip makes a bunch of random numbers, and the random numbers from the the cartridge need to exactly match the game system. So, Tangen used these techniques and they reverse engineered that chip and they made their own chip called the Rabbit. And the Rabbit is backward compatible with the real Nintendo chip, but it doesn't use Nintendo's code. It uses a rewrite and they manufactured their own Tetris using this counterfeit chip and got sued for it. >> I was going to say surely it ended up being sued.
>> They wound up losing the lawsuit. There are different stories about this for something so old you hear lots of rumors. >> One of the stories that I heard was that they had reverse engineered at Clean Room, meaning they had never read any of the Nintendo documentation. >> But back then you would register a copyright with the copyright office. you would send them the actual paper copy. And one of the lawyers at Tenun thought it would be great to just ask for a copy of it. And he did and he got the copy
and he never gave it to the engineers, but during the depositions he lied about it. >> Oh wow. >> Um and lawyers get really nervous when you start lying about things, especially if you get caught. >> Y >> and he got caught and that made them lose the lawsuit. And I think most of those Tetris cartridges were destroyed or something. >> It's amazing stories. I mean, I love this cuz it's it's simple enough to understand, but it teaches you the concept. So, you can go into like much more detail on more modern chips, right? Yeah. Um, on a modern chip, this style
of readon memory, the VIROM, where we have these like dark circles, that actually became popular again. You'll find that in a lot of modern chips. Um, the other styles fit economic models
that kind of faded away in history. Um, so you find those less often in the very modern stuff. >> Travis, I love that demo. That's amazing. So, thanks for like sharing that with all of us. So, for everyone watching, please, you know, add comments. Did you enjoy this? Do you want to see more of this? Do you want to learn more of this stuff? And really appreciate you, you know, making these tools free and giving us a way to learn this stuff. But can you tell us more about what you cover in the book? Perhaps give us like a quick overview of other things that you cover.
>> Yeah, let's flip through it and I'll uh I'll call out page numbers. Okay. So, chapter 12, we have these X-rays on page 120 and page 121. >> Y, >> this is an HID card reader. The model is the RW400. >> Y >> 10, 20 years ago, if you had an office building and you wanted to protect it with the badge, >> you would use this reader. >> Oh, yeah. >> And um do you see here in the center
that vertical line of six connectors on the left? >> Yep. >> That's the programming connector. That's what you use to talk to the PIC microchip inside of it. Um, it's what's called a pick 18. The pin order, as you
see in figure 12.3, um, it's they just flipped two of the lines to make it, not the standard one. >> Wow. >> And so from the X-ray, I can figure out what the right order is, and then I can connect to it and I could read the software out of it. Microchip, the manufacturer of this, you'll see the chip itself on page 127. They didn't want you to be able to copy a product that used their chip, right? Because that that would maybe someone would buy a different chip instead or design a product around a different one. So, they have this rule that you're not allowed to read a protected memory region until
after you erase it. >> This is very handy for development because it means that on my workbench, I can freely read and write it as I'm designing electronics. >> Yeah. But if I give you a copy of the device, like my secret prototype, but I don't want you to rip it off, >> I just protect it first and then you're not able to read it. >> The problem, you can see this in figure 12.6, >> there are different blocks of memory. There's the boot block and then blocks 0 through 3. >> These are each protected separately. >> Okay, >> so when I set that rule, and that seemed like a pretty reasonable rule, right?
You can't read it or write it. >> Yep. >> If after it's protected until you erase it. But I can erase just the boot block and I can replace that with a a new boot
block that gives me all the other blocks. >> Wow. >> Now I have destroyed block the boot block here. >> Yeah. >> But on another chip I can erase all the blocks except the boot block and I can put code in there that dumps the boot block and then for the cost of two readers I'm able to get a copy of all the device memory including the keys to that facility. >> Wow. And having those, I can then program my own badges and uh walk through the front door. >> So, literally, you just bought two of these. You reverse engineer it. You can program your own, break into the facility just by creating your own cards. That's really cool.
>> And the code that actually does the dumping is here in figure 12.7. >> Wow. >> Um this is citing prior art by Milos
Maria. He's a great guy. He published a paper on this ages ago. But in writing this book, um, my two requirements were that I show you how to do all of the techniques. Like I have the real code here for how to dump that out and I'm also very careful to cite the original author for all of this. So, um, I'm the one teaching the technique, but Milos was the one who invented it. >> You're standing on the on the shoulders of giants, right? >> So, cite them. >> Yeah. Yeah. >> Let's skip ahead to some other pieces we've got. So, decapsulation here. This is a hacker conference badge on page 188 that I made for the next hope conference in 2010.
>> Y >> and you see how the center of that is really shiny. >> Y >> what I did was I used red fumine nitric acid to burn a hole in the chip. And when I burn the hole with red fum nitric acid that is nitric acid that is more than 92% pure and less than 2% water.
The lack of water protects the bonding wires. the microscopic wires that connect the actual glass to the frame. So, this still functions. This is still a working hack





