1
1

00:00:00,150  -->  00:00:02,310
<v Instructor>Malware exploitation.</v>
2

2

00:00:02,310  -->  00:00:03,930
In this lesson, we're going to talk
3

3

00:00:03,930  -->  00:00:06,360
about malware exploitation techniques,
4

4

00:00:06,360  -->  00:00:10,020
and so we have to first define what is an exploit technique?
5

5

00:00:10,020  -->  00:00:12,900
Well, an exploit technique describes the specific method
6

6

00:00:12,900  -->  00:00:16,230
by which malware code infects a targeted host.
7

7

00:00:16,230  -->  00:00:19,230
Now, there is lots of different ways that this can be done.
8

8

00:00:19,230  -->  00:00:21,870
In the old days, we used to have malware that would go
9

9

00:00:21,870  -->  00:00:23,670
and rewrite or modify the code
10

10

00:00:23,670  -->  00:00:27,390
within an executable or a macro file on a target disk.
11

11

00:00:27,390  -->  00:00:30,510
That way, whenever that file was run, the virus was loaded,
12

12

00:00:30,510  -->  00:00:34,230
it could execute its payload and go out and do bad things.
13

13

00:00:34,230  -->  00:00:35,430
Now, if you had worm malware,
14

14

00:00:35,430  -->  00:00:38,370
it would actually go out and try to infect only the memory,
15

15

00:00:38,370  -->  00:00:39,750
and then go through a process
16

16

00:00:39,750  -->  00:00:41,430
of going through remote procedure calls
17

17

00:00:41,430  -->  00:00:43,620
over the network, trying to infect as many other hosts
18

18

00:00:43,620  -->  00:00:44,850
as it could.
19

19

00:00:44,850  -->  00:00:46,680
Now, modern malware, on the other hand though,
20

20

00:00:46,680  -->  00:00:49,380
uses fileless techniques to avoid detection
21

21

00:00:49,380  -->  00:00:50,970
by signature-based security systems
22

22

00:00:50,970  -->  00:00:54,690
like antivirus and host-based intrusion detection systems.
23

23

00:00:54,690  -->  00:00:55,800
By being fileless,
24

24

00:00:55,800  -->  00:00:59,460
this means that the malware is executed directly as a script
25

25

00:00:59,460  -->  00:01:02,460
or a small piece of shell code that creates a process
26

26

00:01:02,460  -->  00:01:04,470
in the system memory without having to use
27

27

00:01:04,470  -->  00:01:06,120
the local file system.
28

28

00:01:06,120  -->  00:01:08,040
Now, some of these things will actually get installed
29

29

00:01:08,040  -->  00:01:10,440
to a temporary directory first, and then be run,
30

30

00:01:10,440  -->  00:01:11,910
and then they'll delete themselves.
31

31

00:01:11,910  -->  00:01:14,400
But we'll still consider those relatively fileless
32

32

00:01:14,400  -->  00:01:16,500
because there's not a lot of evidence on the drive
33

33

00:01:16,500  -->  00:01:18,060
for people to find you.
34

34

00:01:18,060  -->  00:01:20,700
Now, this is one of the things that a lot of APTs will use,
35

35

00:01:20,700  -->  00:01:23,790
and so we have to ask the question is how does an APT
36

36

00:01:23,790  -->  00:01:26,190
use this modern malware to operate?
37

37

00:01:26,190  -->  00:01:29,340
Well, first, it's going to use a dropper or a downloader.
38

38

00:01:29,340  -->  00:01:32,400
The first step is the malware has to get on your computer,
39

39

00:01:32,400  -->  00:01:34,410
and it's going to do that in a fileless manner.
40

40

00:01:34,410  -->  00:01:35,370
And the way they're going to do this
41

41

00:01:35,370  -->  00:01:38,460
is by running lightweight shell code on your system.
42

42

00:01:38,460  -->  00:01:40,770
By doing this, this becomes what we call a dropper
43

43

00:01:40,770  -->  00:01:42,180
or a stage one dropper,
44

44

00:01:42,180  -->  00:01:44,820
and it's then going to go out and download the rest
45

45

00:01:44,820  -->  00:01:45,720
of the code.
46

46

00:01:45,720  -->  00:01:47,820
And so that dropper is just a very small file,
47

47

00:01:47,820  -->  00:01:50,100
and can run very easily from memory.
48

48

00:01:50,100  -->  00:01:52,350
Now, the whole point here is to try to trick the user
49

49

00:01:52,350  -->  00:01:54,660
into clicking on something or running the code,
50

50

00:01:54,660  -->  00:01:57,720
and that way, they are infecting their own machine.
51

51

00:01:57,720  -->  00:02:00,990
At that point, the APT then tries to maintain access.
52

52

00:02:00,990  -->  00:02:02,670
The malware is now on the system,
53

53

00:02:02,670  -->  00:02:05,340
and it's going to install that second stage downloader.
54

54

00:02:05,340  -->  00:02:06,780
That downloader can download something
55

55

00:02:06,780  -->  00:02:08,610
like a remote access Trojan,
56

56

00:02:08,610  -->  00:02:10,410
and this will give the adversary C2
57

57

00:02:10,410  -->  00:02:12,210
over that victim machine.
58

58

00:02:12,210  -->  00:02:14,670
After that, they're going to start strengthening their access.
59

59

00:02:14,670  -->  00:02:16,980
And to do that, they're going to use that remote access tool
60

60

00:02:16,980  -->  00:02:19,350
they have from the maintaining access phase,
61

61

00:02:19,350  -->  00:02:20,670
and they're going to start looking around
62

62

00:02:20,670  -->  00:02:23,250
and identifying and infecting other systems.
63

63

00:02:23,250  -->  00:02:25,020
As they're doing this, they're trying to find systems
64

64

00:02:25,020  -->  00:02:28,020
of higher values like servers or domain controllers.
65

65

00:02:28,020  -->  00:02:28,980
But even if not,
66

66

00:02:28,980  -->  00:02:30,960
they want to compromise other workstations too
67

67

00:02:30,960  -->  00:02:32,370
and do this lateral movement
68

68

00:02:32,370  -->  00:02:34,200
so they can gain additional privileges
69

69

00:02:34,200  -->  00:02:35,400
and an additional footprint.
70

70

00:02:35,400  -->  00:02:36,930
So if you find them on one machine,
71

71

00:02:36,930  -->  00:02:38,520
hopefully, you wouldn't find 'em on the other machine
72

72

00:02:38,520  -->  00:02:40,350
and they get to stay there.
73

73

00:02:40,350  -->  00:02:42,000
After this, they move into step four,
74

74

00:02:42,000  -->  00:02:44,010
which is actions on objectives.
75

75

00:02:44,010  -->  00:02:45,420
Now with actions on objectives,
76

76

00:02:45,420  -->  00:02:47,370
the attacker now has enough permissions,
77

77

00:02:47,370  -->  00:02:49,500
and they've identified enough things that are of interest
78

78

00:02:49,500  -->  00:02:51,450
that they can start doing what they want to do,
79

79

00:02:51,450  -->  00:02:53,940
which is usually going to be copying or stealing files,
80

80

00:02:53,940  -->  00:02:55,920
encrypting files, or doing something else,
81

81

00:02:55,920  -->  00:02:57,630
whatever their motive was.
82

82

00:02:57,630  -->  00:02:59,280
And then finally, we have our fifth step,
83

83

00:02:59,280  -->  00:03:00,600
which is concealment.
84

84

00:03:00,600  -->  00:03:02,880
The attacker at this point is going to maintain
85

85

00:03:02,880  -->  00:03:05,610
their tool access, but they might just go ahead
86

86

00:03:05,610  -->  00:03:07,200
and start hiding themself,
87

87

00:03:07,200  -->  00:03:08,790
and they're going to start covering their tracks
88

88

00:03:08,790  -->  00:03:11,250
by deleting log files and things like that.
89

89

00:03:11,250  -->  00:03:13,140
They want to make sure they're eradicating any sign
90

90

00:03:13,140  -->  00:03:15,690
that they were there, and that they infected your system.
91

91

00:03:15,690  -->  00:03:17,460
Because this way, they can stay there longer
92

92

00:03:17,460  -->  00:03:20,490
if they need to, and they can always go back in later on
93

93

00:03:20,490  -->  00:03:22,650
if they need to get something else from the machine.
94

94

00:03:22,650  -->  00:03:25,950
All right, so that is the basic five steps of an attack.
95

95

00:03:25,950  -->  00:03:27,360
And I mentioned a couple of terms there
96

96

00:03:27,360  -->  00:03:28,920
that I think we need to go back and define
97

97

00:03:28,920  -->  00:03:29,970
a little bit deeper.
98

98

00:03:29,970  -->  00:03:32,220
I talked about things like droppers and downloaders
99

99

00:03:32,220  -->  00:03:34,050
and shell codes and lots of other things.
100

100

00:03:34,050  -->  00:03:35,850
So let's take a look at those.
101

101

00:03:35,850  -->  00:03:37,440
First, we have a dropper.
102

102

00:03:37,440  -->  00:03:39,720
Now a dropper is a specialized type of malware
103

103

00:03:39,720  -->  00:03:42,570
that's designed to install or run other types of malware
104

104

00:03:42,570  -->  00:03:45,240
embedded in a payload on an infected host.
105

105

00:03:45,240  -->  00:03:46,950
Usually, this will be a stage one dropper
106

106

00:03:46,950  -->  00:03:48,660
as that code you first got.
107

107

00:03:48,660  -->  00:03:50,280
And once you get that code and run it,
108

108

00:03:50,280  -->  00:03:52,770
it's then going to go out and get some other code,
109

109

00:03:52,770  -->  00:03:55,050
and it uses a downloader to do that.
110

110

00:03:55,050  -->  00:03:57,120
Now, a downloader is a piece of code that connects
111

111

00:03:57,120  -->  00:03:59,190
to the internet to retrieve additional tools
112

112

00:03:59,190  -->  00:04:01,770
after the initial infection happens by a dropper.
113

113

00:04:01,770  -->  00:04:04,260
So often, we'll call this stage one for the dropper,
114

114

00:04:04,260  -->  00:04:06,870
stage two for the downloader.
115

115

00:04:06,870  -->  00:04:08,550
Now in my explanation of that process,
116

116

00:04:08,550  -->  00:04:10,440
I also mentioned the word shell code.
117

117

00:04:10,440  -->  00:04:12,510
Now, shell code is any lightweight code
118

118

00:04:12,510  -->  00:04:14,790
that's designed to run an exploit on a target.
119

119

00:04:14,790  -->  00:04:16,710
This can include any type of code format.
120

120

00:04:16,710  -->  00:04:18,150
It can be scripting languages,
121

121

00:04:18,150  -->  00:04:20,460
all the way down to a compiled binary.
122

122

00:04:20,460  -->  00:04:22,950
Now for the exam, I want you to remember,
123

123

00:04:22,950  -->  00:04:25,200
especially if you have some experience in the field,
124

124

00:04:25,200  -->  00:04:27,750
shell code originally referred to malware code.
125

125

00:04:27,750  -->  00:04:30,030
It would give the attacker a shell or a command prompt
126

126

00:04:30,030  -->  00:04:31,530
on the target system.
127

127

00:04:31,530  -->  00:04:32,940
And if you take the PenTest+ exam,
128

128

00:04:32,940  -->  00:04:34,650
that's how they're going to use that term.
129

129

00:04:34,650  -->  00:04:37,170
But here in CYSA for this exam,
130

130

00:04:37,170  -->  00:04:38,790
they want you to use the definition
131

131

00:04:38,790  -->  00:04:41,280
of the more generic shell code that I just provided,
132

132

00:04:41,280  -->  00:04:43,140
which is any lightweight code designed
133

133

00:04:43,140  -->  00:04:44,730
to run an exploit on a target.
134

134

00:04:44,730  -->  00:04:46,380
It doesn't have to give you a command prompt,
135

135

00:04:46,380  -->  00:04:48,450
it just has to be something that's going to give you
136

136

00:04:48,450  -->  00:04:50,910
some kind of an exploit that's going to be run.
137

137

00:04:50,910  -->  00:04:53,370
Now, once the shell code is created as a process
138

138

00:04:53,370  -->  00:04:55,830
on the target system, all this bad stuff
139

139

00:04:55,830  -->  00:04:57,450
has to start happening to your system, right?
140

140

00:04:57,450  -->  00:04:58,770
How does that happen?
141

141

00:04:58,770  -->  00:05:01,230
Well, one way is through code injection.
142

142

00:05:01,230  -->  00:05:03,240
Code injection is an exploit technique
143

143

00:05:03,240  -->  00:05:05,940
that runs malicious code with the identification number
144

144

00:05:05,940  -->  00:05:07,740
of a legitimate process.
145

145

00:05:07,740  -->  00:05:09,928
So when I go to install this code,
146

146

00:05:09,928  -->  00:05:12,180
and we're going to talk more about process exploring
147

147

00:05:12,180  -->  00:05:15,030
and how we can identify this type of behavior later on,
148

148

00:05:15,030  -->  00:05:16,530
you're going to notice that every process
149

149

00:05:16,530  -->  00:05:18,510
has a unique ID number with it.
150

150

00:05:18,510  -->  00:05:20,490
And so if I have something that is allowed to run
151

151

00:05:20,490  -->  00:05:23,910
like the Explorer for Windows, and I decide to run malware
152

152

00:05:23,910  -->  00:05:25,500
and make you think I'm running it
153

153

00:05:25,500  -->  00:05:27,300
as the Explorer for Windows,
154

154

00:05:27,300  -->  00:05:30,720
I can hide that malware by injecting the code into that.
155

155

00:05:30,720  -->  00:05:32,880
That's the idea of code injection.
156

156

00:05:32,880  -->  00:05:35,100
Now, there's a lot of other techniques we can do
157

157

00:05:35,100  -->  00:05:37,290
as far as different types of code injection.
158

158

00:05:37,290  -->  00:05:39,870
This includes things like masquerading where your dropper
159

159

00:05:39,870  -->  00:05:43,140
is going to replace a genuine executable with a malicious one.
160

160

00:05:43,140  -->  00:05:44,790
You can use DLL injection,
161

161

00:05:44,790  -->  00:05:47,010
where the dropper starts forcing a process to load
162

162

00:05:47,010  -->  00:05:48,510
as part of the DLL.
163

163

00:05:48,510  -->  00:05:50,010
So it's going to load the DLL
164

164

00:05:50,010  -->  00:05:52,380
and the executable malicious code.
165

165

00:05:52,380  -->  00:05:54,420
You also can do DLL sideloading.
166

166

00:05:54,420  -->  00:05:56,790
This is where the dropper is going to exploit a vulnerability
167

167

00:05:56,790  -->  00:05:58,650
in a legitimate program to manifest
168

168

00:05:58,650  -->  00:06:01,050
to load a malicious DLL at runtime.
169

169

00:06:01,050  -->  00:06:02,580
And essentially, use sideload
170

170

00:06:02,580  -->  00:06:04,800
by making it load this malicious thing.
171

171

00:06:04,800  -->  00:06:06,930
Or we can do process hollowing.
172

172

00:06:06,930  -->  00:06:08,670
This is when a dropper starts a process
173

173

00:06:08,670  -->  00:06:09,990
in a suspended state,
174

174

00:06:09,990  -->  00:06:12,060
and then rewrites the memory locations containing
175

175

00:06:12,060  -->  00:06:14,670
the process code with the malware code.
176

176

00:06:14,670  -->  00:06:17,520
So essentially, we're taking over someplace in memory
177

177

00:06:17,520  -->  00:06:19,680
and putting our malicious code in there.
178

178

00:06:19,680  -->  00:06:21,480
Now droppers are likely to implement
179

179

00:06:21,480  -->  00:06:23,310
a lot of these different techniques.
180

180

00:06:23,310  -->  00:06:24,143
In addition to that,
181

181

00:06:24,143  -->  00:06:26,580
they also use some anti-forensic techniques
182

182

00:06:26,580  -->  00:06:28,920
to help prevent detection and analysis.
183

183

00:06:28,920  -->  00:06:30,990
When we talk about anti-forensic techniques,
184

184

00:06:30,990  -->  00:06:33,330
this is things like encrypting their payloads,
185

185

00:06:33,330  -->  00:06:36,810
or compressing their payloads or obfuscating their payloads.
186

186

00:06:36,810  -->  00:06:37,920
Now, when they do this,
187

187

00:06:37,920  -->  00:06:41,250
it makes our job as reverse engineers a lot harder,
188

188

00:06:41,250  -->  00:06:44,070
but we still find ways to find these people.
189

189

00:06:44,070  -->  00:06:46,620
And so one of the things that a lot of pen testers
190

190

00:06:46,620  -->  00:06:48,810
and a lot of attackers are starting to do now
191

191

00:06:48,810  -->  00:06:51,270
is a concept called living off the land.
192

192

00:06:51,270  -->  00:06:53,040
Because when they live off the land,
193

193

00:06:53,040  -->  00:06:55,050
it's really hard for us to find them.
194

194

00:06:55,050  -->  00:06:56,490
When I talk about living off the land,
195

195

00:06:56,490  -->  00:06:59,370
this is an exploit technique that uses standard system tools
196

196

00:06:59,370  -->  00:07:01,830
and packages to perform their intrusions.
197

197

00:07:01,830  -->  00:07:03,750
For instance, they might use something like this,
198

198

00:07:03,750  -->  00:07:05,190
which is PowerShell.
199

199

00:07:05,190  -->  00:07:06,390
PowerShell can be used to do
200

200

00:07:06,390  -->  00:07:08,550
all sorts of malicious activities.
201

201

00:07:08,550  -->  00:07:10,920
And so what we can do is when we break into a system
202

202

00:07:10,920  -->  00:07:12,870
as a pen tester or as an attacker,
203

203

00:07:12,870  -->  00:07:15,510
we can actually use your own PowerShell against you.
204

204

00:07:15,510  -->  00:07:17,820
If I'm on a Linux system, I can't use PowerShell,
205

205

00:07:17,820  -->  00:07:19,380
but I can use Bash scripting.
206

206

00:07:19,380  -->  00:07:21,330
And so again, if I use the tools that are native
207

207

00:07:21,330  -->  00:07:22,920
to your operating system,
208

208

00:07:22,920  -->  00:07:24,990
I am now using tools that were already installed
209

209

00:07:24,990  -->  00:07:26,040
for your administrators,
210

210

00:07:26,040  -->  00:07:27,720
and I'm using them in a malicious way,
211

211

00:07:27,720  -->  00:07:29,700
but it's going to be really hard for you to detect that
212

212

00:07:29,700  -->  00:07:31,470
because I'm living off the land.
213

213

00:07:31,470  -->  00:07:33,630
So if you fall victim to an attacker who is used
214

214

00:07:33,630  -->  00:07:34,680
to living off the land,
215

215

00:07:34,680  -->  00:07:36,000
the detection of that adversary
216

216

00:07:36,000  -->  00:07:37,710
is going to be much more difficult
217

217

00:07:37,710  -->  00:07:39,270
because they're executing malware code
218

218

00:07:39,270  -->  00:07:41,670
within those standard tools and processes,
219

219

00:07:41,670  -->  00:07:43,740
and that makes it really hard to detect,
220

220

00:07:43,740  -->  00:07:44,940
and it's going to allow them to stay
221

221

00:07:44,940  -->  00:07:46,503
on your system a lot longer.
