[00:00.000 --> 00:05.040] Alright, so the next speaker that we have is Gunner Andrews. [00:05.040 --> 00:10.480] And Gunner is working in the application security space for almost five years now. [00:10.520 --> 00:14.700] He is a hacker who is passionate about software and sharing knowledge. [00:14.700 --> 00:20.980] And is currently working as a senior application and a cloud security engineer at Interwell Health. [00:21.340 --> 00:26.220] And also, he's also a SynecRed team member. So please welcome Gunner Andrews. [00:26.220 --> 00:35.100] Alright, hello? [00:35.840 --> 00:37.740] Thanks for coming, first of all. [00:37.740 --> 00:42.480] So this is my talk, called How I Built Recon to Scale with Serverless Architecture. [00:42.680 --> 00:46.460] So we're going to go over a couple different kinds of serverless, some logistics, [00:46.460 --> 00:51.460] and then there's a bunch of screenshots, workflows, code, all that kind of stuff. [00:51.640 --> 00:57.900] The slides get shared and everything else, so if I'm going too fast, it's all available after. [00:57.900 --> 01:00.840] I just wanted to leave it at that, just so people are interested. [01:01.980 --> 01:08.000] Okay, so again, this is kind of what we're going to go over in order. [01:08.380 --> 01:13.380] So obviously I have to start with the Who Am I slide, kind of like what you just heard. [01:13.720 --> 01:16.000] I do AppSec and CloudSec full-time. [01:16.200 --> 01:21.400] In my off-time, I like to develop stuff, I like to build stuff, like to play video games, [01:21.400 --> 01:24.240] like to bug bounty hunt, and I'm into fitness as well. [01:26.980 --> 01:29.640] So we're going to talk about two different kinds of serverless. [01:29.780 --> 01:32.180] So there's a lot of the word serverless flying around. [01:32.260 --> 01:35.020] One is kind of an idea, one is a framework. [01:35.360 --> 01:38.060] So the first one we're going to talk about is the idea of serverless. [01:38.300 --> 01:41.360] So there's a couple quotes up here from both Red Hat and CloudFlare, [01:41.580 --> 01:44.980] a little bit about what serverless actually is. [01:45.020 --> 01:49.560] So basically, if you read a little bit of those snippets, I'm sorry about the small text, [01:50.200 --> 01:54.960] it basically allows you to build applications, manage applications, deploy, etc., [01:54.960 --> 01:58.440] without actually having to manage the infrastructure under it. [01:59.040 --> 02:04.900] There are tools, especially in the bug bounty space, that are developed to help with this. [02:04.900 --> 02:09.740] One is called Axiom, that allows you to basically take a workload and spread it over a bunch of servers, [02:10.220 --> 02:14.580] and then it will basically ingest the data, bring it back, and give it all to you as one thing. [02:14.580 --> 02:18.900] There's also a tool called ShadowClone that actually does get into the serverless space, [02:18.900 --> 02:23.080] that basically allows you to do the same thing, but break up a workload over a bunch of Lambda functions. [02:23.080 --> 02:26.200] Or, I think it uses Azure and GCP, too. [02:26.540 --> 02:31.340] But basically, what serverless computing is, is if you take the... [02:31.340 --> 02:36.620] there's a line that what you're responsible for, and then what, let's say, a cloud provider is responsible for. [02:36.620 --> 02:41.700] If you spin up an EC2 instance in AWS, you are responsible for updating that server, [02:41.700 --> 02:44.300] you're responsible for managing what ports are open on that server, [02:44.300 --> 02:47.500] and there's a whole laundry list of things that you're responsible for. [02:47.500 --> 02:52.940] AWS is responsible for the data center. If someone breaks into the data center, you are not responsible. [02:53.000 --> 02:55.940] If someone breaks into the server, you are very responsible. [02:57.160 --> 03:00.760] Serverless takes that line and moves it basically one more step up. [03:00.820 --> 03:04.960] You are now only responsible for what you are deploying on the servers. [03:04.960 --> 03:09.360] That's actually the code you're writing, the software you may be deploying, whatever it may be, [03:09.360 --> 03:12.060] that's now the only thing you are responsible for. [03:12.320 --> 03:17.440] AWS is actually managing the runtime environments for you, the servers in the backend for you, [03:17.440 --> 03:18.840] scaling, everything. [03:19.600 --> 03:22.640] Caveat that we'll talk about later, obviously you have to pay for that, [03:22.640 --> 03:25.000] but we will talk about that a little bit more in a bit. [03:27.950 --> 03:31.370] So there is a lot of these out there, there's a lot of different flavors, [03:31.370 --> 03:32.930] and they do a lot of different functions. [03:33.430 --> 03:38.230] A lot of what we're going to be seeing today is AWS, and that's some of the stuff you see there on the top. [03:38.270 --> 03:43.010] So we're going to talk about AWS Lambda, AWS DynamoDB, Step Functions, [03:43.010 --> 03:45.130] but GCP has this kind of thing too. [03:45.130 --> 03:49.190] One example is Cloud Run, and Azure also has Azure functions, [03:49.190 --> 03:51.910] I'm pretty sure DigitalOcean also has DigitalOcean functions. [03:51.990 --> 03:55.170] There's a lot of it out there, serverless is kind of spreading to everybody, [03:55.170 --> 03:59.850] but the ones that we're going to focus on today in some of the demos and the screenshots is all AWS, [03:59.850 --> 04:02.110] but it is not cloud agnostic. [04:03.010 --> 04:08.470] But this basically allows a user to either package up code in a zip file, [04:08.470 --> 04:11.810] or use Docker files and Docker containers, [04:11.810 --> 04:15.890] and basically take it to your image, or your zip file of code, and just deploy it. [04:15.890 --> 04:20.130] You're basically telling the cloud this is Python, Go, whatever it may be, and it handles the rest. [04:20.130 --> 04:22.870] All you're worried about is updating and managing the actual code base, [04:22.870 --> 04:24.750] or the software you're deploying, and nothing else. [04:26.830 --> 04:29.410] So this is the other serverless. [04:29.490 --> 04:31.410] This is the serverless framework. [04:32.350 --> 04:34.690] This is basically a CLI tool. [04:34.790 --> 04:36.670] If anyone here has heard of Terraform, [04:36.670 --> 04:42.290] it's pretty much a spinoff of Terraform for only serverless products. [04:42.570 --> 04:46.410] It works with all the different clouds, all the main cloud providers, [04:46.410 --> 04:48.470] and it works with their serverless offerings. [04:48.470 --> 04:51.070] It comes with a whole bunch of plugins to do a whole bunch of things. [04:51.070 --> 04:55.210] One of the plugins we'll see is it allows you to deploy a Python Lambda function [04:55.210 --> 04:59.210] with a requirements.txt file, which has been annoying in the past, [04:59.210 --> 05:01.310] if anyone has done Lambda development. [05:01.310 --> 05:05.790] And it handles these laundry lists of languages that I have up there, [05:05.790 --> 05:07.130] plus a lot more. [05:07.530 --> 05:09.730] And the reason why we're going to talk about it is because [05:09.730 --> 05:13.290] there's a lot of different ways to remotely deploy serverless. [05:13.490 --> 05:17.290] AWS has something called SAM that you can use to deploy serverless. [05:18.190 --> 05:21.630] It's not user-friendly 100% of the time. [05:22.310 --> 05:24.830] This, in my argument, is. [05:24.830 --> 05:26.690] And we're going to show a little video walkthrough of it, [05:26.690 --> 05:30.450] but basically it breaks down to these four things. [05:30.450 --> 05:32.450] It's an npm package that you install. [05:33.030 --> 05:36.690] When you type just serverless, it pulls up a whole list of templates [05:36.690 --> 05:40.090] that you can choose, and it will basically do what a lot of other tools do, [05:40.090 --> 05:43.190] and it will make you a new directory and populate that directory with what you need. [05:43.630 --> 05:46.830] For example, with Lambda, a Lambda handler, the YAML file, [05:46.830 --> 05:49.570] you'll need to deploy it and configure it and everything else. [05:49.870 --> 05:52.450] Whenever you're ready to deploy, you just type serverless deploy, [05:52.450 --> 05:54.530] and obviously there's a bunch of flags if you want to configure it, [05:54.530 --> 05:56.450] but serverless deploy will deploy it. [05:56.450 --> 06:00.390] And then you can invoke it right from the command line, and we'll show that. [06:00.530 --> 06:04.150] There's also ways that I'll show you when you invoke the function. [06:04.150 --> 06:08.590] If you want to test your Lambda locally, you do not have to pay for AWS Cloud9. [06:08.610 --> 06:10.530] You do not have to mess around with SAM. [06:10.530 --> 06:14.210] All you do is, instead of serverless invoke, and you're calling your function, [06:14.210 --> 06:16.330] you just add in local, and we'll show that. [06:16.330 --> 06:18.530] But then you're testing your Lambda function locally, [06:18.530 --> 06:22.510] and you're not actually paying to run a bunch of tests. [06:22.730 --> 06:25.450] And you can hand it data, fake data, dummy data, and everything else, [06:25.450 --> 06:29.210] and you can test all your serverless stuff locally before you actually deploy it. [06:29.550 --> 06:32.110] And if you turn out you want to remove something, [06:32.110 --> 06:36.350] serverless remove removes all the backend, as well as the actual Lambda. [06:36.350 --> 06:39.450] So this runs on the CloudFormation stack, [06:39.450 --> 06:42.230] and then uses, obviously, S3 as a backend for CloudFormation. [06:42.270 --> 06:44.150] And that's actually how it will be deployed. [06:44.150 --> 06:48.930] Very similar to SAM, but it puts it all in a nice little YAML format for you [06:48.930 --> 06:52.670] that we're going to go over, and basically puts a CLI wrapper on it. [06:52.670 --> 06:56.870] So I have a video here, and I'm going to probably speed it up, [06:56.870 --> 06:58.370] and skip through some stuff. [06:59.090 --> 07:02.050] But basically, like I said, when you type serverless in the beginning, [07:02.050 --> 07:04.110] it will let you pick from a bunch of templates. [07:04.110 --> 07:06.190] And there's a whole bunch there if you click Other. [07:06.410 --> 07:09.030] But all I did here was pick an Amazon starter one, [07:09.030 --> 07:12.210] which is obviously, of course, your cliche Hello World. [07:12.730 --> 07:17.510] You're naming it, and it will then build you that new directory, [07:18.190 --> 07:19.970] and deploy it out there, right? [07:21.170 --> 07:23.810] You can use the dashboard. The dashboard is a paid thing. [07:23.810 --> 07:26.050] You definitely don't have to use, right? [07:26.390 --> 07:28.570] And we don't want to deploy it. [07:28.570 --> 07:32.770] After we CD into the directory, I'll show you when you LS in here. [07:32.770 --> 07:38.210] This right here is in your directory. [07:38.210 --> 07:40.070] There's two things in the beginning one. [07:40.070 --> 07:43.310] The handler is the basic handler that you would use, [07:43.310 --> 07:45.890] whether using SAM or something else, to deploy something. [07:45.910 --> 07:48.510] And then the serverless.yaml is the actual YAML file [07:48.510 --> 07:50.410] you're using to configure the Lambda function. [07:50.410 --> 07:52.730] So this is how much memory you want to have, [07:52.730 --> 07:54.950] the timeout you want to have, and stuff like that. [07:54.990 --> 07:57.430] But as you'll see here in a second... [07:57.430 --> 07:58.650] Oh, geez. [08:00.070 --> 08:02.530] I even tried to avoid live demos, too. [08:08.040 --> 08:09.080] So let's go. [08:09.820 --> 08:12.040] Okay, so back where we were. [08:13.420 --> 08:15.360] The handler looks a little bit like this. [08:15.360 --> 08:17.740] This is like a super basic handler, right? [08:18.720 --> 08:22.040] You're defining a function called Hello, since the Hello World. [08:22.040 --> 08:24.060] You'll see that show up in the YAML file. [08:24.160 --> 08:26.420] That function is how you'll tell the YAML file, [08:26.420 --> 08:28.300] like, this function is my handler function. [08:28.300 --> 08:30.080] So it's in a file called handler.py, [08:30.080 --> 08:31.440] and the function's called Hello. [08:31.440 --> 08:33.980] So that's key here, because the next thing that's going to come up [08:33.980 --> 08:35.740] is the YAML file. [08:35.900 --> 08:38.260] The YAML file is very small, [08:38.260 --> 08:40.240] because it's just the basic version. [08:40.500 --> 08:42.120] And I'll show you some of mine later, [08:42.120 --> 08:43.460] as we go into the thing. [08:46.180 --> 08:47.400] There we go. [08:47.500 --> 08:49.140] So this is the YAML file. [08:49.140 --> 08:50.780] So you see in the bottom, you're calling functions, [08:50.780 --> 08:52.060] you're naming a function. [08:52.380 --> 08:53.780] The name is called Hello. [08:53.780 --> 08:55.340] And then you're pointing it to the handler. [08:55.340 --> 08:57.400] So you're pointing it to the file that it should go to, [08:57.400 --> 08:59.240] and then dot whatever function. [08:59.400 --> 09:03.800] You can have a bunch of functions in one directory. [09:03.800 --> 09:05.740] You can make one directory per. [09:05.800 --> 09:06.540] All that kind of stuff. [09:06.540 --> 09:08.900] You don't have to put any secrets in here. [09:08.900 --> 09:10.520] This makes it so you can actually package up [09:10.520 --> 09:12.020] Lambda functions in directories, [09:12.020 --> 09:15.000] and use Git or any other type of version control [09:15.000 --> 09:18.380] to actually co-develop serverless architecture. [09:18.380 --> 09:19.020] Right? [09:22.160 --> 09:22.620] So... [09:22.620 --> 09:29.620] In the hallway, and they stopped everybody. [09:30.140 --> 09:30.840] Oh. [09:32.500 --> 09:33.660] Don't fight. [09:37.300 --> 09:40.380] So, this is the part I'm probably going to skip through, [09:40.380 --> 09:41.940] because this is basically just like, [09:41.940 --> 09:44.300] it runs for about 75 seconds. [09:44.740 --> 09:47.000] But when you type serverless deploy, [09:47.000 --> 09:48.380] like I said, it's using CloudFormation [09:48.380 --> 09:50.100] and S3, just like SAM does, [09:50.100 --> 09:51.400] in the back. [09:51.400 --> 09:53.580] And that will basically, [09:53.580 --> 09:55.700] this is now just deploying it to my AWS account. [09:55.700 --> 09:58.200] So the only requirement to get this to work [09:58.200 --> 10:00.100] is you download the npm package, [10:00.100 --> 10:02.000] and you have your AWS credentials configured. [10:02.000 --> 10:04.760] Just like, you know, if you're using the AWS CLI. [10:04.760 --> 10:05.640] It's the same thing. [10:06.440 --> 10:07.940] So really, at the end of the day, [10:08.580 --> 10:10.660] what it is, is it's a CLI wrapper [10:10.660 --> 10:13.240] and YAML wrapper around the AWS CLI, [10:13.240 --> 10:14.760] and basically doing what SAM does. [10:14.760 --> 10:15.840] It just makes it a lot easier [10:15.840 --> 10:18.760] to locally develop, deploy, and update [10:19.560 --> 10:20.660] what you're doing. [10:20.660 --> 10:22.800] So, once it finishes here, [10:24.300 --> 10:26.180] right here, we're going to invoke it. [10:26.180 --> 10:27.500] You invoke it by the function, [10:27.500 --> 10:29.500] which we called hello. [10:29.540 --> 10:30.600] And when you invoke it, [10:30.600 --> 10:33.280] this is actually running on my AWS account. [10:33.280 --> 10:34.540] After it was deployed. [10:34.880 --> 10:36.000] Like I said before, though, [10:36.000 --> 10:37.700] you can do the same exact thing, [10:37.700 --> 10:39.660] and just tell it to invoke locally. [10:41.620 --> 10:43.220] And this is now using [10:43.220 --> 10:45.580] whatever I have on my machine. [10:45.600 --> 10:46.100] Right? [10:46.820 --> 10:49.000] So if you want to test before you deploy, [10:49.000 --> 10:50.320] you can invoke locally, [10:50.320 --> 10:51.720] and then whenever you're ready to remove it, [10:51.720 --> 10:53.900] the last step, since I don't necessarily [10:53.900 --> 10:56.860] need to keep a hello thing on my account, [10:56.860 --> 10:58.960] you serverless remove, and it removes everything. [11:00.380 --> 11:01.620] It's very simple, [11:01.620 --> 11:03.480] it's very easy to use, [11:03.480 --> 11:05.180] especially compared to some of the other stuff, [11:05.180 --> 11:06.640] like SAM, or just using [11:06.640 --> 11:08.160] the AWS console. [11:08.800 --> 11:11.220] So now, of course, we have to talk logistics. [11:11.780 --> 11:12.660] What I mean by that is [11:12.660 --> 11:14.600] we're going to talk about cost and scalability. [11:16.360 --> 11:17.080] So, [11:17.080 --> 11:19.200] I'm going to pre-wreck this by saying [11:19.200 --> 11:20.900] if you want to use serverless [11:20.900 --> 11:22.700] to build your own automation framework for [11:22.700 --> 11:25.000] either red teaming, bug bounty hunting, or blue teaming, [11:25.000 --> 11:27.120] or whatever it may be, and you want to scan [11:27.120 --> 11:29.000] 100 million domains every [11:29.000 --> 11:31.680] five minutes, forever, [11:31.680 --> 11:33.720] it's going to cost you money. [11:34.120 --> 11:34.500] There's [11:34.980 --> 11:37.660] no way around it not costing you money. [11:37.740 --> 11:39.080] There is a free tier for a lot of [11:39.080 --> 11:41.120] this stuff, and I will talk about some of the [11:41.120 --> 11:42.960] ways to save money if you want to [11:42.960 --> 11:45.600] maybe make it a little bit less user-friendly, [11:45.600 --> 11:47.500] but a little more cost-saving. We're going to go over [11:47.500 --> 11:49.220] that during the example, but [11:49.640 --> 11:51.660] a little caveat is it does save you money. [11:51.960 --> 11:54.340] But, a decent example, [11:54.340 --> 11:55.560] and I'm sorry, again, I'm sorry for the [11:55.560 --> 11:57.780] small text. I tried to make it as big as I could. [11:57.900 --> 11:58.820] At the top [12:00.460 --> 12:01.260] is doing [12:01.260 --> 12:03.420] 10 million DNS resolutions in [12:03.420 --> 12:05.000] Lambda, in estimate. [12:05.200 --> 12:07.560] So if you Google it, or chat GPT, [12:07.560 --> 12:09.260] the average DNS resolution is about [12:09.260 --> 12:11.400] 33 milliseconds. So if you [12:11.400 --> 12:13.280] run a little Lambda function that [12:13.280 --> 12:15.240] resolves one domain, which will [12:15.240 --> 12:17.540] happen in hopefully 33 milliseconds, [12:17.540 --> 12:19.880] and you run it 10 million times, [12:19.880 --> 12:21.680] you pay $1.80. [12:23.080 --> 12:25.680] So if you resolve 10 million domains per month, [12:25.680 --> 12:27.240] you paid $1, almost [12:27.240 --> 12:29.320] $2. Right? If you [12:29.320 --> 12:31.320] buy the smallest EC2 box you can [12:31.320 --> 12:33.140] buy, at least on my account, [12:33.140 --> 12:35.920] you pay $3.65 a month. [12:36.660 --> 12:37.460] So, [12:37.460 --> 12:38.800] if you're resolving [12:38.800 --> 12:41.100] 10 million domains, you're still cheaper [12:41.100 --> 12:43.060] doing it with Lambda than [12:43.060 --> 12:44.940] doing it in EC2. [12:45.260 --> 12:47.160] Now, as data storage [12:47.160 --> 12:49.120] comes into play, or continuous [12:49.120 --> 12:51.180] scanning, right? If you're [12:51.180 --> 12:53.200] going to try and resolve domains every minute [12:53.200 --> 12:54.860] of every month, [12:54.860 --> 12:56.980] that gets a little bit different. So [12:57.660 --> 12:59.220] some of the advantages of [12:59.220 --> 12:59.720] serverless [13:00.940 --> 13:02.880] are as follows. [13:02.880 --> 13:04.640] I tried to fit it all in. [13:04.720 --> 13:07.320] The one thing to look at is whatever you're trying to build [13:07.320 --> 13:08.940] will have a traffic pattern. [13:08.940 --> 13:10.640] If you're doing continuous scanning [13:10.640 --> 13:12.880] and it's always running and it's always [13:12.880 --> 13:14.920] on all the time, don't use [13:14.920 --> 13:16.820] serverless. This is probably [13:16.820 --> 13:17.940] not for you. [13:18.360 --> 13:20.940] Because you will spend more money using serverless [13:22.760 --> 13:24.760] than you would using server-based. The only [13:24.760 --> 13:26.780] advantage is you would be paying more money [13:26.780 --> 13:28.700] to not have to worry about your infrastructure. [13:28.700 --> 13:30.580] That may be worth it to you, it may not, [13:30.580 --> 13:32.620] but this won't save you money. [13:32.680 --> 13:34.740] If you have spiky workloads, [13:34.740 --> 13:36.560] let's say you want to resolve 10 million domains [13:36.560 --> 13:38.560] once a month, [13:39.200 --> 13:40.540] serverless is for you. [13:40.680 --> 13:42.740] Because you don't have to worry about spinning up and spinning [13:42.740 --> 13:44.640] down servers and forgetting it's there and then paying [13:44.640 --> 13:46.560] for the whole month. You don't have to worry about [13:46.560 --> 13:48.500] where your servers are and how big or how small they are [13:48.500 --> 13:50.000] and if they can handle the load or if you're going to [13:50.470 --> 13:52.520] overload the server. All of [13:52.520 --> 13:54.400] serverless has scalability [13:54.400 --> 13:56.220] basically to unlimited. [13:56.520 --> 13:58.820] Obviously there's benchmarks, but [13:58.820 --> 14:00.220] just quote-unquote unlimited [14:00.220 --> 14:02.560] for whatever workload you want to give it. [14:02.760 --> 14:04.500] It will scale for you and you [14:04.500 --> 14:07.200] only pay for what you use in serverless. [14:07.320 --> 14:08.440] So Lambda for instance, [14:08.440 --> 14:10.480] you pay for the computing resources times the [14:10.480 --> 14:12.600] amount of time you're using them. That's it. [14:12.600 --> 14:14.400] It doesn't matter if you do it one Lambda [14:14.400 --> 14:16.800] at a time, it doesn't matter if you do it 100,000 [14:16.800 --> 14:18.480] Lambdas at a time, you're using the [14:18.480 --> 14:20.620] same amount of computing resources, the math works [14:20.620 --> 14:22.820] out the same whether you run it one at a [14:22.820 --> 14:26.120] time or 100,000 at once. [14:26.120 --> 14:26.720] So for [14:26.720 --> 14:29.180] very spiky workloads, serverless [14:29.180 --> 14:31.440] normally will perform better than servers [14:31.440 --> 14:32.580] and it's way easier to manage [14:32.580 --> 14:33.920] and it's way easier to scale. [14:34.420 --> 14:36.660] The other thing like I talked about is the development [14:36.660 --> 14:38.700] maintenance. I do this for fun [14:38.700 --> 14:40.580] and I'm one person. I do not [14:40.580 --> 14:42.780] have a dev team, I do not have an infrastructure team, [14:42.780 --> 14:44.120] I don't have anybody. [14:45.740 --> 14:46.500] This makes it [14:46.500 --> 14:48.180] very easy because all I do [14:48.180 --> 14:50.480] is write code and do what you just [14:50.480 --> 14:52.320] saw, I just deploy it. [14:52.460 --> 14:53.760] And then I don't worry about it. [14:54.380 --> 14:56.560] And we're going to talk about how to schedule it and it'll even run [14:56.560 --> 14:58.320] on its own and all that kind of stuff. You basically [14:58.320 --> 15:00.540] code, it's basically like you're pushing to get [15:00.540 --> 15:02.520] you code, push and you forget. Unless [15:02.520 --> 15:04.540] it breaks. But we'll talk about that [15:04.540 --> 15:05.060] too. [15:08.520 --> 15:09.900] So now... okay good, I'm doing [15:09.900 --> 15:11.860] good on time. So I'm going to go through [15:11.860 --> 15:13.080] my stuff. [15:14.680 --> 15:15.980] A little birdie told me opening [15:15.980 --> 15:18.180] AWS console, a hacker conference, was probably [15:18.180 --> 15:19.240] not a good idea. [15:19.620 --> 15:21.380] So it's all screenshots. [15:22.260 --> 15:23.760] I am not hiding anything. [15:23.760 --> 15:26.200] If you have a question about something or you want to see something, [15:26.200 --> 15:27.720] get in touch with me. [15:27.720 --> 15:30.160] Ask me. I am more than willing to share it with you. [15:30.160 --> 15:31.620] These slides will be available. [15:31.820 --> 15:34.760] All the code is in the slides. [15:34.760 --> 15:36.440] It's just kind of the best way of both worlds [15:36.440 --> 15:38.120] where I'm not showing my AWS [15:38.120 --> 15:39.820] console at a hacker conference [15:39.820 --> 15:41.780] and I can show you guys [15:41.780 --> 15:43.420] how I do things. [15:44.020 --> 15:45.660] So this is [15:46.120 --> 15:47.740] one of the workflows. [15:47.800 --> 15:49.060] This is the one we're going to focus on. [15:49.060 --> 15:51.340] This is a passive enumeration [15:51.340 --> 15:53.880] that I use for bug bounty. There's passive [15:53.880 --> 15:56.080] and active enumeration. This is the passive side [15:56.080 --> 15:58.120] of things. So any bug bounty [15:58.120 --> 15:58.920] people in here, any [15:59.420 --> 16:01.980] all the recon folks in here have heard of [16:01.980 --> 16:03.360] subfinder and amass. [16:03.940 --> 16:05.980] This is basically bundling [16:05.980 --> 16:07.820] those tools up and running them for me against [16:07.820 --> 16:09.440] whatever I want it to run on. [16:10.240 --> 16:12.080] This is called step functions. [16:12.080 --> 16:14.020] In AWS, this basically allows you [16:14.020 --> 16:15.900] to orchestrate both serverless [16:15.900 --> 16:17.260] and non-serverless. [16:18.040 --> 16:20.040] And this basically is a workflow. [16:20.300 --> 16:21.800] So it comes in on the top [16:21.800 --> 16:24.440] to a lambda function that's called passive enumeration. [16:24.680 --> 16:25.920] And then in parallel [16:25.920 --> 16:27.320] it will both delete [16:27.860 --> 16:30.040] what I just processed from the queue, assuming [16:30.040 --> 16:31.860] it's successful, and it will [16:31.860 --> 16:33.960] loop through all my results. And if the domain is [16:34.060 --> 16:35.720] a new domain, it stores it in my database. [16:35.720 --> 16:38.420] Which is going to be DynamoDB, which we'll show in a second. [16:38.600 --> 16:40.000] After that, there's temporary [16:40.000 --> 16:41.900] recon data, because step [16:41.900 --> 16:43.960] functions can only handle so much data being passed [16:43.960 --> 16:45.900] from step to step. And you use S3 [16:45.900 --> 16:47.960] just like basically every other AWS tool [16:47.960 --> 16:49.820] to handle the large temporary [16:49.820 --> 16:51.840] data you're handling in between. And then [16:51.840 --> 16:53.860] it all just gets deleted at the end. Because it [16:53.860 --> 16:55.400] ends up in the database. [16:57.620 --> 16:59.640] So this is just a really quick... [16:59.640 --> 17:01.820] Again, this is my configuration I use, but this [17:01.820 --> 17:03.860] is just the configuration for a very basic SQS [17:03.860 --> 17:05.900] queue. This is basically how everything [17:05.900 --> 17:08.040] talks. So I use a PubSub [17:08.040 --> 17:09.940] type model for my stuff. [17:09.940 --> 17:11.940] And I use SQS queue as that basically [17:11.940 --> 17:13.700] broker in the middle. So anything [17:13.700 --> 17:15.780] that either will go from workflow [17:15.780 --> 17:18.000] to workflow, or that goes from a [17:18.000 --> 17:19.900] workflow getting kicked off into a workflow, [17:19.900 --> 17:22.060] all happens through SQS queues. [17:22.060 --> 17:24.120] SQS queues have a massive [17:24.120 --> 17:26.140] free tier. I have never paid for it [17:26.140 --> 17:28.140] yet. This is not one of [17:28.140 --> 17:30.080] the services where you will pay. [17:30.260 --> 17:32.060] If you break the free tier, [17:32.960 --> 17:33.840] congratulations. [17:34.740 --> 17:36.400] I think it's like 50 million [17:37.340 --> 17:38.680] messages or something. [17:38.940 --> 17:40.260] So this is how everything starts. [17:40.260 --> 17:42.400] Again, I use this for bug bounties, mostly. [17:43.280 --> 17:44.120] As well as a little bit [17:44.120 --> 17:45.800] of work. So PlayStation [17:45.800 --> 17:48.380] is pretty cool. They're giving one away, I think, [17:48.380 --> 17:50.140] in the CTF. But PlayStation has [17:50.220 --> 17:52.080] a bug bounty program. So I have [17:52.360 --> 17:54.360] a separate table in DynamoDB, [17:54.360 --> 17:56.360] which is a NoSQL serverless database [17:56.360 --> 17:58.060] that scales with you, just like everything else [17:58.060 --> 17:59.700] in serverless, on AWS. [18:00.040 --> 18:02.220] And this is what every target I have [18:02.220 --> 18:04.280] looks like. So I put in the URL [18:04.280 --> 18:06.260] of where I would turn in bugs, [18:06.260 --> 18:08.640] hopefully, the name of the program, [18:08.640 --> 18:10.160] and then a list of domains, whatever their [18:10.160 --> 18:12.000] root domains may be. I put any wildcard [18:12.000 --> 18:14.100] domains in here that I'm going to do wide scope recon [18:14.100 --> 18:16.040] on, and these will automatically get [18:16.040 --> 18:17.860] ingested, as we'll see in a moment. [18:18.760 --> 18:19.880] Then this program, [18:19.880 --> 18:21.460] and this kind of thing, will be [18:21.900 --> 18:23.760] cross-searchable across the other tables, which [18:23.760 --> 18:25.320] I'll show in a second. [18:27.280 --> 18:27.980] This is [18:27.980 --> 18:30.100] an example of what it would look like after. [18:30.300 --> 18:32.040] So, again, there are other steps [18:32.040 --> 18:33.840] to this that I only have 45 [18:33.840 --> 18:36.180] minutes to go over. Again, if you're interested, [18:36.180 --> 18:37.440] we can chat. [18:38.640 --> 18:39.760] But it starts out [18:39.760 --> 18:41.780] as it finds domains, it'll put them in there [18:41.780 --> 18:43.780] with the subdomain, the program, and then [18:43.780 --> 18:45.780] an empty list for CNAMEs and IPs that it [18:45.780 --> 18:48.020] finds, and then there's more, obviously. [18:48.020 --> 18:49.680] This is kind of truncated, but then whether or not [18:49.680 --> 18:51.740] it resolves, there's timestamps, everything else. [18:51.740 --> 18:53.260] You can add whatever you want here. [18:53.980 --> 18:55.660] And this can be updated, and this is [18:55.660 --> 18:57.720] one of the tables as a source of truth for [18:57.720 --> 18:59.660] results. Now, with [18:59.660 --> 19:01.700] this, you can do something in DynamoDB [19:01.700 --> 19:03.780] called scanning. It's sort of [19:03.780 --> 19:05.880] an intensive process, but it works [19:05.880 --> 19:07.780] very well cross-table, and you can do a lot [19:07.780 --> 19:09.620] of very cool queries with it. [19:09.620 --> 19:11.780] So, in my opinion, I think it's worth it to look [19:11.780 --> 19:13.740] into. So, for example, [19:13.740 --> 19:15.520] here, if I wanted to go into [19:15.520 --> 19:17.660] my domains table of all my [19:17.660 --> 19:19.620] recon of any amount of domains, and I [19:19.620 --> 19:21.560] just want to find the PlayStation one, it's very [19:21.560 --> 19:23.500] easy to just scan my table [19:23.500 --> 19:25.580] called domains, and the attribute [19:25.580 --> 19:27.860] name is program, and I want it to be equal to PlayStation. [19:27.860 --> 19:29.660] And I'll get every domain from all three [19:29.660 --> 19:31.360] of those seed domains that [19:31.360 --> 19:33.520] PlayStation is a part of. If I just wanted one of those [19:33.520 --> 19:35.660] domains, I can set the attribute name to seed name [19:35.660 --> 19:37.520] equal to whatever the one domain that I wanted [19:37.520 --> 19:39.740] to find was. And you can scan... [19:39.740 --> 19:41.480] those filters are, like I said, very [19:42.320 --> 19:43.120] intense. [19:43.180 --> 19:45.460] You can basically filter against anything you want. [19:48.400 --> 19:49.800] So, this is the other thing. [19:49.800 --> 19:51.700] So, a lot of bug bounty hunters, especially [19:51.700 --> 19:53.620] when you're running automated recon, [19:53.620 --> 19:55.260] you want to know when new stuff shows up, right? [19:55.260 --> 19:57.840] You want to be the first one to it, all that kind of stuff. [19:58.500 --> 19:59.620] DynamoDB makes that very [19:59.620 --> 20:01.360] easy, because there's something called a DynamoDB [20:01.360 --> 20:03.760] stream that streams... [20:03.760 --> 20:05.560] it's basically an event, API, [20:05.560 --> 20:07.620] of everything that's happening to your DynamoDB. [20:07.720 --> 20:09.380] It's very easy to make a trigger [20:09.380 --> 20:11.500] and hook on, just like you see in the thing, [20:11.500 --> 20:12.640] to hook on a Lambda function [20:13.120 --> 20:15.460] to that trigger. So, anytime a new thing happens to your [20:15.460 --> 20:17.340] DynamoDB, there's a Lambda function to [20:17.340 --> 20:19.440] ingest it, and you can tell it, only ingest [20:19.440 --> 20:21.400] inserts, only ingest updates, whatever [20:21.400 --> 20:23.460] it is. So, obviously, for a new domain, [20:23.460 --> 20:25.200] it's pretty straightforward. [20:25.240 --> 20:26.560] Anytime a new insert [20:27.360 --> 20:29.880] goes into my domains table, [20:29.880 --> 20:31.240] that means there's a new domain. [20:31.760 --> 20:33.780] There's a Lambda function called NewDomainNotification [20:33.780 --> 20:35.200] that we're going to show on the screen [20:35.700 --> 20:37.580] that will basically ingest that stream's [20:37.580 --> 20:39.500] API, grab the new domain that just got [20:39.500 --> 20:41.780] added to the database, and shoot it to Slack. [20:42.540 --> 20:43.980] So, I don't use... [20:43.980 --> 20:45.420] there's not necessarily a tool for that. [20:45.420 --> 20:47.500] It's just a POST request to a Slack [20:47.500 --> 20:49.300] webhook that we're going to go over. [20:50.580 --> 20:51.540] So, this is [20:51.540 --> 20:53.160] actually some of the code. [20:53.240 --> 20:55.660] Again, I tried to make it as big as I possibly [20:55.660 --> 20:57.460] could, so it's split up into [20:57.460 --> 20:59.360] chunks. So, this [20:59.360 --> 21:00.820] is a Lambda function [21:01.580 --> 21:03.220] that actually kicks off [21:03.220 --> 21:05.560] running my recon against every [21:05.560 --> 21:08.100] domain I have in that domains table I showed you. [21:08.100 --> 21:10.100] So, all it is, is I go [21:10.100 --> 21:12.300] through the table name that I call targets. [21:12.340 --> 21:13.860] I just have one item [21:13.860 --> 21:16.340] in the database. It's just one big item. [21:17.460 --> 21:18.060] And for that [21:18.060 --> 21:20.460] item, there's a bunch of programs. [21:20.500 --> 21:22.000] So, I loop through the programs, and for [21:22.000 --> 21:24.020] every program, as we saw, we'll have that [21:24.020 --> 21:26.060] list of domains. And all [21:26.060 --> 21:28.080] I'm doing is queuing those domains [21:28.080 --> 21:29.420] up in my SQS queue [21:30.000 --> 21:31.440] to the beginning of the workflow. [21:32.900 --> 21:34.340] We'll look at this later. [21:34.340 --> 21:36.040] This one gets scheduled. [21:36.040 --> 21:37.920] So, I don't kick it off. I have it [21:37.920 --> 21:39.980] scheduled for, I think, every 10 days, I think, [21:39.980 --> 21:41.980] in the picture. So, every 10 days, [21:41.980 --> 21:44.020] this gets kicked off. It takes everything [21:44.020 --> 21:45.960] out of the programs [21:45.960 --> 21:48.240] that I'm hacking on, takes those domains, [21:48.240 --> 21:50.060] puts them into the SQS queue, and there's [21:50.060 --> 21:51.840] another event that we're going to go over [21:51.840 --> 21:53.980] that whenever something gets added to the SQS queue, it [21:53.980 --> 21:55.960] automatically kicks off workflow. So, I'm not [21:55.960 --> 21:57.400] touching it. I'm not [21:58.120 --> 22:00.280] starting and stopping it. You can if you want. [22:00.800 --> 22:02.160] But it is... [22:02.160 --> 22:04.160] it can go, basically, fully automated. [22:04.160 --> 22:06.260] This is the big lambda function that sat [22:06.260 --> 22:08.280] at the top of the workflow. This is [22:08.280 --> 22:10.040] the passive enumeration runner. [22:10.180 --> 22:12.220] So, as you can see, there's a little bit more than when we [22:12.220 --> 22:14.480] did the serverless demo. There's the handler. [22:14.480 --> 22:16.160] It's the same thing. And there's the serverless [22:16.160 --> 22:18.280] YAML. Requirements.txt. [22:18.280 --> 22:19.740] Any Python people in here? That's your [22:20.440 --> 22:22.180] requirements, right? Now, [22:22.180 --> 22:24.320] subfinder and amass are actually just binaries. [22:24.580 --> 22:26.060] Those still get packaged up in the [22:26.060 --> 22:28.140] zip file and go with it. So, all this [22:28.140 --> 22:30.140] is, it's nothing special, as much as I'd [22:30.140 --> 22:32.200] like to pretend it is, is it's just Python [22:32.200 --> 22:34.780] wrapping around tools that I want to use. [22:34.900 --> 22:36.360] That I don't want to run myself [22:36.360 --> 22:37.660] over and over. [22:38.680 --> 22:40.480] And this is the passive part. [22:40.680 --> 22:42.320] The active part looks very similar [22:42.320 --> 22:44.240] to this. Again, I don't have enough slides and enough [22:44.240 --> 22:46.300] time to go over everything, but the active part [22:46.300 --> 22:48.280] would be very similar to this. And you can break [22:48.280 --> 22:49.840] up the workload however you want. [22:53.360 --> 22:54.400] So this, again, [22:54.400 --> 22:56.420] I split it up into chunks. So this [22:56.420 --> 22:58.680] is all, this is the whole YAML file [22:59.640 --> 23:00.440] to deploy [23:00.440 --> 23:02.540] the passive enumeration runner. It's only [23:02.540 --> 23:04.460] this long. It's not, if you do this in [23:04.460 --> 23:06.760] Terraform, anybody who's done Terraform, [23:06.760 --> 23:08.480] it's a lot of lines. [23:08.480 --> 23:10.340] It's a lot of lines. [23:10.580 --> 23:12.340] And it's very readable [23:12.340 --> 23:14.600] in my opinion. So we're telling how much [23:14.600 --> 23:16.520] memory size we want, what we want the [23:16.520 --> 23:18.500] timeout to be for the lambda function, and then [23:18.500 --> 23:20.540] the same thing as before. I'm declaring a function, [23:20.540 --> 23:22.480] it's called passive enum runner, I'm pointing [23:22.480 --> 23:24.560] it to the handler, and then I guess in this one I add [23:24.640 --> 23:26.500] a name and a description. When you want to use [23:26.620 --> 23:28.680] a plugin, it's right there at the bottom. [23:29.220 --> 23:30.900] So serverless Python requirements. [23:30.900 --> 23:32.800] That's the plugin to bring Python [23:32.800 --> 23:34.840] requirements with me into the lambda. [23:38.190 --> 23:40.590] So this code is broken into chunks. [23:40.590 --> 23:42.890] So this is basically my function. [23:42.890 --> 23:44.770] From the serverless YAML that we just saw, [23:44.770 --> 23:47.110] this is the handler that it's calling. [23:47.510 --> 23:48.530] The data that it's [23:48.530 --> 23:50.630] going to ingest is from event. That stuff [23:50.630 --> 23:52.570] you see at the top is configuring the [23:52.570 --> 23:54.470] lambda. I'm adding some config, as [23:54.470 --> 23:56.570] people know who run the tools, there's some config files, API [23:56.570 --> 23:58.050] keys, you know all the secrets off. [23:58.890 --> 24:00.430] And basically I'm using Python [24:00.430 --> 24:02.510] threading to run both SubFinder and Amass at the same [24:02.510 --> 24:04.530] time. Because being that they're passive, [24:04.530 --> 24:06.470] they're pretty low memory, [24:06.470 --> 24:08.370] pretty easy to use. So it's [24:08.370 --> 24:10.310] just running Amass and SubFinder against [24:10.310 --> 24:12.230] whatever domain I give it. It's [24:12.230 --> 24:14.410] pulling the results together, and it's saving them [24:14.410 --> 24:16.370] to S3. Again, it's saving them to S3 [24:16.370 --> 24:18.590] because if I run it on Yahoo, and I pull [24:18.590 --> 24:20.510] tens of thousands or hundreds of thousands or whatever [24:20.510 --> 24:22.490] of domains, that step function [24:22.490 --> 24:24.230] that's orchestrating my workflow, [24:24.230 --> 24:26.190] as data passes in between it, [24:26.190 --> 24:28.570] you can't pass over [24:28.570 --> 24:30.630] I think it's like 5 megabytes [24:30.630 --> 24:33.030] worth of data in between steps. [24:33.490 --> 24:34.810] S3 is what you use [24:35.350 --> 24:36.610] because all of the steps [24:36.610 --> 24:38.730] will ingest directly from S3. [24:38.730 --> 24:40.610] So you can output directly to S3 and at the next [24:40.610 --> 24:42.470] step just say, yeah, grab this S3 file [24:42.470 --> 24:44.610] from the step before. And that's how [24:44.610 --> 24:46.390] you handle... and again, [24:46.390 --> 24:48.550] that definitely won't put you over the free tier. [24:48.550 --> 24:50.590] I mean, unless you are doing something very crazy, in which [24:50.590 --> 24:51.510] case, talk to me. [24:53.970 --> 24:54.690] This is... [24:54.690 --> 24:56.170] I put this on here just in case [24:56.170 --> 24:57.750] anyone's curious how [24:57.750 --> 24:59.490] I actually wrap up [24:59.950 --> 25:02.770] SubFinder in a mass in Python. It just looks like that. [25:02.810 --> 25:04.210] This is the new version of a mass [25:04.210 --> 25:06.290] too, so it changed a little bit. [25:07.450 --> 25:08.390] But it's basically [25:08.390 --> 25:10.250] like that. I'm using my config files. [25:10.250 --> 25:11.750] I'm putting in the domains. It's all [25:11.750 --> 25:14.170] very simple. It's just a wrapper. [25:14.350 --> 25:16.050] Again, there's more than this. I just [25:16.050 --> 25:18.170] don't have time. If this interests you, [25:19.010 --> 25:20.210] we can talk. [25:21.430 --> 25:22.250] So this is [25:22.250 --> 25:24.050] the notification lambda. This is the handler [25:24.050 --> 25:26.590] for the notification... sorry, the serverless.yaml [25:26.590 --> 25:28.030] for the notification lambda. [25:28.030 --> 25:29.910] Notice how it looks very similar. [25:29.990 --> 25:32.090] Once you do this like twice, it gets [25:32.090 --> 25:33.250] pretty quick. [25:35.270 --> 25:36.110] And this is [25:36.110 --> 25:38.130] the code, right? So all it [25:38.130 --> 25:40.070] is, down at the bottom [25:40.070 --> 25:42.230] is my handler function. [25:42.430 --> 25:44.110] I'm starting a message with new domains [25:44.110 --> 25:46.050] found from my [25:46.050 --> 25:47.750] records in the event. The event [25:47.750 --> 25:50.050] is basically the API data that came from [25:50.050 --> 25:52.090] the API. I'm grabbing... [25:52.650 --> 25:54.050] it's called keys. [25:54.770 --> 25:56.310] And basically all that long string [25:56.310 --> 25:57.990] there is doing that appends to the message is [25:57.990 --> 26:00.410] just appending all the new domains that were inserted. [26:00.570 --> 26:02.270] Once those are done, as long [26:02.270 --> 26:04.190] as it counts greater than zero, which means assuming [26:04.190 --> 26:06.090] there was an insert, I'm sending [26:06.250 --> 26:08.130] a message to Slack. It's a POST request. It's just [26:08.250 --> 26:09.550] a POST request to a webhook. [26:09.830 --> 26:14.060] So this is what [26:14.060 --> 26:15.800] it looks like when it works. [26:16.960 --> 26:18.120] The reason why [26:18.120 --> 26:20.040] I use step functions is because as you [26:20.040 --> 26:22.160] build it, and as you use it, [26:22.160 --> 26:23.940] it will track every run for you [26:23.940 --> 26:26.300] and it will tell you what worked, what didn't [26:26.300 --> 26:28.180] work, the input, the output, [26:28.180 --> 26:30.080] how long things ran, [26:30.080 --> 26:32.060] all that kind of stuff. So this is an example [26:32.060 --> 26:34.020] of one that worked. This was ran against [26:34.020 --> 26:36.060] Costco. So you can see the body there [26:36.660 --> 26:38.060] was the program, and then [26:38.060 --> 26:40.080] I do like three lines just to separate [26:40.080 --> 26:42.180] and then the domain that [26:42.180 --> 26:43.220] I was trying to call. [26:44.420 --> 26:46.240] As you can see, everything is green. That means [26:46.240 --> 26:48.260] it works. That's great. It doesn't always [26:48.260 --> 26:49.120] work. [26:49.120 --> 26:50.280] Right? [26:51.140 --> 26:53.320] This is what it looks like. So this was [26:53.320 --> 26:55.240] from a while ago when I was first making [26:55.240 --> 26:57.380] it. As you saw, my serverless.yaml [26:57.380 --> 26:59.160] set the timeout to 900 seconds. [26:59.220 --> 27:01.200] That's because I had it at 600 and it wasn't [27:01.200 --> 27:03.320] enough, if you can read. Right at the [27:03.320 --> 27:05.220] bottom there, it says the task timed out after 600 [27:05.220 --> 27:07.200] seconds. It tells me the error. Sometimes [27:07.200 --> 27:09.020] the error that it gives you right there [27:09.020 --> 27:10.880] isn't the best. That's okay [27:10.880 --> 27:13.220] because right under the passive enumeration [27:13.220 --> 27:15.300] title, that little text that I apologize [27:15.300 --> 27:16.840] for again, says log. [27:17.440 --> 27:18.780] That link takes you [27:18.780 --> 27:20.960] directly to the CloudWatch logs, directly [27:20.960 --> 27:22.960] for that invocation of [27:22.960 --> 27:24.760] the Lambda. Tells you exactly what [27:24.760 --> 27:26.580] happened, exactly each step. [27:26.580 --> 27:28.740] If that error [27:28.740 --> 27:31.260] doesn't give you exactly what you're looking for, [27:31.260 --> 27:33.120] there's a link directly to the CloudWatch [27:33.120 --> 27:34.820] log of directly that invocation. [27:34.820 --> 27:36.860] Which is why step functions really come [27:36.860 --> 27:38.580] in handy as you grow. [27:38.920 --> 27:40.880] Again, before I move on, this is [27:40.880 --> 27:42.380] where you will spend the money. [27:42.560 --> 27:45.000] Probably even more than Lambda. Step functions [27:45.000 --> 27:47.500] are either standard or express. [27:47.680 --> 27:48.960] Standard, you are [27:48.960 --> 27:51.460] charged by state transition. [27:51.500 --> 27:53.040] So when you saw that flow chart, every [27:53.040 --> 27:55.200] time you go to a new square, you're charged. [27:55.200 --> 27:57.140] There is a free tier, it's kind of small, [27:57.140 --> 28:01.440] and then it's like .000025 cents per state transition. [28:01.440 --> 28:03.080] But, if let's say [28:03.080 --> 28:04.960] you have a state to store a domain, for [28:04.960 --> 28:06.800] instance, and you're storing 100,000 [28:06.800 --> 28:08.960] domains, that could be 100,000 [28:08.960 --> 28:11.480] states. But, [28:11.480 --> 28:12.980] the other form [28:12.980 --> 28:14.480] of a state function [28:15.740 --> 28:17.540] is called express. [28:17.540 --> 28:19.240] That, you are not charged [28:19.240 --> 28:20.920] by state transition. [28:20.920 --> 28:22.620] You're charged similar to Lambda [28:22.620 --> 28:25.180] based on how much compute resources you use [28:25.180 --> 28:27.200] and for how long. You're not [28:27.200 --> 28:29.860] charged by state transition. [28:30.320 --> 28:31.100] The kicker [28:31.100 --> 28:33.120] to that is express will only [28:33.120 --> 28:34.140] run up to five minutes [28:34.780 --> 28:37.020] for the whole, whatever you have in an express state [28:37.020 --> 28:39.160] function. Standard will run [28:39.160 --> 28:40.260] for a year. [28:40.260 --> 28:42.060] So, if you have a very large [28:42.060 --> 28:44.020] workflow, you kind of have to go standard [28:44.020 --> 28:46.140] if it's long running. But, if I'm [28:46.140 --> 28:48.320] using a workflow to store domains [28:48.320 --> 28:50.280] 100,000 times, it should [28:50.280 --> 28:52.120] be express. I haven't broken [28:52.120 --> 28:54.180] the express free tier yet, I have [28:54.180 --> 28:55.700] broken the standard one. [28:56.320 --> 28:58.220] Right? The good [28:58.220 --> 29:00.060] thing about that is, is when you looked at my [29:00.060 --> 29:02.200] workflow, you [29:02.200 --> 29:04.320] can take the map [29:04.320 --> 29:06.080] element, which is a loop element, [29:06.080 --> 29:08.500] and inside of a looping element, [29:08.500 --> 29:10.900] people assume you're going to loop a lot. [29:11.000 --> 29:12.700] So, you're allowed to take a map element [29:12.700 --> 29:14.600] in a standard step function [29:14.600 --> 29:16.820] and make just that map element [29:16.820 --> 29:18.560] express. So, you're [29:18.560 --> 29:20.420] charged by an [29:20.420 --> 29:22.500] express state function for that [29:22.500 --> 29:24.960] loop. So, when I loop through all those domains, [29:24.960 --> 29:26.480] even though the whole workflow is a standard [29:26.480 --> 29:28.460] state function, that loop where I'm storing [29:28.460 --> 29:30.440] all my domains is charged as express. [29:30.440 --> 29:32.320] And that saves a lot of money. [29:32.360 --> 29:34.560] You can plug and play state functions into [29:34.560 --> 29:36.560] each other. One state function can call [29:36.560 --> 29:38.540] another state function, so you can embed [29:38.540 --> 29:40.720] them, and you can basically plug and play [29:40.720 --> 29:42.460] with that as you will. I like [29:42.460 --> 29:44.480] using it for this reason, but if you're trying [29:44.480 --> 29:46.460] to save money, you can [29:46.460 --> 29:48.700] ditch the state function and just have one lambda [29:48.700 --> 29:50.580] trigger another lambda, trigger another, and do its [29:50.580 --> 29:52.620] own thing. You don't have [29:52.620 --> 29:54.400] to use state functions. You just get [29:54.400 --> 29:56.480] much less visibility as you [29:56.480 --> 29:58.480] scale. But, you don't have to [29:58.480 --> 29:59.240] use it. [30:01.700 --> 30:02.580] This is [30:02.580 --> 30:04.960] now getting into how I trigger it. [30:04.960 --> 30:07.020] All of this happens in event [30:07.020 --> 30:08.980] bridge. There's an event bridge pipe [30:08.980 --> 30:11.180] that I use in this demo, [30:11.180 --> 30:13.040] and there's an event bridge schedule. [30:13.040 --> 30:15.140] Schedule is cron, pipe is [30:15.140 --> 30:16.080] basically event [30:17.520 --> 30:18.920] happens, what you see at the bottom. [30:18.920 --> 30:20.920] There's a source and a target. The source [30:20.920 --> 30:22.940] in this pipe is my SQS [30:22.940 --> 30:24.980] queue. Anytime a message gets added to [30:24.980 --> 30:26.900] the SQS queue, it triggers the pipe [30:26.900 --> 30:29.280] and the target is the step function. [30:30.000 --> 30:31.500] It's very easy. [30:31.500 --> 30:33.300] Anytime a message gets sent to the SQS [30:33.300 --> 30:35.500] queue, it will either sit in the queue [30:35.500 --> 30:37.380] if I have the max amount of [30:37.380 --> 30:39.680] concurrent step functions I have set running, [30:39.680 --> 30:41.320] and then it will trigger it when it's [30:41.320 --> 30:43.820] ready. Or, if there's none running, [30:43.820 --> 30:45.280] it will automatically [30:45.280 --> 30:47.340] kick off a step function, which will ingest the message [30:47.340 --> 30:49.460] from the SQS queue and kick off. [30:50.000 --> 30:51.360] The other one that I have [30:51.360 --> 30:53.340] in event bridge, again, is called a schedule, [30:53.340 --> 30:55.820] which is basically cron in AWS. [30:56.280 --> 30:57.340] So, I have a schedule [30:57.340 --> 30:59.400] at a rate of 10 days, and you [30:59.400 --> 31:01.240] target it at a lambda function. [31:01.240 --> 31:03.240] Like I said, that target one right next to [31:03.240 --> 31:05.500] the schedule is where you'll pick your lambda. [31:06.000 --> 31:07.320] And I pick... so every 10 [31:07.320 --> 31:09.220] days, I have a target of that full [31:09.220 --> 31:11.120] run lambda that we talked about that [31:11.120 --> 31:13.160] just goes through my targets table and [31:13.160 --> 31:15.240] posts them all to the queue, which will then trigger [31:15.240 --> 31:17.160] the pipe on the last slide and [31:17.160 --> 31:19.120] ingest it all into step functions. And that happens [31:19.120 --> 31:21.260] every 10 days automatically without touching [31:21.260 --> 31:23.180] it. You can change that, you can delete it, you can do [31:23.180 --> 31:25.040] whatever you want. You can obviously manually [31:25.040 --> 31:27.240] kick off and invoke lambdas if you want to [31:27.240 --> 31:29.220] and you don't feel comfortable doing it automatic. [31:29.220 --> 31:31.280] That is basically what [31:31.280 --> 31:33.320] it is. I will say [31:33.320 --> 31:35.220] since I'm pretty sure... [31:35.220 --> 31:36.840] So I will say before the [31:36.840 --> 31:38.920] thank you and the questions, I will say [31:38.920 --> 31:40.520] I have personally [31:41.300 --> 31:43.160] monitored a couple hundred thousand [31:43.160 --> 31:44.880] domains, because I don't do mass [31:44.880 --> 31:47.180] recon. I like to do recon on the targets that I'm [31:47.180 --> 31:48.760] hacking on at that time. [31:49.120 --> 31:51.140] I have monitored fairly [31:51.140 --> 31:53.400] continuously a couple hundred thousand domains [31:53.400 --> 31:55.380] and kept my price [31:55.380 --> 31:57.120] pretty firmly under $50 [31:58.020 --> 31:58.740] a month. [31:58.740 --> 32:01.220] So it's not crazy expensive, it does [32:01.220 --> 32:03.260] cost money, and again, it's [32:04.040 --> 32:05.240] not... if you scale [32:05.240 --> 32:07.260] it, it will scale with you and it [32:07.260 --> 32:09.160] will work very good, but [32:09.160 --> 32:10.540] you still pay for it. [32:11.360 --> 32:13.240] So yeah, that's all I have. [32:13.240 --> 32:14.640] It looks like I do have [32:14.640 --> 32:17.200] 10 or 15 minutes here for questions, because I [32:17.200 --> 32:18.800] do have to jet after, but [32:18.800 --> 32:21.080] if there's any questions, I would love [32:21.080 --> 32:22.680] to answer them. [32:22.720 --> 32:23.360] Yeah. [32:24.860 --> 32:26.420] Thank you. [32:44.540 --> 32:46.620] Yes and no. No, because [32:46.620 --> 32:48.520] the Lambda has ephemeral memory that will [32:48.520 --> 32:50.780] grow with you. Yes, because there is a [32:50.780 --> 32:52.780] limit to that, and you pay [32:52.780 --> 32:54.800] for that also, and [32:54.800 --> 32:57.000] there is a limit. It's rather [32:57.000 --> 33:00.200] large, but there is a limit. Yeah. [33:00.200 --> 33:08.510] Sure. [33:08.510 --> 33:09.890] Yes, so [33:09.890 --> 33:11.870] serverless will set up [33:11.870 --> 33:13.290] the IAM roles that go with [33:13.290 --> 33:14.570] the Lambdas automatically, [33:14.570 --> 33:16.670] and you can configure those either in the YAML [33:16.670 --> 33:18.670] or in AWS, but they do get spun [33:18.670 --> 33:20.110] up automatically. So if your [33:20.110 --> 33:22.590] handler imports [33:22.590 --> 33:24.810] the Bottles3 library [33:24.810 --> 33:26.250] and uses DynamoDB, [33:26.250 --> 33:28.630] it will spin up an IAM role for [33:28.630 --> 33:29.930] you that gives you [33:30.490 --> 33:32.870] access to DynamoDB to that Lambda. [33:36.470 --> 33:37.490] Yes. [33:38.090 --> 33:38.950] Yep. [33:39.650 --> 33:40.670] Yeah. [33:53.780 --> 33:55.480] So when I... [33:55.480 --> 33:57.400] And again, the reason why I didn't touch the active one [33:57.400 --> 33:59.140] is because it gets a little more interesting. [33:59.860 --> 34:01.480] But the active stuff, the way I [34:01.480 --> 34:03.480] approach it, is I split it [34:03.480 --> 34:05.680] into super teeny chunks that run lightning fast. [34:05.720 --> 34:07.500] So that's why I talked about domain resolution [34:07.500 --> 34:09.560] because I resolve domains one at a time [34:09.560 --> 34:11.240] and they resolve in, like, milliseconds. [34:11.480 --> 34:13.440] Because at the end of the day, it doesn't matter. [34:13.440 --> 34:15.560] It's all runtime versus memory. So it doesn't [34:15.560 --> 34:17.460] matter if I resolve a chunk of 10,000 domains [34:17.460 --> 34:19.400] at the same time or one at a time. It's all [34:19.400 --> 34:21.440] the same runtime. So [34:21.440 --> 34:23.400] the only thing that would really matter, that [34:23.400 --> 34:25.480] really matters, is hitting your database [34:26.160 --> 34:27.460] a bunch. So you can [34:27.460 --> 34:29.580] resolve a bunch and have them all catch [34:29.580 --> 34:31.480] at a step in the step function, and then [34:31.480 --> 34:33.520] as batches happen, then you can batch [34:33.520 --> 34:35.460] update databases. But for the active [34:35.460 --> 34:37.460] stuff, I break it into super teeny [34:37.460 --> 34:39.440] chunks, so I never really have to worry [34:39.440 --> 34:40.420] about a time limit. [34:42.340 --> 34:42.920] Yeah. [34:54.470 --> 34:55.790] You can do either one. [34:56.850 --> 34:57.690] Yep. Yep. [34:57.690 --> 34:59.170] You can configure it to do either one. [35:00.170 --> 35:00.850] Yeah. [35:05.250 --> 35:05.430] ... [35:06.290 --> 35:06.730] ... [35:13.570 --> 35:14.010] ... [35:15.490 --> 35:15.930] ... [35:15.930 --> 35:16.050] ... [35:16.670 --> 35:19.270] Absolutely. So serverless, the [35:19.270 --> 35:21.770] framework, supports Azure as well. [35:21.770 --> 35:23.310] And I think it's called Azure Functions. [35:23.310 --> 35:25.430] Again, I'm kind of hiding AWS. [35:25.690 --> 35:27.430] But Azure has Azure [35:27.430 --> 35:29.410] Functions, and it is, I'm sure [35:29.410 --> 35:31.270] it is very similar. It will handle it [35:31.270 --> 35:33.150] all for you and deploy it. [35:33.150 --> 35:33.530] ... [35:33.530 --> 35:35.230] Mm-hmm. [35:39.560 --> 35:40.920] So I personally [35:40.920 --> 35:43.220] talked to AWS before I gave the talk. [35:43.220 --> 35:44.780] They said as long as I'm not doing anything [35:44.780 --> 35:46.860] naughty, it's allowed. Right? [35:47.080 --> 35:48.900] Because it's just public [35:48.900 --> 35:50.900] domain. But I did have someone [35:50.900 --> 35:52.940] else from AWS tell me to [35:52.940 --> 35:54.940] watch out. So it is. And I have heard [35:54.940 --> 35:56.820] of people getting banned off the platform. So I've got [35:56.820 --> 35:58.580] I was going to say, I've gotten pretty mixed reviews [35:59.260 --> 36:00.900] from it. I haven't gotten personally [36:00.900 --> 36:02.900] in trouble yet. As well as when [36:02.900 --> 36:05.260] Lambda spin up, they run on different IPs. [36:05.260 --> 36:07.580] So I guess there's that benefit. [36:07.580 --> 36:09.400] I don't really use it for that benefit. And again, [36:09.400 --> 36:10.280] I don't [36:11.740 --> 36:13.180] use this type of recon [36:13.180 --> 36:15.200] to continually berate [36:15.200 --> 36:16.620] sites. Right? I [36:17.260 --> 36:18.820] do pretty relaxed [36:19.280 --> 36:20.540] scanning, if at all. [36:21.060 --> 36:23.180] And I don't try and update data [36:23.180 --> 36:25.300] every minute on the minute. That kind of stuff. [36:25.300 --> 36:27.220] So I feel pretty safe [36:27.220 --> 36:29.260] about that. But I mean, if you were using it like that... [36:31.140 --> 36:31.760] Yeah. [36:31.760 --> 36:33.220] You might get in trouble. [36:33.220 --> 36:34.060] Yeah. [36:35.720 --> 36:36.140] Yeah. [36:37.160 --> 36:38.040] Absolutely. [36:40.260 --> 36:41.140] Yeah. [36:45.220 --> 36:46.100] Yep. [36:49.160 --> 36:51.260] You can. It's all the same thing. [36:51.280 --> 36:52.740] I use Lambda because [36:52.740 --> 36:55.140] again, when I do active scanning, [36:55.140 --> 36:57.760] I just break it up into super tiny chunks. [36:58.400 --> 36:59.100] Fargate, [36:59.100 --> 37:00.840] literally, you can use the same thing. [37:00.840 --> 37:03.220] You would just do the same thing with step functions, but for the longer... [37:03.220 --> 37:05.020] If you want longer running [37:05.020 --> 37:06.940] jobs, you'd have to use a standard step function, [37:06.940 --> 37:08.940] so it can run for up to a year. And then you would just [37:08.940 --> 37:10.500] plug Fargate in, and it would be the same thing. [37:11.320 --> 37:12.920] Personal preference. If you want to do the exact [37:12.920 --> 37:14.900] same thing, but with Fargate, [37:14.900 --> 37:16.640] it will work almost [37:16.640 --> 37:17.440] identically. [37:19.440 --> 37:19.980] Yeah. [37:23.920 --> 37:24.880] Good question. [37:36.480 --> 37:37.440] There you go. [37:38.660 --> 37:39.460] Yeah. [37:48.080 --> 37:48.480] Yes [37:48.480 --> 37:49.800] and no. [37:50.760 --> 37:52.600] I am, like I said, I'm willing to [37:52.600 --> 37:55.040] share, and I may, [37:55.040 --> 37:56.480] if there's a lot of ask for it, I may [37:56.480 --> 37:58.800] just make it easier to put some stuff in a [37:58.800 --> 38:03.180] GitHub repo and share it. I'm not against that. [38:03.180 --> 38:04.560] Part of it, [38:04.560 --> 38:08.220] I won't, just because it's a lot. [38:08.220 --> 38:08.760] But again, [38:08.760 --> 38:10.620] if you have a question, get in touch [38:10.620 --> 38:12.080] with me over Twitter or something like that, and I can. [38:12.080 --> 38:14.000] And if there's a lot of interest, I probably will. [38:14.320 --> 38:16.580] I guess I didn't have plans for it, but it's not necessarily [38:16.580 --> 38:18.400] because I'm [38:18.820 --> 38:20.640] secretive or anything. I guess if there was interest, [38:20.640 --> 38:22.460] I wouldn't be against it, but I didn't [38:22.460 --> 38:24.220] originally have plans to, yeah. [38:26.000 --> 38:26.460] Cool. [38:26.460 --> 38:27.160] Thanks, guys.