1 00:00:00,000 --> 00:00:04,760 So basically the title says it all. I wrote a Python script 2 00:00:04,760 --> 00:00:07,520 basically that does some cool stuff and we'll talk about it 3 00:00:07,520 --> 00:00:12,700 for the next 20 minutes. The obligatory about me slide, 4 00:00:13,620 --> 00:00:16,780 bottom line is this is a recon village so my name and Twitter 5 00:00:16,780 --> 00:00:20,960 handle are up there. You guys don't care who I am but you guys 6 00:00:20,960 --> 00:00:25,180 can look me up if you want to. I'm pretty approachable. So 7 00:00:25,180 --> 00:00:28,840 basically I did a lot of network defense for the last 8 00:00:28,840 --> 00:00:33,440 couple of years doing enterprise sized networks. Ran into a lot 9 00:00:33,440 --> 00:00:35,640 of issues. So you get a lot of syslog data, you get a lot of 10 00:00:35,640 --> 00:00:38,860 sourcing data, you get pcaps, you get net flow data. The 11 00:00:38,860 --> 00:00:41,820 problem is you get inundated with all this data and there's 12 00:00:41,820 --> 00:00:44,940 nothing really out there to do anything with it. There's a lot 13 00:00:44,940 --> 00:00:47,400 of enterprise solutions that are getting better but they're 14 00:00:47,400 --> 00:00:49,760 really, really expensive, really high learning curve and you 15 00:00:49,760 --> 00:00:52,200 can't play with them at home because a lot of these guys 16 00:00:52,200 --> 00:00:55,100 don't, we're not walking around with licenses for these half a 17 00:00:55,100 --> 00:00:58,820 million dollar software. I came across specifically folks who 18 00:00:58,820 --> 00:01:00,620 are focusing on internet of things devices and that's like 19 00:01:00,620 --> 00:01:03,940 the new hotness right now. And I'm a big fan of like raspberry 20 00:01:03,940 --> 00:01:08,220 pies and cheap affordable like approachable programming and 21 00:01:08,220 --> 00:01:12,040 tools. So cable labs posted a story a couple of years ago 22 00:01:12,040 --> 00:01:15,640 basically saying that net flow detection systems that seek to 23 00:01:15,640 --> 00:01:17,760 identify devices communicating with known command and control 24 00:01:17,760 --> 00:01:21,020 systems. So this is one of their primary means of detecting bot 25 00:01:21,020 --> 00:01:23,400 nets and malicious activity on the internet using net flow 26 00:01:23,400 --> 00:01:27,320 traffic analysis. So kind of my two cents, my plug to somebody 27 00:01:27,320 --> 00:01:28,800 else is more important to me. It's supporting my network. So I 28 00:01:28,820 --> 00:01:31,420 think that's my concept. But then you have this little diagram 29 00:01:31,420 --> 00:01:34,620 down at the bottom. So what I like about this is you have your 30 00:01:34,620 --> 00:01:36,740 bot nets, you know, everybody kind of thinks that you're like 31 00:01:36,740 --> 00:01:40,320 as an attacker you're going from attacker to the attacked. But 32 00:01:40,320 --> 00:01:43,380 what I noticed doing a lot of net flow traffic analysis is the 33 00:01:43,380 --> 00:01:47,040 real issue that we have is the devices on your network at home 34 00:01:47,400 --> 00:01:51,780 that have the ability to reach out to the public internet and be 35 00:01:51,780 --> 00:01:54,400 compromised that way. So you don't have to have a 36 00:01:54,400 --> 00:01:56,920 vulnerability on an internet of things device like a fridge or 37 00:01:56,920 --> 00:01:58,800 whatever in your house. There can be a vulnerability on a 38 00:01:58,820 --> 00:02:03,100 database server in the cloud, 100,000 miles away, and that's 39 00:02:03,100 --> 00:02:05,480 how the attacker is actually getting access into your home 40 00:02:05,480 --> 00:02:08,180 network. And the only way you're going to detect that is 41 00:02:08,180 --> 00:02:09,940 through network traffic analysis. It's going to pass all 42 00:02:09,940 --> 00:02:11,380 your checks, it's going to be allowed through your firewall, 43 00:02:11,800 --> 00:02:17,060 and it's pretty hard to see with a normal syslog type stuff. So I 44 00:02:17,060 --> 00:02:20,540 wrote basically a Python script. It's open source. It's all on 45 00:02:20,540 --> 00:02:24,680 GitHub. And it basically aggregates a whole bunch of 46 00:02:24,680 --> 00:02:27,080 blacklists. So Firehole IP manages a whole bunch of 47 00:02:27,080 --> 00:02:28,800 databases that are updated, pre-installed, and then it 48 00:02:28,820 --> 00:02:30,560 aggregates pretty regularly depending on which ones you want. 49 00:02:31,460 --> 00:02:34,680 Some of them are huge, like gigabytes worth of data. Some 50 00:02:34,680 --> 00:02:37,040 of them are really small. But the key here is that we're looking 51 00:02:37,040 --> 00:02:40,500 at like IP addresses. So the next slide I'll go into NetFlow. 52 00:02:40,680 --> 00:02:45,880 But it aggregates all these blacklists, does open source 53 00:02:45,880 --> 00:02:48,460 intelligence gathering using Shodan, VirusTotal, and some 54 00:02:48,460 --> 00:02:52,000 other APIs. And then it kind of builds a threat intelligence 55 00:02:52,600 --> 00:02:54,960 dashboard that you can use to kind of see what's going on on 56 00:02:54,960 --> 00:02:58,800 your home network or your small home, small office network. And 57 00:02:58,820 --> 00:03:02,140 then at one point I had integration for text message 58 00:03:02,140 --> 00:03:04,760 alerts. So I'd get a text message any time my computer or a 59 00:03:04,760 --> 00:03:08,540 device on my network talked to a malicious IP address. I took it 60 00:03:08,540 --> 00:03:13,160 out because I ran out of free API rules. So feel free to add it 61 00:03:13,160 --> 00:03:15,440 back in if you want, but you're going to have to pay for API 62 00:03:15,440 --> 00:03:22,000 service for SMS. So for anybody that doesn't know, NetFlow is 63 00:03:22,000 --> 00:03:24,780 basically based on the five tuple. It's a Cisco proprietary 64 00:03:25,360 --> 00:03:28,520 protocol, but there's a lot of free and open source similar 65 00:03:28,820 --> 00:03:32,180 protocols that use the exact same byte orders. But it captures 66 00:03:32,180 --> 00:03:35,440 the source, destination, IP address, source, destination 67 00:03:35,440 --> 00:03:39,940 port, and the average size of the bytes for the session. So 68 00:03:39,940 --> 00:03:42,520 with that information you can see who you're talking to, who's 69 00:03:42,520 --> 00:03:44,980 talking to you, and how much traffic is going back and forth. 70 00:03:45,780 --> 00:03:49,660 So that's NetFlow in a nutshell. The bottom left is the actual 71 00:03:49,660 --> 00:03:52,300 like parser that I use where I broke out the actual bytes of 72 00:03:52,300 --> 00:03:55,720 the packets, which is all being stored into a SQL database in 73 00:03:55,720 --> 00:03:58,800 the back end. So that's NetFlow in a nutshell. The bottom left is 74 00:03:58,820 --> 00:04:01,440 NetFlow. And once again, going back to the beginning, so there's 75 00:04:01,440 --> 00:04:03,280 not a whole lot of options out there, but there are some options. 76 00:04:03,520 --> 00:04:05,640 So I'm sure you guys are familiar with like the commercial options 77 00:04:05,640 --> 00:04:08,800 like SolarWinds, McAfee's got a lot of products, really 78 00:04:08,800 --> 00:04:12,100 expensive. Then you have all the free options. So you have Elk 79 00:04:12,100 --> 00:04:14,980 and Security Onion, which are really great, but they don't run 80 00:04:14,980 --> 00:04:17,440 on a Raspberry Pi, or if they do run on a Raspberry Pi, they run 81 00:04:17,440 --> 00:04:22,760 like crap. So if anybody's used massive databases or anything 82 00:04:22,760 --> 00:04:26,800 like that on a $5 computer and has good success, please let me 83 00:04:26,800 --> 00:04:28,800 know, because I think everybody here in the room knows what 84 00:04:28,820 --> 00:04:33,560 they're doing here would be interested. So Elk is kind of 85 00:04:33,560 --> 00:04:37,680 another option. So Lassa Search, Logstash, and Kibana. Kind of the 86 00:04:37,680 --> 00:04:41,000 backbone of Security Onion. Once again, doesn't work very 87 00:04:41,000 --> 00:04:43,480 well because of the data size and the database accesses on a 88 00:04:43,480 --> 00:04:50,120 Raspberry Pi. And then more reasons why I think my Raspberry 89 00:04:50,120 --> 00:04:53,440 Pi project was pretty neat, but basically the recommended 90 00:04:53,440 --> 00:04:56,540 guidelines for a lot of those open source softwares are, you 91 00:04:56,540 --> 00:04:58,800 know, 8 gigabytes of RAM. A couple of things that I think 92 00:04:58,820 --> 00:04:59,480 people need to be aware of. One, you need to have at least a 93 00:04:59,480 --> 00:05:03,040 dual core, preferably a quad core processor. And then you're 94 00:05:03,040 --> 00:05:04,660 going to need to power it, too. So like a lot of people don't 95 00:05:04,660 --> 00:05:07,360 consider that as like a cost, but I've lived in a couple of 96 00:05:07,360 --> 00:05:09,180 different places around the country and I've experienced 97 00:05:09,180 --> 00:05:11,560 like electricity bills higher than you can possibly imagine. 98 00:05:12,640 --> 00:05:15,480 So anything I can do to not plug something else into the 99 00:05:15,480 --> 00:05:19,140 network and run it 24 hours a day, 7 days a week, works for 100 00:05:19,140 --> 00:05:25,180 me. So to summarize a lot of that, what I just said, you know, 101 00:05:25,200 --> 00:05:27,200 I'm looking for a low cost, low power, easy to configure, 102 00:05:28,180 --> 00:05:28,800 integrates intelligence. So I'm looking for something that's 103 00:05:28,800 --> 00:05:30,220 easy to use. It's got a lot of intelligence and it has a cool 104 00:05:30,220 --> 00:05:34,920 black hacker-like interface. So we end up with the Raspberry Pi, 105 00:05:35,080 --> 00:05:37,500 specifically the Pi Zero W because they're like 5 bucks 106 00:05:38,060 --> 00:05:42,000 every couple months, 10 bucks not on sale. And then they got 107 00:05:42,000 --> 00:05:44,220 this Pi Zero stem. So if you haven't played with that, it's 108 00:05:44,220 --> 00:05:48,040 awesome. Integrates, solders right onto the board, allows you 109 00:05:48,040 --> 00:05:51,480 to use it as a storage device and power. And it's pretty 110 00:05:51,480 --> 00:05:53,860 cheap. It's like $1.50 or something like that from a lot 111 00:05:53,860 --> 00:05:58,660 of the Raspberry Pi type stores. So we take a Raspberry Pi, 112 00:05:58,660 --> 00:06:03,100 Zero W, Python, intelligence, all for about 15 bucks plus 10 113 00:06:03,100 --> 00:06:05,540 minutes worth of soldering and you have your own threat 114 00:06:05,540 --> 00:06:10,340 intelligence dashboard for your home network. And then to go 115 00:06:10,340 --> 00:06:12,940 into like the science behind it, so, and I use science loosely 116 00:06:12,940 --> 00:06:15,740 because it's not, I mean it's data science, but it's not like 117 00:06:15,740 --> 00:06:19,840 data science. This is the kind of process that I was working 118 00:06:19,840 --> 00:06:22,360 with. So first we collect the raw data. We get all our NetFlow 119 00:06:22,360 --> 00:06:26,740 traffic in and we parse it and we make sense of it and then we 120 00:06:26,740 --> 00:06:28,640 put it into a database. You see, you know, we have a lot of 121 00:06:28,640 --> 00:06:31,020 SQLite as the database of choice because there's no extra 122 00:06:31,020 --> 00:06:33,320 services. You can copy, paste it. You can upload it. You can 123 00:06:33,320 --> 00:06:35,960 share it. You can do whatever you want with it. And then you 124 00:06:35,960 --> 00:06:39,180 do the analysis on the data. So that's where the Firehole IP 125 00:06:39,180 --> 00:06:43,460 reputation comes in, Shodan queries, virus total queries, and 126 00:06:43,460 --> 00:06:45,280 anything else that you can possibly imagine. It's pretty 127 00:06:45,280 --> 00:06:49,080 modular and it's really easy to just add your own stuff. Results 128 00:06:49,080 --> 00:06:53,000 may vary, of course. And then visualize the data. So a whole 129 00:06:53,000 --> 00:06:56,300 bunch of database queries is pretty boring to look at. And we 130 00:06:56,300 --> 00:06:58,160 know we're in the 21st century so we want something with like 131 00:06:58,160 --> 00:07:01,340 colors and stuff. So I use Folium, which is an awesome 132 00:07:01,340 --> 00:07:05,340 Python library to build maps and graphs and anything that you can 133 00:07:05,340 --> 00:07:09,160 think of like data wise. Some Flask because it's a really 134 00:07:09,160 --> 00:07:14,480 great, I don't know, low resource intensive interactive web 135 00:07:14,480 --> 00:07:17,620 dashboard. So I was told to use Django by some other people. 136 00:07:18,100 --> 00:07:20,960 Django is great but it's a little bit more involved. Just 137 00:07:20,960 --> 00:07:24,120 set it up and manage it. Flask I can turn on, turn off real 138 00:07:24,120 --> 00:07:28,000 quick. And the Alexa uses Flask and I was programming for Alexa 139 00:07:28,160 --> 00:07:32,160 at the same time. And then JavaScript. And then I share the 140 00:07:32,160 --> 00:07:36,300 information. So after you have all the information, what do you 141 00:07:36,300 --> 00:07:38,640 do with it, right? So we have a whole bunch of disparate people 142 00:07:38,640 --> 00:07:43,180 running these servers all around the world. That's where I got 143 00:07:43,180 --> 00:07:46,260 into Twillo, which was my SMS notification. So you can do SMS 144 00:07:46,260 --> 00:07:50,240 notification, e-mail notification. You can push your 145 00:07:50,240 --> 00:07:53,240 results back to FireHall. So another thing that I was working 146 00:07:53,240 --> 00:07:57,280 on was modifying it from looking at IP addresses that are bad to 147 00:07:57,280 --> 00:07:58,140 looking at patterns that are bad to looking at patterns that are 148 00:07:58,160 --> 00:08:01,500 behavior. So you have your malicious ports. If you see 149 00:08:01,500 --> 00:08:07,380 Telnet, 4444, your standard botnet type ports, you can start 150 00:08:07,380 --> 00:08:10,640 taking the people scanning your public interface for those ports 151 00:08:10,640 --> 00:08:13,040 on the public Internet and feeding those back into these 152 00:08:13,040 --> 00:08:15,620 threat databases so you can kind of build the bench and share 153 00:08:15,620 --> 00:08:20,660 that information with the rest of the community. So this is a 154 00:08:20,660 --> 00:08:25,300 similar slide, just a little bit more detail. So we have the raw 155 00:08:25,300 --> 00:08:27,880 data ingest. So if you guys aren't running like custom 156 00:08:27,880 --> 00:08:30,480 firmware on your router, it's pretty easy to set up. So you can 157 00:08:30,480 --> 00:08:37,140 get your own NetFlow exporter. I run it on my LED router, so it's 158 00:08:37,140 --> 00:08:40,880 just an open WRT router running, I think it's like rflow or inflow. 159 00:08:41,860 --> 00:08:44,960 Saves all that in NetFlow version 5 because it's a lot less fields 160 00:08:44,960 --> 00:08:49,240 to parse through. And then puts it in a database. Does the 161 00:08:49,240 --> 00:08:52,700 analysis, visualizes it, and then sends it right back out to the 162 00:08:52,700 --> 00:08:57,860 community for sharing that information. So we have a lot of 163 00:08:57,860 --> 00:09:04,380 code. So this is the code. Pretty exciting stuff. On the left, 164 00:09:04,420 --> 00:09:07,800 NetFlow collector. On the right, it's the IP databases and stuff 165 00:09:07,800 --> 00:09:12,960 like that that I'm pulling down from the Internet. And then we do 166 00:09:12,960 --> 00:09:14,940 some geolocation, too. So if you haven't played around with 167 00:09:14,940 --> 00:09:18,340 IP geolocation, it's fairly accurate down to about the city 168 00:09:18,340 --> 00:09:22,520 level. It's kind of hard to spoof your IP locations, but 169 00:09:22,520 --> 00:09:27,760 it's not impossible. So it gets me pretty decent results. And 170 00:09:27,860 --> 00:09:31,200 then Shodan because I wanted to play with Shodan. Shodan has a 171 00:09:31,200 --> 00:09:34,240 great API if you haven't played with it. The free version gives 172 00:09:34,240 --> 00:09:38,020 you about three queries a second. So I was able to basically 173 00:09:38,020 --> 00:09:45,420 run 1,000 to 1,500 results a day. It takes about 10, 15 174 00:09:45,420 --> 00:09:48,200 minutes. So right now the bottlenecks, not the Raspberry 175 00:09:48,200 --> 00:09:51,740 Pi, it's these free APIs that are charging us. And then Virus 176 00:09:51,740 --> 00:09:57,420 Total. Virus Total has a really, really slow API. Everything came 177 00:09:57,420 --> 00:09:57,840 to a screen. It's a really, really slow API. It's a really, 178 00:09:57,860 --> 00:09:58,880 really fast. I went to the tradition hall. It was like two 179 00:09:58,880 --> 00:10:01,180 or three queries a minute. I talked to some Virus Total 180 00:10:01,180 --> 00:10:04,360 engineers here. They said they'll speed it up. So if you 181 00:10:04,360 --> 00:10:07,800 want free API access, talk to somebody around here. Maybe 182 00:10:07,800 --> 00:10:13,120 they'll give it to you. Results may vary. Finally the first 183 00:10:13,120 --> 00:10:16,480 slide with like a picture of the actual thing. So this is the 184 00:10:16,480 --> 00:10:20,600 map that I built. It's black because that's what hackers do. 185 00:10:22,540 --> 00:10:24,860 And, you know, kind of like what I was talking about with 186 00:10:24,860 --> 00:10:27,520 those Shodan restrictions. So each one of these dots is based 187 00:10:27,520 --> 00:10:32,000 on, you know, the color of the dots based on the density and the number of IP addresses from 188 00:10:32,000 --> 00:10:38,040 a given area. And then you can zoom in further to actually see the details. So what it does, 189 00:10:38,060 --> 00:10:42,020 it takes the showdown results that you have and puts them into a little I frame so you can 190 00:10:42,020 --> 00:10:46,020 click on any of these dots and you can get like a rundown on exactly what's running, what 191 00:10:46,020 --> 00:10:53,060 open services are on that, who owns it sometimes, the DNS resolution if there is one. What I 192 00:10:53,060 --> 00:10:59,100 was pulling in from VirusTotal is they maintain a database of the last 100 DNS resolutions 193 00:10:59,100 --> 00:11:05,420 for a given IP address. And then they can also do malware analysis. So if you have an IP 194 00:11:05,420 --> 00:11:09,080 address associated with a piece of malware, you can get that information out of VirusTotal 195 00:11:09,080 --> 00:11:13,860 and you can actually see what malware may be running on these potential botnet or scanning 196 00:11:13,860 --> 00:11:22,740 systems out on the public Internet using APIs. And then the flask, so I don't know why I 197 00:11:23,060 --> 00:11:29,100 hid my IP address because it's home.evilbotnet and it resolves to the IP address. But this is 198 00:11:29,100 --> 00:11:34,220 where I'm running it right now. This is using the flask. So it's basically an interactive web 199 00:11:34,220 --> 00:11:38,920 interface so you can run a number of queries. I added ports, services, so you can kind of 200 00:11:38,920 --> 00:11:43,940 basically a database manager, if you will, so you can view the raw data if you're into that 201 00:11:43,940 --> 00:11:53,040 kind of thing. So as I'm going through this, right, so the next step obviously is the 202 00:11:53,060 --> 00:11:57,240 fact that you have to like hack back or go back after the people that are going after you. My 203 00:11:57,240 --> 00:12:01,860 employer won't let me talk about that so I'm not going to talk about that. But the potential is 204 00:12:01,860 --> 00:12:07,260 there, right? So a lot of these devices, I'd say 50% scanners and like script kitties on the 205 00:12:07,260 --> 00:12:13,240 Internet. I get a lot of stuff from like University of Michigan. Shodan scans me a lot. And a 206 00:12:13,240 --> 00:12:17,020 whole bunch of stuff from like DigitalOcean. So DigitalOcean must have really loose like 207 00:12:17,740 --> 00:12:22,080 hacking rules. I know AWS will kick you off really fast if you do any kind of scanning without 208 00:12:24,600 --> 00:12:27,400 that information. But you can take that information, like I mentioned, you can push it 209 00:12:27,400 --> 00:12:32,980 right back up into the databases that you're pulling information from. So the chart in the 210 00:12:32,980 --> 00:12:38,580 middle is actually a chart from VirusTotal. And you can ‑‑ or sorry, IP abuse database. 211 00:12:39,960 --> 00:12:44,440 And really easy way, it's like one line of code just to shoot that information right back up to 212 00:12:44,440 --> 00:12:49,920 them. Basically confirm that these IP addresses are bad, good. But it's a good way to 213 00:12:49,920 --> 00:12:53,040 contribute back to the community. And then potentially if you felt like you were going to 214 00:12:53,060 --> 00:12:58,320 not like it, you could write a search integration and build your own exploits and weaponize 215 00:12:58,320 --> 00:13:07,640 the system if you wanted to. So that's basically it. I didn't mention it before, but I'm not a 216 00:13:07,640 --> 00:13:12,540 full‑time programmer by any stretch of the imagination. So I did this as a way to learn how 217 00:13:12,540 --> 00:13:18,700 to program. And I learned a lot throughout the process. But it's buggy as hell. And it will 218 00:13:18,700 --> 00:13:23,040 have a lot of bugs in it. It's all up online. So github.com slash evilbots.com. And you'll get a lot of 219 00:13:23,060 --> 00:13:27,220 good stuff on the internet. Please contribute. Download it. Tell me if it works. Tell me if it 220 00:13:27,220 --> 00:13:32,320 doesn't. Build your own. Rip it off. Do whatever you want. But I really had a lot of fun building 221 00:13:32,320 --> 00:13:38,420 the project, talking about the project. And I think it works well for my situation. So I guess I 222 00:13:38,420 --> 00:13:45,140 have five minutes for questions. . 223 00:13:53,060 --> 00:13:53,200 .