All right. Good afternoon, everybody. I'm Jared DeMott. I'm going to be talking to you about fuzzing, and I am just happy, ecstatic, and amazed that this house is packed. Dan Kaminsky is talking in the other room, and I wasn't sure I was going to get too many people in here today, so that's awesome. How many saw Atlas or Johnny Long? Raise your hand yesterday. Did you guys see that? Who loved the video of Bruce Potter? Did you guys like that? Oh, man. To me, that was hilarious. That was just off the hook. So let's jump into this. I've got a lot of stuff, so I'm going to move pretty fast. The range of people I think in here goes everywhere. I've talked to people who don't know what the word fuzzing means, and I've talked to people that have been doing this for five-plus years. So I'm going to do a background, current state, talk about context-free grammar fuzzers, talk about generic fuzzers, talk just real briefly about how web and file fuzzing kind of fits into this a little bit, talk about some formal metrics and kind of advancing the state and where some of my research is going with this. So for those of you who do not know what the word fuzzing means, it's basically an automated testing technique to find bugs in software. That's it. That's the short version, and there's a lot of debate longer about what else exactly it means, and maybe fuzzing is only random, and maybe it's structured, and we'll talk a little bit about that. So Peter Ohart from the former Microsoft says, A highly automated testing technique that covers numerous boundary cases, using invalid data from files, network protocols, API calls, and other targets, as application input to better ensure the absence of explodable vulnerabilities. And then the word fuzzing comes from 1990 with Barton Miller. A lot of people apparently say, I can't even attest to this personally, but for modem application tendency to fail due to random input caused by line noise on fuzzy telephone lines. So he did some research in 1990. So to get everybody on the same page, what I like to do, too, is just give a really quick example of, fuzzing, just up front, show what it is, and then we'll talk more in detail about it. So say we have this fake little protocol, and it's user, Jared, that's a client, and the server says, okay, good user, give me your pass, password, my lane pass, and the server says, all right, cool, and then client, here's a command. So that's the fake protocol. Now, how would you fuzz that, okay? Well, first we'll talk about just the data, and then we'll talk about monitoring the server. But basically, you could, like, see in loop three, I send you, user, Jared, and he says, okay, and then I give some random data. So that is not truly random fuzzing, right, because we have some protocol knowledge. We send the first leg, we get the second leg, and then we send some crazy stuff in the third leg, right? So that could be maybe just seeing how it handles arbitrary binary data. That's test one, say, or maybe these tests are randomized. A lot of different ways to write fuzzers, and we'll talk about that, too. In the first loop, you see I send 50,000 FFs. Maybe you're looking for long strings, or again, how it handles non-ASCII data. Second loop, we see 12% ends in the middle of the Jared for the user name, percent ends. We all know what that is, right? What am I looking for? Who knows? Format string bugs, right. And if you don't know what that is, there's lots of good data out there. So those are what are called attack heuristics. Sending a long string, sending a format string, sending a null byte at the end instead of a carriage return, changing the delimiters, right? These are like in a text protocol, the normal sequence of events, is like string, delimiter, string, line ending, maybe changing delimiters, or line endings, or chaining command. There's a lot of different attack heuristics that should and could be built into a good fuzzer. So, just again, so we're all on the same page with the word fuzzing, since I use it like a million times in this presentation. Other words, there's sort of like two industries that are now, I hope, colliding, because I think software will be at its best when the QA world, software testing. Who does software testing? Quality assurance. Raise your hand. Anybody out there? No, that's good. I like that. And then there's security researchers doing fuzzing to find bugs in software. Who's doing that? Raise your hand. Let's see. Yeah, there's more of those guys. All right. Me too. So anyway, if the QA guys learn a little bit more about what the security guys are doing, things are going to get better. And if the security guys know a little bit about regression testing and some of the QA things, then their testing could get better too. So the word that the QA guys tend to use is robustness testing or negative testing. Or all kinds of other words. Stochastic means random. Monkey, I've heard. Boundary, stress. Some of these are a little bit different, but they can be used in the same context. I'm just going to use the word fuzzing today. So how does fuzzing fit into software testing? If I'm Microsoft and I want to fuzz to make my software better, which if you went to the Vista talk at Black Hat, it was pretty good actually. They talk about that. They do that. Okay. Well, software testing, as we know, is difficult. It's tedious. It's expensive. It's like half the budget. But it's something that you can do. It's all we have. It's really the only way and the primary way that you have to gain confidence in your software, that your software is any good. Pre-release. Post-release, you have this whole group of third-party security reachers that will be glad to find bugs and resell them and do this whole thing that we do as an industry now. So testing, again, we probably know if we've seen this before, there's Black Box, Dynamic, which is like you have a real binary running on a real server, and you're sending real stuff to it and really interacting with it. And there's White Box, which is more like code audits and scanning through sources. You're scanning source code, and both are good. You should do both. There's some pros and cons to each. The pro of Black Box is that if you send real data to a real server running on a real box, you'll find a real bug, and you can really exercise it remotely. If you're scanning source code and your lint or your whatever tells you, hey, here's a stir copy, that's kind of naughty. And then you're like, all right, well, let me go look into this. And then you find out, yeah, that is a problem. When the config file gets loaded by the admin who has to be admin to load the config file, then that could be a problem. But you can't really exercise that bug remotely. So there's a problem. There's a slight difference in terms of usability. But all bugs should be fixed from a QA standpoint, right? Bugs are bugs. But it's just in terms of attack surface, which we'll just explain pretty briefly in a minute. So how does fuzzing fit into that quality assurance lifecycle? Or how does fuzzing fit in? We know how fuzzing fits in from a research standpoint, right? We want to find bugs. We fuzz. We find a bug. We do whatever we want to do with it, right? But from a QA standpoint, you have formal methods and software engineering. You know, you should have this formal process. This process of developing software. And part of that is your quality assurance group. And part of that is your testing group. And part of your testing group is fuzzing. It's just one small piece of it, okay? And fuzzing actually is kind of gray boxy. I mentioned that. And there's a lot of other testing that should take place. Unit, integration, blah, blah, blah, blah, blah, blah. So is fuzzing better than reverse engineering? Is fuzzing better than source code auditing? Is fuzzing better than gambling? I don't know. I think so. But I'm a little biased there. So the answer is no. It's not. Okay? It's really not. It just supplements all those things. You should still reverse engineer. You still need source code audits. You still need testing. You still need pen tests for a lot of reasons. And one of those reasons is probably fairly obvious in that fuzzing is not a catch-all solution. It doesn't work against every kind of app. If you have this special Java web thingy and you want to see, can I go from logic to fuzzing? Can I log in PHP to logged in PHP? Fuzzing doesn't really do a lot for you there, right? That's more of a pen test kind of thing. Sending random data to that might help you. And actually, we'll talk a little bit about how that could be interesting. But traditionally, especially if you're looking for memory corruption bugs, which are still the majority of all the bugs out there. Buffer overflows, heap overflows, stack overflows, pointer overflows. You know, all these kinds of corruption, memory corruption type errors. In C or C++ apps. That's where the goodies are. And if you have a server that was written in C that runs on a box that doesn't have any heap and stack protection and all this kind of stuff. Fuzz it because I guarantee you'll find an ODE in it. Well, not guarantee it. But there's a good chance there's probably some bug in there somewhere. Okay, so there's a lot of people that have been doing fuzzing for a lot of years actually. And when Miller first did this thing 16 years ago in 1990, I don't know if anybody really cared about his research. He didn't get much academic respect. Because all he really did. Was basically take a random stream generator and pump those bytes to like LS and other Unix utilities. And it was sort of like everyone in the academic community was like, wow, that's kind of lame. But it was amazing. He like crashed like half the apps on all the Unix boxes at the time. So things have gotten better since then. You can't just send truly random stuff anymore. It won't help you a whole lot these days. It could. But it's been, fuzzing has been effective for a long time. And we just saw the month of browser bugs, right? We all know that. So fuzzing is doing its thing still. It's alive and kicking. I'm making a living doing it. So, yeah. Okay. So who does this fuzzing thing? Software companies ought to be doing this. And I think they are now. Probably starting about a year ago. They really jumped on this bandwagon and said, hey, we're getting killed. The bad guys are, they're fuzzing. And they're finding bugs. And we got like a multi-billion dollar budget. And we're not finding them. What's up? So they're fuzzing. Vulnerability analysts are fuzzing. So fuzzing companies are creating fuzzers to sell. Okay? I don't know exactly how many fuzzer companies are out there. There are some. I'll talk a little bit about Codynamicon in Finland just briefly. They do some good academic work at Ulu. So there's academic work. I'm doing that too. And there's hackers. Lord knows. So fuzzers are built, bottom line, end of intro, because they work. Okay? But the question is, how do they work? And, okay, so at the bottom of this slide, you see there's this thing called attack surface. So a program is big. Most programs are pretty big, right? And I talked about that mythical program that read a config file and there was an error in it and stuff like that. That could be considered part of maybe like the local attack surface. Maybe not, depending on how that exactly worked. There's definitely an attack surface from an external point of view, right? And that's the one that's most interesting for remote vulnerabilities. There's this bit of code and there's the parsers that are in that code that read the traffic that comes remotely. That's the attack surface I'm talking about. There could be an attack surface. Jesse Burns gave a talk at Black Hat talking about the interprocess communication attack surface. There's an attack surface there between programs within a box and there's local attacks. So figure out what your attack surface is. And then the second most important part, and I think it's kind of overlooked, because we all know we've got this source data that we have to become fuzzy that we somehow deliver to an application. We know that, right? We got that down. But the other part is how do we monitor the application to make sure that we notice when something bad happens? And that's actually a really tough problem. It's not just, you know, run something and hope it dumps core. That's what it used to be. That's not what it is anymore. You can still do that, actually, and that still works in certain cases. But it's getting tougher. One way is to attach a debugger, okay? You start the process in a debugger. It's tricky, too, because some processes are really hard to start in a debugger. At the end of this, I'm going to give a demo on a tool that I wrote. And I'm going to, it's on DoveCod. DoveCod's the application I'm going to run GPF against. GPF's the fuzzer. I wrote General Purpose Fuzzer. So, and show a bug in that, multiple bugs in that, actually. And it's really hard to start DoveCod in GDB because, like, the parent process starts and it starts like an auth process, which starts like three children process for each protocol. And if any of them die, that parent will just kick them off and restart them, the whole thing. So, it's a little tricky to just, quote, unquote, start DoveCod in GDB. So, you can monitor logs. You can, you know, application logs, system logs. I'm just going to be doing it two ways. I'll actually show that it dumps core because I do ulimit-c unlimited to get to dump core. And also, by tailing the var log, we'll see a message in the mail log itself. But there's a lot of different ways. And one final note about the debugger that was really interesting. You guys maybe noticed that there was a sendmail bug this year. Well, that was actually a timing issue, a race condition. And if you attach a debugger to it, okay, to monitor and try and find this bug, you really can't find it because it screws up the race condition, right? The debugger changes the timing of race conditions in some cases. So, you can't even unilaterally say that we'll just start it in the debugger and fuzz and find bugs, right? So, okay, enough said on that. Okay, so, again, one more sort of intro slide. So, why do they work again? Well, a few reasons. There's this general goal of QA guys to do functional testing in the past. I think this has definitely changed now. But in the past, QA was like, does our program work like it's supposed to? And the hackers were like, I don't know how this program works. I don't care how this program works. I want to find a buffer overflow, right? So, there was a definite difference in approach and goal. And that made, you know, two different approaches, two different results. Not terribly surprising, right? And part of that is sort of what I call gap coverage, which is like, even if that wasn't true, internally, we bought this really expensive fuzzer on Microsoft. We paid a million dollars for a fuzzer. And it rocks. You know, it found like 99 of 100 bugs. And here I am, maybe I'm this like lame-o hacker and I wrote this fuzzer and it sucks. But it doesn't really matter because it found one bug. And that bug was exploitable, okay? So, you see what I'm saying? There's a notion of a gap, that the tools are different. And because of that, you can still find bugs. Even if your fuzzer isn't uber cool. So, and the other deal is code coverage. I just like to talk about this because it's interesting from kind of an academic, excuse me, standpoint. Which is basically like in the past, QA guys were given sort of like incentives or bonuses. Sort of like, our goal is to get 80% code coverage with your test tool suite against our product. If your tool achieves that, and the faster you achieve that, you can get a bonus or something like that. I don't know exactly how it works. I've actually never worked in QA. I'm sorry if I'm insulting the QA world. But, and so they would do that. They would write a tool that was based on just getting code coverage. They wanted to cover as much code as possible. But the problem, again, go back to format strings or anything else. Well, they went through that, the sprint F or whatever. But they didn't give it a percent N, right? So, it didn't crash. Because they didn't give it the right data when they got code coverage. So, code coverage tells us something very, very, very useful. But it only tells us half the battle. Which is this. If you cover something, you know that you've covered. But if you haven't covered it, then you haven't tested it and you certainly haven't found bugs. So, if you haven't covered it, it tells you that, right? It tells you that you haven't even tried. So, you need to get code coverage. Code coverage is a good metric. And it's an important metric to test against anything. Fuzzers, testing suites, whatever. But it doesn't tell the complete story. So, these guys marketing my fuzzer gets 80% code coverage and yours only gets 50. You know, it doesn't really, okay, well, let's think about that. It doesn't necessarily tell the whole story. It does tell us something, though. Okay, so. General fuzzing types of tools. There's generation fuzzers, which is what the majority of fuzzers I think out there are. Which is this. I make an FTP product, say. I want to test it. I buy an FTP fuzzer. It fuzzes FTP. It finds three bugs. I fix them. I run it again. They're not there. Regression testing. The whole thing. That works. Okay? The other type is mutation or capture replay, which is sort of like I use ethereal. I capture any session, whatever. And I'll talk about this. This is my tool that I wrote. GPF is kind of like this. You can capture FTP, whatever. And then you can replay that, right? And you can replay it with faults injected in certain spots. And if it's a cryptographic protocol, you can't just replay it directly, right? You need some user function that lets it know, hey, when you do this, you do a hash. And it's kind of complex. Actually, Ike's not a real good one to use for mutation, which is why I actually wrote an Ike fuzzer, too, separately. Because Ike is a tough nut to crack with a general purpose. But it can be done. And general purposes are great against a lot of other protocols, too. And hopefully we'll see that. There's fuzzing frameworks. You know? And there's old-school, straight-up random generators. And, yeah, there's a lot of different kinds. So of the categories, how do they create this semi-valid, or some people call it semi-invalid. It's the same word. It basically means, like, most of the stuff. And the protocol is right. Okay? And that's key. That the rate of faults be relatively low. Because if all your stuff is totally random, you'll never make it past, like, leg one of the protocol, right? I showed that little example. Client said this. Server said this. Client said this. Server said this. Well, if all you ever send is totally random junk in leg one, the server is just going to boot you, right? You're going to get reset. And you'll never make it into the further legs. So if you want to fuzz, like, the 20th leg of some arbitrary protocol, 19 of those 20 steps need to be exactly right. Okay? So you can see that the rate of faults need to be fairly low in general when you're fuzzing. So to create these faults, you could just randomly do it. You know? You could say, pick a random leg, pick a random position on that leg, pick some random data of a random size with some random bytes and stick it in. And that actually works fairly well. It's kind of cool. You know, maybe you don't want to do that. Maybe you want to be very cyclic, very deterministic in exactly how this thing runs. I want to fuzz every byte of every variable. Variables are basically like what we saw. Like, it was user, space, password, you know, line ending. All those pieces are considered a variable. String, delimiter, string, line ending. You could say, for every string, pick a spot in the middle and insert one to 10,000 bytes by one using every byte. Okay? That's deterministic. It could run forever. All right? And that gets into this whole, like, infinite run time deal if you talk about true randomness. So, and library is a good one. Test cases is a good one. Library is kind of like, I have this list. I have 10,000 naughty strings. I have 10,000 strings that I like. One's big. One has format stuff. One has whatever. One has hacks. You know? And I just replace each variable on the line with a string from my library. That's good. That works really well. Test cases are, a lot of the ones for sale do this. They're like, sort of like, my tool has 10,000 cases against FTP. How many test cases does your tool have? You know, so you can, you can have, like, a number of already preset test cases. You run it. You run it again. That same kind of deal. There's a lot of different ways to do this. And a lot of them are really good. So. Funny stories about fuzzing. I was, I was talking to Dan Kaminski at lunch, day two, black hat. And I told him, hey, I do fuzzing, too. I'm giving a talk on that. And he does fuzzing, too. And he's like, dumb or smart? And I'm like, hmm, well. I knew what he meant. Okay? Because I've been in this, I've been fuzzing long enough to know what he was asking. But it's kind of a strange question. A lot of people ask, ask, ask that. Is it intelligent fuzzing? Is it dumb fuzzing? And dumb doesn't necessarily. Doesn't necessarily have any negative connotation like your fuzzer is dumb and mine is intelligent. It doesn't have the connotation that one is worse than the other. What it really means is dumb means more randomness and smart means less randomness. And either extreme, sort of like in politics, right? If you're way on the left or way on the right, you know, you can get lost. But if you're sort of that line of holiness right down the middle that we're looking for. And fuzzing is kind of the same way. If your fuzzer knows too much about the protocol, that means it follows the RFC exactly and does everything exactly right. I never expect more than 200 bytes here. So I never send more than 200 bytes. Well, then you're not really fuzzing, right? You just have a client. And if it's totally dumb, totally random, we already talked about run times infinite and you're not going to get anywhere fast. So you want something in the middle. Faults relatively low. We've talked about that. So the question here is which fuzzer of all those that we just talked about is better? Commercial? Open source? Generation? Generic? There's actually really no research done on this. And it would actually be a really good research problem if somebody else was looking to pick up a Ph.D. in fuzzing. This would be a great problem. I mean, code coverage, for instance, could be a metric. You could say, well, one fuzzer gets better code coverage than the other. But like we talked about, that doesn't give you a complete picture. Okay? And you could say, well, number of bugs it finds. That's actually a fairly good metric. But it's fairly hard to determine against software that hasn't been tested yet because you really don't know if there's bugs or not. Right? So you could take software. You could maybe write software that only one person knew of the bugs that are in it. And the people that are fuzzing don't know where these bugs will be. And you could maybe have kind of a shootout. That would actually be pretty sweet. Nobody's done that. Okay. So that's all the intro stuff. And we're going to go into context-free grammars. I'm not a context-free grammar expert. I admit that. I've never written a fuzzer that uses context-free grammars. But the people at ULU University Secure Programming Group came up with Protos. I know you guys have probably heard about that if you've been fuzzing for a while. And they did some really good research on that. And I'm just kind of going to blow through this pretty quickly and not really talk about how, you know, the BNF language and all that stuff works. But basically here's an example. You can properly and completely define a protocol using context-free grammars. Like transfer is a read or a write. A read is a read request and a reads. A read request is a null or a one, a file name. A file name is a character. A character is a one through seven F. Right? You can, you can. And if you want to write a fuzzer that does context-free grammar fuzzing, you could say basically do this right thing or do this bad thing. So here's the, here's the description. It's normal. But 30% of the time do this thing that's not normal. Okay. And you can just iteratively define a protocol with those kind of faults injected in that way. And that's actually a really, a really good way to do it. So Protos talks a little bit about their, their interface roundup. There's a lot of data on this slide. My slides are on AppliedSec.com. My tools, my slides, my paper, everything's there. Go grab it. In fact, you want to grab my tool off AppliedSec.com, not off the DEF CON CD because it's slightly updated. So one of the things that I liked about the third point of this limitation of vulnerability testing is what I talked about earlier that not everything can be monitored. It's really, I think, somewhat impossible to monitor the server in every scenario. If you attach a debugger, you could miss a race condition. If you don't attach a debugger, you're probably going to miss some other bugs. If you're just looking at logs, maybe it doesn't generate logs all the time in certain scenarios. If you're looking at CPU utilization, memory utilization, you can catch some kind of runaway integer. You know, there's a lot of different ways you can monitor the process. And ideally, you do it all, particularly if you're serious about finding bugs in some given app. And I like this just because you talk about, like, biology kind of mixing into the computer science world. They talk about their tool having basically a pesticide paradox against given software. That is, if they have a SMTP fuzzer, they run it against a SMTP server. It finds 10 bugs. You fix the 10 bugs. You run it again. They're gone. That software's immune. Okay? And all tools are like that. And one of the cool things about, like, my tool in interjecting randomness is it has a seed for that random value, right? So in my tool, you seed it, and there's definitely randomness throughout. And if you want to replay that exact session again for regression testing, use the same seed. But if you want it to be randomly differently, seed it differently, and you can potentially maybe get some different results. So, you know, there's varying mileage varies, sort of, so to speak, on that kind of stuff. So into a little more of my specialty and where kind of some of my research has gone is in generic fuzzing, which is general-purpose fuzzing. There's another guy that wrote a tool, Martin Bugnaud, called Otto DeFe that I'll talk about. That he has not released yet, but apparently intends to do so. So automatic protocol detection, that's what I talked about before. Capture session with ethereal. Convert it to a neutral format. That's a good thing to do, because libpcap files are not all that easy to manually modify. Convert it to some text-looking format. Even if it's binary data, you can do this, all right? And you'll see that if you play with my tool. And, like, say you captured a stream of an FTP session, but, you know, you screwed up your login name or something like that. You can just change it in the file real quickly to the right password or the right username. You can get, obviously, different tests, different pass through the code, different coverage, depending on exactly how well your fuzzer understands the protocol. How much protocol knowledge and how many various iterations through different state spaces that it transfers. So that's a nice thing to have, the ability to do that. And I use that all the time. In fact, sometimes, if the protocol is simple, like in the case of the example I'll show you with IMAP, fuzzing dovecats. I didn't even capture a session. I just created a quick protocol description in a text file the way that the GPF expects to see it. And you can just fuzz directly from there with it. You just sort of give it the protocol knowledge. And it's very simple because the bugs I found are pre-login. So I just gave it basically the 12 valid IMAP commands or something like that and told it to go to town, right? So there's ways that that can just be really. And good generic fuzzers should be able to, based on any given capture, should be able to fuzz either in the server direction or the client. Both are important. It should be able to fuzz either way pretty easily. So attack heuristics, we've talked about that. Long strings, weird strings, format strings. Intelligent randomness we've talked about. The only thing about intelligent randomness is, again, going back to another, this would be another great research project, is basically that there has not been any research kind of trying to find where that holy line I talked about is. Nobody really knows where that is, how to weight exactly how often there should be faults or where there should be faults or how the faults are created, how much randomness. There's no definite research there. As of now, that's basically an art. There's no scientific data at all that I've seen that indicates what method may be preferred. So I weight it basically best I think it should be. Remote debugging is a sweet thing that Autodefay does. And that's basically like you've got your fuzzer fuzzing, say, a server or client, whichever direction you want to think of it in. And you have this process that is a debugger that attaches to the process, but it's also communicating with the fuzzer, right? So you're getting this backend knowledge. Hey, something just happened. It's signal 11. Let's log it and let's keep fuzzing. Like there's this cool stuff you can do with remote debugging. Really, really good stuff. Dynamic weighting is another thing I'll talk about. And distributed fuzzing is kind of an idea I had that I've never actually seen played out anywhere. And you can do this a little bit with GPF. It has a super GPF mode that will basically start, you know, as many instances of GPF as you want. And it actually, it kind of like file fuzzes your capture file. And it sort of fuzzes the switches that GPF expects on the command line. So it starts a lot of strange instances against different captures that fuzz normally. So it's really kind of wild. The problem with that is it's really hard to identify when an error has occurred. If you have a thousand versions of a fuzzer sending a thousand packets a second and you're not doing some sort of remote debugging or some sort of logging of when exactly a fault occurs, or even if you are, if you have some second generation bugs or a heat bug. I talk about second generation. I'm talking about uninitialized stack or heat bugs. I don't know. Does anybody know what an uninitialized stack bug is? Raise your hand if you know what that is. So there's a few. There's a few hands out there that know what that kind of flaw is. It's kind of a cutting edge flaw which basically goes along the lines of somebody in their code just says like, you know, int i at the top of a routine or something. They don't say int i equals zero. So they don't actually manually initialize it. Well, suppose there's some routine in code and I've actually found one of these in the wild. Suppose there's some routine in code that goes through and there's a path where there's no bug but it just so happens you overwrite maybe by four bytes and you overwrite the initialization of some variable that gets later used. Then you start again from the top of this program and you're going through down this other path through the code and whoa, something crazy happens because that variable was initialized and the code didn't know that. It doesn't expect it to be initialized. It wasn't written for it to be initialized. So there's, you know, there's some really cool things that can be found with fuzzers but trying to track down exactly what data caused the fault and where it happened and how and why, it's tricky. It really is, especially if you've got some of this wild stuff happening, you know, and there's some weird bugs and it can definitely be kind of tricky. All right. We're running out of time. So briefly, web and file fuzzing. Basically, we'll talk just real quick. How is web fuzzing different than, say, fuzzing a standard C-type daemon? Well, basically, it's just this. If you're fuzzing an HTTP server like you want to find an ODA in Apache or IIS, well, good. I'm glad that you're looking at that and good luck to you. It's getting harder to find those, okay? That code set's getting better and I think we should still continue to look at it and there probably certainly will be bugs found in it but they're hard to find, very hard, okay? I think we can all agree to that now. But there's all kinds of these crappy PHP web apps for like myblogger.com or thing and they suck, all right? They are not written well at all. But the question is how do I find these? Has anybody heard of a file inclusion bug? You're looking for it? There's a few. File inclusion, you guys know what that is. So it's kind of a pen testing sort of thing trying to find bugs and web apps and a fuzzer that's just basically sending semi-valid data watching Apache, waiting to see Apache die. You're going to be waiting a while, okay? So because the web app is having all kinds of problems but you never see it by watching Apache. You need to watch the HTTP return codes coming back from those web apps to see what's going on. And I actually have not written a tool that does this but I used SpyDynamics called SpyFuzzer just a little bit and it's kind of slick. It's not, I'm not going to say it's the greatest thing in the world because you basically got to define all your tests manually and there's really no good, not a real good like kind of but it will if you know of a certain test you want to do, like you want to say I'd like to like check this checkout cart. Like what if I buy, you know, one through 10,000 items of this type without logging in or something. You know, you've got this idea how to sort of pen test this web app. You can automate that with SpyFuzzer and that's kind of cool. So it's a little different. File fuzzing is actually very similar to normal fuzzing but there's just slightly different tools and I mean there's a lot of different ways to do this too. Very similar to the fuzzing we're talking about. It's sort of like you have a Word document. Okay, one way is you could just manually mutate that. You could, I don't know, just change every tenth byte and then give that file to Word and watch Word and see if Word dies. If it does, you found a bug, right? So there's a lot of different ways you could try to automate that and some guys gave some good tips. You can go to Firefox, Sutt & Green and Black Hat. You can go to iDefense. You can grab their tools. They're up on the website. So if you want to learn more about that. There should be and I don't think, I can't remember. I'm trying to remember off the top of my head. It's been a while since I looked at their tools. But there should be some ways to do some more intelligent fuzzing too besides just, you know, randomly. Obviously, there should be some protocol knowledge. I think they do some of that too. So okay, fuzzing metrics. Basically, the big deal is Martin Vagno wrote a paper on fuzzing. It was a pretty good one. The paper and the paper by Peter Olhart are probably the best two papers besides mine, of course. Look at AppliedSec. You'll see my paper. There is that. But they wrote some really good stuff. And his is basically not rocket science but it is, it's just, it makes sense, right? He's like, I want a metric to know how long will it take for my fuzzer to finish. Well, if you use true randomness, basically the answer is your fuzzer is never finished, right? And that's one of the things I'm studying in my research too is sort of like when's a good cutoff time? You know, how can we say that we think we've covered enough? Or whatever. But his tool is actually very deterministic. And what he does is he says all the variables, that is the user, space, pass, you know, all these things, those are called variables. And I have a list of a really long like 10,000, you know, member list of bad strings. And I'm going to take those strings and just put them in place of the variables, right? So I have library times variables times a half second or whatever it takes to run each test equals run time. That doesn't sound like, you know, rocket science. That's computer science kind of stuff. But actually it's, believe it or not, it's fairly revolutionary in this field. There hasn't been much formal study at all in fuzzing. It's basically just been like I send crap, I found a buffer overflow. I'm the man. I posted it, put bug track, you know, all that kind of good stuff. So now he does another really slick thing that's kind of cool. He basically, so not only does he have a run time, but he orders that too, which is kind of cool. It's basically like if the variable is good, if the variable is used in one of these naughty functions, got a big list of naughty functions, right? Then we fuzz those first. Again, not rocket science, but pretty revolutionary, you know, in terms of fuzzing and the way he, the remote debugger relays that to the fuzzing tool itself. So pretty good stuff. You know, there are some issues obviously, of course, with the fact that, you know, maybe more randomness could be good for second generation bugs. Maybe Windows Vista says this whole list of naughty functions shall never be used in Windows Vista. That's what they said at the talk at Black Hat. They have ways of completely eliminating these from the Windows Vista source code altogether. So in that case, it doesn't really help us all that much weighting, weight rise, right? And of course, attaching a debugger, which is a must for this kind of stuff, could potentially make you miss, you know, sort of like attaching a debugger is great for 95%. There's that 5% of race conditions or something you could miss. So basically, some future research. My thoughts are kind of like, I like to combine those kind of things that are out there, like Vecno's approach with my tool and my approach. And even kind of, basically the approach is something like this. Let's do some deterministic, structured stuff up front. And if you don't find any bugs with careful inspection, then you can sort of open up the throttle, right? You can introduce more, you know, randomness per byte or more junk, basically. You can kind of throttle back and let it run longer if you have time to try and find more of those second generation kind of things. And then, really surprisingly to me, I went to Sparks, Edmonton, Cunningham. Their talk on Sidewinder at Black Hat, great talk. They talked about using genetic algorithms in fuzzing. And I actually take a genetics algorithm class this fall. I was planning to do research on genetics algorithm. But I was happy when I saw their talk. Now I'm upset because they laid a great groundwork to kind of get started in how some of this might be used as of yet their tool wasn't working. They weren't super useful against multi-leg protocols and stuff like that. But they had some great groundwork laid on how, basically, what they use for the genetic algorithm stuff. So hopefully I can kind of build on that this year. That's my plan. So basically what I'm going to do right now is give a quick demo and then we'll take whatever questions you guys have, okay? All right. This is the only time wireless mics are really kind of handy. So basically if I just – let me make sure I click in my VM here. Cat all three. What I'm going to show you again is just I'm going to run my tool against Dovecot and show you some bugs that I found. I was not able to take these bugs and turn them into O-Days. But it's like a take-home assignment for you all. If you're smarter than me, see if you can take these bugs and turn them into O-Days. Good luck with that. So they're pre-logging. And you can see GPF and then I got pre-logging fault one. It's basically just going to run a capture file that I have. And if I cat pre-logging fault one – wow. Okay. Dot. There we go. So you can see what a capture file looks like for me in my neutral format. It's not in libpcap. It's basically like source means it came from the server. And you can reverse that easily when you run the tool. The size is 5 and the data is basically 05 and then probably like a slash r slash n and an all or whatever the data actually is there. So that's just what the capture file format looks like. It's real simple. It's real straightforward. It's simple to modify if you wanted to change that a little bit, change the byte, change the size, okay? No problems there. So what I'm going to do is I'm going to get ready to run a couple versions of GPF. And the switches that I showed you, you'll have to check out the readme. It's fairly good documentation, I think, for a readme. There's a lot of different little switches that GPF expects, but they're not that hard to use. And I'm actually going to be using it in just straight replay mode. It's not going to be fuzzing because these bugs, I don't even actually have to fuzz them to find them. It's just when you send a certain sequence of bad things, DubCut will crash. But I found that. Based on fuzzing, okay? So let me start, do a U limit so I can get a core dump, dash C, unlimited, okay? And then start DubCut. The server should be running. So if I go over to, this is a tail, tail dash F of var log, mail log. We see the entry DubCut starting up. So the question is, what happens if I do a PS dash EF grep DubCut. What happens if I do a, this is the thing you need to do before you fuzz, by the way. Before you fuzz until you've done something like this, you need to figure out what will a fault look like to me. Will I be able to see it in logs or not? Will I be able to get, what am I doing? I need to, I'm talking while I'm trying to do this. So I'm just going to put in a PID. So if I kill dash 11 DubCut auth, who thinks they know what will happen? Does anybody know? Take a guess. Who thinks they know what's going to happen if I just do this? It'll dump core because I set a U limit, right? And it doesn't, depending on kernels and, you know, EUIDs and there's a lot of different problems that can create, that process may not dump core. But when I do that, it does dump core. See, there's a core there. Let me remove it so it's not confused with a different one, core.297. And if I do the PS again, we see that DubCut auth is back and it has a different PID, okay? So we know that the DubCut watch daemon will restart it. And we see in the log, see what we see in the log? We saw this child was killed with signal 11, okay? So pretty straightforward. We know what to expect. We do that before we fuzz, right? Okay, and now we actually will send it. So I run the script. Here's GPF. It's running. You see client server, client server. It's sending data. Sometimes it prints in hex and sometimes it prints in ASCII. I don't know if you noticed that. Let me page up. Just based on what it sees. If the first few bytes look like they're binary, it'll print it in binary. If the first few bytes are, you know, ASCII, it'll print it in ASCII kind of deal. So pretty straightforward but pretty cool stuff. And then you see, like, couldn't read socket negative 2, right? So that means that there maybe was an issue. And if we go back and look at our log, it's like, oops, what was that? We got auth died and the login process died. So both pre-login. I didn't even use a user in the past. We got two problems right off the bat in DubCut there. So that's my demo and that's my tool and that's my talk. Thanks. I raced through that because I wasn't sure if I was going to make it through that. So do we have any questions? Anybody have a question? I think there's a microphone. Go ahead. You want to step up to the mic or ask it from there? Whatever you like. Yes, you have to go to the microphone, he said. How are you doing your tokenization to differentiate between strings so that you know where to fuzz? Well, that's a good question. GPF has a few different modes. You don't have to tokenize, right? GPF has lots of different modes. And if you see that in the read me, you'll see, like, you can just tell it to do some cyclic stuff, like just insert large strings or just insert format strings and do it only in this leg and do it only in this position. You can do a lot of different stuff. Or you can run it in a dash P mode, which I call pattern matching, which is tokenization. And it will basically do what you say. It will say, okay, this looks like there's a string here. Okay? And you have to actually tell it on the command line. What a dilemma. So it says I'm expecting strings to be this. I expect a delimiter to be a space of one byte long. And I expect a line ending to be a slash R slash N. So once it knows that it expects that that's the pattern, it will just find that. And based on that, it will do different things for delimiters and line endings than it would for data. So does that answer your question? Okay, great. Have you reported the problems you found to the DoveCop people? I reported a couple. Did you get any response? What's that? Did you get a response? Yeah, actually. Yes, I did. So they're going to put out a fix? These particular bugs, I don't know if they're fixed in the newest version or not. I really don't. I leave that as an assignment for you all to have fun with. Okay. And did you play with the DoveCop POP3 daemon at all? Did I what? The DoveCop POP3 daemon. Did you try fuzzing it? Yeah, I did. I fuzzed that a little bit, too. And I didn't find any problems there. But again, you know, there's a lot of different modes. I've added some stuff since then. So I say fuzz away. Okay, thanks. Yeah, no problem. DoveCop has actually had it. I found a number of problems. One of the problems was actually POP3 that I reported that was fixed. But that one's fixed now, so. Just with genetic algorithms, I mean, the key is the fitness function, obviously. Yeah. And it seems like you either crash it or you don't crash it or you get garbage out when you shouldn't get garbage. So how do you define a useful fitness function? Because it doesn't seem like the search space is that fine-grained. Yeah. Yeah, that's a great question. That is the problem. And if you, I don't know if you were at Black Hat or not, but they talked a little bit about that. I missed the talk. I wasn't at Black Hat. Otherwise, it's potentially already answered. But I just thought since you're talking about using it, I thought you might have a reasonable answer to that. Yeah, yeah. Well, there's a lot of different fitness functions, right? One they mentioned was basically like a point in the program. If we ever get to this point, then that's fit. So the code pass or the data that allows us to do that. That allows us to get closer, excuse me, to this code path are more fit than others. And they do that by setting breakpoints on everything along the way to that and checking the data. So the data could be fit based on that. And there's probably a lot of other ways you could generate fitness. And that's really one of the things that I'm going to be studying here exactly, right? Because even once you do that, it's sort of like, well, we found data that was fit and it made it to this point. Well, that's great, but it didn't necessarily crash it and it didn't necessarily find us a bug, right? So we got to find a way to work that in, right? To finding data that's fit in the sense that it's problematic. So how do you pick those points? I mean, like, in kernel hacking, there's obviously a bunch of places where, quote, unquote, we should never get here. I mean, is that type of location that you think about? Or, I mean, and obviously that's harder if it's a closed source application. Yeah, that's a really good point. Well, one of the things you can do is you can pick, potentially going back to that list of naughty strings. If you, you know, throw it in IDA Pro and you find it. Oh, there's three strcopys here. If we ever make it, can we make it to this strcopy? That's a good question. And that actually is a really useful thing to know. From a remote, does this attack service ever lead us to this somehow, right? So that's kind of a useful thing in that sense. Okay, so that is potentially automatable. If there's a set of functions that are potentially vulnerable, then you can effectively automatically pick those out. Then use those to predefine a set of fitness functions. Is that kind of what you have in mind? Yeah, yeah. There's probably a lot of different ways, so good question. Thanks. Hi. How do you get around code that inherently rate limits you? I'm sorry, can you say it one more time? Yeah, how do you get around code that inherently rate limits you? Code that rate limits me? Yeah, that tries to put in delays to stop you throwing so much data in a particular time sequence or time frame. So a lot of authentication protocols will actually put in delay and back you off. Yes. So is that particularly easy to get around? What are the issues there? That's a great question. Actually, a really, really good question. Timing is a huge issue when you're fuzzing because if you fuzz too fast, this fuzzer just may blacklist your IP, right? Or the server may just say, oop, this guy's doing something weird. I don't like him. That's a great question, and that's a problem you run up against. One of the parameters that you feed GPF is timing. I default sort of have it at 1,000 milliseconds per leg, but you can back that way off if you need to. Or you can do, there's user functions I talked about. There's user functions in GPF, like if your protocol has an encrypted hash, it expects you to do this, do a hash, and send it back. You can have a user function do that, and you could also have a user function just maybe every 10 times you have the program sleep for a minute or something. Whatever you need to do to keep the timing sane, you can do that. Yeah, thanks. Good question. Any more questions? All right. Well, peace, blessings, and good luck.