As you've just been hearing, can everybody hear me clearly? X, KSO, NMAP, most recently WING, these are examples of operating system tests. Methods to detect what operating system is running on a computer over the internet or on the same LAN from another computer by testing how it looks at the network. Now that can mean looking at its TCP IP stack or its ICMP implementation or maybe its services or its services pattern. There's lots of ways to do that. Up till now, though, you have had to access these things in a tool, such as the X tool, X probe 2 tool, or NMAP or KSO or whatever, or WING. How many people have looked at WING? Seen WING? Okay, cool. So, now to start with, which is why you should not leave me in the middle of this thing, is I'm going to show you what I've been doing. This is a program that I've written using my library. Now, right now, the library works in C and Java. You're looking at Java because Java's easy to make a GUI in. What you see in the bottom right window is loads of modified versions of the NMAP database and the KSO database. Very soon, once I look at X probe 2 and look at its database, since it's now in a file, they'll be in there, too. It's a list of all the operating systems that you find. In those databases. And then over here, you'll find little check boxes for the tests. So far, in Java, I've implemented the MANGA packet tests of NMAP fame and of KSO fame. In CI, I've also done the X stuff. Next is going to be the T-sequence test and WING. So, let's see if I can get it to work the first time. All right. Now, earlier you were mentioning, somebody here, was mentioning the fact that X probe 1 used a tree. Used a SYNT1 packet and then based on a tree that it had in its memory, would send the next packet based on the result of the first packet. And as a result, would send in total less packets than NMAP1 or I think any other test at the time. And as a result, it could send more packets. It could limit the number of packets it sent, reducing its IDS profile, reducing, increasing speed, all these kind of things. So, what if you could do the same thing with NMAP? What if you could run NMAP one step at a time and then use the results that you got back since NMAP runs? NMAP alone has the seven MANGA packet tests that you see there and a T-sequence test, which tests initial sequence numbers and a poor reachable UDP test. What if you could use those one at a time? Well, this program right here shows what happens if you do that. If I run the NMAP4 and the COSO2 tests, the source port of 10,000. I hope this is open. I hope this is closed. Now, a lot of the values in the test are based on starting sequence number. And this allows you to play with that. Now, oh, no suitable device found. Damn. So, again, so I'm plugging in a network cable cord. I'm not going to belabor it. I'm not going to play with this too long. The fact that I'm going to move on now anyways and I'll come back to that. But that's the kind of thing that you can do. I'll just keep that up since I think it's cool. That's the kind of thing you can do when you're able to access the tests in a systematic way. So hopefully now you should be convinced that you might want to hear the rest of the presentation. And, again, if you don't, feel free to leave. Especially since I know that some of you who dream in Perl could be very upset with the fact that you're not getting Perl code right now. I understand. I feel your pain. Okay. Another thing. The TGZ on the CD is useless. Go to my website. All right. Who is this code for? Well, the answer is kind of everybody. If you're a hacker, you won't be able to write a script that says don't run my exploit on anything except an exploitable box. If you are able to detect that you can sort out Windows 2000, version this, rev this with this service running, in this version, before you ran your tests, what you'd be able to do is have a mini vulnerability test right before you actually ran your exploit. Which means that instead of, like, running a system where you scan the host, you figure out what operating system it's running, you figure out what ports are open, you research what hacks are available, you could just run the hack and it would stop if it wasn't the right operating system. It would just not run. And if you're writing a worm, I'm not recommending that you write a worm. But if you're writing a worm, you might not want to scan Linux hosts over and over and over and over again like you've all seen in your logs. You might just want to scan Windows 2000 boxes. Well, by including all or a portion of an operating system fingerprinting library in your code, you can do that. White hats. The same reason that a black hat is interested in what operating system is running on your network, you should be interested in what operating system is running on your network. Vulnerabilities are based on options. There's an operating system and service version. Not all versions are vulnerable. Sometimes it's all BSD. Sometimes it's just free BSD. Sometimes it's just Linux. Sometimes it's just Linux 2.2. You care because you're going to be able to get broken into based on what you're running on your network. Now, on the other hand, besides from a security perspective, it would be nice for administrators to know what's running on their network. So these are just the reasons that you are interested in operating systems. Fingerprinting. Ava's talk is so deep that he just kind of goes into it and he doesn't realize, I'm sorry, he doesn't talk to why people are enjoying his code. Most of the people who enjoy his code don't actually do bad things with it, I hope. Okay, this is a deep knowledge track about beta code. If you're here expecting something you can go and then program in your application tomorrow, again, with apparel people, sorry. Not going to happen. Okay, why a live memory as opposed to a tool? Well, this way you can write things for yourself that are operating system sensitive. Let's say you don't want to write a hack. Maybe you want your web page to just be displayed for Windows 98. Or maybe you want your web page just to be displayed for Windows. All of them. Maybe you just want to be able to display one administrative home page for Windows, one for Linux, and you want that web page, hopefully I'll be talking about the Apache module and planning, you want that web page to be able to say, hey, I'm going to give you this content based on what you are. That would be a very, very convenient way to hand out patches. You could hand out exactly the patch that needs to be handed out to exactly the person that needs that patch. It means less clicks, which administrators or thousands of users love. So let's talk about the problems with tools, the problems with programs right now. There's a bunch of tests, right? Some of them are test, some of them are test, some of them are test, some of them are, you know, rings. Some of them are service tests. Well, you have different algorithms that are using these things different ways. Algorithm A by Afer and Fyodor is now using fuzzing. So what's the most sensitive and advanced algorithm out there? NMAT just uses brute force. It runs all the tests all the time and can come back with pretty good results usually. So you've got some... More advanced algorithms. But at the same time, you want to be able to have more control over your algorithm. If you're programming, say, Nessus, you might want to do different things and test differently than you are if you're doing another scanner. If you're doing a web page, for instance, you might want to scan another way. If you're on a friendly network and you're responsible for a network and you're scanning it, you definitely don't want to do tests that are going to possibly hang up any operating system. There are operating systems, older ones, that will hang up on different versions of NMAT's tests. It's just a version of a DOS. You run NMAT on it and it turns it off. This is a bad thing. So you can have polite, you can have stealthy, things that don't get detected. All these algorithms, though, are meta-tests. They're above the test level. They're not actually involved with the tests themselves. They're above the test. And these kinds of algorithms have the problems that Afer was just talking about when he was saying, you know, how do you deal with the results if you're talking about a low-balance test? How do you deal with the results if you're talking about this situation? How do you deal with the results in this situation and this situation? All that's dealing with interpreting the results of a test, which is a meta-level algorithm issue. So what I'm trying to do is provide a way for you to get very easy access to the tests themselves so you can do whatever you want on top with an algorithm. Okay. If you're not a librarian, well, I'm always going to be playing catch-up. I'm not going to be able to write new tests. I'm not going to be able to write, you know, zippy-do-do-da things. Maybe someday, like, I'll be able to come up with something new. But in general, people like Afer, Fyodor, Fyodor, these are the people who are going to be writing the new tests. They're going to be coming up with new code. They're going to be coming up with new algorithms. They're going to be doing the new, cool stuff. What's in the library is going to be the yesterday, old stuff, but just in a way that you can access. Right. And this is not going to be a tool. Like, I'm never going to... I'm going to hand out something that's going to be particularly useful to you right now. If you're a script kiddie, you're not going to get anything. You can run on the command line. Okay. Let's talk a little bit about the background of operating system fingerprinting. The first grandfather of all fingerprintings is KSO. How many people have used or heard of KSO? How many of you like KSO? Okay. Less. That's first generation. Why was it first generation? It was the first operating system fingerprinting code, and I'll talk about this a little later, to pull the database outside of the program itself so that the database of fingerprints and the logic to fingerprint them were separate. After that, we have the passive side, PLF siphon, stuff that's looking at traffic doing fingerprinting. Right now, I'm not implementing these tests, and these are probably the last tests that I use. And the reason is that they're not particularly useful for administrators. If you're interested in doing passive fingerprinting, usually you're going to be... a person who's interested in not being seen. The other case is when you're interested in seeing what traffic is going in and out of your network. And in that case, I think the fingerprinting, passive fingerprinting stuff that's going to become available in Snort is going to be far better than what I could do real quick. So I'm going to focus on the left side of the map here. So you have InMap. InMap is the seminal operating system fingerprinting. And the reason is, is it's the first to treat it as a real science. FIDO used a statistical test. He used Mengel packet tests. He used UDP tests. That's a pretty broad spectrum of ways to guess at operating systems to use in tests. And the other thing that he did that's very significant is that he tested lots and lots and lots of operating systems. If you've got OpenBSD running on a Macintosh like they had last year here, you might be able to get InMap to pick it up. You never know what's going to be in the database, though. And that's a complaint that people like Afer have been pointing out. Because that database is so huge that it really is becoming unmanageable and kind of useless, like what he was talking about for the printers. I mean, it's very difficult when you've got 20 signatures, 10 signatures for HP printers, and they all come up. That's just not useful. Okay, second generation is X. X was the first test to use, to not send all the packets at once. It made decisions based on previous tests about what test to do next. The problem with that is it was static. That means that the tree was hard-coded. So you had the tests, and then you had the tree. But just like the early versions of fingerprinting software had both tests and algorithm inside the code, the tree and the tests both need to be outside the code. So the algorithm for choosing what tests to do when and the tests themselves need to be configurable. So that makes it a second generation. Now, third generation is XFERB2, which I didn't know a whole lot about until today. So that code is addressing a lot of the problems with X, which is making it the most advanced fingerprinting system available. Now, once he does all the things that he's planning to do, it will probably be creating the crop. It will be the tool you want to use, because it will probably incorporate a lot of the tests that IMAP is using, the T-Sequence test, these kinds of things. Hopefully, what I'll be able to do is look at their API, the one that he was just describing, and use my library to code tests for his API, which means the fact that I finished the KSO and IMAP tests and made them separate and pulled them out and done all that work will mean that he's kind of handed that on a silver platter. But we haven't talked about it, so that's up in the air. Okay, the other thing is the WIG. Now, the one unique thing about T-Sequence tests and IMAP was that it was totally normal traffic. What it did is it sent it. It sent a packet. It sent a packet. How many people understand the TCP handshake? If you don't understand the TCP handshake, what I'm going to say right now is going to be just like gobbledygook. God sends you gobbledygook. Right? So just forget it if you don't understand that. You send the packet with a sequence number. It's going to respond back with a SYNAC, a certain value in its packet that corresponds in some way to the value that you sent. Now, by doing that over and over and over again, you can get a statistical relationship between what you send and what you get back. So you can find out if they're generating these sequence numbers, the ones that come in response randomly, or they're adding something to your sequence number. Very common is to add 100 bytes or add the value of 800 or some other constant. But there's no way to detect that. That will slip through a firewall. As long as you've got a website running. That's it. All the firewalls. You'll be able to get that test through. So the T-Sequence test is unique because it's extremely stealthy. It uses normal traffic. It's not doing anything illegal at all. If you stop T-Sequence tests, you stop your web server. That's the only way to stop that test. It's normal TCP traffic. Now, the other thing that's normal TCP traffic is a ring. And the way a ring works is that when you send out a SYNPACKET and then they send back a response and then you do nothing, they're going to try to repair it. They're going to try to repair that connection. Like it's supposed to be you talk, I talk, you talk, I talk, okay, we're talking. That kind of thing. Well, instead I go, I talk, and they go, we talk. And then you go. And then you say, they're not going to say it. We talk. We talk. We talk. And the periods between the we talks is something that's constant per TCP IP stack implementation, which means you can test for it, which means you can determine which operating system is running. Now, what's the significant thing about that? It's very much like FIDO NMAP's T-Sequence test in that it uses totally normal traffic. It's not something you can detect with an IDS system. It's the same from an IDS perspective as someone unplugging their Ethernet cord or a host going down. The number of false positives you get by writing an IDS signature for that kind of a test would be phenomenal. So, both the T-Sequence test and the ring test represent methodologies. They're methods for getting an operating system in a very stealthy way. We're talking about KSO again. If you want to know about KSO, read FIDO's paper. In fact, if you want to know about operating system fingerprinting, read FIDO or NMAP FIDO's paper. That's the seminal work in the field. It's the first real scientific look at it. Now, if you really want to know about operating system, then read AFER's X paper. It's that thick. And you'll know a lot more. But if you want to start out, if you want to review these concepts, FIDO's paper is a great place to start. NMAP. Exactly what I just said. Robust database. Really big. And it's the first to be really scientific and really systematic about the way you fingerprint. X. First use intelligence. It's all scientific, but it's got a hard-coded algorithm for determining what tree it is. Ring. We just talked about it. X2. You know as much as me. All the stuff that you just said, that's what X2 is. Can everybody hear me still? Cool. Okay, let's talk about the structure of my library. All the tests right now are actually written in C. The reason that that's the case is that C has the best and most documented method for accessing raw IP sockets. Most of the tests, many of the tests involve writing packets in very specific and non-usual ways. So you need to have access to those raw libraries. The other thing is that I use the X2. I use LibNet, the beta version, because it's cool and does things for me that I don't have to sort things out because I use it. It's got a lot of functionality. It's really cool. So that's in C. That's in C2. The other thing is that actually running the tests is irrelevant. The important thing is you have that information from somewhere. So the easiest way to write the test is in C. So that's how I do it. Okay, C applications. Java applications. C++ applications across the top there. And then beneath those, you have the X2. So you have the C library, Java library, C++ library, and Perl library. The Java library is the one that's most robust, obviously, because that's the one that I just showed you. So right now, I'm going for implementing X, KSO, Nmap, and Ring, and all these different tests, and having them move up in between these different programming languages. So wouldn't it be cool if you could write a Perl script that says, if Windows do this, or if some function returns as Windows, do this, or if some function returns as Windows, you do this. This would be a good thing. The other thing with Perl, and this is something that actually I'd love to get this functionality from Perl into other languages once I get done, is you can take a look at Rainforest Puppy's LibWhisker. LibWhisker is capable of doing very, very accurate fingerprinting of the web port. It can sort out what server is doing what. It can sort out what web server is running on a particular computer. I was doing a pen test recently, and they were using a FreeBSD. It was a product that was based on FreeBSD, and they were using it to proxy an NT2000 web server. Well, when Whiskers first went into it, it said, oh, it's reporting back, it's saying it's Windows 2000. So that's what it is initially. And then it runs a bunch of other tests, and it finds that the actual behavior of the server is more like FreeBSD. So it comes back and says, actually, no, this is a package. This is a patchy. It looked like Windows 2000 at the beginning, but it's really a patchy. Wouldn't it be neat if you could get the, this isn't what the web server really is from LibWhisker, and move it over and make decisions based on that in other programming languages? So you could say, because Apache, for instance, runs on Windows 2000. Rarely do people do that. But it does. It runs. So you can get that legitimate header back from that web server. And then if you're running IIS hacks against Windows 2000, it runs on Windows 2000. It runs that box. Why? So being able to say, for instance, run a T sequence test against port 80, get a sequence number, run a ring test against port 80, those are both totally stealthy, and then just ask for what, do a service test to find out what web server's running, you'd be able to fingerprint a host with absolutely no IDS detectable stuff. All that stuff is totally legitimate traffic. And it would tell you a lot of information. So every language here has different advantages. The reason I did Java first is because most of what I want to focus on is how OOP, and object-oriented programming, really affects the fingerprinting science in Java. It's very easy to get threads and OOP out of Java. So I started there, and then I'll use what I've learned there to do the elements. So we kind of understand what I'm talking about here. Have I lost everyone? Have I not lost everyone? Okay. Okay, right now, for my .c files, each test is written as a listen function and as a send function. Now, for instance, the sending portion of in that T1 through T7 are very different, but the fingerprinting portion are all identical, so you can collapse the listening file into one. So you can collapse the listening file into one. So basically, from a C perspective, it's functional programming. By using my C library, you should be able to just call functions with the right stuff and run whatever test you want. Let's take a look at the C code. Talk amongst yourselves. Okay. There it is. Perfect. All right, and I'm off. Okay, so you're back in Google. Repeat in Once Round. So you can use it to load, load, load, test it, test it, okay it's back on. So you have a function call, takes a source IP, destination IP, source port, destination port, and initial sequence number. Now in C++ or Java what you can do is overload these functions so that you don't actually have to give it a sequence number. You don't even have to give it a source port number. Basically the source port in the Nmap meta-level algorithm is chosen for you, it's chosen randomly. But you don't have to do it that way, if you want to you can configure just about everything. On the other hand, the overloaded functions will allow you to run it the same way that Nmap does. So if you just want to have a destination IP, assuming that you're using your own IP so you don't need a source IP, assuming that you're going to generate a source port randomly so you don't need a source port, and you need a destination port, you don't need a sequence number because it's going to choose that randomly, then that function will just have destination port, destination IP. You build the options. Nmap TCP tests use crazy options. It's one of the IDS signatures of the tests. Any time you see this particular set of options all together in one place in a packet, it's usually an Nmap test. Then you set up the build TCP portion of it, I don't know how many of you are familiar with Nmap, and you use the SYN port and the BOGUS port here. There are so many flags that a TCP packet can have. There is one that is not defined, that's a BOGUS. Nmap sets that flag. Most TCP IP implementations have no idea what to do with it. So they'll respond back. Sometimes an operating system will take the packet it's reading in, change it into the response, which means they don't actually write a new packet. If they do that, then the BOGUS flag in the packet that comes back will also be set. So again, depending on how you implement it, the results are different. You make enough space in the IP and then you send the test. Alright, moving back to my PowerPoint, talk amongst yourselves. Okay, here is something that I would actually like some feedback from people at this conference about. And the question is, how do you classify an operating system? For instance, the way I'm doing it right now is with OS family name, major version, minor version, other information, and architecture. I know for a fact that this is not a good way to do it. And the reason is, is think about how many BSD variants there are. If you have a family and you want to be able to write a test that's for all BSD, or you want to be able to write an exploit that's for all BSD boxes, if you're doing that, you want to say, if the family name, if this top level group is BSD, then run the test. If not, then don't run the test or the exploit. Okay, if you do that, then what goes in major versions, since that's the next touchdown, would be free BSD. And then under that would be four point something. Well, the problem is it just doesn't split up very well. Like, for instance, Windows. Windows is the family name, then you have 98 and all of the other things. So when you're using Windows and the major version is 98, that's comparable to, like, the entire operating system of free BSD. Probably shouldn't be. So how do you classify an operating system? How do you group them? That's a difficult question, and it really takes some knowledge of operating system history, of which I, unfortunately, know only a lot apart. So I'd like some discussion, perhaps, if you'd like to come talk to me about this afterwards, please do. But every class JLS test, which every test is a subclass of. Has this information in it. Not only that, it has, again, if you don't know Java, then this is going to sound irrelevant to you, so just ignore it. I've redone the equivalency stuff so that it does the equivalency in such a way that it won't order any given set of these operating systems by their actual classification. So we're going to take OS family name into account first, then major version, then minor version, then something like this. So we're going to do that. So that you can do, you can use the actual Java compare to function, and it will actually return a negative or positive number based on the relationship between two operating systems. Which means you can, for a given operating system, you can run tests based on less or more stuff. If you know Java, then perhaps you know what I mean. If not, perhaps you know what I mean. Okay. Threading. Operating system fingerprinting should be threaded. And the reason is, is that there are some tests that are related to each other. For instance, that tree that X did. But there are other tests that are totally irrelevant. So you could be running the X tree, all those ICMP tests. At the same time, you're running in-map tests. the same time you're running service tests and then the whole time you could be using you know race condition safe data objects to to move information about what tests should be run so you can have basically what this allows you to do is write testing algorithms that will turn on its head based on the results of one tests it may be just you can write dynamic trees so you can say well let's start running these four tests and then get those four tests back and as a result run total different other set of tests and the reason that's important is that one of the problems with in maps fingerprinting and just just just vulnerability assessment in general is that it tends to be slow it takes a long time to do this if you can do stuff in parallel if you can get information in different directions at the same time that gives you a huge advantage can you've already looked at the code see pro module and C++ module will happen someday if you're a pro guy and you love writing modules that access C libraries and move like large amounts of data back and forth please come talk to me I'd love to have your help C++ I think I'll be able to handle just because it's easy okay what's the future of my fingerprinting library well obviously it's to implement all tests when you're able to access all hotels in my library in one place that's all I give you that means that it's it's it's an easy place for you to start assuming your life operating system system fingerprinting code the other thing is sorry fingerprinting there's a program called win fingerprint that does nothing but fingerprint all those dangerous turn them off please one 30x windows ports that you should never be using ever. So you can run an entire sequence of service testing to fingerprint what NetBIOS, what SMB, all those things, what they're doing, what they mean. The stuff that they can return, I haven't looked at the code carefully, looks like it's pretty impressive, very much like the Whiskers ACTP ability. And as a result, if you can get that service information, then what you can do is you can have associations between service generations, like SendMail version this goes with Solaris version this, and IIS version this goes with Windows version this. Like some of these things, you have them off the top of your head. Some of them, on the other hand, are a little more complicated. But since vulnerabilities are based on service member and operating system member, it would be nice to be able to use service to get operating system member guesses and use operating system guesses to get service member guesses. So hopefully we'll be developing a beta version of NetBIOS. The other thing is that what you can get if you have all of this stuff is a CDE database, kind of a Nessus lite. Nessus actually tests to figure out whether or not you're vulnerable. What if you don't care? What if you don't really care if you're vulnerable or not? What if you're running a version of Windows blah blah blah or FreeBSD blah blah blah that's vulnerable to five things? Well, maybe all you care about is that you need to upgrade to the next version. Maybe you're on FreeBSD 4.0 and you need to be on 4.1. Maybe you're on Windows 2000 and you really should be on Windows XP. If that's all you care about and you're an administrator, you don't need to have a full blown vulnerability test to make sure you are in fact vulnerable to something. All you need to know is not current version, please batch. That's it. So if you can be very aware of operating system fingerprints and service fingerprints, you get a very, very cheap, very, very fast vulnerability scanner. The other thing is to develop a simple scanner. Something that does, I don't know, a clue of what Nmap does. I don't know if you guys have looked at Nmap 3. It's up on insecure.org. You definitely ought to go take a look. The Windows versions of Nmap and the Unix versions are merged. It's pretty cool. But that's, I definitely don't want to write stuff that competes with these tools that are out there because they're so good that it's very unlikely that I'll ever be able to generate something that's going to be able to keep, you know, pace with those technological developments. Rather, I prefer to kind of imitate what they did last week. I think the coolest thing would be a little less Apache module so that you could give different information to different web, to different users based on their operating system. So you set your proxy up so that, let's say, you do, you combine your CD database scanner and your little less Apache model. You scan your network. You come up with 192.168.1.5. . It's a vulnerable version of FreeBSD. You associate, you put the patch up on a web server and you say, if FreeBSD version this, show this page. And then you write into your proxy for your web surfing that they have to go to the patch version update page first. Well, that means that you scan your network for all the vulnerable things. You put the patches that they need up on the website. And then those servers or workstations that are vulnerable will automatically be forced to go down to freebsd.com. And then you download the patches before they can go continue surfing. Now, they might not install the patches, but at least they download it and that's a start. You cannot lead, you cannot make a horse drink. Okay. That's everything. Thank you. And do you have any questions? Yes. Oh, and actually, I'm going to have to do microphone switching since nobody can hear. So if you'll just come up. Oh, I'm sorry. That's a very good question. And it's on the HTML documentation that's inside the CD. It's www.synseer.net. S-Y-N-S-E-E-R. Good point. Next question. Next question. I can't hear a word you're saying. TCL. That would be a good idea. Yes. The GSTCL. And I said yes. Anybody else? Okay. I officially am relinquishing the microphone. Please feel free to come up and do the one-on-one questions if you feel like it. Bye-bye now.