Okay, let's get started on the next session. I've got Jamie Sanchez with derevolutionizing OS fingerprinting, the cat and mouse game. Jamie's got over 20 years experience as a specialist advisor for large national and international companies, focusing on different aspects of security. And without further ado, I'll hand over to Jamie. Thanks very much. Well, hi, hello. It's great to be here. Thank you for coming to see this talk. Just some things about me. I've been working in security for almost 20 years. It's not my first time in Vegas. So it's great to be here again. What we are going to talk about is OS fingerprinting, you know, that is something very interesting from different perspectives, you know, from the attacker point of view, for defenders, administrators, vendors, you know, you really need to know what kind of operating system you are trying to connect. If you try to attack, you need to know, for example, if it's a Windows XP without a service pack or whatever before launching your exploit, you have to know the memory addresses. So it's described as basic collection of configuration attributes from remote devices but it's not also this because there are a lot of approaches for operating system fingerprinting. You know the old days when everything was like banner grabbing, that's manual recognizance. Then we moved to active operating system fingerprinting with tools like Xboot, like Nmap. Then we have also that basic point of view where you are only an analyzer like a packet sniffer. All the traffic that you are generating on your side and on the other side just to get useful information. But there is another approach that are the timing attacks. We are not going to see it here. So the first technique is banner grabbing is very simple. You connect, you use Telnet for example to a web server to get all the headers information if you are dealing with an ESS or NGINX, whatever. You can also connect to FTP services, Telnet to see the banner. You can use SNMP. That's kind of active techniques. But you can also get free information for other services, you know, Emap, Finger, NTP. And if you have access to the remote machines, you can also play with some configuration files for the issue files, the banners and you can try to port a scan and also you can try to do social engineering just to get information about the technologies used by any company. There are a lot of services that gives any other information, for example FTP use the SST command that asks information about the server operating systems and you have some examples there. Another useful thing would be for example in FTP connecting to the FTP, get any file that is inside, for example the LS, compress, cut and try to get information on your local machine. For example here you can see that our file is compiled for Linux, for Sun, whatever. You can also use all the kind of search engines like Sodan, like Census, that get all this information for you so that you don't have to interact with the other machine. For example, this is very useful because I don't know if you can see it there. Well, don't worry. If you try to scan, for example, mobile networks, you can try to look for ports 62078 as well for jailbroken iPhones and you can try to connect with SSH with the file credential that are root and alpine and try to move on. So this is very important to know. To know what kind of operating system you are dealing with. In this case I only use the mobile phones to jump to another machine and finally attack my target. Try to get all the information and try finally to attack my final target. So some things you need to know, TCP IP theory. This should be very basic but it's something that people have to understand before going into fingerprinting. For example, in IP you have to know what kind of protocol you are dealing with, TCP, UDP, ICMP, that are the most important ones that we are taking a look. Source address, destination address, something you know. But in TCP we will be dealing with SIM packets, ARC packets, push. We have to know not every, almost every TCP option that is available. But you have to understand that every almost operating system uses some TCP options in the same order and maybe in Windows XP and Windows 2000 they have the same options but they are in different order. So that's the way that we can make the difference and know what we are dealing with a Windows XP or Windows 2000. The same for UDP. Just to know source port, destination port. You will see that in Nmap it has like a custom data that has a lot of C's. And finally ICMP that is used by Nmap. So these are some basics that you will see that in any database. You get all this information if there is a congestion flag that is on. If the default fragment flag is on. So for active operating system fingerprinting we are going to see just little tools that for example some of the first one that was called Queso. That is in Spanish. It's like which operating system. And it was sending like seven kind of tests. You can see the SYN, SYN plus acknowledge, SYN. And then they moved and another project was released that called XProof. XProof deal a lot of, deal with a lot of packets of ICMP. Send also UDP packets. But this kind of tools are some old right now and I think that almost everyone in the security is using Nmap. Nmap is a mask for pen tester for everyone. And Nmap gives you a lot of information about what kind of device you are dealing with. For example the device type in this case is a general proposed because it's a computer but it can also tell you if you are dealing with a printer, if you are dealing with a firewall, with a router or if it doesn't know well it can give you information about this maybe should be a router or maybe it's a firewall. Next thing that we'll tell you is the family in this case is Linux and the generation. The generation is practically the version that you are running. Common platform enumeration, that's something standard. The details on the fingerprint. If it's not a perfect match because there are some times where you have like a firewall or you are not getting all the traffic, you can get a message like just guessing. So Nmap doesn't know exactly what kind of operating system it is but maybe it's telling you that you are dealing with a Solaris. Maybe this version, maybe another one. You know, a lot of information, the network distance like if you were doing a trace route, uptime guess, TCP sequence prediction. But you can also use version scan. Version scan is very useful when you are dealing with a proxy because if you try to make the operating system fingerprinting you are dealing really with the proxy and you need to get information about the remote host. So in this case you can get a lot of information about if it's an SSL service, if it's running TCP in UDP, it can deal with a map, whatever service. But the interesting thing here is how does Nmap works? How does it really works? The new working for this is that Nmap is leaving 15 TCP proofs to UDP and ICMP. All these tests are with a custom destination port. They have custom flags. And the result for the Nmap database is something like that. I don't know if you can see it very fine. But you can find it in the slides that you have a lot of information about every operating system that you are dealing. For example, the first TCP proofs. So it has like this custom TCP options. If you want to get more information about this, it's really useful to get the official Nmap book. It has a lot of information about this. So you can get all the TCP options that they are using, the port, the remote port they are using, if they are looking for a network congestion flag, if the default fragment bit is set on ICMP. And it begins with the real proofs of T1, T2 to T7. When you have a lot of, a lot of flags that you will know that you will receive. For example, packet T2 is no flags. Fragment bit is on. It's window size is 124. This is all the information I got. So I can know which packets I should filter and I should manipulate and let all the traffic go to the, all the traffic go to my machine. So I, in this case, we will see a tool that is called OSFiller that is only dealing with the specific packets for Nmap. All the other traffic should be treated by the kernel. This case is UDP. UDP has a special payload because it has like 300 times the letter C. So it's very easy to, to recognize that kind of, of packets. I have a small demo but I think it will be better if we do it live because we can make the screen bigger. So the same thing is for basic operating system fingerprinting. You know, it's like dealing with a packet sniffer. What you are trying to do is coping the data without modifying it. You don't manipulate the traffic. You just get all the information and try to analyze it locally to get all the information you can about the remote host. And for this you got, for example, OSFiller, the tool I'm presenting, can hold all the information from the database from version 2. It's very simple. Every line is like this. The first is the window size for the, for the TCP IP stack. Time to leave if the default fragment flag is on. The TCP options and the order. And some quirks, for example, if you get a SIM packet, you shouldn't have any payload inside but there are some operating systems that send this kind of information so this is very useful to identify them. And finally you got the, like, like the label for the operating system. This is fully working but then both move to another version, version 3, that is like a complete rewrite of the, of the original code. And it deals with TCP packets, the SIM packets, but the, the SIM and the acknowledged packets, HTTP request, so it's more complete. In this case, instead of rebuilding all OSFiller, what I'm trying to do is just to migrate this kind of database to the old format so we can, we can use it. If you can see, it's almost the same kind of information. You have the time to leave, the length of the packet, maximum segment size, you have the TCP options, default fragment, some more quirks that are available in, on this operating system. So this is very easy to, to identify. And finally, there are a lot of people that are still using Ethercap. Ethercap is almost using the same technique as both. It's only copying all the traffic and just trying to analyze. And it has some, uh, database. If you can see all, practically all the, all the, all these tools use the same format, all the same information, it analyzes TCP options, length of the packet, what kind of information if it has a payload. So in this case, um, in the next release of OSFiller, I will migrate the same database from Ethercap to both. It's very simple because, uh, the version two of, of database, um, database of, of, of version two, uh, is being parsed by OSFiller and it is 100% complete. So it works like a charm. So I will be doing this, this change. But also there are some commercial engines like Surefire or Fireside that use this kind of techniques to, to identify all the traffic for, for the IPS or the IDS. When you get an alert, they tell you like, hey, you have been attacked by this kind of machine, maybe it's a Linux, maybe it's a Windows machine. They are using almost the same information and the same information, you can, you can spoof the, that kind of, of, of fingerprint. So you can try to confuse administrators, defenders. And this is really useful to know because there are other online services, for example, for vendors of, for ads or whatever, that use this online. So it's very useful for, for vendors, for example, to know if you are using not only, uh, Chrome or Safari, but if you are using, uh, Macintosh, you are using Windows, you are using Solaris, whatever. So in this case, it's very simple to make the same thing in, in the, in the first approach, it thinks it's a Linux version three. And in the second one, we are running only OSFiller and you get like Windows NT kernel. So that's because it's using same database like both of the gap. So it's very simple to deal with this. So other techniques to, to do this kind of fingerprinting could be analyzing the, the DHCP requests. So when you, when you ask, for example, for options like the DNS server, default gateway, it's asking in an, an exact order. So you can try to do, there is a tool called Satori. There is a very interesting, uh, white paper that you can download and take a look. And at last you can use other techniques like identify the MAC addresses, for example, Apple or Sony use some kind of patterns. So you can use that to get all the information about the, the machine you want. So at this point we know how to do that kind of active fingerprinting, basic fingerprinting, but which kind of countermeasures do we have to protect from this? I have collected some information about uh, just uh, someone's, for example, IP personality. It was very famous because, um, depending on some parameters, it let you change sequence number, window size, IDs, uh, how it answer to TCP packets. But the problem is that, uh, it changed a lot of, of, of the behavior of the TCP IP stack for Linux. And this, uh, was working for all releases of the kernel. So nowadays it's not very useful. Uh, the other one was the steal patch, uh, that was running from kernel to 22 to 24. But this problem, this, this tool have a problem that, um, if you change some parameters when it's scanning, you can know that this, this, the, the remote machine is using this tool and you can identify because you know that steal patch only works for some kernels. So it makes easier to understand. Many others, it was a blue, black hole, fingerprint fucker, more, there were a lot of tools, but nowadays I, I didn't find any useful tool to, to avoid this. So when I was working, I worked for Telefonica. When I was working at the security center, I have to deal with a customer that it was scanning all his network every day, every day. I, I didn't have time enough. I didn't have alerts so fast to notice him that I know that he was scanning. So I tried to make some kind of cool thing that this was detecting the, the scannings, uh, uh, with a program I made in Perl. Um, but also try to fool him. And so like, Hey, you're scanning, but you have a PlayStation inside your network. You see, you have a Sonny Wallman Ericsson. Um, and that's how we came to OSFiller. OSFiller, if you know, uh, packets are inside the kernel space and you are, uh, on, uh, on user space. So you can not interact with packets in real time. So, uh, the solution was to use NFQ. NFQ is, uh, an extension for IP tables that accepts some, uh, some, uh, uh, extensions and lets you put all the packets inside some queues. So you have two elements. You have a queue handler that deals with the, with the packets, with the kernel. So it tells the kernel, just give me the packets and it moves to user space. In user space, you can receive those packets, manipulate them and send them back. The only problem here is that you have a maximum queue length that is 1,424. So you have to manipulate all those packets very, very fast because if you don't and the queue gets full, all the traffic will be re, will be rejected. And that's a big problem. So if just, just take a look, for example, let me see if I can. Okay. Okay. Now you have, I think that you can see the screen now. If you, for example, do an Nmap scan for localhost, it will give no information why because I don't have any open port. So let's start, for example, secure cell. So we have, I'm running a Kali. I have the Linux with kernel version 3, 3.7 to 3.10. So this is all information that Nmap can give me. So we will be using our tool is OSFueler. OSFueler is working. So what can you do? First of all, just let you know that here we are only dealing with, in case of Nmap, only dealing with a specific test for Nmap. All the traffic, all the traffic should go directly to your computer and shouldn't be manipulated in any way. So, for example, if you just want to take a look at what kind of operating systems do you have, minus N. We are interacting with the official Nmap database. So you can just update it and we will be working. So this is almost all the operating systems that are available right now. There are a lot of them. Just to let you know that it has like 5,500 signatures. So there are a lot of operating systems to emulate. So if you do the same thing, for example, with Poth, the same. In this case you have to deal with what kind of operating system do you want and then you go to the versions. In this case, Nmap, with OSFueler you can go in both ways. You can specify I want to be like a Windows and I need the version to be like XP or 2000 or maybe you just specify the family. I need to be Windows and every packet that you are sending will be in a loop and you will be changing your ID inside Windows. For example, the first one will be XP, second one will be 98, the third one will be 2000, that kind of things randomly. There are not so much signatures for Poth. There are like 250 and there is a special flag that if you just want to search, for example, give me all the information that you have. Not for Windows but let's see if you have something that is smaller. For PlayStation, Nmap has like 1, 2, 3, 4, 5 signatures available for PlayStation and you have one available for Poth. In this case there are two queues for the traffic. One will go to Poth to basic fingerprinting. The other one will go only to Nmap. So when you are running OSFiller you get those different queues and in this case the program is running in multithreading. So I have made some tests, not some stress tests but because last day in the demo labs people asked me about the performance. So when using in a web server without a lot of connection you have to understand that you have 1,024 packets per queue. But in case of Nmap, Nmap sends like 20 packets. So to get the queue full you will need maybe like 200 attackers scanning at the same time and yourself running a Celeron or something like that. So if you just wanted to, let's search if we can do Nmap. Let's search for Windows Poth Nmap. For example this one. Now I have the information so let's emulate to be Microsoft Windows 2000. And you get this info. You are mutating to Nmap. You get in the database the signature. You can see that there are some proofs that we shouldn't respond. For example for UDP, for example for ICMP. And if you open a new window, let's repeat the same test. Do you see? Nmap thinks that we are running Microsoft Windows 2000 or maybe XP. That's because the signatures are very similar and Nmap doesn't have all the information it needs to complete the profiling of my operating system. If you use the verbose option and you launch the same scan, you will get information for every packet that you receive from Nmap. So for example you remember I told you that UDP test in Nmap has a payload of 300 C's. You can see it here. So this is not only useful to try to defeat Nmap but you can also let it run in the background and write directly all this information to a log and try to get information when you are getting a scan. The same thing we can do with for example Puff. We search Windows for example. Let's work with 2002. So family is Windows, details are this and interface would be localhost. The same. You get here the signature for Windows 2000 and let's get in Puff. Let's get in Puff. Just let me launch some localhost connections. If you see I have started a secure cell connection and Puff thinks that we are running Microsoft Windows XP. If you stop always filler and do the same thing, in this case it doesn't have information because it's a newer kernel and all that base of Puff doesn't have it but it's not the same signature. And you remember I told you that you can just specify the family. I'm telling filler to try to emulate almost every version of Windows it has on every new packet. So if you launch Puff, Windows CE, Windows 98, Windows 2000, Windows NT, Windows 98. So on every connection you will be changing inside the same family your fingerprint. You can go to random. In this case it's a sound receiver. Linux 2.6.39. Search for playstation. Now let's see if we can get something cooler. Sony Ericsson mobile phone. And you see. Same thing for this. So it's very easy for the tool to get all this information to read the Nmap database, to read Puff databases. Nmap database is working like 95% because there are some signatures that doesn't have all the fields and I have to change the inner working of filler to change that. But in this case Puff is running with almost every operating system. And I think that's all. You can get those fillers using github or using pip and feel free to collaborate on certain issues that you find. So if there is any question? Yes? I can hear you. No. In this case we are only dealing with active fingerprint. This is not valid proof. This is only a proof of concept for Nmap and for Puff. If you make some modifications in Nmap for example and you deal with some small changes you can get information about the remote host. So this is not a valid proof but only proof of concept for those specific tools. You can still use like DHCP, you can use the MAC address, you can use timing attacks to identify the operating system. So this is not working for every technique. Just should be working fine for this kind of tools. Yes? Excuse me? That's what I told you before. I haven't made any stress test but think of that in the case of FACIF you are only modifying the SIM packets and in the case of Nmap you are only dealing with almost 20 packets per scan. So that shouldn't be a problem. You should maybe have a slow machine and have like 200 or 400 attackers scanning you at the same time to get the queue full and the program works with multithreading. So I haven't made a lot of tests but it should be working fine. I'm using like on my pen test when I'm trying to do research and it's working fine. With some servers I have on internet and it's working okay. But if any of you can get those information, that information about the performance, it should be great to have it inside the GitHub. Thank you.