Hello, everyone. Thanks for coming to our talk. What the facts. Let's do some 1980s hacking party. Yeah, so my name is Yaniv Balmas and here is Eyal Itkin. We are both security researchers who work for Check Point Research. And let's begin with a brief history of facts. So it was, it all started in 1846 when a scientist named Alexander Bain invented, sent the first image of a wire. And just a fun fact, this happened around 20 years before the invention of the light bulb. And then facts happened. I'm sure you're familiar with the evolved a bit and came to be these machines. Again, just before the invention of the telephone, radio fax came to be. And then in 1966, a small company called Xerox invented the first commercial fax machines and really changed the way we send electronic documents from one to each other. And then throughout the years, there was few standards for fax, but in 1980, the last and most recent standards for fax came to be by an organization called ITU, and namely the protocols are T30, T4, T6. Those are practically the same protocols we still use today when we send fax. And now, you know, this was in the past, but what's happening today? I mean, let's compare, we have better ways to send electronic documents from one to other, right? Let's compare fax to just one of them. Let's say e-mail, right? So if we compare fax to e-mail, and just to, if we compare fax to e-mail, let's compare fax to fax to e-mail, and just to remind you, we are comparing this to this, right? So in terms of quality, you've just saw the pictures, you know, I have nothing to add. In terms of accessibility, I'm pretty sure most or all of you have 24 by 7 access to e-mails, right? I'm not so sure you're carrying around your fax machines with you. In terms of reliability, so when you send an e-mail, it gets received, but you know, when you send a fax, it might get accidentally shredded, the dog might, might eat it, or you know, you might give it to your dog that's keeping the fax, that's know, you can never know if it got to its destination. And in terms of authenticity, well, we can argue about email, whether or not it's authenticated, but we do have extensions like public key cryptography. What we don't have is, we have nothing for fax, simply no authentication at all. So, yeah. Looking at this table, you might think, okay, so it's 2018, who is using fax? Probably nobody is using, right? Wrong. Fax is pretty much live and can kick in still. It's being used all over the place. Ships, maritime use it to receive those critical maps in open seas. According to Wikipedia, 90% of the Japanese population use fax. Well, they really like fax over there, but I don't know why, but they are Japanese, so. And if you do a lot of Google combos, like, you know, contact us and fax, you'll find over 300 million fax numbers published on Google, and that's the number of fax numbers in the world. It's just the published numbers. Think about how many fax machines don't have published numbers out there. So it's simply a huge amount of fax numbers and fax machines out there today. And the thing is that it's not only how many fax machines are out there, but it's also who uses fax. Well, if you're a small corporate or a huge corporate, you have a fax number. You don't necessarily receive faxes over this number, but you do have a fax number and it's published out there. If you're a bank, they love faxes in banks, right? So this is Bank of China. They're the biggest bank in the world with over 3.62 trillion dollars in assets, and that's their fax number. And maybe most importantly, government offices use fax. If you ever wanted to fax our beloved Donald Trump, this is his fax number. We just Googled it. It's there. So the thing is that sometimes those banks and health care and government agencies, they don't only allow you to send fax, but it's actually mandatory to send fax. You can send fax to a bank, or you can either use postal mail or fax to send them information. It's a good thing that they took mail pigeons out of it. But, you know, so, yeah, it's a thing. And when you're thinking about it, well you're thinking probably, what the fax? I mean, it's 2018. We should evolve to better ways of electronic document delivery, right? And now see, this is how fax looks like today. Well, it's no longer these standalone fax machines that we used to have 20 or 30 years ago, right? Today fax is embedded, these old protocols are embedded within newer technologies. We have fax to email services, as I said we have fax over radio and fax over satellite and we have I think most commonly these all in one printers. They have a lot of things, right? And they come pre-equipped with fax functionality in them. And now let's take a look at these all in one printers for a second. And if you think of it from a security point of view, they are just black boxes, right? And those black boxes has interfaces. On one side they have interfaces like Wi-Fi, USB, Bluetooth, Ethernet, stuff like that. Those interfaces connect us to the internal network or to the external network or basically they connect us to the world, right? And on the other hand we have interfaces for connecting fax to the phone line. And those interfaces are connected to the internet. And on the other hand we have interfaces that connect us, well, to the 1970s, something like that. And now this sounded interesting to us. And we thought, okay, let's imagine this nice attack scenario, right? If you consider those all in one printers are at the end of the day nothing but computers, right? They have memory, they have CPU, they are just big computers. What happens if an attacker with access to the telephone line and equipped only with its victim's phone number will be able to attack this printer just through the telephone line and exploit the printer and then take full control of it, right? In this scenario it can then propagate from the printer through any one of the other interfaces, let's say the Ethernet, to the internal network, right? Effectively creating a bridge between the internal network and the external network using the telephone. That's 1980s again, right? So we thought that's a really cool concept and we went on and began to the research for that. And after we got excited, we sat down and talked about the challenges that we have and it seemed like we have quite a few challenges in front of us. And they are really not simple. So let's just name a few of those challenges. For example, how do we obtain the firmware, the code for this printer? How do we analyze the firmware once we got it? What operating system does this huge monster are using? And how do we get the code for this printer? How can we debug this thing? We have no idea. How does fax even work? We just know the beeping sounds. We have no idea how fax works. And then after we understand all that, we need to understand where should we look for vulnerabilities inside this big, big, big ecosystem. So today we're going to try and take you through these questions one by one until we'll be able to exploit this printer right here on the table. So let's begin with how do we obtain the firmware for a printer? So this is our printer. I can tell you a lot of things about why we chose this printer, but basically it's the cheapest one. So yeah, we could afford to break like four or five of those during the research. So that was fun. Actually we have a lot of ink and it's really expensive. So if you want some ink, we'll be happy to share. So we need to break fax, right? But just a minute before we break fax, we need to break the printer. And I mean literally, break the printer. That was the fun part of the research. We broke everything up and tried to look inside and see what is this thing even built from. And this is basically the brain of the printer. That's how it looks like in the inside, from the inside. Let's go through the major components of this PCB. So it has a flash ROM, manufactured by expansion, and then some more memory. And looking at it, it looks a bit like some components are missing, right? That's mainly because the PCB has two sides. So on the other side is the most interesting stuff, like USB, Wi-Fi, electricity, SRAM, this huge battery that's used for something. And then two very interesting components. One is the main CPU. That's a Marvel CPU and it's manufactured specifically for HP. By the way, didn't mention that we chose HP, not because we dislike HP, but they are just the biggest vendor. They have around 40 percent of the market share, so they look like a good target. And then another component is this component. And this is a fax modem. It's a CSP1040. And we basically want to focus our research on those two components and understand how do they work and what is the relation between them. So as I said, one of the first challenges will be to obtain the firmware of this printer. So we're taking a closer look at this PCB and we find these two very interesting, very interesting things in here. Like, it's serial debug and a JTAG. It's clearly marked on the PCB. So we say, OK, this is going to be really easy. If you're not familiar with them, they are just interfaces that will let you debug the printer, the CPU, read and write memory. So that's basically all we need to obtain the firmware. Unfortunately for us, the JTAG is completely disabled. We can't access it. And the serial, well, we were able to access the serial and get this terminal, but we're not able to access the serial and get this terminal. But, unfortunately, we can't access the almost every command we tried to write would give us this strange message that I don't understand. We don't understand either. So it seems like we're not going to go anywhere from here. We need to find an alternate path to get the firmware. We looked a bit around and it turns out that actually luckily for us, HP has this site online, an FTP site and this site contains each and every firmware version for every HP product ever produced in history. That's a huge FTP site. It actually took us about two weeks to find our firmware within this mess of filmers. But, yeah, finally we were able to find this firmware and now we have our firmware file. Yeah, we can start working. But then we asked ourselves, wait, how do you even upgrade a printer firmware? Have you ever done that? I haven't. So, yeah, we have this file. We need to understand how to do that. And the answer to this question is surprisingly simple. Well, you just print it. Yeah. You see HP defined this standard called PCLXL feature reference protocol class 2.1 supplement. That if you are still sane after reading this thing, you understand that the printer receives a firmware upgrade just the same way as it receives a print job, a normal print job. That's nice. So, you know, we can do that. So, cool. If we look at the file that we got from this FTP site, this actually correlates pretty well. You see it says PJL. It stands for print job language. So, now that we know that, we just need to decode this firmware. We're not going to take you through the process of decoding this thing. I'll just give you the highlights. This thing is composed of a few decoding, decoders, like serial, serially aligned decoders. Like this one here. This one is like null decoder, tiff decoder, delta row decoder. There's a lot I can say about them, but they do something like, you know, if the previous line was all spaces, then if this line is also all spaces, just write one instead of the line. So, you will save some space. Now, this makes a lot of sense if you're talking about a print job because you're expecting to see a lot of empty lines in there. But when you're talking about binary file, it makes absolutely no sense to encode it this way. And to that, we have to say, well, if you're a hammer, everything looks like a nail. And if you're a printer, everything looks like a print job. And, okay, we were finally able to decode this thing and we got ourselves what seems to be the firmware file and now we can finally start working. But how do we analyze this file? So, we start looking at this file and right in the beginning of it, we see something that looks like a table. So, we're able to parse this thing and to understand that it is a table and this actually is a section table. So, it means that the big file that we have is actually composed of sections and this table actually tells us stuff like the loading address for each section. Sorry. The section name and the location in binary and this basically enables us to break these big file into smaller sections and now we can inspect each and every section. Specifically, there's one really big section in there that we're really interested in because it looks to be our actual firmware and we start to look at it. And when we look at it we see this. This looks promising but something is not right. Look at this. This is the part of the section. It clearly says error I don't understand. This is the same error message we got from the serial port. So yeah, that's probably the code that we're looking for, right? But it's not exactly there. Something is missing. You see we can understand it's error I don't understand but something is missing. Some bytes are missing and those bytes are consistently missing from the entire file. So although we know we are there, we still can't analyze this thing until we will be able to fill those missing bytes. And now we are trying to understand what is this thing. There are a lot of options. All of them are crazy. But the least craziest option is to understand that this thing is another form of compression. Because, yeah, it's just, it has to be. There is no other option. It's a really bad compression because when we try to compress this thing with Zlib, for example, we get 80% better compression. And the thing is that we know that we have Zlib in the printer because we see the strings to it. So why would we use this compression? I don't know. But it must be a compression. And now let's try to analyze this thing together here. So this is one of the snippets I just showed you before and let's try to analyze it. Basically it's composed of two parts. One part is ASCII characters, stuff that we can read, right? And the other part is non-ASCII characters, stuff that we can't read. Those non-ASCII characters are actually the missing bytes that we have. And we need to understand how to, you know, understand what they are. So what we do is just take this byte view, right? And take all the ASCII characters out of it. And now we are left with our missing bytes, right? Now if you stare at this long enough, you will start seeing a pattern. And let me help you a bit with this. Because, you see, this thing is composed of single bytes and double bytes, right? And the distance between the single bytes looks suspiciously patternish, I would say. Like 8 bytes, 9 bytes, 9 bytes, 8 bytes. And now try to look at this for a second from a different perspective. So from this perspective, the pattern starts seeing, being more clear, right? Because you see the F7 and F7, they look the same. The FF and FF, they look the same. But what does it mean? Well, to understand that, you need to sharpen your binary view for a second. And if you understand that FF, for example, is just 8, 1 bits, right? And if you do this consistently for every chunk that you have here, you will see the pattern. And the pattern is that the 0 bit always falls within this 2 bytes hole. And that practically means that the first byte is just a bitmap describing the next, the following 8 bytes. So this is all 9 byte chunks and the first byte is just a map of the, of the following 8 bytes. That's amazing. So now we understand what this 1 byte, 1 bytes are. And all we need to do is to understand this 2 bytes. What are those 2 bytes? And they must be replaced for some characters, but what are they replaced for? Um, that's a big question. It took us some time to, to, to understand that. And if you know anything about compression, you know that you don't have a lot of options here. It can either be a forward or backward pointer. It could be some kind of dictionary. Or it could be a set of numbers. And you know, if you know anything about a sliding window. Now, we could pretty easily say that it's not a forward and backward pointer and it's also not a dictionary because we try to find references with, with, uh, from within our file and we can't. So the only valid option will be that this thing is a sliding window, right? And equipped with this information, we go to our favorite place, to Google, um, and in some dark corner of the internet, we find this wiki, strange wiki page, uh, defining something called a soft disk library format. And this thing within it has a compression algorithm that looks really familiar and it looks really like ours. I mean, really, really like ours. I mean, it looks exactly like our compression. Exactly the same thing. Uh, we find it really funny and the thing is that this thing, anybody knows what soft disk is? Uh, so it turns out that this compression algorithm was invented by soft disk, uh, and it was used once in history, once in the past. Uh, you never guess where, um, that's because it was used in Commander Keen. Yeah. Now, how did this make its way into an HP printer? I have no idea. But it did. Uh, so if you want to follow up on that, uh, feel free. Um, and now, uh, once we have, we're, we're equipped with this information, we actually know what those two bytes are. I mean, they are just composed of, you know, this, this, uh, bitmap, which, uh, stands for two values, a window location and a data length. And that's basically all the information we, we require, you know, to open this thing. Let me show you how it works. So we have an input text, an output text, and a sliding window. And let's try to compress this string here. A, B, C, D, E, F, G. Uh, so what we do is the first byte, as I said, is a bitmap. So we just leave it open for now. We don't know what the value will be. And we start working. So A, we write it both in the output text and the sliding window. Same for B, C, D. And then we get to A. A is already present in the sliding window. So we don't need to write it in the output text. And then B, again, is just following A. And then when we hit E, we just write 0, 0, 0, 2. That means go to the sliding window at position 0 and take the first two bytes. That's, that's the replacement that we were looking for, right? And then we continue. E, F, G. And once we have it, we just write 0, 0, 0, 2. And then we go to the next bitmap. And once we have that, we can just put our bitmap here, see that the, the replacement was at this position. And we, we have our bitmap. That's pretty easy. Looking at that way, of course, when you're doing it in, in reverse, it's, uh, kind of a bit more tricky. Um, but with this, we were able to open the firmware file. And now we have a full firmware file that we can finally, finally analyze. Um, and now that we have that, we need to understand, what operating system is this monster using? Uh, and, and, and, and, uh, well, we spent quite a few time on that, but let me give you a brief, uh, explanation. So basically, this thing, uh, has a operating system called Tradix. It's a real-time operating system, and the CPU is running on its ARM line, big in the end, um, something really sexy. Um, and then there's some system and stuff here, some common libraries that are loaded, and tasks, which are the rough equivalent of processes in normal operating systems. Um, now, the, for system, we have two-stage bootloader, and some common libraries that are loaded, and some networking functionalities, and some other stuff. Uh, we have a lot of common libraries, just common libraries. Uh, and then we have tasks. And once we have this picture in mind, we know that we have to focus on these specific tasks, because this is what we're looking for. T-30, fax lock, T-modem, all the rest we can pretty much put aside, right? Uh, so we need to start analyzing them. But just a second before we do that, we notice something that looks fishy. Um, you see, this thing has, uh, it has, uh, it has, uh, it has, uh, a SpiderMonkey library. Now, if you're not familiar with this, SpiderMonkey is the Mozilla implementation of JavaScript. It's used in Firefox. And we were thinking to ourselves, why would a printer use JavaScript? It, it, it makes absolutely no sense. Uh, uh, and, and we were intrigued by this question, so we tried looking at where does this thing implement JavaScript, and it turns out that the answer is simple. It uses that in a feature called PAC, P-A-C. Uh, this stands for Pro, Proxy Auto-Configuration. Uh, it's a, it's a, it's a it uses JavaScript in order to auto-configure proxies. It's a pretty, pretty common thing. Um, and the thing is that the top layer functionality of this thing was written by HP. And when we're looking at this top layer functionality, um, we see this. This thing, before it does the PAC, uh, functionality, it con, it, it contacts this URL, fake URL 1234.com. It does nothing with it. It just, it just contacts to it, and, and that's it. Like, some sort of sanity test, maybe. I don't know. Uh, but the interesting is, thing is, does anybody know who owns the domain fake URL 1234.com? Any guesses? How did you know? Yes, it wasn't registered, so we just registered this domain. So, if anybody is interested in the domain, um, please contact me. I have a very good price, uh, for this domain. Uh, basically, every HP printer in the world now con, connects to my domain. Uh, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, uh, a lot of techs will get cost reads so. Uh, that's really nice. Um, and, now, after we've done all that, we need to actually start looking at FACTS, and for that head it over to Eyal. So, so, thank you, Nir. Um, after we finished messing around with Spiderman Key attacks on X書壇, we can actually focus on T 30. T 30 is a standard defined FACT's water closing. It called! It, ah, one V$. It's a tool on that we will actually trust once you know how to do it because T30 in its full name. The standard defines the procedures and traces and messages needed in order for the standard to see the fax document. It's actually a huge standard. It has a PDF with over 300 pages. We read through it all and it's complicated. The standard itself was first designed in 1985 and it was last updated more than a decade ago. So from our perspective it was like, it's an old standard, it's complicated, we're going to find vulnerabilities in it. While we read through the standard, we started to reverse engineer the T30 state machine in the firmware and you can look to see how it looks like. Don't let this graph view fool you as most of the code blocks you see over there contains additional state machines inside them and this means we're going to have a pretty rough job reversing it. That wasn't enough. It turns out the firmware heavily relies on function pointers and global variables and it's going to be a real mess to statically reverse engineering this thing. So we decided to change tactics. We're going to use dynamic reverse engineering. We'll need a debugger. So how can you debug a printer? We can't connect to it. You've already said that we try to connect to the JTAG and the serial port, but that wasn't really helpful. We're going to try to connect to the JTAG. We then tried to look for a built in GDB stub we could connect to, but we couldn't find one either. At this point we should remember that I can't simply load a debugger because we don't have any control over the execution flow. And even if we could load a debugger, the printer uses a hardware watchdog. As soon as the CPU will halt or enter an endless loop, the watchdog will trigger a reboot and a breakpoint usually halts the program. So we can't do this. We can't simply hit breakpoints without the watchdog kicking us out. At this point we decided to split it in parts. If we could find a code execution vulnerability, we could try to exploit it and load our own debugger. At this point we had a stroke of luck. Actually we believe that luck is an important part of every research project and we sure had our stroke of luck. On the 19th of July, Sanrio published a vulnerability called Devil's Ivy. Devil's Ivy is actually a remote code execution vulnerability in the GSOAP open source library. Embedded devices and our printer included tend to implement embedded web server inside them so you could manage and configure your embedded device. In our case, the printer uses GSOAP in its web server. After we dug in a bit deeper, we saw that we had a jackpot. Our printer is vulnerable to Devil's Ivy and we now have high debugging vulnerability. So for those of you who are not familiar with Devil's Ivy, this is a relevant piece of code and here is the vulnerability itself. The bad part about this vulnerability is that it's assigned integer underflow. And this means we need to send roughly two gigabytes of data in order to exploit it. I don't know if you're familiar with the data rates of printers. However, printers are pretty slow. So after many optimization rounds, we wanted to reduce the data. So we set the transmission time to roughly seven minutes. So each successful exploit took us seven minutes. And this practically signals the end of our stroke of luck because our exploit had several side effects on top of them. So after each successful exploit, we're going to have a grace period of three to ten minutes. And then the printer crashes. So we waited a lot of seven minutes in our research. But at least we had a lot of data. So we're going to have a lot of data. We have a vulnerability. We can try to use it for debugging. It's better than nothing. So we had pretty much, we had several debugging challenges. So we need to focus up. Originally we wanted to read RAM and write RAM so we could dynamically reverse engineer the T30 state machine. So now we have a control over the execution flow. We can use Devil's Ivy. We can try to exploit it in order to load a debugger of our own. Once loaded, we'll need to tell the MPU that our debugger is worthy of execution. So we get privileges. And when we start executing our debugger, we need to actually install it and blend it inside the firmware address space because we want to connect to this debugger and we don't want it to crash the printer. So it should natively blend inside the firmware address space. We couldn't find any known debugger we know that does it. And my brother was the one who did it. So we need to find a way to do that. And he told me to stop reinventing the wheel. And he's correct because wheels are not very useful. So we reinvented the debugger instead. So meat scout. Scout is an instruction based debugger that we've developed. It currently supports Intel CPUs as well as ARM. And in fact, it even supports ARM thumb mode. I don't really like this mode, but that's what the printer uses. So you get it as a bonus. I'm not so much a fan of them as I am a fan of the our previous research, we used actually a prototype version of Scout in a Linux kernel environment in which we loaded Scout as a Linux kernel driver to debug RPE. This time we used Scout in its embedded environment. In this environment we used Scout with a fully positioned independent compilation. It actually uses its own global of the table when it tries to locate and execute functions from the firmware itself. All you have to do in order to use Scout is to compile it and supply it with the other cells in the firmware of user firmware functions such as socket, bind, mem copy or even sleep. Once compiled, you throw the compiled binary somewhere inside the other space of your target and you have it. Once executed, Scout will create a network server and wait for instructions because it's an instruction based debugger. By remotely connecting to the newly created network server, we can now issue instructions to read RAM, write RAM or any other extension you wish to implement. It's extendable. In checkpoint research we believe in sharing with the community so we can find Scout in our GitHub account. It includes an embedded environment, tutorials and even the Linux kernel driver we used for previous research. At this point of the topic we covered many different subjects but we haven't covered yet the most important thing, how a fax actually works. Using Scout we were able to dynamically reverse engineer the firmware so let us now tell you how a fax actually works. In order to set a fax, I need a fax machine. It's going to be sent to the receiver's modem. The modem will transfer packets. The fax will be sent directly to the CPU which handles the 30 state machine and later on the data will be handled with sambal. When we start interacting between both of the modems we have network interaction, we have probing and rating, we have an equalizer and echo counselor, and we have additional trainings. You should be quite familiar with these four phases. They actually sound like this. What we actually done was to create an HDLC tunnel. Using this HDLC tunnel we are able now to send our T30 packets as HDLC datagrams from our fax machine to the receiver fax machine. T30 itself has many faces of its own. On face A we send our caller ID. It's 20 bytes string. We face C is the most important face of them all because here we actually send the data itself. So our document is going to be sent line by line, page by page until it's finally received. And on face D we finish. We send the fax, we receive the fax, and that's it. So let us now see how a normal black and white fax document is going to be sent through this protocol. So here's our document. It will go through the HDLC tunnel. The data will be sent to the fax machine. And it will be transferred using face C. And the received result looks like this. We actually send the data of a TIFF file format, compressed in G3 or G4 compression layers. And if you think that something here is missing, then you're correct. We can't control the headers of the TIFF file. The printer actually builds them itself using data we negotiated on face A and face B. So from an attacker's perspective, this is partially bad news. We can't control the headers. There are many vulnerabilities and TIFF parsers. However, they usually require us to control the header. This time we only control the data itself. So we're a bit limited. And after we finish building up and processing the TIFF file, it's going to be sent for printing, you know, because that's what normal people do with fax documents. And here it's where it becomes really interesting. Because we figured out that T30 had several different types of extensions for it. And one of the extensions, can you guess? Well, the extension is color extension. I didn't know that faxes can be colorful, but it's a thing. So let's see how a colorful fax is going to be sent. We have here our fax document, which will travel through the ATLC tunnel using face C of the T30 protocol. And the received result will be this. This is the JPEG file. This time we control the entire JPEG file, its headers and data, because the colorful fax is in fact a fully functional JPEG file. So we received a T file with a black and white fax, and a JPEG file with a colorful fax. Both will be sent for printing. Now that we finally understood how fax even works, where we should look for vulnerabilities in it. So all of the layers that we showed earlier can contain vulnerabilities. We have complicated state machines. We exchange strings for several decompression layers. And we have two different file formats we need to parse. We decided that the most convenient layer of them all will be the application one. And more specifically, the JPEG parser. Because we can fully control the entire JPEG file, so we have a much better attack surface. Let us now see how JPEG file actually looks like. So this is JPEG file. It stands for, it defines a colorful image. And the most important thing is that JPEG consists of markers. You have a start of marker. After which you have an additional marker with its opcode, length field and data. After which you have a marker with its opcode, length and data. And so on and so on. And you finish with a marker. So this is the JPEG file. Now we know how JPEG file actually looks like, let's zoom in on one such marker. Our specific marker is going to present a compression table. We define a 4 by 4 compression matrix to efficiently compress our specific document. In T files you use other tables and they were designed and fixed. And JPEG files you can use your own compression table for a specific image. So the JPEG file itself looks like this. You have our opcode, our length field, the 4 by 4 matrix and our data. If you zoom in a bit deeper, we can see that the values of our 4 by 4 matrix are going to be accumulated together. The matrix is supposed to be really sparse, as you can see over there. Most of the zeros, some 1s, some 2s. The accumulated value is going to be the length field. So you can see that the 4 by 4 matrix is going to be really sparse. So you can see over there the length field for the data inside the marker. In this case, we have our data is 6. So we're going to have 6 data bytes. The data bytes themselves are going to be copied into a small array located on the stack. So let's sum it up a bit. We're going to sum all of the values in our 4 by 4 matrix. The length field will be 6 in this case. And 6 bytes are going to be copied into our local stack buffer. As so. At this point, we're going to have a little bit more time. So we are like, what the facts? Because what will happen if we use large values inside our matrix? We have 16 bytes in our 4 by 4 matrix. And we are going to sum them all up to roughly 4 kilobytes. And 4 kilobytes of data are going to be copied into a small stack buffer of size 256 bytes. So that's bad news for the firmware. We have an overflow. Now, we're going to have a little bit of time. Now that we found our vulnerability, it's a trivial stack based buffer overflow, let us see if we have any sort of constraints. Because we simply copied data from our file to the stack buffer, we have no constraints or forbidden bytes. We can use null bytes, non-ASCII bytes, whatever bytes you choose. We can use up to 4 kilobytes of data and we can control the length. So we actually used in our exploit roughly 2K. So it's controllable. And since we actually sent a large JPEG file, we can embed inside it much more data to be used later. So we can use roughly 4K for our exploit and our exploit can load enormous amount of data from the fax itself so we can continue on. At this point, we have our vulnerability. Let us now see what bypass we should use for operating system security mitigations. Nah, not really. Because it's a real operating system, all of the addresses are fixed, there is no stack, all of the tasks share the same address space, we run in the highest of privileges, so it's an 80s party. And it couldn't be easier. Once we found the vulnerabilities, we contacted HP and we started a responsible disclosure process. We actually flew over there to HP's campus to help them. We demonstrated a vulnerability and we helped them patch it. And we found out that the vulnerability is not true. So we interesting because at first we were told to fly to Portland. And there are no HP offices in Portland. So we talked to them a bit more and they told me that I should fly to Vancouver. And we were like Vancouver in Canada. So I flew to Portland and I drove to Vancouver, Washington. And we helped them fix it. And if you were to Black Hat, I was the Black Hat for the first time this year. You couldn't miss a huge booth of HP using the wolf or the fixer this year. So you probably know that HP really cares about the security of its product. So we got an official CVEs from HP. Here are the two CVEs. They're both rated as critical with a CVE score of 9.8 out of 10. So that's quite rare. Maybe you've been familiar with the these two CVEs because they got several media attention in the past week. So here's the official response from HP. When HP learned of the issue, they worked quickly to provide updates to mitigate risks. HP takes security seriously and encourages customers to keep their systems updated to protect against potential vulnerabilities. And once we finish this, this is a good time for our live demo. . Okay. Thank you. So we don't have a lot of time. Let's see this thing in action. So we brought you here a printer. Defcon couldn't supply us with phone lines. So we just brought our own phone thing. And then we have the attacker laptop over there. And we're sending our fax now. . Yeah, it will answer in two rings. Okay. So this is the phone line. So we're going to take a look at the LCD screen of the printer. Receiving fax from malicious attacker. If you can read it. So if you see these fax, run away. . And should be here now. Yeah, fax is all slow. Sorry for that. Yeah, fax received. Now the JPEG parsing is going on. And basically we have control of the printer. So this is our logo and that means the printer is ours. Thank you. Thank you. But we have something else because now that we have control of the printer, it's not enough. We want to show that we can propagate from the printer to the rest of the network. And basically what we did is to embed eternal blue, the leaked NSA exploit, within our fax. And now this printer, once it identifies any connected computer, you just try to exploit it. And here, if you look at the laptop for a second, then you will see a calc popping. . So we did it. It was a long research, let me tell you, but it was successful. We think that this is groundbreaking. I hope you feel the same. And now let's sum up with some conclusions. If you switch back to the presentation. Yeah. Thank you. So conclusions. Well, PSTN is still a valid attack surface even in 2018. Fax can be used as a gateway to internal networks. And another thing is that all outdated protocols are probably bad for you. So keep an eye for them. And now probably you're asking yourselves, what can you do? Well, you can do some stuff. You can patch your printers. As we said, HP published patches for these specific vulnerabilities. You can find them in this URL here. And instructions from HP to identify. By the way, this works for any HP Office Jet printer. Inkjet. Inkjet, yeah. Like 80 or 100 models of them. So make sure that you have the printer. Make sure you are patched. Another thing is don't connect fax if you don't need it, right? And if you do need to connect fax, then make sure to segregate your printers so they won't be connected to the rest of the network. So if somebody manages to take over your printers, at least the risk will be contained within the printer and you won't be able to propagate to the rest of the network. Now, these are all really good suggestions. But really, the best suggestions that I have to give you today is please, please, please, please, please, please, stop using fax. Now, we really couldn't do a lot of this research if it wasn't for our wonderful friends. So they helped us physically, technically, and mentally throughout the entire process of this research. So they deserve some clapping. Thank you. Thank them. And one specific suggestion that I need to guy, Yanai, also helped us a lot in the firmware thing. And that's practically it. So thank you very much. And if you want to follow us, please follow us on Twitter. Read our stuff on our blog. And thank you very much for coming to this talk.