WEBVTT

00:00:01.440 --> 00:00:03.170
And now it's demo time.

00:00:03.170 --> 00:00:04.320
In this one,

00:00:04.320 --> 00:00:08.200
we'll be reviewing the Zeek package and corresponding scripts to

00:00:08.200 --> 00:00:10.850
allow us to carve files from the network stream.

00:00:11.540 --> 00:00:12.070
Then,

00:00:12.070 --> 00:00:14.960
we'll validate that the functionality is there before we

00:00:14.960 --> 00:00:17.160
move along to the next learning objective.

00:00:17.250 --> 00:00:18.350
Let's hop in.

00:00:19.540 --> 00:00:21.550
All right, and here we are in the lab.

00:00:22.040 --> 00:00:26.500
Now I'm in my Zeek box. And what we're going to use in this demo to

00:00:26.500 --> 00:00:30.270
expedite the process of file extraction and the configuration for it

00:00:30.280 --> 00:00:32.119
is we're going to use a prebuilt package.

00:00:32.119 --> 00:00:36.280
And then once we install that, we'll dive into the configs and check them out,

00:00:36.280 --> 00:00:38.260
see how we can use them in different ways.

00:00:38.270 --> 00:00:41.560
So if you remember from one of the previous modules,

00:00:41.640 --> 00:00:45.090
we were able to install packages using the ZKG,

00:00:45.100 --> 00:00:46.860
or the Zeek Package Manager.

00:00:47.140 --> 00:00:49.870
So let's do the zkg command.

00:00:49.880 --> 00:00:52.050
And the package that we're going to install is

00:00:52.050 --> 00:00:55.260
zeek/hosom/file‑extraction just like that.

00:00:56.040 --> 00:00:59.660
So now that that's installed, what we need to do is load it.

00:00:59.660 --> 00:01:03.830
We can use the zkg load command as well to go ahead and load the package,

00:01:03.830 --> 00:01:06.610
and I see that it already did after the installation.

00:01:06.610 --> 00:01:09.300
But I'm just going through this in case we ever need to go

00:01:09.300 --> 00:01:11.830
through and manually load the packages.

00:01:11.830 --> 00:01:13.050
And there we go.

00:01:13.640 --> 00:01:15.980
So now the first thing we should do is go check out the

00:01:15.980 --> 00:01:18.560
configs for this file extraction package.

00:01:19.640 --> 00:01:23.090
All right, and as you can see, we have a plugins directory here.

00:01:23.090 --> 00:01:27.640
We have a config.zeek file and a file‑extensions.zeek file.

00:01:27.640 --> 00:01:30.230
So let's check out that config.zeek first.

00:01:30.230 --> 00:01:33.970
But first, I'm going to go ahead and just jump into that directory,

00:01:33.970 --> 00:01:35.460
and there we go.

00:01:35.470 --> 00:01:38.530
All right, so let's go ahead and more config.zeek.

00:01:38.530 --> 00:01:42.070
And as you can see, it's super long.

00:01:42.080 --> 00:01:42.860
I'm just kidding.

00:01:42.870 --> 00:01:44.280
So it's not very long.

00:01:44.290 --> 00:01:44.670
Really,

00:01:44.670 --> 00:01:48.020
all it's doing is telling us which of the scripts or

00:01:48.020 --> 00:01:50.460
plugins inside of this package to load.

00:01:50.470 --> 00:01:55.760
And as you can see right here, it defaulted to just the common exploit types.

00:01:56.440 --> 00:01:59.560
So now let's go check that out and see what it actually entails.

00:02:00.140 --> 00:02:01.370
So we're going to more that one.

00:02:01.380 --> 00:02:03.650
And again, it's not very long, right?

00:02:04.140 --> 00:02:06.570
But what it's doing is it's calling additional loading

00:02:06.570 --> 00:02:09.039
directives into the Zeek instance.

00:02:09.039 --> 00:02:14.450
So we have extract‑java, extract‑pe, extract‑ms‑office, and pdf.

00:02:14.840 --> 00:02:19.040
So what this is telling me is that out of the box for this package specifically,

00:02:19.040 --> 00:02:20.290
when we load it,

00:02:20.300 --> 00:02:23.680
it's going to just extract files from these four

00:02:23.680 --> 00:02:25.980
categories or these four configurations.

00:02:25.980 --> 00:02:30.760
And we can actually jump into one of those too and see what those entail.

00:02:30.760 --> 00:02:32.330
Again, another short one.

00:02:32.340 --> 00:02:35.160
But this is because with extracting files with Zeek,

00:02:35.640 --> 00:02:38.350
the configurations can get pretty robust and complicated,

00:02:38.350 --> 00:02:40.010
but they don't have to be.

00:02:40.010 --> 00:02:45.080
So for this one, we're looking for the mean type of application/pdf.

00:02:45.080 --> 00:02:46.960
And that's it.

00:02:47.340 --> 00:02:50.150
It's going to call the file extraction hook and extract

00:02:50.150 --> 00:02:51.660
it and save it wherever we need to.

00:02:52.240 --> 00:02:55.480
Now there's another script in here that we're actually going to turn on,

00:02:55.480 --> 00:02:58.130
and that's the extract‑all file one.

00:02:58.140 --> 00:03:00.550
So let's go ahead and look at that one real quick.

00:03:00.940 --> 00:03:06.140
And really, this one's indifferent about the application type or the meme type.

00:03:06.140 --> 00:03:08.460
It's just telling us extract everything.

00:03:08.840 --> 00:03:13.330
So let's use that one to go ahead and configure Zeek for file extraction.

00:03:13.330 --> 00:03:16.090
That way we can get everything extracted instead of just

00:03:16.090 --> 00:03:18.760
certain documents or certain file types.

00:03:19.540 --> 00:03:22.520
So what I'm going to do is I'm going to go ahead and

00:03:22.520 --> 00:03:24.850
just nano the config.zeek file.

00:03:25.640 --> 00:03:28.690
I'm going to comment out the extract‑common‑exploits one,

00:03:28.690 --> 00:03:33.370
and I'm going to add a new load directive for the plugins and

00:03:33.370 --> 00:03:36.760
extract‑all‑files just like that and save it.

00:03:37.740 --> 00:03:39.900
Oh, and there's one more thing that I have to do in there.

00:03:39.900 --> 00:03:43.770
We have to define this path where the extracted files will be stored.

00:03:43.780 --> 00:03:47.000
So what I'm going to do is just place that in this extracted

00:03:47.000 --> 00:03:49.800
folder inside of my Zeek home directory,

00:03:49.810 --> 00:03:51.960
just for testing purposes in this lab.

00:03:52.340 --> 00:03:56.340
All right, let's save that, and I'm going to redeploy Zeek.

00:03:56.340 --> 00:04:01.430
Now that that's redeployed, let's jump back over to our home directory.

00:04:01.430 --> 00:04:05.690
And as you can see, we have this extracted folder here.

00:04:05.690 --> 00:04:07.880
So let's hop into there.

00:04:07.880 --> 00:04:11.560
And as you can see, we're already starting to get files.

00:04:11.940 --> 00:04:14.460
We have this SSL user‑cert file here.

00:04:14.840 --> 00:04:19.160
But let's really test it and see if it's working properly for us.

00:04:20.040 --> 00:04:22.350
What I'm going to do now is pull up Cyberduck.

00:04:22.740 --> 00:04:27.810
I'm going to use that to pull a file from my FTP server on the Zeek

00:04:27.810 --> 00:04:32.180
network and drag it into a folder on my current desktop just to

00:04:32.180 --> 00:04:34.790
replicate a file being transferred somehow.

00:04:34.800 --> 00:04:36.760
And I'm using FTP just to show it.

00:04:37.940 --> 00:04:42.050
Let's go ahead and do something like the FileZilla EXE file.

00:04:43.040 --> 00:04:44.150
So that's transferred.

00:04:44.740 --> 00:04:48.320
Let's hop back over into Zeek and see what's here.

00:04:48.320 --> 00:04:51.360
And it looks like that EXE file didn't want to be extracted.

00:04:51.360 --> 00:04:52.660
So let's try a different one.

00:04:53.240 --> 00:04:57.330
Let's try the module 2 slides from my Writing Zeek Rules and Scripts course.

00:04:57.330 --> 00:04:58.060
How about that one?

00:05:06.340 --> 00:05:08.940
And Zeek doesn't seem to be wanting to extract my files,

00:05:08.940 --> 00:05:13.870
so trying to investigate it.

00:05:13.870 --> 00:05:19.750
And after some troubleshooting, I was having network interface problems.

00:05:19.750 --> 00:05:23.250
And just to give you a little insight into what the issue was,

00:05:23.640 --> 00:05:25.650
when you go look at the current log for files,

00:05:26.240 --> 00:05:28.770
it tells you if you're missing any bytes.

00:05:28.770 --> 00:05:31.960
And if you are, it's not going to be able to extract the entire file.

00:05:32.340 --> 00:05:34.910
And so my NIC was oversaturated,

00:05:34.910 --> 00:05:39.420
and it wasn't able to capture all of the packets as it was sniffing the network.

00:05:39.420 --> 00:05:41.990
So we had missing bytes in the files section,

00:05:41.990 --> 00:05:45.960
so we were unable to actually extract the entire file.

00:05:45.960 --> 00:05:50.620
Now that that's fixed, let's try to make that work with a text file real quick.

00:05:50.620 --> 00:05:55.530
Before we do though, I'm going to go ahead and clear out this extracted folder,

00:05:55.540 --> 00:05:58.720
remove everything, and then allow us to do the transfer.

00:05:58.720 --> 00:06:01.460
So let's test it with this helloworld.txt file.

00:06:02.440 --> 00:06:08.120
All right, that transferred in, and we have two different FTP docs here.

00:06:08.130 --> 00:06:13.090
This first one is the actual file, Hello World. And then the second one,

00:06:13.100 --> 00:06:15.740
it has the listing of all the files that are available

00:06:15.750 --> 00:06:18.060
that we saw in Cyberduck right here.

00:06:19.340 --> 00:06:23.150
Now if we wanted to open that file ourselves and test it out,

00:06:23.150 --> 00:06:26.630
we can see that it's 12 bytes just like it matches up in the

00:06:26.640 --> 00:06:29.750
FTP server as well. And we can open it up,

00:06:30.340 --> 00:06:35.650
download it. When it pulls up, you can see that it's just that helloworld.txt.

00:06:36.840 --> 00:06:40.020
So here, we were able to validate that we were able to

00:06:40.030 --> 00:06:42.400
extract files from the network stream,

00:06:42.410 --> 00:06:46.650
validate that they were extracted, and validate the file itself was intact.
