start	end	text
830	7170	Okay, so now is the time for the second last talk for today.
8770	11950	And we've got some interference from our neighbors.
11990	14770	So we'll have to bear with it, cope with it, unfortunately.
16150	19450	So we've got this time Jasper Insinger.
19850	23610	Jasper is a security researcher at Hadrian Security.
24110	29690	He has given multiple presentations in the past and has been present in Black Hat multiple times.
29690	31710	He was in Black Hat yesterday as well, I'm assuming.
31710	32310	Yes.
32310	33190	Nice.
33950	40070	The topic that he will be covering is pushing the limits of mass DNS scanning.
40550	47710	Now, Jasper and his team developed an ultra-fast open-source DNS scanner named as SanicDNS.
47710	57130	Using multiple parallelization techniques, the result in a scanner is that it has two orders of magnitude.
57130	59310	The result is twice faster.
59310	62870	It has two orders of magnitude faster than other popular tools.
63270	70050	Jasper will take us under the hood of the code and share the techniques that have been used in identifying such kind of a result.
70550	81010	With SanicDNS, it is possible to identify DNS misconfigurations, conduct name server takeover scans, and do a lot more fun stuff, which Jasper will let us know about.
81010	82830	So please give it up for Jasper.
85210	86650	All right, thank you.
89920	91520	Okay, let's get into it.
91840	93280	So thanks for inviting me.
93280	97320	So I've also talked about exactly this subject two years back.
97600	102500	And back then, the tool was like half-finished, very shitty, not usable at all.
102500	113400	But in the last two years, I've been able to actually polish it up, make it a lot nicer, and also especially make sure that everyone in the security community can go and use it.
114320	115620	So who am I?
115620	116720	I'm Jasper.
117500	120100	My background is in electrical engineering.
120220	123020	So I studied back in the Netherlands, Dutch guy.
123240	127240	And I primarily just love C++ and building fast things.
127600	132120	That has kind of been my main thing in life that I just absolutely love.
132120	134560	The background in embedded systems.
134920	143160	Currently, I'm working as a security researcher at Hadrian, where I work primarily on DNS scanning, and also just building random hacking tools.
143160	144800	Whatever works.
145680	147120	All right, quick outline.
147300	152100	So first, I'm going to start with why do we actually want to scan DNS?
153040	155440	Because, like, why?
155800	161860	Also, after that, we're just going to go into how you can actually build a brute-forcer where you can actually reach these lightning speeds.
162360	164480	Tell a bit about the tool itself.
165300	171720	Also, of course, I'm going to do a recap of how you can use the tool and also why you would want to use this tool.
171720	176400	And also, a mandatory scanning responsibly.
176720	180460	And I think there's also quite some future work that can still be done.
181660	182640	So, DNS.
182640	183700	Why scan it?
184180	186340	DNS is like the backbone of the Internet.
186340	188160	Like, a very nice spine here.
189180	195140	And HTTP, FTP, SSH, they all kind of need DNS to work nicely.
195140	197720	Because you don't want to be typing in IP addresses.
198400	201660	And DNS is in this way critical to the Internet.
201660	202940	It's been around for a long time.
203540	207360	And it's just super, super relevant for almost anything you want to do online.
208560	212700	So, DNS is very relevant for hackers because of this.
212920	218880	Because the step zero for any hacker should be to map out the attack service of the target they're trying to hack.
219320	223660	And one way that this can be done is by DNS brute-forcing.
223940	228960	And this is basically trying millions and millions of subdomains for a given root domain.
228960	234580	And the larger the word list, they have a higher chance of finding interesting stuff.
234800	241320	But the downside is that if you have a super large word list, then it's also going to take a lot of time for a scan to complete.
241320	242800	Which you don't really want.
243360	246000	Which brings us to scanning fast.
247140	251100	So, large attack service, lots of things to scan.
251480	254900	And currently mass DNS is the fastest tool for DNS scanning.
254900	257480	You have ZDNS, which also comes quite close.
257480	269360	But one thing that I noticed is that ZMap or some other fast port scanning tools can actually reach orders of magnitudes higher in packet rates than mass DNS can.
269360	279500	So, for example, you can reach millions and millions of packets with ZMap while mass DNS only does like 50k, maybe 100k if you're very lucky.
281080	286460	So, why is mass DNS so slow in comparison to these port scanning tools?
287440	291720	So, I made this very nice schematic representation of how mass DNS scans.
292020	300620	So, we have mass DNS, we have the Linux kernel, and you have your network interface cards which connects your actual OS to the worldwide internet.
301920	306780	So, mass DNS goes around and says, yo, Linux kernel, can you send this packet for me?
307040	310160	Linux says, alright, I can do that for you.
311000	316540	It asks the NIC to send the packet, the NIC sends the packet, and it goes to the internet.
316820	322140	And the same thing has to happen the other way around when the answer is received.
322420	328300	NIC receives the answer, goes to the kernel, goes to mass DNS, but there's a lot of overhead.
329020	340340	So, Linux networking is super chill to use for if you're, I don't know, doing anything with web browsing, emails, just any regular internet traffic, but it is just not very, very fast.
340720	343000	So, how do we fix this?
343000	348280	That brings us to the next part, which is the kernel bypass networking.
349420	355100	So, the mass DNS situation is kind of like this, but a bit more professional schema.
355180	365000	Hardware talks to the device driver, device driver puts the packet into the network stack, and through the network stack, the packet goes to the application.
366140	370460	So, how do we make it faster if the Linux is actually slow?
370460	372400	Solution, skip the kernel.
372880	377840	So, what you can do is, like, I'm using the Data Plane Development Kit.
378380	387220	Usually, you would use the Data Plane Development Kit if you're a researcher, and you're working on data centers, and you're working on hyper-fast interlinks, or whatever.
387980	391420	It allows you to access the NIC directly from your application.
392500	398940	And port scanners actually use a similar principle to really speed up their scanning speed.
399380	401780	So, the advantages, it's a little faster.
402020	404480	Disadvantage, it's super hard to use.
404560	408000	It cost me, like, a month to even send a single packet and receive a reply.
408600	410480	It is quite cumbersome.
411580	418680	But, what if there was a DNS scanner that was written with this kernel bypass mechanism, and loads of other tricks, by the way.
418680	420760	So, it goes way deeper than that.
421040	424200	That you can install in 10 seconds, written in C++.
424420	426820	So, introducing SonicDNS today.
426820	429660	With exactly that purpose.
431160	434040	So, how fast can we go?
434340	437880	So, this benchmark is very much lab-tested.
438140	442860	So, I use a self-written resolver, which only returns NX domain responses.
443100	446620	And I use, like, a 9 gigabit input file with domains.
447180	451180	And, using this method, I can reach, like, over 7.5 million packets per second.
451180	458980	Which is, like, quite a bit faster than messaging in S3, which can maybe, like, 50k, 100k per second, if you're really lucky.
460540	461960	So, it's super nice.
461960	468920	And can we, like, connect this to the internet right now and expect to brute force anything with 7.5 million packets per second now?
470580	472560	Well, unfortunately not.
472920	477260	So, today I'm also gonna tell you a bit , like, why that is, and how we can circumvent that.
478320	484260	So, there are some limits towards, like, actually scanning the internet really, really, really, really fast.
484460	489300	So, you want to be this guy scanning with your minigun, just hitting those DNS resolvers.
489520	493120	But, that's unfortunately not always how it works.
493620	496820	So, first limit is the resolvers.
496820	499860	Second limit is, like, bad network interfaces.
500040	503080	And third limit is packet switching limits.
503080	506240	I'll take you through these in individual slides.
506940	510500	First of all, the recursive resolvers.
510500	519240	So, recursive resolvers such as 1.1.1.1 will actually take care of the actual resolving part and walking the DNS tree for you.
519580	523020	But these resolvers actually start rate limiting quite fast.
523240	527980	So, in order to scan fast, you need lots of good resolvers and spread the load.
528260	531700	But still, these resolvers remain a very, very tricky subject.
531700	535120	They start rate limiting, they start giving back bullshit responses.
535860	548040	So, like, having a really, really good, like, a word list with resolvers is actually critical towards getting good results with MyDNS and also with MassDNS.
549440	554200	So, I personally use the fresh resolvers and Trickist repos for that.
554200	556460	They have some pretty nice resolvers in there.
556980	562380	But, like, experiment and if you find a resolver list that's even better, please pop me a message.
562380	564300	I'd be very interested to hear.
565500	568580	Like, limit two bad network interfaces.
568900	573240	So, what you probably all have is your VPS, which you use for scanning.
574040	575180	And they're super convenient.
575180	580540	You can go to DigitalOcean, Skillway, Linode and pay a couple of dollars a month.
580540	582600	Sometimes a bit more if you want a beefy one.
583760	588520	Super nice, but these VPSs have virtualized network interfaces.
588980	599080	So, in the image here on the right, you can actually see that these VPSs run on one larger server that's actually the bare metal server.
599700	611320	And the downside is that the actual physical network card is connected to this bare metal server and these VPSs communicate to the internet with virtualized network interfaces.
611640	624780	And the big downside with these virtualized network interfaces is that they're just not so fast as your dedicated super fast network card that these servers usually have.
626020	630120	Which brings us to the third limit to fast DNS scanning.
630480	632240	Packet switching speeds.
632680	637240	So , some of you might already have a 10 gigabit internet connection at home.
638140	647060	Can you actually go and scan DNS with 10 gigabit now, which is in outgoing packets around 10 million packets per second?
647560	649140	Unfortunately not.
649400	656620	And that is mainly because consumer routers cannot handle the packet routing speeds necessary for these DNS packets.
657020	667920	So, usually what you do when you have your 10 gigabit internet system is you use it to download a large file or use it to transfer large files.
667920	669860	That's, I think, the main use case.
670460	677720	And what the internet does with these large files is they cut the large files up into pretty big chunks.
677880	681880	And your router can actually process those really big chunks quite well.
682060	687760	But if you give your router very, very small packets then it just becomes totally overwhelmed.
687760	690640	I definitely had my home router crash with this once.
690700	693060	Then I didn't use it anymore from home.
693060	695360	And also my internet at home is quite shit.
695360	697400	So, that doesn't help.
697760	703500	But anyway, also that is like a serious limit that you will also encounter in data centers.
703580	706300	And it's actually really, really hard to get around this one.
707300	708380	Alright.
708460	710840	Then, also very, very important.
710840	712700	What is in this for you guys?
713540	716840	Because I already thinking, I don't have a dedicated server.
716840	719820	I don't have a super crazy network card.
719820	722000	I hate C++, because who doesn't?
722120	725040	And this is my $5 a month VPS.
725400	727720	So, what do I do now?
727900	730060	Can I use this tool?
730860	732360	Well, I have good news.
732360	738040	This tool can actually bring a lot for you, especially if you have a shitty VPS.
738500	746320	Because static DNS is like a lot more efficient in well, basically anything than ZDNS or mass DNS.
746420	748740	Also, when you're a very shitty VPS.
749240	756180	So, with static DNS, you can go around like if you're lucky, it has a good day and the internet has a good day.
756180	762360	You can go around like scan 100K domains a second, just from the super, super simple VPS.
762360	766540	And with mass DNS, usually I get like 1 or 2K domains a second.
766540	770480	I put the max here I ever saw, which is 5K domains a second.
771020	773700	And what brings this for you?
773700	781040	So, for example, if you look at the zonefiles.io screenshot, they have like 266 million domains in there.
781780	792280	Which sounds like quite a lot, but what this tool allows you to do is actually scan every root domain out there on the internet, with your shitty $5 VPS, in under an hour.
792500	794440	So, that's pretty sick.
794500	798500	And you can put that in a database and do, for example, reverse IP lookups.
798500	800980	So, that's actually what I use this tool most for.
801000	807240	I scan 2 billion DNS records, put them in a database so I can do reverse IP lookups, reverse MX lookups.
807240	809800	So, that's my personal use case for this tool.
811100	812660	So, demo time.
812660	814860	So, let's hope the live demo doesn't break.
816700	817580	Alright.
817580	818380	Perfect.
818380	824640	So, what I'm gonna do is I'm gonna create a... let's see if this page still works.
825100	825820	Yes.
826520	827560	Yes.
827760	831300	Alright, I'm gonna make a new VPS.
831400	833900	This is how you show the installation process.
834120	835600	Pro XS.
835600	837300	So, it's not very big.
837300	839600	It's like the lowest tier you can get here.
840320	841720	$0.05 an hour.
841720	843080	So, expensive.
844140	846260	Create it, wait for a bit.
846600	847980	It actually goes quite fast.
847980	849500	I tested it a lot of times.
852720	855380	Alright, let's wait for it to start for a bit.
858840	860000	Alright, running.
863810	865550	Try SSH into it.
867950	870990	Yeah, it usually takes a couple of tries on the first time.
875010	876210	Give it a minute.
879330	880970	Gotta take a picture of the guys.
880970	883350	Lots of people have come over.
883430	884370	Alright, there we go.
884830	886750	So, now we can actually go connect to the VPS.
888510	890530	So, totally blank VPS.
890530	891530	Nothing on there.
894750	895570	One password.
897470	900250	Alright, so, nothing on there.
900250	901090	Totally new.
901870	905930	First need to install jq, because otherwise it doesn't work.
906370	908370	Can you guys in the back read it, by the way?
908370	910010	Otherwise I can also make it a bit bigger.
911450	912770	Alright, perfect.
915050	915930	Oh, bigger.
915930	918830	I thought I saw the thumbs up.
921090	922190	This okay?
923470	924450	Yes, nice.
924450	925470	Love to hear it.
925670	927710	Alright, then we go to the SonicDNS repo.
927710	929990	I have a single line install script.
932230	934010	There we go, that's it.
937470	944450	Now, so, actually, because of the way this works, it needs some, like, more specific kernel thingies, such as huge pages.
945130	946770	So, it makes it run faster.
946790	948210	I mean, who doesn't want that?
948930	951610	Also, I'm going to download the majestic-million.txt.
952250	955190	That is just a million domains that we can go resolve right now.
956290	957710	And I think, actually, that's it.
958330	960150	Then, let's try to copy this.
961850	965430	Let's put a timeout at, like, one second or something.
967470	971730	We're gonna, like, have 300,000.
972090	975750	So, now we can, like, resolve 300,000 domains at the same time.
976190	978750	All very efficient, so you can, like, run it on anything.
979650	982810	Let's just start with, like, 80,000 packets per second.
983830	984990	Let's hope it works.
986770	987790	There we go.
988850	1001610	I mean, you can see that it's kind of, like, doing weird stuff, because, like, the SSH connection is not working too well when, like, you're resolving this fast, because you're, like, hammering that network interface, like, really hard.
1002070	1002510	But...
1003110	1005350	Last time also takes a bit longer.
1007250	1008430	But there we go.
1008430	1009610	22 seconds.
1009710	1011010	One million domains later.
1012050	1016890	So, like, this is really, really nice, and you can try it for yourself with mass DNS.
1017050	1020470	I'm not gonna go through the installation process myself right now.
1020930	1032190	But, like, most I've gotten was, like, 3k packets per second, like, sustained brute forcing with exactly the same resolvers and stuff, exactly the same VPS.
1032690	1034110	So, nothing different there.
1034490	1036990	It's just, like, really, really, really efficient.
1036990	1040710	So, also, when you have a small VPS, it'll run a lot faster.
1042230	1052770	So, what you can do if you want to resolve even more, like, these things are 5 cents an hour, you just get 10 of them, and then you resolve and get, like, 800,000, or, like, it's pretty well scalable.
1052770	1054230	You just get more VPSs.
1056330	1060290	So, brings us to the next slide, which is scanning responsibly.
1061190	1068230	So, this is kind of a schematic representation of static DNS versus your average Python-based resolver of most companies.
1068310	1071990	At least, I don't know what they actually use, but we wouldn't be surprised if they use Python.
1072090	1073390	It's not a fair match.
1074210	1080170	So, this tool can actually resolve way, way, way faster than most things are made to handle.
1080610	1082530	So, don't break stuff, please.
1083270	1092630	Static DNS is really, really nice for internet-wide DNS research, or, I mean, that's also why I'm putting it online, so I hope you guys can find more use cases.
1092730	1094510	But if used correctly.
1095070	1098630	If you don't use it correctly, then don't do that.
1098630	1099470	It's not good.
1102230	1105730	So, DNS servers are just not made for this type of traffic.
1106290	1112310	And also, one thing is be nice to authoritative DNS servers, which I will explain in a bit.
1112710	1122950	So, for example, a very common use case, I think a lot of you guys are doing this, you have a couple of programs you want to go brute-force, and you have a word list that you're going to use for the inputs.
1123930	1137910	So , the left thing is what you shouldn't do, where, for example, you want to brute-force github, apple .com, and google.com, where you first go and resolve everything for github, then everything for apple, and then last, everything for google.
1138530	1151410	This is really bad, because that'll make sure that first, all the load gets redirected to github, then all the load goes to apple, and then all the load goes to google, and you made them all very, very pissed.
1151770	1155130	So, what you can better do is actually mix it all up.
1155510	1161610	That's also what I do myself, or if I have to do like 2 billion very, very big DNS resolvings.
1162050	1164070	So, I just jumble it all up.
1164530	1172110	You just round-trim it between the github, apple, google, github, apple, google, apple, github, google, I don't know, I messed the order up there.
1173170	1181890	But in this way, you're making sure that you're spreading the load over the authoritative DNS resolvers of github, apple, and google, and that you're not making anyone angry.
1182710	1185270	The tool I use myself is Terashift.
1185390	1186490	Very, very nice tool.
1186490	1194390	It can take a 50 gigabyte input file and shuffle all the lines and this will make sure that you're not going to make anyone angry.
1195070	1201370	Also, if you do the thing on the right, then you'll be able to go a lot faster because everything starts rate limiting a lot less fast.
1202550	1205670	So, I think that was the majority of it.
1205790	1208030	Now some future work that I still want to do.
1208370	1212970	So, one very relevant thing is wildcard detection, of course.
1213290	1218010	So, we can resolve really fast, but wildcards, they'll still pop up all over the place.
1219650	1232990	Also, one thing that I think would be very nice, implementing IPv6, so we can actually rotate the IPs that we're using because there are 128 bits worth of IPv6 addresses, which is way too much.
1233170	1243210	So, it's very easy to get your hand on, like, a block of a gazillion IPv6 addresses and you can just rotate through all of them, which will evade rate limiting, which is, of course, what we want.
1243490	1249850	Another thing that I want to combine the IPv6 stuff with is recursive resolving in the tool itself.
1250530	1259450	Like, right now, you need recursive resolvers to actually go and, like, ask for these IP addresses, but it is actually pretty doable to also implement this yourself.
1259710	1272070	And I think if you combine that with IPv6 and the wildcard detection, then you have, like, a DNS scanning tool where you can actually go and make a live map of the entire internet in real time.
1272070	1274370	And I think that is, of course, really nice.
1274370	1276370	So, that's what I personally want.
1277830	1279230	But I think that's it.
1279230	1280750	So, that kind of wraps it up.
1280750	1282150	Output is all JSON, by the way.
1282150	1283470	So, JSON line by line.
1283470	1285070	I mean, go check it out.
1285690	1291910	You can find the repo link on github.com slash Hedion security slash static DNS.
1292370	1295510	I also included some basic documentation of how it works.
1295770	1299670	Not finished completely, but I hope to get to that next week.
1299670	1307710	And if you have any ideas, questions, recommendations, feel free to, like, make a GitHub issue or send me a message at github.com.
1308990	1310470	So, just contact me on X.
1310470	1312670	And thanks a lot, guys, for being here.
1316590	1317510	All right.
1318210	1319410	Any questions?
1324410	1325210	Nothing?
1325750	1326670	All good.
1328550	1330170	Lots of information, I know.
1332350	1332710	Yes.
1332710	1332890	All right.
1332890	1333470	Thanks, guys.
