WEBVTT

00:00.000 --> 00:01.400
Good afternoon everyone.

00:01.400 --> 00:03.040
It is 3 p.m.

00:03.040 --> 00:04.880
at DEF CON 31.

00:07.120 --> 00:09.520
Welcome to Village Talks.

00:10.140 --> 00:14.160
This next talk is presented by the Packet Hacking Village.

00:15.600 --> 00:25.880
The Packet Hacking Village talk, the whole premise is, is to give information and content that people can grasp and use immediately.

00:27.100 --> 00:39.820
This next talk that we're going to present, remember when we did the CFP for this, and it caught our attention right away.

00:40.400 --> 00:44.840
And Riverside said, we have to accept this talk.

00:45.160 --> 00:47.480
This talk looks really, really good.

00:47.480 --> 00:59.540
And it is my pleasure to introduce to you someone who I've gotten to know pretty well within the last, what, 24, 48 hours.

01:01.260 --> 01:06.100
Jared Stroud, who is a security lead at the MITRE Corporation.

01:06.580 --> 01:13.480
And one of the things is, is that I will want to let everyone know here, who here is this is your first DEF CON?

01:13.480 --> 01:15.760
Is this is your first DEF CON?

01:15.860 --> 01:17.060
Welcome.

01:17.960 --> 01:22.460
And please take advantage of your learning opportunities.

01:22.820 --> 01:27.040
But I also warn each and every one of you as well too.

01:27.040 --> 01:32.280
And Jared is, sir, gave, served as a really, really good warning.

01:32.840 --> 01:41.980
I don't know if you all know, but the tech and the secure, the tech and especially the security community is extremely small.

01:42.420 --> 01:48.040
Do you know how they say, what is that thing that they said about the uh, the six degrees of Kevin Bacon is it?

01:48.100 --> 01:49.580
Is that what it's called?

01:49.580 --> 01:51.000
Something like that?

01:51.380 --> 01:56.760
Here, if you're at DEF CON, like the degree of separation is not even six.

01:56.760 --> 01:59.460
It's like more like one or two.

01:59.460 --> 02:10.640
And it is just absolutely crazy to hear, you know, that former students and friends have while working with Jared.

02:10.860 --> 02:20.800
And it's just like absolutely and this is, and I've been at DEF CON for many, many years and this has been, it just happened each and every year when I'm here.

02:20.800 --> 02:31.020
So just to let you know is that, you know, you don't even, chances are you'll probably know who you're going to be talking to or you probably have, you know, a little bit about the person next to you.

02:31.020 --> 02:35.020
So just be careful that the degree of separation is extremely small.

02:35.060 --> 02:43.060
But nonetheless, it is my pleasure to introduce to you, Jared Stroud, who's going to talk about line pairing with malware.

02:44.040 --> 02:45.080
Take it away.

02:49.960 --> 02:50.920
Alright.

02:51.080 --> 02:54.020
Well thank you Ming and thank you Packet Hacking Village for having me.

02:54.020 --> 02:55.920
DEF CON, this is awesome.

02:56.180 --> 02:57.720
That was a really nice introduction.

02:57.720 --> 02:59.260
Hope this doesn't suck.

02:59.620 --> 03:01.660
So, how's everybody doing today?

03:02.420 --> 03:04.240
Alright, not hungover at all.

03:04.440 --> 03:05.400
Exciting.

03:05.420 --> 03:06.060
Cool.

03:06.060 --> 03:08.180
So, my name is Jared Stroud.

03:08.180 --> 03:10.200
On the internet, I am DLO Cool J.

03:10.480 --> 03:15.700
And today we're going to be talking about line pairing with malware and some fun we can have across the way.

03:16.500 --> 03:19.880
So, fun disclaimer, but since it's DEF CON, we don't read those.

03:20.560 --> 03:23.940
I am a lead security engineer at the MITRE Corporation.

03:23.940 --> 03:27.660
I'm also an adjunct lecturer at the Rochester Institute of Technology.

03:27.660 --> 03:28.580
Go Tigers.

03:28.820 --> 03:36.580
And additionally, recently I actually just was a finalist in the Sentinel 1 and VX Underground Malware Analyst Competition.

03:36.620 --> 03:39.360
And that's where a lot of the talk is going to come from.

03:39.360 --> 03:44.500
Some of the side work that I do at home in my home lab and some interesting things around malware.

03:45.040 --> 03:48.400
And additionally, after this, come swing by the contest village.

03:48.400 --> 03:50.560
I'm helping run a contest called Battle of the Bots.

03:50.560 --> 03:51.620
Also Hack Fortress.

03:51.620 --> 03:53.820
Would love to chat more later.

03:55.140 --> 03:55.660
Cool.

03:55.660 --> 03:56.600
So, why are we here?

03:56.600 --> 03:56.860
Right?

03:56.860 --> 03:58.400
And again, thank you all for coming.

03:58.400 --> 04:00.280
We're going to talk about what wine is.

04:00.280 --> 04:02.560
So, if you've never heard of wine, don't worry.

04:02.560 --> 04:06.520
But out of curiosity, how many people have heard of wine?

04:07.180 --> 04:07.860
Awesome.

04:07.860 --> 04:09.100
A lot of hands.

04:09.100 --> 04:13.540
Also out of curiosity, how many people have had issues with wine?

04:14.000 --> 04:15.760
Somehow more hands went up.

04:15.760 --> 04:17.800
I'm a little confused about that.

04:17.800 --> 04:18.800
But excellent.

04:18.800 --> 04:20.780
Hopefully I can shed some light into this.

04:20.820 --> 04:27.100
So, we're going to talk about how wine works and why we care about using wine for both offensive and defensive purposes.

04:27.260 --> 04:35.600
And my big goal is to get you to walk away with some actionable evidence today that makes sense for both, again, offensive and defensive things.

04:36.420 --> 04:37.280
Cool.

04:37.320 --> 04:44.140
So, this all got started because, again, I have a home lab that I'm super passionate about and I call that Arch Cloud Labs.

04:44.140 --> 04:46.560
I blog about silly things related to malware.

04:46.640 --> 04:59.180
Now more than ever, anyone can go and grab APT samples from a VX underground or a mal share and start digging in and doing their own reverse engineering, their own blue teamwork or red teamwork where they're trying to emulate threats.

04:59.220 --> 05:00.540
That's really cool.

05:00.540 --> 05:02.620
Never has that happened before.

05:02.620 --> 05:16.260
And along with releases like Ghidra and various other open source tools with Yara, you can really build your own blue team D4 home lab and get those skills up for whether it be like contests or employment, whatever the case may be.

05:16.860 --> 05:27.520
But something that I was running into in my home lab, if you get a big old batch of malware, going in and executing this to get those initial artifacts is a super big pain.

05:27.520 --> 05:29.120
I want DNS requests.

05:29.120 --> 05:30.940
I want outbound TCP and UDP.

05:30.940 --> 05:32.400
I want all that good data.

05:32.400 --> 05:35.820
But I don't want the overhead of actually managing that infrastructure.

05:35.940 --> 05:40.920
I don't want to have to run an ESXI cluster and then install cuckoo and manage my base images.

05:40.920 --> 05:50.200
And then after I run the malware, take snapshots, store those snapshots, and at some point I finally get the PCAP and go, okay, here's the domain that this cobalt strike beacon was calling out to.

05:50.200 --> 05:51.500
This seems like too much.

05:51.500 --> 05:52.500
This is all too much.

05:52.500 --> 05:56.260
I want initial artifacts that I can immediately start digging into.

05:57.500 --> 06:00.260
So with that, I started to take a look at wine.

06:00.320 --> 06:00.700
Right?

06:00.700 --> 06:03.720
And again, seems like a lot of people in here know wine.

06:03.720 --> 06:11.220
I'm going to take a shot in the dark and say that some people may know that from valve and steam and their fork of it called proton.

06:11.400 --> 06:17.340
But if you've never heard of wine before, wine is a recursive acronym that stands for wine is not an emulator.

06:17.380 --> 06:20.280
It does not do emulation of win 32 API calls.

06:20.280 --> 06:28.380
It does translation from whatever is happening in the windows world and DLLs and kernels and so on and so forth into the posit calls equivalent.

06:28.380 --> 06:32.360
So it's actually executing him on the underlying Linux kernel.

06:32.760 --> 06:34.160
So this is really cool.

06:34.160 --> 06:34.700
Right?

06:34.700 --> 06:42.180
So with this, it's a open source project that's labeled or that's under the GPL license and there's a couple of commercial backers.

06:42.180 --> 06:53.540
Notably valve and their proton release of that which is really just focused around some fixes of graphics drivers and more intense things to run triple A games.

06:53.560 --> 06:54.980
And then there's also code weavers.

06:54.980 --> 07:03.800
And code weavers has a tool called crossover and crossover is just trying to help you run whatever your windows software of choice is on Linux a little bit easier.

07:05.100 --> 07:13.320
That being said, the core of wine is a free open source product that is getting all of these contributions rolling in all the time.

07:13.320 --> 07:17.880
There's three different staging branches of excuse me, there's three different branches of wine.

07:17.880 --> 07:20.520
You have your staging branches where some bug fixes are coming in.

07:20.520 --> 07:21.780
It's not quite stable.

07:21.780 --> 07:24.760
You have stable and you have some release candidates as well.

07:24.760 --> 07:35.260
So this is a very active project that's constantly getting new patches submitted upstream and this example that I have on the screen here is just to show, hey, folks from valve are submitting their upstreams.

07:35.260 --> 07:41.420
Folks from crossover are submitting their upstream patches and overall that wine project keeps getting better and better over time.

07:42.220 --> 07:51.200
So with this, let's go ahead and take a look at how wine actually works underneath the hood and how we can start thinking about ways that we can use it for our workflows.

07:51.600 --> 08:04.380
So when you run wine and then whatever exe, like malware.exe or Microsoft office.exe, what's happening underneath the hood is a separate service is getting spun up, excuse me, a separate process called wine server.

08:04.380 --> 08:09.780
Wine server is going to go ahead and create a Unix socket that your main process is going to talk to it over.

08:09.780 --> 08:22.140
This wine server is then going to load its DLLs which are really just Linux shared objects that are going to do all of that translation to the underlying Linux API calls from the Windows 32 calls.

08:22.580 --> 08:29.580
As an example, up here to my right, we see the MSDN documentation for git native system info.

08:29.580 --> 08:35.240
It's going to go ahead and take in some pointer to some struct, populate that data and return it to you.

08:35.240 --> 08:44.740
And then the wine equivalent over here, you take in some struct of sys info, you start populating it as we go down the path.

08:44.740 --> 08:49.980
So all of the magic of that actual translation where that's occurring is in these DLLs.

08:49.980 --> 08:55.680
That's going to be an important thing to keep in mind that we'll circle back on later how we can use that to our advantage.

08:57.260 --> 09:00.460
So at this point we're thinking, all right, that's pretty cool.

09:00.460 --> 09:10.300
We can start seeing like you can execute maybe an interpreter shell or something like that on a Linux system and start getting those artifacts.

09:10.620 --> 09:13.820
But naturally I'm not the first person to think of this.

09:14.060 --> 09:26.840
Doing a little bit of deep dive in both the academic and open source research, the earliest document I could find was from 2005 and it was a Linux.com article talking about running Windows viruses on Linux.

09:27.080 --> 09:29.600
And this was all getting done via wine.

09:29.980 --> 09:33.340
But the overall result was, hey, this sucks.

09:33.440 --> 09:39.860
We don't have, you know, the spammers aren't spamming, the worms aren't worming, it looks like Linux wins again.

09:39.860 --> 09:42.920
And that was kind of all you saw for a pretty long time.

09:43.140 --> 09:56.790
Then, excuse me, but it does pose the question of as wine got better over time, does Windows malware pose a threat to Linux servers, right?

09:57.170 --> 10:02.310
Now, any Linux admin or Linux user over there is probably thinking right now, well, wine's not installed by default.

10:02.310 --> 10:04.230
I'm not super concerned about that.

10:04.230 --> 10:14.730
But that is a lot of the angles that academia take of, hey, can we run these Windows samples on a Linux machine if wine is installed and will the damage be equivalent?

10:15.050 --> 10:22.270
And the overall result from these papers was maybe and a lot of that came out from the samples that they were picking.

10:22.810 --> 10:25.050
And when I say samples, I'm referring to malware samples.

10:25.270 --> 10:31.150
Largely this was just an arbitrary selection of whatever malware dump the researcher had to them at the time.

10:31.290 --> 10:37.610
In a lot of situations, the malware they were executing was dependent on external services that wine did not spawn.

10:37.970 --> 10:41.290
For example, with Mimi cats, there is no LSAS process.

10:41.450 --> 10:46.350
So if you have some kind of precompiled binary that's going to try to dump from LSAS, it's immediately going to fail.

10:46.450 --> 10:49.890
That's not the fault of wine, that's just the service doesn't exist.

10:49.970 --> 10:53.230
Same thing to be said about trying to poke at an active directory server.

10:53.690 --> 10:56.710
You know, you can go from there with the other dependencies that may exist.

10:57.230 --> 11:05.150
Additionally, a lot of these academic research projects were using open source projects that wrapped wine but did not use wine directly themselves.

11:05.150 --> 11:08.550
And these open source projects were largely abandonware.

11:08.550 --> 11:13.190
A paper from 2018 was leveraging something that wasn't last updated from 2013.

11:14.030 --> 11:18.950
But I'm here to talk to you today about saying not all hope is lost.

11:18.950 --> 11:25.910
We can actually build our own execution environment with thinly wrapped wine wrappers to execute malware.

11:26.590 --> 11:30.250
So this is where my talk title actually kind of comes full circle here.

11:30.250 --> 11:32.690
This is the wine pairing with malware.

11:32.690 --> 11:41.190
We have to pick our samples appropriately to make sure that we're not going to be dependent on some kind of foreign service that isn't going to run in wine.

11:41.330 --> 11:47.430
Now, that doesn't mean you need an aged cobalt strike to pair with a newer release of wine.

11:47.430 --> 11:55.610
You can just go ahead and grab the latest version of wine off the website and execute it against the samples that you have today.

11:56.310 --> 12:09.990
Looking at the threat trends, we're seeing from a SOPHOS report released about last month, we're seeing that Meterpreter and Metasploit and its associated projects and payloads are kind of on the rise, right, to the surprise of no one.

12:09.990 --> 12:15.890
Criminal groups and APT actors alike, maybe a shell code runner's difference, but Metasploit gets used a lot .

12:15.890 --> 12:16.870
It's very scriptable.

12:16.870 --> 12:21.350
It's very easy to make to use into whatever offensive workflow you have .

12:21.970 --> 12:33.970
Looking at a 2013 report from Red Canary, they said that cobalt strike and Metasploit continue to be the most popular C2 framework with a couple of other open source and commercial vendors on the rise.

12:33.970 --> 12:37.370
Those include Brute Radle, Sliver and Mythic.

12:37.490 --> 12:40.010
But again, we're seeing the usual suspects here, right?

12:40.010 --> 12:41.670
We're not surprised at what we're seeing.

12:41.670 --> 12:46.110
We're seeing Metasploit, we're seeing cobalt strike and a handful of offensive frameworks.

12:46.270 --> 12:51.330
So with that, why grab all of these random old ransomware samples or old malware samples?

12:51.330 --> 12:56.510
Why not test what is likely going to end up at some point in the ticket queue for your SOC?

12:56.510 --> 12:58.810
And then what can you do with that information?

12:59.410 --> 13:15.770
So for my research, I picked these three frameworks largely because of their ubiquitousness in the APT and crimeware world as well as the ability to kind of make a little lab for everybody to test out afterwards with Metasploit, right?

13:15.770 --> 13:18.310
So cobalt strike, no surprise there.

13:18.310 --> 13:21.350
Human operated ransomware groups continue to use this.

13:21.350 --> 13:23.190
Same thing with APT groups.

13:23.190 --> 13:28.590
Empire is getting picked up more by APT groups and notably it has C sharp functionality.

13:28.590 --> 13:32.370
So that's a nice little twist at Metasploit because again, Metasploit.

13:34.070 --> 13:40.590
So let's go ahead and start talking about why we're using wine and not just spinning up a Windows VM to actually do this execution, right?

13:40.590 --> 13:42.810
We love Linux because of its flexibility.

13:42.810 --> 13:45.510
We want to pipe set and awk and grep our way to victory.

13:45.510 --> 13:47.090
We want to get those initial shared objects.

13:47.090 --> 13:51.750
Again, I don't want to have to instrument a whole ESXI workflow to get these artifacts.

13:51.950 --> 13:59.350
And what we're having shown here is a very, very, very simple example of instrumenting this execution with a container.

13:59.390 --> 14:10.370
I go ahead and spin up a container that simply copies my malware over, runs wine and then on the underlying host, I'm capturing that data with wire shark, a TCP dump, whatever you may have you.

14:10.370 --> 14:15.890
And then also I'm getting the rest of the host based artifacts in what's known as a wine prefix.

14:18.430 --> 14:30.710
Looking at, you know, scaling this execution, we can go ahead and actually take our container with pod man and generate the YAML to get it to execute in Kubernetes as well.

14:30.890 --> 14:41.550
So while we're doing basic example execution with just one sample, that's not to say that you can't actually scale this to handle all of the daily dump that you're getting from virus total mal share or VX underground.

14:42.310 --> 14:46.670
But I talked about a wine prefix a moment ago and we're going to dive deeper into that.

14:46.670 --> 14:53.870
Your wine prefix is effectively your C drive or a wrapper for the C drive for the underlying wine environment.

14:53.870 --> 15:03.070
Here we see DOS devices end up being your com objects, drive C is the C drive and then you have a handful of registry files that get created as well.

15:03.070 --> 15:10.090
When you're executing a malware sample with wine, you can go ahead and create a unique wine prefix per sample.

15:10.090 --> 15:19.590
Suddenly you have N number of wine prefixes for N number of samples and again you can sed, awk and grep your way for those artifacts and start looking at what's going on there.

15:20.450 --> 15:36.910
Looking at the two files that we have here of user def dot reg and user dot reg, these are the, excuse me, the difference here is that user def dot reg is the default registry keys that get created and user dot reg are the registry keys that get created after execution.

15:37.070 --> 15:44.850
So if a malware sample goes and creates registry keys and is trying to do a UAC bypass, you can easily diff these files and see the changes.

15:44.990 --> 15:49.150
That's pretty sweet compared to using red shot, taking snapshots and reverting.

15:49.150 --> 15:50.290
That's very fast.

15:50.290 --> 15:57.510
That shortens your workflow for basic samples that you may be pulling in from a virus total or what have you.

15:58.490 --> 16:16.550
Looking at this in a slightly different light, if we went ahead and got an interpreter session through wine, started executing commands and dumping data to files like we see here at 1, malware does a thing, I'm just listing the contents of a directory,

16:16.550 --> 16:22.230
we can jump down to the host machine, in that wine prefix we can grab whatever files are getting dropped.

16:22.730 --> 16:33.610
So again, that wine prefix ends up being a pretty neat thing that we can tar up and move to a file system without having to juggle VMDKs and any big virtual disk images.

16:33.610 --> 16:34.730
That's pretty neat.

16:35.550 --> 16:37.950
The same can be said about the registry.

16:38.170 --> 16:48.530
As I stated earlier, we just go ahead and can cat user.reg, pipe grep for HKCU and start looking at newly created registry keys.

16:48.530 --> 16:57.730
Up at the top here, I'm simply using a post exploitation module from Metasploit to create a run once key so on boot I will get my session restored.

16:57.750 --> 17:01.710
Nothing super crazy but a demonstration of how this could be beneficial to you.

17:03.050 --> 17:04.010
Cool.

17:04.010 --> 17:09.270
So you didn't just come here for me to tell you, hey, run wine and then evil.exe and get your IOCs.

17:09.270 --> 17:10.750
That's not why we're here.

17:10.870 --> 17:14.570
The real magic is in the DLLs as I said earlier.

17:14.750 --> 17:21.830
What you can do is effectively build your own DLLs to get loaded at run time and then start instrumenting your execution.

17:22.070 --> 17:23.450
What do I mean by that?

17:23.450 --> 17:38.530
Well, if there's specific API calls you want to capture more data on dynamically, you can go ahead and grab that data, send it to a sim, write it to a file or otherwise ingest it into your workflow to start gathering more valuable intelligence information.

17:38.930 --> 17:46.830
Additionally, wine has the equivalent of an LD preload where you can say, hey, look here for my shared objects.

17:46.830 --> 17:52.570
So you don't need to recompile wine every time you want to suddenly get say registry keys like I have on the screen.

17:52.570 --> 18:00.890
You can simply have a directory for your custom shared objects, load them when you need them to get that data and then otherwise execute wine normally.

18:01.250 --> 18:09.730
So this is super powerful especially when you start thinking about altering return values and really controlling the execution of malware as a whole.

18:10.990 --> 18:12.510
But it's not perfect.

18:13.010 --> 18:18.690
Wine again is trying its best to go ahead and provide a one to one translation for these calls.

18:18.890 --> 18:22.470
But when things go awry, you can't just say, oh, this is broken, this isn't good.

18:22.470 --> 18:25.030
You have to dig a little bit deeper and look at the source code.

18:25.130 --> 18:34.270
For example, the anti-malware scan interface at the time of this recording of this talk, if we go ahead and look, all this simply does is return, hey, there's no malware here.

18:34.270 --> 18:34.890
Everything's good.

18:34.890 --> 18:36.530
Just go ahead and execute that.

18:36.590 --> 18:43.030
So this is an example of where you need to dive deeper and understand what these return values are going to be from wine.

18:43.150 --> 18:56.990
But the neat thing about this also is that, well, if AMSI is always returning, hey, this isn't malware, maybe this is an opportunity to start looking at fuzzing targets and playing around with other Windows software that leverages AMSI, right?

18:57.130 --> 18:59.850
Could be a neat thing to explore.

19:02.130 --> 19:06.830
But for my red team focused friends, there's also hope for you as well.

19:07.030 --> 19:12.930
If we go ahead and take a look at an example offensive development life cycle up here, right?

19:12.930 --> 19:26.390
Maybe you leave DEF CON, you're on Twitter, X or Mastodon, pick your social media site and you get a new idea for some blog or some talk post and you're like, hey, this is a pretty cool thing I want to integrate into my offensive workflow and I want to start messing around with it,

19:26.390 --> 19:26.730
right?

19:26.730 --> 19:32.170
So then you start developing that POC, integrating it with whatever offensive framework you get.

19:32.170 --> 19:35.990
Then you test in your range, you test in your VM, so on and so forth.

19:36.030 --> 19:40.870
Double check all the things and you finally get to the stage where you're ready to go and use that in an engagement.

19:40.950 --> 19:43.110
All of this is a fairly long cycle, right?

19:43.110 --> 19:45.170
You don't want to get caught as a red teamer.

19:45.530 --> 19:51.910
Well, I'm here to talk to you about shortening that churn zone by having faster feedback loops, right?

19:51.930 --> 19:58.730
Don't wait until your SCP or file share, your malware sample copies over, you can kind of execute everything on one host.

19:58.730 --> 20:07.510
So that's pretty powerful when you start thinking about shell code runners or looking at making sure that your tunnels are working the way that you expect them to.

20:07.510 --> 20:16.550
Simply running line and then whatever you're building, making sure that those tunnels exist and you're getting those callbacks is a quick way to avoid issues down the road.

20:17.790 --> 20:22.890
Additionally, it allows for much easier adoption for CICD for shell code runners.

20:22.910 --> 20:36.810
If I can go ahead and not have to spin up and maintain and patch and host a Windows service or Windows machine, excuse me, I can go ahead and just leverage a docker container, run wine with my shell code runner, verify that the output said, hey, you got a shell,

20:36.810 --> 20:39.010
you got execution and go on from there.

20:39.010 --> 20:43.350
And this is how you can start adopting software engineering practices into your offensive work flow.

20:43.350 --> 20:49.970
That's super powerful when you start considering maybe you want to play around with different frameworks or seeing how other frameworks are going to integrate.

20:49.970 --> 20:53.530
There's always a new thing written in rust or whatever the framework of the day is.

20:53.530 --> 20:55.610
Last year at DEF CON NIM was the hotness.

20:55.610 --> 20:58.930
This allows for a little bit easier integration and repeatability.

21:00.810 --> 21:07.710
And then looking for my friends that are leveraging more in memory execution, talking about beacon object files.

21:07.710 --> 21:11.790
If you're unfamiliar with beacon object files, they're made popular by cobalt strike.

21:11.790 --> 21:17.310
Effectively what they are is a way to execute a payload in memory without writing to disk.

21:17.750 --> 21:19.210
However, they're tricky to write.

21:19.210 --> 21:21.530
They have a limited C API.

21:21.970 --> 21:27.750
And if something goes wrong and they crash, well, you lose your beacon because it's executing in the process of beacon.

21:27.890 --> 21:32.250
That being said, Metasploit has its own beacon object file loader.

21:32.250 --> 21:42.610
And because we can execute Metasploit generated payloads with wine, we can suddenly create a feedback loop of writing a potentially complicated or maybe it's new to you boff file.

21:42.630 --> 21:49.130
Executing that in the meterpreter session via wine and ensuring that you're getting the output that you expect.

21:49.190 --> 22:00.410
So here with my meterpreter session, I'm leveraging trusted sex cough loader and there's situational awareness boffs to go and get the ARP information of the host that I'm executing on.

22:00.930 --> 22:02.110
Pretty neat.

22:02.170 --> 22:13.210
Furthermore, you can grab all of this output through Metasploit because of its easy scriptability features, making sure that you can or excuse me, allowing you to integrate it into your CICD workflows.

22:13.910 --> 22:15.370
But again, the world isn't perfect.

22:15.370 --> 22:16.750
It does fall short, right?

22:16.750 --> 22:22.470
I'm not suggesting you go and blow away all your Windows VMs and just go, hey, wine's great, let's do that from here on out.

22:22.470 --> 22:31.870
But this does shorten that initial proof of concept phase to get to the point to go and test as close to the target host as possible.

22:32.410 --> 22:39.110
Some of the issues that I've personally found is anything in kernel land, so doing direct sys calls, that's not a great time.

22:39.290 --> 22:44.770
And again, we have some issues with everything not being one to one with our API call implementations.

22:44.770 --> 22:49.470
For example, with those AMSI returns, we're always returning, hey, this isn't malware, this isn't a problem .

22:49.550 --> 22:53.850
So taking some time to look at the code base is super important.

22:54.370 --> 22:59.130
And wine by itself does not provide any sandboxing capabilities.

22:59.130 --> 23:09.190
So you still need a dedicated machine to execute malware on and isolate it appropriately, making sure that you're not about to run something on your host machine or machine you carry about.

23:09.730 --> 23:19.310
Additionally, for the folks that are interested in this from a how do I detect or evade this, there's a lot of very key artifacts that would show that you're running in a wine environment.

23:19.310 --> 23:22.890
Such as the name being such as some of the process names being wine.

23:24.390 --> 23:29.730
Additionally, wine for this is executing x86 and 64 bit PE files.

23:29.730 --> 23:37.010
So if you have some kind of old DOS binary or something like that, that's where you're going to start looking at DOS box and your results may vary there.

23:37.150 --> 23:38.930
And again, it is an evolving project.

23:38.930 --> 23:39.850
There are bugs.

23:39.850 --> 23:42.770
So there are unknown unknowns that you may run into.

23:42.770 --> 24:01.710
But for the vast majority of malware that is getting reported on by these threat intel companies as the most commonly seen, you can easily instrument an execution environment for the situations where maybe you don't want to upload that sample to virus total or maybe you don't have a cuckoo or the equivalent execution environment locally.

24:02.590 --> 24:09.030
So with all that being said, I will have a handful of key takeaways that I want you to go away from this talk, right?

24:09.030 --> 24:16.170
Because Packet Hacking Village is very much structured around actionable talks and being able to take something from them.

24:16.610 --> 24:19.710
Wine can execute trending malware in 2023.

24:19.710 --> 24:20.870
Absolutely a fact.

24:20.870 --> 24:31.590
You can go grab some cobalt strike off the shelf mess plate or grab some cobalt off the shelf artifact from mal share and execute it to get those DNS and host artifacts.

24:31.730 --> 24:40.370
You can also build custom DLLs to instrument your execution, grab additional artifacts or maybe some neat instrumentation that you're looking to do.

24:40.570 --> 24:47.770
And then Wine can also shorten the red team testing for our friends that are looking to do proof of concept stuff related to new ideas.

24:48.410 --> 24:51.470
I really want to give a shout out to everybody coming here to watch this.

24:51.470 --> 24:52.290
This means the world to me.

24:52.290 --> 24:53.750
So thank you very much.

24:53.750 --> 24:59.290
And then if any of this was interesting or you're looking at recreating this on your own, go ahead and take a screenshot of this.

24:59.290 --> 25:06.190
The slides and then some walk through examples of leveraging pod man and docker for creating these environments and doing the execution.

25:06.190 --> 25:09.090
They're all on GitHub as of about an hour ago.

25:09.190 --> 25:10.810
So definitely check these out.

25:10.810 --> 25:12.750
Create Git issues if you run into them.

25:12.850 --> 25:15.910
And I'll be around after this talk to chat more.

25:15.910 --> 25:16.790
Thank you all so much.

25:16.790 --> 25:17.930
I really appreciate it.

25:24.550 --> 25:25.690
Thank you, Jared.

25:25.930 --> 25:28.690
I can tell you right now, I can tell you're a good teacher.

25:28.730 --> 25:29.510
I can just tell.

25:29.510 --> 25:30.930
I was watching this whole thing.

25:31.510 --> 25:37.190
Now, if anyone actually have any questions for Jared, you can feel free to use the microphone.

25:37.650 --> 25:38.190
Yeah.

25:38.190 --> 25:41.990
If anyone will have a question for Jared, you can feel free to use the mic.

25:41.990 --> 25:42.550
Feel free.

25:42.550 --> 25:42.750
Yeah.

25:42.750 --> 25:44.030
It should be open.

25:47.560 --> 25:51.620
Hey, thanks for the talk.

25:51.960 --> 25:56.800
Just wondering, in your experience, as you mentioned, it's not a new thing to run it under wine.

25:56.800 --> 26:04.000
Have you seen malware that's either looking for wine to do something benign instead of its true payload?

26:04.000 --> 26:08.520
Or have you seen things that are actually looking to actively burn it down?

26:11.490 --> 26:12.230
Hello.

26:12.230 --> 26:12.550
Okay.

26:12.550 --> 26:13.170
Great question.

26:13.170 --> 26:19.050
So the question was, have I seen any malware samples that are looking for any wine artifacts that then do something different?

26:19.050 --> 26:20.430
I have not.

26:20.450 --> 26:27.490
I think largely, you know, a lot of socks have the ability to throw data to a virus total or equivalent.

26:27.490 --> 26:34.450
But for the situation such as home lab enthusiasts or people just getting started, wine provides a pretty neat opportunity to execute those payloads.

26:37.370 --> 26:43.150
I'm quite lazy and don't like running my own instrumentation or compiling my own stuff.

26:43.150 --> 26:50.170
Would you recommend any like L trace or S trace equivalents built into wine doing the dynamic instrumentation you recommend?

26:51.570 --> 26:53.130
I think I heard you.

26:53.130 --> 26:57.970
I think you said that you're looking for any kind of L trace or S trace equivalents built into wine.

26:57.970 --> 26:58.590
Cool.

26:58.590 --> 27:05.950
So wine does have a debugger that you can use to go just like GDB or win debug that you can go forth and start poking at memory addresses to dump it.

27:06.090 --> 27:08.730
Your results may vary on the success that you have there.

27:08.750 --> 27:18.110
But also in the same vein of things, because all of those syscalls are getting translated to the POSIX equivalent syscalls, you can check out S trace.

27:18.110 --> 27:26.170
Furthermore, two years ago I actually gave a talk on leveraging S trace for Linux binary analysis at hacking village that you will also find on that GitHub.

27:26.170 --> 27:28.190
So definitely check that out.

27:31.880 --> 27:33.780
Similar vein of question.

27:33.780 --> 27:37.260
How easy is it to like compile the shared libraries?

27:39.830 --> 27:40.730
Hello?

27:40.730 --> 27:41.350
Hello?

27:41.350 --> 27:42.070
Okay.

27:42.510 --> 27:49.870
How easy is it to compile the like shared libraries for wine to like do any kind of analysis on the things you?

27:49.970 --> 27:51.470
I'm sorry, I cannot hear you.

27:51.470 --> 27:53.010
I think I'm backing away.

27:53.010 --> 27:53.690
Okay.

27:54.470 --> 28:03.750
For yeah, for the shared libraries, is it like you compile it and it's like a Linux shared library that wine then loads or?

28:03.750 --> 28:04.310
Yeah, great question.

28:04.310 --> 28:06.650
So yes, it absolutely is a Linux shared library.

28:06.930 --> 28:10.450
And then you can get it to execute or return data or whatever you want to do.

28:10.450 --> 28:11.090
Yes.

28:13.430 --> 28:14.910
Hi, thanks for the talk.

28:15.090 --> 28:18.550
So you tried it out on Metasploit and Empire.

28:18.550 --> 28:24.490
These are both pretty well supported malware.

28:24.510 --> 28:29.430
Well, malware or red team tooling project.

28:29.430 --> 28:41.330
Have you tried this out on just random samples on VX underground, for example, that are often less or those samples support less Windows versions, for example?

28:43.310 --> 28:44.610
Yes, those are great questions.

28:44.610 --> 28:47.890
The question was, tried it out on Metasploit, Empire, Cobalt Strike.

28:47.890 --> 28:52.430
Have you tried it with other samples that you just kind of grab off of VX underground?

28:52.430 --> 28:56.910
So going back to kind of the home lab story here, I pull in daily dumps from MalShare.

28:56.910 --> 29:01.870
Those MalShare samples end up largely being Cobalt Strike and Returpreter samples.

29:01.870 --> 29:04.410
So my big target base is that.

29:04.410 --> 29:14.870
I haven't tested it on all or a bunch of VX underground samples, but I have thrown in some random things that are kind of custom built and I've had success.

29:15.710 --> 29:17.190
But your results may vary.

29:17.950 --> 29:18.370
All right.

29:18.370 --> 29:18.910
Thank you.

29:18.910 --> 29:19.630
Sounds cool.

29:19.630 --> 29:20.850
I'm going to try it out.

29:23.420 --> 29:24.180
All right.

29:24.180 --> 29:30.280
So you've made a bunch of changes to the Wine source code to do various things.

29:30.280 --> 29:32.840
Have you sent anything back upstream?

29:32.860 --> 29:34.500
And if so, how did that go?

29:36.140 --> 29:37.360
Yes, that's a great question.

29:37.360 --> 29:40.160
So the question was, you've made changes to the Wine source code.

29:40.160 --> 29:41.840
Have you submitted anything back upstream?

29:41.840 --> 29:49.260
So most of the changes that I've made have been to capture specific parameters that are getting passed into, say, like a reg query to then log off to the side.

29:49.260 --> 29:53.220
So these changes don't improve the overall functionality or support of Wine.

29:53.900 --> 30:01.960
WineHQ.com has an excellent breakdown on how to submit upstream patches, how to double check their bug tracker, so on and so forth of everything related to development.

30:01.960 --> 30:04.080
And I would highly encourage you to check that out.

30:04.200 --> 30:10.800
But for the small samples, or excuse me, for the small changes that I've made, it has been nothing substantial to go forth and contribute upstream.

30:25.540 --> 30:27.160
Anyone else?

30:29.400 --> 30:32.400
If I may, then sure, if there's time.

30:32.400 --> 30:39.000
So how easy is it to make changes to Wine in such a way that it behaves like a sandbox?

30:39.000 --> 30:52.400
Because many sandboxes do not only have the functionality of being a Windows box, but also making memory dumps, taking dumps of the network traffic, stuff like that.

30:55.060 --> 30:55.760
Test.

30:55.760 --> 30:59.880
So I think the question was, how easy is it to make changes to the underlying Wine source code?

30:59.880 --> 31:00.780
Did I hear you correctly?

31:02.720 --> 31:07.660
Yeah, so either the source code or just setting up... Sure.

31:07.660 --> 31:09.640
Just all of the things.

31:09.640 --> 31:10.280
Sure, sure, sure.

31:10.280 --> 31:10.840
So cool.

31:10.840 --> 31:12.060
So like, let's run through that really quick.

31:12.060 --> 31:18.260
So one of the things in the, like, lab repo thing that I have up here is I'm leveraging Podman over Docker.

31:18.260 --> 31:24.940
And the reason for that is you can actually pause containers when you're executing containers with Podman.

31:24.940 --> 31:36.260
So with that, if we're running a malware sample in Wine in a container with Podman and I pause that execution, we can go ahead and dump that memory and start taking a look at those artifacts that may get decrypted, decompressed, so on and so forth, right?

31:36.260 --> 31:39.880
Same example for a packed or encrypted sample or region of memory.

31:40.220 --> 31:49.040
For the situation of how easy is it to capture Wireshark data, it's as easy as literally spinning up Wireshark and selecting the interface and capturing it from there.

31:49.500 --> 32:02.920
But again, and I just want to double stop this, you know, Wine doesn't provide any kind of sandboxing features, so you still need that host to make, that host hardening and sanitization process to make sure that you're not about to run malware on a host you care about.

32:07.200 --> 32:08.860
Dan Shroud, everyone.

32:08.860 --> 32:09.700
Have a drink.

