WEBVTT

00:00:00.000 --> 00:00:01.560
To make sure that you're able to have a really good

00:00:01.560 --> 00:00:03.840
conversation with your malware author, you also need to

00:00:03.840 --> 00:00:05.200
make sure that malware runs properly.

00:00:05.200 --> 00:00:07.400
We talked about simulating the network. Right. How do

00:00:07.400 --> 00:00:09.870
we‑‑‑we're on a virtual machine. Yes,

00:00:09.870 --> 00:00:12.390
some malware is kind of getting over the fact that it's

00:00:12.390 --> 00:00:13.650
going to be on a virtual machine,

00:00:13.650 --> 00:00:17.240
but some malware still does care. Correct. And so how do we

00:00:17.250 --> 00:00:20.310
make that virtual machine hide and look like a real machine?

00:00:20.310 --> 00:00:21.500
Are there techniques for that?

00:00:21.500 --> 00:00:23.950
So there are a number of ways that we can do this.

00:00:24.510 --> 00:00:26.940
Remember that the virtual machine software, there's no way that it

00:00:29.260 --> 00:00:33.560
can completely look like a piece of hardware. However, there're

00:00:33.560 --> 00:00:36.670
some changes that we can do to the virtual machine software itself

00:00:36.680 --> 00:00:37.720
to make it look more real.

00:00:38.920 --> 00:00:41.350
We'll talk about some ways that we can do it within the OS,

00:00:41.350 --> 00:00:44.480
but right now we're just going to talk about how we can change VMware itself

00:00:44.480 --> 00:00:49.820
to look more real and not look like like VMware. Now understand there's no

00:00:49.820 --> 00:00:52.170
way that we're going to get through everything, we're going to be able to

00:00:52.170 --> 00:00:55.940
hide from everything, but we can at least do some things to change this

00:00:56.990 --> 00:01:02.150
initially. So we can kind of look to see how our changes are affecting the

00:01:02.160 --> 00:01:04.813
operating system, we can go ahead and run a tool called Pafish, and this tool

00:01:06.860 --> 00:01:10.180
kind of goes through all of the different checks that malware does in order

00:01:10.180 --> 00:01:13.530
to see if it's on a VM and tells us what it detects it and what it doesn't.

00:01:13.530 --> 00:01:16.760
So what I'm going to do is I'm going to run Pafish, and we'll run it once,

00:01:16.760 --> 00:01:18.710
and we're going to see all the stuff that it detects,

00:01:18.720 --> 00:01:20.210
and then we're going to make our changes,

00:01:20.210 --> 00:01:22.570
and then we'll run it again, and we'll see the difference

00:01:22.570 --> 00:01:25.670
between the two. And the same people who make Pafish aren't

00:01:25.670 --> 00:01:26.840
the same people who make the malware,

00:01:26.840 --> 00:01:29.010
right? No. So it's not false sense of security.

00:01:29.220 --> 00:01:32.650
No, Pafish is an open source tool, so you can actually go in,

00:01:32.650 --> 00:01:34.070
you can see how it's doing these checks.

00:01:34.140 --> 00:01:36.520
You could see exactly what it's doing. If you didn't trust

00:01:36.520 --> 00:01:38.120
the executable that you can download,

00:01:38.120 --> 00:01:40.330
you can actually go in and compile it yourself.

00:01:40.540 --> 00:01:42.340
So it is a safe piece of software.

00:01:42.340 --> 00:01:44.580
It's not malware. It's just using the same checks.

00:01:44.680 --> 00:01:48.080
That being said, your antivirus is probably going to detect this.

00:01:48.100 --> 00:01:50.540
That makes sense because it is using those those checks. But,

00:01:51.430 --> 00:01:53.820
again, this is why we're executing it in a virtual machine.

00:01:53.830 --> 00:01:54.450
Absolutely.

00:01:54.530 --> 00:01:55.650
All right, let's check this out.

00:01:56.080 --> 00:02:00.579
So what I'm going to do is it's a command line tool, so

00:02:00.580 --> 00:02:02.850
I'm going to open up a command line,

00:02:04.140 --> 00:02:07.080
and I am going to run as administrator just so I give it all of the

00:02:07.090 --> 00:02:09.680
privileges that it needs to run within an environment.

00:02:09.680 --> 00:02:16.530
I always run everything as an administrator. Exactly. So, here I've got my tool.

00:02:19.020 --> 00:02:22.080
It's just pafish.exe. I've got an old log file in there.

00:02:22.080 --> 00:02:24.060
I'm just going to delete that. It'll create a new one.

00:02:24.070 --> 00:02:25.970
And then I'm going to run Pafish.

00:02:25.970 --> 00:02:27.980
You don't have to give it any parameters or anything like that.

00:02:27.980 --> 00:02:30.150
You just go ahead and run it. It is a command line tool.

00:02:30.490 --> 00:02:32.050
It's a command line tool. And you can see it's already going through,

00:02:32.050 --> 00:02:34.940
and it's doing some detections. It's looking for, Is there a debugger?

00:02:34.940 --> 00:02:36.650
I don't a debugger running, so we're good.

00:02:36.770 --> 00:02:41.070
But then it does this checking the difference between CPU timestamps.

00:02:41.140 --> 00:02:41.860
And it found it.

00:02:41.870 --> 00:02:43.610
You could see that it went through.

00:02:43.760 --> 00:02:45.080
I'll scroll back up a little bit.

00:02:45.190 --> 00:02:46.460
You can see that,

00:02:46.470 --> 00:02:49.370
while we do have a bunch of things that it did not find that

00:02:49.370 --> 00:02:53.200
we're okay on, it did find a number of ways that it could

00:02:53.200 --> 00:02:55.670
detect that we're in a virtual machine.

00:02:55.980 --> 00:02:56.130
Yeah,

00:02:56.130 --> 00:02:58.265
that's interesting. So I know VMware and a type‑2 hypervisor in

00:02:58.265 --> 00:03:04.210
general use CPU queuing, they share the time of the CPU.

00:03:04.210 --> 00:03:07.720
So it's using those timestamps to understand that the usage time for the

00:03:07.720 --> 00:03:10.730
host versus the usage time for the virtual machine? Yeah,

00:03:10.740 --> 00:03:11.500
well,

00:03:11.500 --> 00:03:14.235
I I think in here what it's doing is it's going through,

00:03:14.235 --> 00:03:17.860
it's taking a snapshot of the time,

00:03:18.020 --> 00:03:20.060
running through some instructions and taking a second

00:03:20.060 --> 00:03:21.810
snapshot and kind of comparing those two.

00:03:21.900 --> 00:03:24.910
And it kind of knows how much time should have

00:03:24.920 --> 00:03:26.380
elapsed between those two time periods.

00:03:26.540 --> 00:03:29.780
And if it doesn't match up, then it knows that it's either

00:03:29.780 --> 00:03:31.950
being analyzed or it's in a virtual machine.

00:03:31.950 --> 00:03:35.610
And this is actually a very common technique that malware does in order

00:03:35.620 --> 00:03:39.360
to kind of detect if it's being analyzed or not. That's really smart

00:03:39.360 --> 00:03:43.042
because the host is going to use up some of the CPU ticks. That's just

00:03:43.042 --> 00:03:43.400
the way it is. Exactly. That's great.

00:03:43.550 --> 00:03:45.010
So we've run this.

00:03:45.010 --> 00:03:49.370
What we're going to do here is we're going to modify VMware itself.

00:03:49.540 --> 00:03:51.089
In order to do that, we need to shut down our VM.

00:03:51.350 --> 00:03:55.100
So I'm going to shut down my VM because VMware does not like it if

00:03:55.100 --> 00:03:59.710
you make changes to the VM itself while the VM's running. So I'm

00:03:59.710 --> 00:04:02.510
going to shut this down. It should only take a second. And then

00:04:02.510 --> 00:04:03.850
while it's shutting down,

00:04:05.210 --> 00:04:08.560
I'm actually going to close VMware out just so I don't have anything running

00:04:08.560 --> 00:04:13.530
and just in case that the virtual machine needs to do anything. And what I'm

00:04:13.530 --> 00:04:17.899
going to do here is I'm going into my virtual machines. Again, we're using a

00:04:17.899 --> 00:04:21.300
Windows 10 virtual machine, and what I want to do is I want to go to the

00:04:21.310 --> 00:04:27.380
VMware VMX file. The VMX file is the configuration file for the entire

00:04:27.380 --> 00:04:28.350
virtual machine.

00:04:28.880 --> 00:04:30.030
Now this is just a text file.

00:04:30.040 --> 00:04:32.140
If you would go and double‑click right here,

00:04:32.340 --> 00:04:34.660
it would actually launch VMware, and we don't want that.

00:04:34.660 --> 00:04:35.850
So I'm going to right‑click on it.

00:04:37.040 --> 00:04:45.230
And then I am just going to open it with Notepad++. And you can see

00:04:45.770 --> 00:04:47.850
here, we can kind of scroll through everything, you can see that it

00:04:47.850 --> 00:04:50.510
has a bunch of configuration options.

00:04:50.750 --> 00:04:54.900
So it kind of looks like options that you can get to in the

00:04:54.900 --> 00:04:56.660
options for the properties from the VM.

00:04:56.980 --> 00:04:58.100
Yeah, absolutely.

00:04:58.230 --> 00:05:02.539
A lot of these options you can actually get to within the GUI of the VM of

00:05:02.539 --> 00:05:07.180
VMware. We'll actually go in and modify one more setting within the GUI just

00:05:07.180 --> 00:05:09.830
because it's a little bit easier and there're some back‑end checks that it

00:05:09.830 --> 00:05:13.090
does. If we would modify it in here, it might not work right.

00:05:13.630 --> 00:05:16.250
But what we're going to do is we have our VMX file here.

00:05:16.980 --> 00:05:21.020
I am going to take these settings, and we'll make the settings available.

00:05:21.050 --> 00:05:24.990
These are settings that are going to modify our VM a little bit.

00:05:24.990 --> 00:05:27.910
It's going to modify the underlying way that VMware

00:05:28.310 --> 00:05:30.090
kind of virtualizes the environment.

00:05:30.280 --> 00:05:34.070
And these settings are going to allow us to bypass some of those checks.

00:05:34.830 --> 00:05:36.450
All I'm going to do... You're saying we're going to put

00:05:36.450 --> 00:05:38.030
these in the demo content for the course?

00:05:38.030 --> 00:05:38.920
Yes, absolutely.

00:05:38.950 --> 00:05:40.660
Great. So all I'm doing is I'm copying these.

00:05:40.860 --> 00:05:44.550
I'm going to paste them into our VMX file and then save it.

00:05:45.800 --> 00:05:49.310
So this is just in addition to what is already existing inside the VMX file?

00:05:49.420 --> 00:05:50.650
Yes, absolutely.

00:05:51.340 --> 00:05:55.500
So I'm going to close that out. And just to show you what happens

00:05:55.500 --> 00:05:58.150
when you double‑click on it, we've already saved our VMX file,

00:05:58.400 --> 00:05:59.650
I'm going to double‑click on this.

00:06:01.540 --> 00:06:04.970
And it should open it up in VMware. So, great, this is where we want to go.

00:06:04.970 --> 00:06:08.130
I'm not going to launch it yet because we want to do one more setting. So

00:06:08.130 --> 00:06:10.390
I'm going to go up into the Virtual Machine Settings.

00:06:11.330 --> 00:06:15.250
Click Edit. Then I'm going to go down to the Network Adapter.

00:06:16.090 --> 00:06:18.360
What we want to do is we want to change the MAC address

00:06:18.360 --> 00:06:20.540
of our network adapter. Oh good, I was going to ask you

00:06:20.550 --> 00:06:21.520
about the MAC address. Right,

00:06:21.530 --> 00:06:27.055
because VMware, it has its own prefix for MACs, and malware know

00:06:27.092 --> 00:06:30.400
this, so it knows that all it needs to do is check the MAC address

00:06:30.410 --> 00:06:33.270
of the network interface of what it's on.

00:06:33.340 --> 00:06:36.400
And if it's one of these MAC addresses assigned to VMware, then it knows

00:06:36.400 --> 00:06:38.550
that it's in VMware. So we're going to change that.

00:06:39.120 --> 00:06:41.270
So all I do is I go into the Network Settings.

00:06:41.270 --> 00:06:42.310
I click Advanced,

00:06:42.370 --> 00:06:45.890
and then down here with the MAC address, now you can click Generate and it's

00:06:45.890 --> 00:06:48.760
going to generate a new one. But it's got the same prefix.

00:06:48.770 --> 00:06:50.040
Yeah, it's going to have the same prefix.

00:06:50.040 --> 00:06:51.050
So all I'm going to do here,

00:06:51.050 --> 00:06:56.839
honestly, is I'm just going to change this 00 to, I'll say, 05.

00:06:56.839 --> 00:06:59.190
That's probably assigned to something else.

00:06:59.290 --> 00:07:01.490
But for our purposes because we're in a virtual network,

00:07:01.500 --> 00:07:06.620
it doesn't matter. We're good as long as we somehow don't happen to choose

00:07:06.620 --> 00:07:09.460
the same NIC as something else on our virtual network,

00:07:09.470 --> 00:07:13.170
which the odds of that are pretty small, we should be okay.

00:07:13.180 --> 00:07:16.820
Is there any benefit to choosing something that matches a specific

00:07:16.820 --> 00:07:20.520
type of hardware? There is. If you want to simulate a specific

00:07:20.520 --> 00:07:23.230
type of hardware, then you would have to go in and research what

00:07:23.230 --> 00:07:23.970
type of hardware that was.

00:07:24.530 --> 00:07:27.510
I've never seen any malware that would actually go that in‑depth to see

00:07:27.980 --> 00:07:31.770
if the MAC address kind of matches to what it's on. That would be pretty

00:07:31.770 --> 00:07:34.379
advanced to do. I guess an attacker could do that. There are some ideas

00:07:34.379 --> 00:07:39.020
for you attackers. Exactly. But for our purposes, this should be okay.

00:07:39.020 --> 00:07:44.000
So, hopefully, if I click OK, it'll work. See, so, this is what I was

00:07:44.000 --> 00:07:46.220
talking about, the back‑end checks that VMware does. Apparently, in MAC

00:07:47.280 --> 00:07:50.180
addresses, the first byte can't be odd. Because I changed it to an odd

00:07:50.750 --> 00:07:53.270
number, if I would have changed that in the configuration file,

00:07:53.280 --> 00:07:56.150
it wouldn't have done this check, and my VM wouldn't have been able to launch.

00:07:56.240 --> 00:07:58.920
It's like this is a weird hacker trick that I get to know

00:07:58.920 --> 00:08:02.340
now. I'll know the answer to this 10 years later is that

00:08:02.340 --> 00:08:03.300
it can't be an odd number.

00:08:03.310 --> 00:08:04.740
So when you do hacker Jeopardy,

00:08:04.850 --> 00:08:07.659
I know what to do. So I'm going to change that from a 5 to a 4,

00:08:07.660 --> 00:08:10.050
and hopefully this will work now. We're good.

00:08:10.560 --> 00:08:14.060
I'm going to click OK. And then I'm going to power on our machine.

00:08:14.900 --> 00:08:17.390
Now the thing that I want to say too while our machine is coming

00:08:17.390 --> 00:08:20.000
up, all these changes that we made, we made to the underlying

00:08:20.010 --> 00:08:22.920
hardware of the way that VMware works.

00:08:23.120 --> 00:08:26.550
Making these changes can make your virtual machine unstable.

00:08:26.560 --> 00:08:31.780
These are undocumented changes that VMware doesn't necessarily support.

00:08:32.039 --> 00:08:35.780
So understand any of these changes could end up blue screening your

00:08:35.780 --> 00:08:40.340
system or crashing VMware. So your mileage may vary as to if these

00:08:40.750 --> 00:08:42.570
work. But as we'll see in a second,

00:08:42.690 --> 00:08:46.220
these are going to allow you to kind of hide from some of these checks.

00:08:46.320 --> 00:08:46.750
Awesome.

00:08:46.760 --> 00:08:50.980
Are there any particular changes that you made that you want to call out? I see

00:08:50.980 --> 00:08:54.830
one of them is the IBM Corporation asset tag for the bios.

00:08:55.500 --> 00:08:58.120
Yeah, so a lot of the bios tags,

00:08:58.120 --> 00:09:01.902
or even actually a lot of places within the virtual machines software and

00:09:01.902 --> 00:09:06.912
VMware, it actually says that the company name is VMware. So what some of

00:09:06.912 --> 00:09:10.830
these changes do is they go in and they modify it from saying VMware to

00:09:11.245 --> 00:09:14.815
IBM. You can modify that to Dell or or any other thing that you want. You

00:09:14.815 --> 00:09:15.650
can make up your own name.

00:09:15.650 --> 00:09:20.250
As long as it doesn't say VMware, you should be good. It's just string matching.

00:09:20.880 --> 00:09:21.770
Exactly.

00:09:22.020 --> 00:09:25.690
We're just going to log back into our virtual machine here, and

00:09:25.690 --> 00:09:28.800
notice that my user name is John. It's not my name,

00:09:28.910 --> 00:09:33.130
and it's not sandbox. Don't name your virtual machine sandbox.

00:09:33.130 --> 00:09:37.260
Don't name your username sandbox. Surprisingly, there are

00:09:37.270 --> 00:09:41.660
commercial sandboxes that do this. But don't make it look

00:09:41.660 --> 00:09:43.270
like you're actually analyzing it.

00:09:43.640 --> 00:09:45.660
Because then when you get in a chat with your malware author,

00:09:45.660 --> 00:09:46.640
they might make fun of you.

00:09:46.830 --> 00:09:48.950
They might, and they're not nice.

00:09:50.120 --> 00:09:52.970
So what I'm going to do here just so we can kind of see all this

00:09:53.380 --> 00:09:55.579
is I'm going to go into Pafish, the directory where we have

00:09:55.579 --> 00:09:58.730
Pafish running, and the log files here,

00:09:58.730 --> 00:10:00.730
and I just want to save this log file off so it doesn't get

00:10:00.730 --> 00:10:03.640
overwritten, so we can kind of do a comparison.

00:10:03.720 --> 00:10:05.200
Okay, so that's the before log.

00:10:05.210 --> 00:10:06.099
Yeah, this is the before,

00:10:06.100 --> 00:10:12.230
so I'll just call this pafish_before. Close enough. And then, again,

00:10:12.240 --> 00:10:14.350
I'm going to rerun Pafish.

00:10:16.640 --> 00:10:18.700
So I'm opening up my command prompt as an

00:10:18.700 --> 00:10:24.660
administrator, going into the Pafish directory,

00:10:26.870 --> 00:10:27.620
and I'm ready to run.

00:10:27.620 --> 00:10:29.350
So I'm going to run it again. And, remember,

00:10:29.350 --> 00:10:31.360
and we'll do a comparison after we run this, but, remember,

00:10:31.360 --> 00:10:32.840
we saw a whole bunch of checks.

00:10:32.840 --> 00:10:36.010
We saw a whole bunch of those red traced things.

00:10:36.150 --> 00:10:42.430
So as we run this now, we should see less. Less red is usually good. More green,

00:10:42.430 --> 00:10:43.050
less red.

00:10:43.150 --> 00:10:45.660
All right. So it's running, and you can even see right

00:10:45.660 --> 00:10:48.530
away that the one you called up before, the timestamp

00:10:48.530 --> 00:10:50.100
check, we've already bypassed that.

00:10:50.110 --> 00:10:56.000
Now it does a different timestamp check, which is still traced.

00:10:56.320 --> 00:10:59.760
Remember, I said we're not going to be able to bypass everything,

00:11:00.020 --> 00:11:04.255
but there is definitely much less red than there was

00:11:04.255 --> 00:11:06.770
before. Absolutely. I'm actually super impressed that we

00:11:06.770 --> 00:11:11.680
bypassed the time check. In fact, if we go in here,

00:11:11.680 --> 00:11:16.280
I'm going to open up the before.

00:11:20.240 --> 00:11:23.860
Here's our before log, and you can see the different places that it

00:11:23.860 --> 00:11:26.820
checked it, traced using mouse activity. At the very top,

00:11:26.820 --> 00:11:29.300
we have our timestamp counters.

00:11:29.310 --> 00:11:36.970
Let me open up the new log, and we'll kind of compare the two.

00:11:42.370 --> 00:11:45.590
And you can see the one on the left is our before, the one on the right is

00:11:45.590 --> 00:11:49.260
our after. And the one on the right, we made these checks.

00:11:49.260 --> 00:11:53.610
It still detected something, but it's definitely much less than our before.

00:11:53.620 --> 00:11:58.000
So the changes we made did go in and hide our VM from the malware

00:11:58.450 --> 00:12:00.570
checks. With the ones that that it is checking,

00:12:00.580 --> 00:12:03.540
we could go in, and we could do some analysis and research and

00:12:03.540 --> 00:12:05.150
figure out how we can hide from those as well.

00:12:06.100 --> 00:12:07.540
And I'm sure that there are other things that we can

00:12:07.540 --> 00:12:10.770
go in, modifying the registry, making some of those changes.

00:12:10.770 --> 00:12:14.650
Maybe there're other configuration changes that we can make to hide from these.

00:12:15.280 --> 00:12:18.750
But for the most part, I would say we're doing pretty good.

00:12:18.840 --> 00:12:19.520
Yeah, absolutely.

00:12:19.520 --> 00:12:22.140
Like even just taking a quick look now, I can see that mouse activity, I'm

00:12:22.140 --> 00:12:24.250
sure there're ways we can, have you heard of Sikuli?

00:12:25.570 --> 00:12:29.510
Yes. So you can use Sikuli to simulate user input and stuff as scripted.

00:12:29.840 --> 00:12:30.490
Absolutely.

00:12:30.490 --> 00:12:32.960
And then there's a reg key for SCSI.

00:12:32.970 --> 00:12:34.710
I guess we're using SCSI as the hard drive,

00:12:34.720 --> 00:12:37.690
but we can simply change the ID or something like that. Exactly.

00:12:37.690 --> 00:12:38.900
And then go right here.

00:12:38.900 --> 00:12:45.400
It's calling out a registry key, which is probably going to have VMware in it.

00:12:45.400 --> 00:12:49.020
We could just go to that registry key and rename it and then bypass it. Yeah,

00:12:49.020 --> 00:12:49.560
that's great.
