start	end	text
0	2820	Okay, let's get started on the next session. I've got Jamie
2820	8220	Sanchez with derevolutionizing OS fingerprinting, the cat and
8220	12020	mouse game. Jamie's got over 20 years experience as a
12020	14840	specialist advisor for large national and international
14840	18260	companies, focusing on different aspects of security. And
18260	20880	without further ado, I'll hand over to Jamie. Thanks very
20880	26500	much.
26500	31160	Well, hi, hello. It's great to be here. Thank you for coming to
31160	38140	see this talk. Just some things about me. I've been working in
38140	43160	security for almost 20 years. It's not my first time in Vegas.
43700	50460	So it's great to be here again. What we are going to talk about
50460	54760	is OS fingerprinting, you know, that is something very
54760	58320	interesting from different perspectives, you know, from
58320	62420	the attacker point of view, for defenders, administrators,
62420	68080	vendors, you know, you really need to know what kind of
68080	73120	operating system you are trying to connect. If you try to
73120	76800	attack, you need to know, for example, if it's a Windows XP
76800	81680	without a service pack or whatever before launching your
81680	86540	exploit, you have to know the memory addresses. So it's
86540	90540	described as basic collection of configuration attributes from
90540	94660	remote devices but it's not also this because there are a lot of
94660	99520	approaches for operating system fingerprinting. You know the old
99520	104100	days when everything was like banner grabbing, that's manual
104100	109000	recognizance. Then we moved to active operating system
109000	113940	fingerprinting with tools like Xboot, like Nmap. Then we have
113940	119040	also that basic point of view where you are only an analyzer
119040	124880	like a packet sniffer. All the traffic that you are generating
124880	130000	on your side and on the other side just to get useful
130000	132780	information. But there is another approach that are the
132780	138620	timing attacks. We are not going to see it here. So the first
138620	141680	technique is banner grabbing is very simple. You connect, you
141680	145420	use Telnet for example to a web server to get all the headers
145420	152080	information if you are dealing with an ESS or NGINX, whatever.
152100	155120	You can also connect to FTP services, Telnet to see the
155120	163120	banner. You can use SNMP. That's kind of active techniques. But
163120	166700	you can also get free information for other services,
166700	171120	you know, Emap, Finger, NTP. And if you have access to the
171120	174740	remote machines, you can also play with some configuration
174740	180460	files for the issue files, the banners and you can try to port
180620	184720	a scan and also you can try to do social engineering just to
184720	188020	get information about the technologies used by any
188020	194820	company. There are a lot of services that gives any other
194820	199320	information, for example FTP use the SST command that asks
199320	202660	information about the server operating systems and you have
202660	208340	some examples there. Another useful thing would be for
208340	213400	example in FTP connecting to the FTP, get any file that is
213400	219500	inside, for example the LS, compress, cut and try to get
219500	222040	information on your local machine. For example here you
222040	227740	can see that our file is compiled for Linux, for Sun,
227740	233920	whatever. You can also use all the kind of search engines like
233920	237940	Sodan, like Census, that get all this information for you so
237940	243520	that you don't have to interact with the other machine. For
243520	248180	example, this is very useful because I don't know if you can
248180	257300	see it there. Well, don't worry. If you try to scan, for
257300	262180	example, mobile networks, you can try to look for ports 62078
262660	266560	as well for jailbroken iPhones and you can try to connect with
266560	269540	SSH with the file credential that are root and alpine and
269540	274480	try to move on. So this is very important to know. To know what
274480	277060	kind of operating system you are dealing with. In this case I
277060	280820	only use the mobile phones to jump to another machine and
280820	286560	finally attack my target. Try to get all the information and try
286560	291980	finally to attack my final target. So some things you need
291980	296460	to know, TCP IP theory. This should be very basic but it's
296460	300380	something that people have to understand before going into
301860	308080	fingerprinting. For example, in IP you have to know what kind of
308080	311940	protocol you are dealing with, TCP, UDP, ICMP, that are the
311940	317600	most important ones that we are taking a look. Source address,
317600	321280	destination address, something you know. But in TCP we will be
321280	327220	dealing with SIM packets, ARC packets, push. We have to know
327220	332080	not every, almost every TCP option that is available. But
332080	334840	you have to understand that every almost operating system
334840	340860	uses some TCP options in the same order and maybe in Windows
340860	344980	XP and Windows 2000 they have the same options but they are in
344980	348980	different order. So that's the way that we can make the
348980	351580	difference and know what we are dealing with a Windows XP or
351580	358220	Windows 2000. The same for UDP. Just to know source port,
358220	361900	destination port. You will see that in Nmap it has like a
361900	370300	custom data that has a lot of C's. And finally ICMP that is
370300	375620	used by Nmap. So these are some basics that you will see that in
375620	380740	any database. You get all this information if there is a
380740	388220	congestion flag that is on. If the default fragment flag is on.
388220	392120	So for active operating system fingerprinting we are going to
392120	396940	see just little tools that for example some of the first one
396940	402140	that was called Queso. That is in Spanish. It's like which
402140	408060	operating system. And it was sending like seven kind of tests.
408060	415800	You can see the SYN, SYN plus acknowledge, SYN. And then they
415800	420760	moved and another project was released that called XProof.
420760	427260	XProof deal a lot of, deal with a lot of packets of ICMP. Send
427260	433320	also UDP packets. But this kind of tools are some old right now
433320	440380	and I think that almost everyone in the security is using Nmap.
440760	445290	Nmap is a mask for pen tester for everyone. And Nmap gives you a
445290	448030	lot of information about what kind of device you are dealing
448030	450470	with. For example the device type in this case is a general
450470	453410	proposed because it's a computer but it can also tell you if you
453410	457210	are dealing with a printer, if you are dealing with a firewall,
457210	461530	with a router or if it doesn't know well it can give you
461530	464830	information about this maybe should be a router or maybe it's
464950	469050	a firewall. Next thing that we'll tell you is the family in
469050	472130	this case is Linux and the generation. The generation is
472130	477730	practically the version that you are running. Common platform
477730	483050	enumeration, that's something standard. The details on the
483050	487070	fingerprint. If it's not a perfect match because there are
487070	490510	some times where you have like a firewall or you are not getting
490510	495090	all the traffic, you can get a message like just guessing. So
495090	497910	Nmap doesn't know exactly what kind of operating system it is
497910	500510	but maybe it's telling you that you are dealing with a Solaris.
500510	504890	Maybe this version, maybe another one. You know, a lot of
504890	509070	information, the network distance like if you were doing
509270	515850	a trace route, uptime guess, TCP sequence prediction. But you
515850	520930	can also use version scan. Version scan is very useful when
520930	523910	you are dealing with a proxy because if you try to make the
523910	527050	operating system fingerprinting you are dealing really with the
527050	529830	proxy and you need to get information about the remote
529830	534010	host. So in this case you can get a lot of information about
534010	540250	if it's an SSL service, if it's running TCP in UDP, it can deal
540250	545150	with a map, whatever service. But the interesting thing here
545800	550050	is how does Nmap works? How does it really works? The new
550050	556730	working for this is that Nmap is leaving 15 TCP proofs to UDP and
556730	563130	ICMP. All these tests are with a custom destination port. They
563130	567950	have custom flags. And the result for the Nmap database is
567950	570870	something like that. I don't know if you can see it very
570870	574350	fine. But you can find it in the slides that you have a lot of
574350	577410	information about every operating system that you are
577410	583990	dealing. For example, the first TCP proofs. So it has like this
583990	589170	custom TCP options. If you want to get more information about
589710	594130	this, it's really useful to get the official Nmap book. It has
594350	599730	a lot of information about this. So you can get all the TCP
599730	604270	options that they are using, the port, the remote port they are
604270	609650	using, if they are looking for a network congestion flag, if the
609990	616010	default fragment bit is set on ICMP. And it begins with the
616010	625670	real proofs of T1, T2 to T7. When you have a lot of, a lot of
625670	629210	flags that you will know that you will receive. For example,
629210	635450	packet T2 is no flags. Fragment bit is on. It's window size is
636070	640790	124. This is all the information I got. So I can know which
640790	645170	packets I should filter and I should manipulate and let all
645170	650290	the traffic go to the, all the traffic go to my machine. So I,
650290	653470	in this case, we will see a tool that is called OSFiller that is
653470	656850	only dealing with the specific packets for Nmap. All the other
656850	665550	traffic should be treated by the kernel. This case is UDP. UDP
665550	670910	has a special payload because it has like 300 times the letter
670910	675410	C. So it's very easy to, to recognize that kind of, of
675410	679730	packets. I have a small demo but I think it will be better if we
679730	685250	do it live because we can make the screen bigger. So the same
685250	689390	thing is for basic operating system fingerprinting. You know,
689390	692810	it's like dealing with a packet sniffer. What you are trying to
692810	696670	do is coping the data without modifying it. You don't
696670	699290	manipulate the traffic. You just get all the information and try
699290	702710	to analyze it locally to get all the information you can about
702710	708510	the remote host. And for this you got, for example, OSFiller,
708510	713530	the tool I'm presenting, can hold all the information from
713530	716750	the database from version 2. It's very simple. Every line is
716750	719750	like this. The first is the window size for the, for the
719750	725890	TCP IP stack. Time to leave if the default fragment flag is on.
725890	730190	The TCP options and the order. And some quirks, for example, if
730190	733530	you get a SIM packet, you shouldn't have any payload inside
733530	736830	but there are some operating systems that send this kind of
736830	739850	information so this is very useful to identify them. And
739850	743230	finally you got the, like, like the label for the operating
743230	747650	system. This is fully working but then both move to another
747650	752130	version, version 3, that is like a complete rewrite of the, of
752130	757630	the original code. And it deals with TCP packets, the SIM
757630	762490	packets, but the, the SIM and the acknowledged packets, HTTP
762490	767370	request, so it's more complete. In this case, instead of
767370	771650	rebuilding all OSFiller, what I'm trying to do is just to
771650	776050	migrate this kind of database to the old format so we can, we can
776050	778950	use it. If you can see, it's almost the same kind of
778950	782250	information. You have the time to leave, the length of the
782250	785510	packet, maximum segment size, you have the TCP options,
785690	790310	default fragment, some more quirks that are available in, on
790310	794150	this operating system. So this is very easy to, to identify.
794910	798490	And finally, there are a lot of people that are still using
798490	801950	Ethercap. Ethercap is almost using the same technique as
801950	806290	both. It's only copying all the traffic and just trying to
806290	810510	analyze. And it has some, uh, database. If you can see all,
810510	813350	practically all the, all the, all these tools use the same
813350	815930	format, all the same information, it analyzes TCP
815930	819110	options, length of the packet, what kind of information if it
819110	823730	has a payload. So in this case, um, in the next release of
823730	828790	OSFiller, I will migrate the same database from Ethercap to
828790	832170	both. It's very simple because, uh, the version two of, of
832170	836750	database, um, database of, of, of version two, uh, is being
836750	841390	parsed by OSFiller and it is 100% complete. So it works like
841510	845290	a charm. So I will be doing this, this change. But also
845290	848190	there are some commercial engines like Surefire or
848190	852110	Fireside that use this kind of techniques to, to identify all
852110	856650	the traffic for, for the IPS or the IDS. When you get an alert,
856650	859630	they tell you like, hey, you have been attacked by this kind
859630	862810	of machine, maybe it's a Linux, maybe it's a Windows machine.
862810	865330	They are using almost the same information and the same
865330	870810	information, you can, you can spoof the, that kind of, of, of
870810	873870	fingerprint. So you can try to confuse administrators,
873870	880690	defenders. And this is really useful to know because there are
880690	884830	other online services, for example, for vendors of, for
884830	889370	ads or whatever, that use this online. So it's very useful for,
889370	891950	for vendors, for example, to know if you are using not only,
891950	897190	uh, Chrome or Safari, but if you are using, uh, Macintosh, you
897190	901430	are using Windows, you are using Solaris, whatever. So in this
901430	906250	case, it's very simple to make the same thing in, in the, in
906250	909950	the first approach, it thinks it's a Linux version three. And
909950	913470	in the second one, we are running only OSFiller and you
913470	917650	get like Windows NT kernel. So that's because it's using same
917650	921730	database like both of the gap. So it's very simple to deal with
921730	927410	this. So other techniques to, to do this kind of fingerprinting
927410	933930	could be analyzing the, the DHCP requests. So when you, when you
933930	937650	ask, for example, for options like the DNS server, default
937650	941830	gateway, it's asking in an, an exact order. So you can try to
941830	944070	do, there is a tool called Satori. There is a very
944070	947410	interesting, uh, white paper that you can download and take a
947410	952830	look. And at last you can use other techniques like identify
952830	957130	the MAC addresses, for example, Apple or Sony use some kind of
957130	960910	patterns. So you can use that to get all the information about
960910	966190	the, the machine you want. So at this point we know how to do
966190	968730	that kind of active fingerprinting, basic
968730	972410	fingerprinting, but which kind of countermeasures do we have to
972410	976890	protect from this? I have collected some information about
976890	981990	uh, just uh, someone's, for example, IP personality. It was
981990	985450	very famous because, um, depending on some parameters, it
985450	990730	let you change sequence number, window size, IDs, uh, how it
990730	994410	answer to TCP packets. But the problem is that, uh, it changed
994530	999850	a lot of, of, of the behavior of the TCP IP stack for Linux. And
999850	1003290	this, uh, was working for all releases of the kernel. So
1003290	1008570	nowadays it's not very useful. Uh, the other one was the steal
1008570	1016150	patch, uh, that was running from kernel to 22 to 24. But this
1016150	1020550	problem, this, this tool have a problem that, um, if you change
1020550	1023470	some parameters when it's scanning, you can know that
1023470	1027430	this, this, the, the remote machine is using this tool and
1027430	1030590	you can identify because you know that steal patch only works
1030590	1035730	for some kernels. So it makes easier to understand. Many
1035730	1041050	others, it was a blue, black hole, fingerprint fucker, more,
1041050	1045510	there were a lot of tools, but nowadays I, I didn't find any
1045510	1050390	useful tool to, to avoid this. So when I was working, I worked
1050390	1054170	for Telefonica. When I was working at the security center,
1054170	1057870	I have to deal with a customer that it was scanning all his
1057870	1062390	network every day, every day. I, I didn't have time enough. I
1062390	1066430	didn't have alerts so fast to notice him that I know that he
1066430	1069950	was scanning. So I tried to make some kind of cool thing that
1069950	1073850	this was detecting the, the scannings, uh, uh, with a
1073850	1078490	program I made in Perl. Um, but also try to fool him. And so
1078490	1081030	like, Hey, you're scanning, but you have a PlayStation inside
1081030	1085150	your network. You see, you have a Sonny Wallman Ericsson. Um,
1085150	1089970	and that's how we came to OSFiller. OSFiller, if you
1089970	1093950	know, uh, packets are inside the kernel space and you are, uh,
1093950	1098290	on, uh, on user space. So you can not interact with packets in
1098290	1104890	real time. So, uh, the solution was to use NFQ. NFQ is, uh, an
1104890	1111330	extension for IP tables that accepts some, uh, some, uh, uh,
1111330	1115390	extensions and lets you put all the packets inside some queues.
1115770	1119770	So you have two elements. You have a queue handler that deals
1119770	1122370	with the, with the packets, with the kernel. So it tells the
1122370	1127250	kernel, just give me the packets and it moves to user space. In
1127250	1130330	user space, you can receive those packets, manipulate them
1130330	1133750	and send them back. The only problem here is that you have a
1133750	1138910	maximum queue length that is 1,424. So you have to manipulate
1138910	1142010	all those packets very, very fast because if you don't and
1142010	1144730	the queue gets full, all the traffic will be re, will be
1144730	1152730	rejected. And that's a big problem. So if just, just take a
1152730	1206630	look, for example, let me see if I can. Okay. Okay. Now you
1206630	1213420	have, I think that you can see the screen now. If you, for
1213420	1220940	example, do an Nmap scan for localhost, it will give no
1220940	1224180	information why because I don't have any open port. So let's
1224180	1236570	start, for example, secure cell. So we have, I'm running a Kali.
1236570	1242710	I have the Linux with kernel version 3, 3.7 to 3.10. So this
1242710	1247570	is all information that Nmap can give me. So we will be using
1248470	1256170	our tool is OSFueler. OSFueler is working. So what can you do?
1256910	1262590	First of all, just let you know that here we are only dealing
1262590	1268330	with, in case of Nmap, only dealing with a specific test for
1268330	1272070	Nmap. All the traffic, all the traffic should go directly to
1272070	1277070	your computer and shouldn't be manipulated in any way. So, for
1277070	1280050	example, if you just want to take a look at what kind of
1280050	1287970	operating systems do you have, minus N. We are interacting with
1287970	1291330	the official Nmap database. So you can just update it and we
1291330	1295750	will be working. So this is almost all the operating systems
1296270	1303810	that are available right now. There are a lot of them. Just to
1303810	1310470	let you know that it has like 5,500 signatures. So there are
1310630	1316510	a lot of operating systems to emulate. So if you do the same
1316510	1326310	thing, for example, with Poth, the same. In this case you have
1326310	1330590	to deal with what kind of operating system do you want and
1330590	1335230	then you go to the versions. In this case, Nmap, with OSFueler
1335230	1340090	you can go in both ways. You can specify I want to be like a
1340090	1345610	Windows and I need the version to be like XP or 2000 or maybe
1345610	1348630	you just specify the family. I need to be Windows and every
1348630	1351830	packet that you are sending will be in a loop and you will be
1351830	1355010	changing your ID inside Windows. For example, the first one will
1355010	1359390	be XP, second one will be 98, the third one will be 2000, that
1359390	1364690	kind of things randomly. There are not so much signatures for
1364690	1373090	Poth. There are like 250 and there is a special flag that if
1373090	1376890	you just want to search, for example, give me all the
1376890	1379850	information that you have. Not for Windows but let's see if
1379850	1384950	you have something that is smaller. For PlayStation, Nmap
1384950	1388170	has like 1, 2, 3, 4, 5 signatures available for
1388170	1396120	PlayStation and you have one available for Poth. In this
1396120	1402960	case there are two queues for the traffic. One will go to Poth
1402960	1406900	to basic fingerprinting. The other one will go only to Nmap.
1406900	1411140	So when you are running OSFiller you get those different queues
1411140	1417300	and in this case the program is running in multithreading. So I
1417300	1421400	have made some tests, not some stress tests but because last
1421400	1425580	day in the demo labs people asked me about the performance.
1425660	1432600	So when using in a web server without a lot of connection you
1432600	1438600	have to understand that you have 1,024 packets per queue. But
1438600	1443540	in case of Nmap, Nmap sends like 20 packets. So to get the queue
1443540	1449600	full you will need maybe like 200 attackers scanning at the
1449600	1455280	same time and yourself running a Celeron or something like that.
1455400	1467960	So if you just wanted to, let's search if we can do Nmap. Let's
1467960	1480690	search for Windows Poth Nmap. For example this one. Now I have
1480690	1488230	the information so let's emulate to be Microsoft Windows 2000.
1488230	1495490	And you get this info. You are mutating to Nmap. You get in the
1495490	1498390	database the signature. You can see that there are some proofs
1498390	1503550	that we shouldn't respond. For example for UDP, for example for
1503550	1512430	ICMP. And if you open a new window, let's repeat the same
1512430	1525290	test. Do you see? Nmap thinks that we are running Microsoft
1525290	1529590	Windows 2000 or maybe XP. That's because the signatures are very
1529590	1533650	similar and Nmap doesn't have all the information it needs to
1533650	1540270	complete the profiling of my operating system. If you use the
1540270	1552550	verbose option and you launch the same scan, you will get
1552550	1557790	information for every packet that you receive from Nmap. So
1557790	1563350	for example you remember I told you that UDP test in Nmap has a
1563350	1569450	payload of 300 C's. You can see it here. So this is not only
1569450	1576530	useful to try to defeat Nmap but you can also let it run in the
1576530	1579910	background and write directly all this information to a log
1579910	1584910	and try to get information when you are getting a scan. The same
1584910	1592910	thing we can do with for example Puff. We search Windows for
1593470	1612460	example. Let's work with 2002. So family is Windows, details are
1613550	1620680	this and interface would be localhost. The same. You get here
1620680	1628200	the signature for Windows 2000 and let's get in Puff. Let's get
1635160	1642380	in Puff. Just let me launch some localhost connections. If you
1642380	1647660	see I have started a secure cell connection and Puff thinks that
1647660	1653340	we are running Microsoft Windows XP. If you stop always
1653340	1658280	filler and do the same thing, in this case it doesn't have
1658280	1662420	information because it's a newer kernel and all that base of Puff
1662420	1666600	doesn't have it but it's not the same signature. And you remember
1666600	1674500	I told you that you can just specify the family. I'm telling
1674500	1679260	filler to try to emulate almost every version of Windows it has
1679260	1689870	on every new packet. So if you launch Puff, Windows CE, Windows
1689870	1696850	98, Windows 2000, Windows NT, Windows 98. So on every
1696850	1703490	connection you will be changing inside the same family your
1704090	1713720	fingerprint. You can go to random. In this case it's a sound
1713720	1731070	receiver. Linux 2.6.39. Search for playstation. Now let's see if
1731070	1768650	we can get something cooler. Sony Ericsson mobile phone. And you
1768650	1779150	see. Same thing for this. So it's very easy for the tool to
1779150	1783910	get all this information to read the Nmap database, to read Puff
1783910	1789770	databases. Nmap database is working like 95% because there
1789770	1792410	are some signatures that doesn't have all the fields and I have
1792410	1796620	to change the inner working of filler to change that. But in
1796620	1800580	this case Puff is running with almost every operating system.
1800760	1805420	And I think that's all. You can get those fillers using github
1805420	1809740	or using pip and feel free to collaborate on certain issues
1809740	1825040	that you find. So if there is any question? Yes? I can hear
1825040	1831180	you. No. In this case we are only dealing with active
1833600	1842620	fingerprint. This is not valid proof. This is only a proof of
1842620	1846120	concept for Nmap and for Puff. If you make some modifications
1846120	1850020	in Nmap for example and you deal with some small changes you can
1850020	1853780	get information about the remote host. So this is not a valid
1853780	1857540	proof but only proof of concept for those specific tools. You
1857540	1861680	can still use like DHCP, you can use the MAC address, you can
1861680	1866740	use timing attacks to identify the operating system. So this is
1866740	1870700	not working for every technique. Just should be working fine for
1870700	1891350	this kind of tools. Yes? Excuse me? That's what I told you
1891350	1897530	before. I haven't made any stress test but think of that in
1897530	1902410	the case of FACIF you are only modifying the SIM packets and in
1902410	1907450	the case of Nmap you are only dealing with almost 20 packets
1907450	1914230	per scan. So that shouldn't be a problem. You should maybe have a
1914230	1918390	slow machine and have like 200 or 400 attackers scanning you at
1918390	1922490	the same time to get the queue full and the program works with
1922490	1927750	multithreading. So I haven't made a lot of tests but it should
1927750	1931610	be working fine. I'm using like on my pen test when I'm trying
1931610	1935750	to do research and it's working fine. With some servers I have on
1935750	1941430	internet and it's working okay. But if any of you can get those
1942190	1944630	information, that information about the performance, it should
1944630	1954240	be great to have it inside the GitHub. Thank you.
