I'm going to go ahead and get started even like kind of as people are coming in. And that's just how it's going to go. So this is identifying and correlating anomalies in internet wide scan traffic to newsworthy security events. Also known as the longest title of a talk I've ever given in my entire life. My name is Andrew Morris. I work for a company called Gray Noise. All the slides are gray. Now they're purple. So I work for a company called Purple Noise. Again, my name is Andrew. I work at Gray Noise. I also am Gray Noise. There's no one else in the company. It's literally just me. But it's kind of an open secret. And I like referring to the company as we because it makes us sound more legit and professional. But make no mistake, it's just a guy in an apartment doing all of this. Before I started Gray Noise, I was on the R&D team at Endgame. And prior to that, I was always kind of private sector red team doing various different things. I've been staring at internet scan traffic. I've been staring at internet scan traffic for so, so, so very long. And I'm not a data scientist. I'm not good at math. I'm not even good at stats. I'm not good at machine learning. I don't know anything about any of these things at all. But I had to learn a little bit about some very basic statistics to kind of do the thing that I'm trying to do and write this big old bastard of a SQL query that I'm going to show you guys. So today what I want to do is go from I want to talk about the process of going from a bunch of disparate systems to actually, you know, some kind of anomaly, some kind of indicator of an anomaly that is able to be correlated with an actual thing that makes sense. So just a bunch of Apache and firewall logs from that in a lot of systems to, hey, at this time and this place, there's a giant uptick in people scanning and probing for those things and it probably had something to do with this vulnerability that is associated with that traffic. Or this event, this thing that happened, right? And so that's it. And the way that I did it is with this. That's it. This giant-ass SQL query. Will you guys do me a favor, if anyone in the room, who has already heard of gray noise before? Will you raise your hand if you've already heard of gray noise? All right. So we've got probably, I don't know, maybe 3% of the people in the room have already heard of gray noise. So we do this thing, and I'm always going to say we. It's just hardwired in my brain. We do this thing where we write these tweets any time we see, you know, a bunch of these upticks in scan traffic that are explainable, that have value, and this is how we do that. We just run this query. I mean, it takes forever, but this is it. And so I'm going to break this whole thing down, and I'm going to kind of get there, right? So what's Internet background noise? It's basically, it's the baseline omnidirectional scan traffic that's generated by all these people that are scanning the Internet. Like the Shodans and the Mirai's and, like, the censuses and, like, the WannaCry's and, like, everybody scanning the Internet creates this thing called Internet background noise, right? So what does scanning the Internet actually mean? Really, it just means querying all 4 billion routable IPs, 4 billion-odd routable IP addresses, sending them, like, a SIN packet or a UDP prober or something like that to try to figure out, like, a certain open port or protocol. Way back in the day, it used to be that if you had, like, one box and you wanted to figure out what was running on it, you'd port scan it, and that would basically be one IP, many ports, and you'd get information. Now, mass scanning is the flip, is the inverse of that. It's one port every IP to figure out what's open on the Internet. Right? So why would people scan the Internet? There's many reasons to do it. Find exposed devices, measure risk exposure, like, try to figure out how many Apache servers are there or how many people have this port open or how many places are this version of software running. Or I just want to hack a bunch of devices. I don't know. Whatever. So who actually does it? Lots of good guys do it. Shodan, Project Sonar, binary edge census. I have, like, actually many giant lists of all the labels that I've provided in here, and I'm going to go through that. A lot of bad guys, too. Mirai, WannaCry, Satori, Mustik. What's an anomaly? What's an anomaly? What's an anomaly? It just means, like, anything more than we're used to seeing. Like, an actual, like, an uptick. Some amount more. Right? And what is a newsworthy event? That's just, like, a thing that happens that we're trying to talk about that falls into something of interest. Right? This is, like, one list of the labels that we have already made in GrayNoise right now. This is, like, in GrayNoise, like, what we do is, like, we're looking at all of this omnidirectional Internet-wide scan traffic, and we're trying to label all of this stuff. So these are some of the actors that do it. Here are even more of the actors that do it. I took these screenshots right before I came up here on stage. So I guess before I go any further, I'm going to go and explain, like, what GrayNoise is and how it works. So it is a system that collects and analyzes all Internet-wide opportunistic omnidirectional scan and attack traffic. Right? Why? Well, the reason why is because every single one of those packets that's flying around the Internet has its own unique and special story. And that's actually true. And that's actually true. And that's actually true. There's no such thing as random noise that happens for no reason. Every single thing is explainable. It's just that everyone thinks that it's just bullshit, but it's not. You can look at these, the trends of this Internet-wide backscatter and scan traffic to figure out, like, what's going on, to try to peel back, like, what, why are people looking for these things, you know? And from a security operation center's perspective, if you're, like, a network defender or something like that, then if you're actually looking at the firewall of your network or something like that, you need to be able to differentiate between the, you know, if you're looking at the actual things that matter that are hitting you specifically versus, like, the things that are just hitting everybody on the entire Internet. How many times have people been responding to an incident or something like that that ended up just being, like, a Chinese SSH bot or something like that? And it's, like, this is not a big deal. This thing is hitting everybody. This isn't some sexy APT shit. So, really, what we're trying to do is we're trying to provide rock-solid negative ground truth of what everyone should be expected to see. And this is actually something that Alex here over at Verizon has been working on for a long time. And he actually said yesterday, two days ago. And I love that, negative ground truth. That's exactly what we're trying to do. So the technical mission statement of GrayNoise is label every single Internet-wide scanner as either good or bad. And put it, first of all, take the category of everyone and then try to label as many of them as humanly possible. Like, what are you, what are you doing, why are you doing it? This is kind of a state of the union of that. Where right now, good, the markup of good is about fraction of a percent. It's about 1 10th of a percent of Internet-wide scanners. Bad is about 1 10th of a percent of internet-wide scanners. Bad, as you said, is a about 10 to 20%. It's labelable where we know they've done something violating some like the computer fraud and abuse act. They're logging into a system that they don't belong. It doesn't belong to them. They're slinging an exploit. They're compromised and they're slinging an exploit on behalf of somebody else, blah, blah, blah. And then unknown. That's everybody else. That's the gray noise or I guess the purple noise. So how do we do it? We have a big network of nodes in a gajillion different networks all around the internet that are constantly shifting around in AWS and Google Cloud and DigitalOcean and all these different providers. They're always shifting around. They have no business value whatsoever. And they just hang back and they wait for people to talk to them. They're completely passive. It's just like a ton of people with their ears to the ground listening for like these little teeny tiny minute signals and then aggregating all of those together in one place and doing all this labeling and analytics to try to find value in all of that. So again, we want to go from all of the traffic that's hitting everyone to actionable, hey, this thing happened and it probably had to do with this, right? This is probably what happened. And then we want to go from all of the traffic that's hitting everyone to actionable, hey, this thing happened and it probably had to do with this, right? This is probably why. So this is what the raw data looks like a lot of the time. These are just IP tables logs. And I ripped these straight out from gray noise. So at some point, a long time ago, those were gray noise nodes. It's a bad op sec. And so now I need to figure out, okay, well, why is what we're doing challenging? What are some of the things we have to overcome? First of all, you have to get when you're doing this kind of thing, you need to have a very diverse optic. You need to have a very diverse set of data. You need to have data in a lot of different places. And you need to make sure that the anomalies that you're measuring are being that they're justifiable in equal amounts of places that you are observing, which is to say that you have to avoid collection biases. If you have one little optic in one place, and that starts seeing all kinds of crazy stuff, that is not an internet wide anomaly. That's just probably somebody scanning your machine or something like that, right? But you need to really be able to correlate it across many different places that have different that are different kinds of networks and things like that. And so you need to be able to do that. So it's insufficient to just have cloud providers to do this. Really, you really need to have residential IP space as well, business IP space as well, because there is like an idea of macro targeting that mass scanners do. I'm not even going to get into that right now. One of the other reasons is you have to make sure that you're getting like an unbiased opinion with your data. You can't just install a honeypot on a network that you own because that device has business value. And if something has business value, then bad guys are going to pay close attention to that. They're not going to just like backs. They're not just going to like, accidentally see that. Like, you need to have things that have no business value, right? You need a lot of data. And so you need to have a lot of volume. And managing that amount of volume can be difficult, especially if you, you know, if you don't, if you're not used to dealing with relatively large amounts of data and putting them into databases and querying them and all things like that. And then money, like, who cares about this kind of stuff, right? So like, for me, everything that I need to do, this is all I do. Gray noise is all I do. So like, I need to be working. It's for, this is the kind of thing that I'm talking about right now that is like, it's more of like an R&D thing. It's less of like a thing that is easy to package and product and make money with. Which is mostly why I'm just like lobbing it out for free for everybody. So the solution, my proposed solution to this is collect all this stuff, put it into a database, average it over time, and then when we see any more unique IPs, any more than two or three times the normal amount of that, of what's expected over some period of time, then have it tell you and then do a little bit of work on it. And then when we see any more unique IPs, any more than two or three times the normal amount of that, of what's expected over some period of time, then have it tell you and try to tie it to some kind of event. So you're going to parse out the data and this is really what you need. You need the time, the source IP, the destination IP, the protocol, the port, that's it. And if you really want to do this on a budget, you can do like, you can have like a unique constraint with this. Like you don't need to record any of these data points more than once. You really just need them kind of once. Once you've seen somebody scan a box that you own on a certain port at a certain time, and then they do it again, you don't need to record that again. You just need to, all right, this is fine. This is good. Okay. So you're going to and so then what we're going to do is given a 30-day rolling average of the unique IP addresses scanning the internet for a given protocol pair, show me if there is an increase in unique IP address count that is higher than three or four or whatever times the rest of the month's day-to-day increase. Which is to say, and this is where things are going to get a little tough for me because I am bad at math and I'm still grasping this stuff myself. But what is the average number of unique IP addresses scanning the internet for a given protocol pair? And so then what we're going to do is we're going to look at the number of IP addresses on the internet that are scanning for a given port protocol over the past 30 days. What's the average daily? And also, what is the difference from yesterday to today? How many times? Is it like a 0.9X multiplier? Is it a 1.1X multiplier of that rolling 30-day average? And let's, and then show me everything that is above four times the regular 30-day. And like, I can see some people right now that are like, this is so simple. And it's not. It's not. It's not. It's not. It's not. It's not. It's not. It's not. And it is. I mean, I know, I know this is easy stuff, but it's really, really effective when you have really good, clean data. And so then there's, I mean, there's all kinds of like statistical trade-offs, which in this case, like if you decrease the window from 30 days to like a week, then you're going to be able to get, you know, a measure of the anomaly faster. But it's going to be, it's going to, it's going, it's going to, you're going to get it faster, but it's going to be less accurate, right? It's going to be more chaotic and sporadic. And I'm volatile. If you increase the, if you increase the number of IPs that you need to see or above or below a certain number of IPs that you need to see, then you're going to miss some of the smaller anomalies. So how did I actually did it, do it? I did it in SQL, which is the literal worst possible way that you can do this because I hate myself and it looks like this. So I'm going to just basically break down this whole thing. So the first thing that we do, I'm not a DBA. I'm like not a lot of things today. But I'm really not a DBA. So from, first of all, we're going to take a window of the last 30 days with the date or protocol and the day and the number of times we've seen a distinct IP hit, hit us. Hit a node that belongs to us in the last 30 days. So where we have where date greater than current date minus interval 30 days, that's easy to understand. And then we're just going to mash it all together. But we have a having clause, which basically says it's like just to avoid another gross subquery. We basically are grouping out in the groups after the group by. And so then we're going to say, but I only want to see things where that if I only want that count to be protected when we've seen some one unique IP address that has touched one over over one distinct node. So don't show me anything that's only seen that's only touched one of our devices. It has to be two or more. Right. And that's going we're going to call that like so wait, that's having. Yeah. OK. And then so now that we've put that kind of into its own little list now. Show. Show me the average. I don't understand Windows very well. This is very like this is very cobbled together from like Stack Overflow. But basically, I want to see everything where. Yeah, at the end, I want to see all of the different the days, the port protocols, the unique amount of IPs and what the both the month. Yeah. What the month the average the 30 day rolling average was for that given thing. On that day. And then. Out of all of those things, show me everyone there at the very end, select date protocol port IPs round times mean show me everything that. Is above a four X multiplier on the 30 day rolling average in the last five days. Oh, God, I never want to do that again. How can we make that better? I can do that by doing literally anything else probably. I mean, this takes forever to run. It's inefficient. It's in sequel. It's gross. It's slow. It's not real time. It's it's limited to dates, not times. We don't have any time stamps factors. Very little information, like an anomaly. Here is just like dictated by how many people are looking at something. But there's way more ways to calculate out an anomaly, like maybe an ASN that scanning the Internet for a certain given thing or maybe a you know maybe a i don't know like a given organization or or boxes that look like a certain thing um etc um and i mean i'm sure any actual decent library you could just like cram into this and it would just do everything that i just spent the last six months working on just immediately um so then the correlation piece of it is like okay why does that like why did you see that what is the the um the cause most likely to for that to explain that increase most often it's like a big botnet has just operationalized a new vulnerability that they want to they want to capture um as many devices as humanly possible on the internet that um that are exposed to that vulnerability or something like that um sometimes it's because a new cv comes out like heartbleed or you know like shell shock and everyone and their grandma is like oh let me scan the internet to figure out how many devices are vulnerable to this thing which is funny because when whenever this happens it's always security researchers are that big first wave you can see them all like using this standard security researcher tool and then like the bad guys are way slower they come in like months later because it's all these like bottom of the barrel bad guys that are like you know kind of it's a numbers game for them they're just trying to compromise as many devices as possible but it's always like you know it's like six months later they kind of like you know gotten around to like figuring out how many boxes are exposed but like there's not there's not a big jump it's always the it's always the people in this room that are doing it basically um or like a worm breaks out right it's like which we've seen with like regimen um i mean way back in the day obviously um the the great example would be uh conficker mso067 back in the day i mean that was if you were if we had the same information if we had the same object then at the time then we would have seen on one day many people are scanning for port 445 and on this next day that times a quintillion people are scanning for port 445 right so um and we see other like worm stuff now which i'm not really going to get too terribly into right now but so like some easy hacks if you want to do this um uh to do some of the correlation piece is just googling the port number to try to figure out search search github to find the port number to try to associate it with something that you're seeing um look on exploit db for new exploits for a given vulnerability um use metasploit to figure out the default port number for different things that's an effective tactic look at cve sometimes cve the cve actual page will contain the port that the vulnerability is on most of the time it doesn't actually almost none of the time it does but one of the resources in those things will will include that information check out router exploit which is like metasploit for only for routers um so here's some of the things that we've found um some of the observations actually like over the last seven months um these are just like screenshots of tweets but i'm gonna go through kind of each one of these a couple of the success cases so like top left was um yeah 52 8 69 we weren't the first one to catch this 360 netlab was and um i have a shout out to them they do they do great work um uh it was like a universal plug-and-play service that satori had weaponized um so we tagged everything that every all of the new people were doing that all of a sudden and like figured out a signature to be able to have that tagged as bad uh top right gray noise observed site 5555 this one's whack um it is the adb android uh debug bridge vulnerability um which is like adb like in your android device when you're you know doing something there's a vulnerability it's not technically a vulnerability it's like a design thing where you can do arbitrary code execution if you have access to that daemon or whatever back in february we detected a big uptick in that i think we covered it we're gonna talk about that in the next few minutes of people like looking for it and but there was no real like smoking gun at the time and then probably like a month ago we saw people start to actually exploit it on the internet bottom left um uh oh yeah belkin n750 that was just like a some crappy router that had some vulnerability that we started seeing just like this giant thing giant uptick and we dug into it and we found that um and then yeah this d-link 2750b um on port 8000 we saw we saw a 1000 increase from one day to the next thing was like all right something's going on here um this was the adb thing i mean this is what like this what the actual numbers kind of looked like of how many people on average were scanning for some of these um so this i mean the reason that i'm putting a news article in here is not because i'm trying to show like how cool we are i'm trying to show you that this works it's a effective i mean we wrote this and it was like we like saw this and it matched perfectly with what the rest of the world was seeing with um what some of like other people were reporting on uh the same thing happened this one was gnarly um this was um red shmay this micro tick vulnerability that i think might have been like a vault seven thing and so this one was it was a gigantic um um . the other fun thing with gray noise is like once we have these upticks we can look back in time and figure out like who's scanned for this thing like ever like who scanned for it like last year um so yeah and then this is just kind of a summary of some of the ones that we've been able to find uh these were the successful predictions that we've been able to find using this methodology um i think i just went over all these triple get and that was gnarly we do the same thing with uris that people request so like um we were able to do the same exact thing and we were able to do to see when Drupalgeddon was beginning to be opportunistically exploited. We see Oracle WebLogic is like the gift that keeps on giving. It's just like permanently screwed up, and it's just always being exploited. And I think I talked about all the rest of them. Failed predictions. There was one maybe like four months ago where we saw this uptick in port 5647 TCP, and the people that were scanning for that port also had the port open on their device, which is like a golden ass indicator. And so we were like, yeah, we are clearly the smartest people that ever exist. Well, I was like, I'm clearly the smartest person that ever exists. I was so wrong. And so I worked with the Red Hat people. It affected like Red Hat satellite server. That was what it was the default port for. I was like, yeah, man, like this is so cool. I'm saving the world. And then I ended up working with their team, and they're like, yeah, that's not us at all. Like our devices are never exposed to the internet. They're deep inside of networks. And the IPs that you published out are not running Red Hat. A lot of them are running Windows. I was like, ah, shit. Okay. So then I had to kind of eat crow on that one. Blah, blah, blah, blah, blah. But they were awesome to work with. They were really, really great. They were super cool about it. They knew that we were like trying to do the right thing. But yeah, they were like, yeah, this does not affect us. And I was like, shit. Okay. So I just kind of want to get a couple tips for people. If you're going to be doing the same thing or want to do the same thing, filter out the known good actors when you're doing stuff like this. So Bob Rudis or Harbormaster on Twitter over at Rapid7, he was the first person that I know of to bring in known good labels when he's calculating upticks. So what that is to say is if Shodan's out there scanning the internet for a given thing and then they add a different thing from a thousand different places, he doesn't want that to affect.