1
1

00:00:00,360  -->  00:00:02,220
<v Instructor>Dynamic analysis.</v>
2

2

00:00:02,220  -->  00:00:03,180
So up to this point,
3

3

00:00:03,180  -->  00:00:04,950
we've talked about static analysis
4

4

00:00:04,950  -->  00:00:07,290
and going through the code line by line
5

5

00:00:07,290  -->  00:00:08,940
using our decompiler.
6

6

00:00:08,940  -->  00:00:10,530
In this lesson, we are going to talk
7

7

00:00:10,530  -->  00:00:13,560
about why you might want to do dynamic analysis instead.
8

8

00:00:13,560  -->  00:00:15,210
Now when you do static analysis,
9

9

00:00:15,210  -->  00:00:17,490
we're going to be looking through the disassembled code,
10

10

00:00:17,490  -->  00:00:19,170
but that's far from perfect
11

11

00:00:19,170  -->  00:00:22,020
because a lot of times, it's been changed and modified
12

12

00:00:22,020  -->  00:00:23,970
so we can't see what's going on.
13

13

00:00:23,970  -->  00:00:26,040
So when a malware writer takes their code
14

14

00:00:26,040  -->  00:00:27,600
and tries to hide their intent,
15

15

00:00:27,600  -->  00:00:29,910
stack analysis can be really difficult.
16

16

00:00:29,910  -->  00:00:33,930
So what we might want to do instead is do a dynamic analysis.
17

17

00:00:33,930  -->  00:00:35,760
Now, with a dynamic analysis,
18

18

00:00:35,760  -->  00:00:38,700
this involves the execution of a compiled program
19

19

00:00:38,700  -->  00:00:40,710
and then we're going to analyze the way it executes
20

20

00:00:40,710  -->  00:00:43,920
and interacts with the host, the system, or the network.
21

21

00:00:43,920  -->  00:00:47,160
By doing that, we can figure out how this thing works.
22

22

00:00:47,160  -->  00:00:49,260
So if you think back to our different types of testing
23

23

00:00:49,260  -->  00:00:52,020
with known environment test and unknown environment test,
24

24

00:00:52,020  -->  00:00:53,490
dynamic analysis is more like
25

25

00:00:53,490  -->  00:00:55,350
unknown environment test, right?
26

26

00:00:55,350  -->  00:00:57,570
We're going to run it and see what comes out the other side,
27

27

00:00:57,570  -->  00:00:59,040
what changes it makes.
28

28

00:00:59,040  -->  00:01:01,080
With static analysis, we're trying to essentially
29

29

00:01:01,080  -->  00:01:02,550
do a known environment test, right?
30

30

00:01:02,550  -->  00:01:04,650
We're trying to get to something that looks like code
31

31

00:01:04,650  -->  00:01:07,740
so we can analyze all the moving pieces inside of it.
32

32

00:01:07,740  -->  00:01:09,750
Now, when you're doing dynamic analysis,
33

33

00:01:09,750  -->  00:01:11,970
there are a couple of different tools you're going to use.
34

34

00:01:11,970  -->  00:01:15,090
You might use a debugger, a stress test application,
35

35

00:01:15,090  -->  00:01:17,400
a fuzzing application, and we're going to talk about
36

36

00:01:17,400  -->  00:01:19,410
each of these three in this lesson.
37

37

00:01:19,410  -->  00:01:20,910
Now, when we talk about a debugger,
38

38

00:01:20,910  -->  00:01:22,380
this is a dynamic testing tool
39

39

00:01:22,380  -->  00:01:25,740
that's used to analyze software as it's being executed.
40

40

00:01:25,740  -->  00:01:28,080
Now essentially what the debugger allows you to do
41

41

00:01:28,080  -->  00:01:31,620
is step through the program instruction by instruction.
42

42

00:01:31,620  -->  00:01:33,450
If you looked in IDA, we had that pseudo code.
43

43

00:01:33,450  -->  00:01:35,520
There was 50 lines of code there.
44

44

00:01:35,520  -->  00:01:36,353
Now in a real program
45

45

00:01:36,353  -->  00:01:39,750
there might be 50, 500, or even 5,000 lines.
46

46

00:01:39,750  -->  00:01:42,390
With the debugger, I can go and run one line at a time
47

47

00:01:42,390  -->  00:01:45,000
through that code or one instruction at a time
48

48

00:01:45,000  -->  00:01:47,970
based on the assembly code that that binary has.
49

49

00:01:47,970  -->  00:01:50,850
Now, I can stop it at any point and then start looking at it
50

50

00:01:50,850  -->  00:01:52,920
and that's what a debugger allows us to do.
51

51

00:01:52,920  -->  00:01:55,560
The debugger is going to allow us to pause the execution
52

52

00:01:55,560  -->  00:01:57,810
and monitor or adjust the value of variables
53

53

00:01:57,810  -->  00:02:00,180
at different stages through its execution.
54

54

00:02:00,180  -->  00:02:02,250
Again, this allows us to control a little bit
55

55

00:02:02,250  -->  00:02:04,050
what's inside that black box
56

56

00:02:04,050  -->  00:02:05,700
so we can see what comes out the other side
57

57

00:02:05,700  -->  00:02:06,990
and then we might be able to figure out
58

58

00:02:06,990  -->  00:02:08,580
how it actually works.
59

59

00:02:08,580  -->  00:02:11,250
Now when you use a debugger, it looks something like this.
60

60

00:02:11,250  -->  00:02:13,200
In this example, you can see a breakpoint
61

61

00:02:13,200  -->  00:02:16,380
that little stop sign was set at line 209.
62

62

00:02:16,380  -->  00:02:18,030
This means the program will start running
63

63

00:02:18,030  -->  00:02:20,910
and when it gets to line 209, it's going to stop.
64

64

00:02:20,910  -->  00:02:22,770
Now once it stops there and pauses,
65

65

00:02:22,770  -->  00:02:24,990
at this point I can highlight that line
66

66

00:02:24,990  -->  00:02:27,150
and I can look at the different values of the command
67

67

00:02:27,150  -->  00:02:29,040
or the value of a particular variable.
68

68

00:02:29,040  -->  00:02:31,500
In this case, it's letting me see what the value
69

69

00:02:31,500  -->  00:02:36,500
of wcoef[1] is going to be in this case minus 0.72.
70

70

00:02:38,220  -->  00:02:39,810
Now, does that mean anything to us right now?
71

71

00:02:39,810  -->  00:02:41,370
Not really, but if we were going through
72

72

00:02:41,370  -->  00:02:43,500
and analyzing this program, it might be helpful
73

73

00:02:43,500  -->  00:02:45,420
to know what all those things are.
74

74

00:02:45,420  -->  00:02:47,880
Now debuggers are legitimately used by programmers
75

75

00:02:47,880  -->  00:02:49,140
to find errors in their code
76

76

00:02:49,140  -->  00:02:50,970
and then identify how to fix them,
77

77

00:02:50,970  -->  00:02:53,790
but as a malware analyst, we can use them too.
78

78

00:02:53,790  -->  00:02:55,890
Now, we're not the only ones who use 'em, though.
79

79

00:02:55,890  -->  00:02:57,450
Some attackers and reverse engineers
80

80

00:02:57,450  -->  00:03:00,030
can use debuggers as well to step through a binary
81

81

00:03:00,030  -->  00:03:02,250
and determine how to best exploit any weakness
82

82

00:03:02,250  -->  00:03:03,900
or vulnerability in it.
83

83

00:03:03,900  -->  00:03:07,140
This is used by both sides, defense and attack
84

84

00:03:07,140  -->  00:03:08,430
and so it's really something that's useful
85

85

00:03:08,430  -->  00:03:10,740
for you to understand if you happen to be a programmer
86

86

00:03:10,740  -->  00:03:13,530
and you're working as a reverse malware engineer.
87

87

00:03:13,530  -->  00:03:14,730
Now the next time we're going to talk about
88

88

00:03:14,730  -->  00:03:16,260
is known as a stress test.
89

89

00:03:16,260  -->  00:03:18,750
Now a stress test is a software testing method
90

90

00:03:18,750  -->  00:03:21,990
that evaluates how software performs under extreme load.
91

91

00:03:21,990  -->  00:03:24,930
Now that extreme load can come as lots of different things.
92

92

00:03:24,930  -->  00:03:26,610
It might be extreme processor load,
93

93

00:03:26,610  -->  00:03:29,340
extreme memory load, extreme network load.
94

94

00:03:29,340  -->  00:03:30,173
That's up to you
95

95

00:03:30,173  -->  00:03:32,670
and what you're trying to stress inside your test.
96

96

00:03:32,670  -->  00:03:34,650
Now a stress test can be used to determine
97

97

00:03:34,650  -->  00:03:36,930
what could trigger a denial of service.
98

98

00:03:36,930  -->  00:03:39,480
So a lot of times we'll stress test our own applications
99

99

00:03:39,480  -->  00:03:41,490
and our own networks because for instance
100

100

00:03:41,490  -->  00:03:43,020
when I'm setting up my new website
101

101

00:03:43,020  -->  00:03:44,970
and I'm going to have all my students come onto it,
102

102

00:03:44,970  -->  00:03:46,650
I want to know how many students can I take
103

103

00:03:46,650  -->  00:03:48,390
before the site crashes.
104

104

00:03:48,390  -->  00:03:50,190
Well, I can run a stress test against it
105

105

00:03:50,190  -->  00:03:51,030
and when we've done this,
106

106

00:03:51,030  -->  00:03:52,860
we figured out that we can support
107

107

00:03:52,860  -->  00:03:54,360
10,000 students simultaneously
108

108

00:03:54,360  -->  00:03:56,160
or a hundred thousand students simultaneously
109

109

00:03:56,160  -->  00:03:58,110
or 10 students simultaneously.
110

110

00:03:58,110  -->  00:03:59,250
We have to know what that number is
111

111

00:03:59,250  -->  00:04:01,740
so we can actually sell the right number of students
112

112

00:04:01,740  -->  00:04:03,660
without giving you bad quality of service
113

113

00:04:03,660  -->  00:04:06,390
and that's what a stress test allows you to do.
114

114

00:04:06,390  -->  00:04:09,150
Now as a cybersecurity analyst, you might do a stress test
115

115

00:04:09,150  -->  00:04:12,240
of your systems to see what would make them fall down,
116

116

00:04:12,240  -->  00:04:14,430
what would make them have a denial of service
117

117

00:04:14,430  -->  00:04:15,510
and so you can use a program
118

118

00:04:15,510  -->  00:04:17,400
like this web application stress.
119

119

00:04:17,400  -->  00:04:19,260
You can run this program against your server
120

120

00:04:19,260  -->  00:04:21,270
and it will run a bunch of different scripts against it
121

121

00:04:21,270  -->  00:04:22,890
and that way it'll be able to figure out
122

122

00:04:22,890  -->  00:04:25,560
what would cause that denial of service for you.
123

123

00:04:25,560  -->  00:04:27,840
Again, this might be resource exhaustion.
124

124

00:04:27,840  -->  00:04:29,340
It could be something like you're using up
125

125

00:04:29,340  -->  00:04:32,400
all the processor, all the memory, all the disk space,
126

126

00:04:32,400  -->  00:04:35,100
all the network bandwidth, whatever the limitation is,
127

127

00:04:35,100  -->  00:04:37,020
you can find it by doing a stress test
128

128

00:04:37,020  -->  00:04:39,450
and so often when you're deploying a new network
129

129

00:04:39,450  -->  00:04:40,800
or a new web application,
130

130

00:04:40,800  -->  00:04:42,750
you would be asked as a cybersecurity analyst
131

131

00:04:42,750  -->  00:04:43,920
to test that system
132

132

00:04:43,920  -->  00:04:45,900
by putting it through some stress testing.
133

133

00:04:45,900  -->  00:04:48,090
The next area we're going to talk about is fuzzing.
134

134

00:04:48,090  -->  00:04:50,850
Now, fuzzing is a dynamic code analysis technique
135

135

00:04:50,850  -->  00:04:52,830
that involves sending a running application,
136

136

00:04:52,830  -->  00:04:54,810
random and unusual input
137

137

00:04:54,810  -->  00:04:57,390
to evaluate how the application responds.
138

138

00:04:57,390  -->  00:04:58,860
Now let me give you a simple example
139

139

00:04:58,860  -->  00:05:02,250
of how fuzzing is used to see if it can crash something.
140

140

00:05:02,250  -->  00:05:04,890
For example, on my website we have a checkout page
141

141

00:05:04,890  -->  00:05:06,630
and you're going to enter your credit card.
142

142

00:05:06,630  -->  00:05:08,730
Now we expect what to be entered there?
143

143

00:05:08,730  -->  00:05:09,600
Your credit card, right?
144

144

00:05:09,600  -->  00:05:11,310
It should be 16 digits.
145

145

00:05:11,310  -->  00:05:12,720
What if you start adding in things
146

146

00:05:12,720  -->  00:05:14,850
like special characters or letters?
147

147

00:05:14,850  -->  00:05:16,290
Will that crash our system?
148

148

00:05:16,290  -->  00:05:18,060
Well, if we do a fuzz test,
149

149

00:05:18,060  -->  00:05:20,040
we're going to send some of those random things in there
150

150

00:05:20,040  -->  00:05:21,480
to see if we can crash it
151

151

00:05:21,480  -->  00:05:22,410
and then we can find out
152

152

00:05:22,410  -->  00:05:24,300
have we done proper input validation
153

153

00:05:24,300  -->  00:05:26,130
to prevent this from crashing?
154

154

00:05:26,130  -->  00:05:28,680
That's what fuzzing does, it test your input validation
155

155

00:05:28,680  -->  00:05:30,510
and your other systems to make sure
156

156

00:05:30,510  -->  00:05:32,370
you have the right protections in place.
157

157

00:05:32,370  -->  00:05:33,630
Now, fuzzing is a technique
158

158

00:05:33,630  -->  00:05:36,270
that's designed to test your software for various bugs
159

159

00:05:36,270  -->  00:05:37,680
and vulnerabilities.
160

160

00:05:37,680  -->  00:05:39,570
Like I said, I can test your application
161

161

00:05:39,570  -->  00:05:40,890
and see if it's going to crash
162

162

00:05:40,890  -->  00:05:43,470
when you send it some kind of wacky input.
163

163

00:05:43,470  -->  00:05:45,180
That's what fuzzing is all about.
164

164

00:05:45,180  -->  00:05:46,590
Now, when you use a fuzzer,
165

165

00:05:46,590  -->  00:05:48,330
there are three different ways to inject
166

166

00:05:48,330  -->  00:05:51,000
that manipulate input into your application.
167

167

00:05:51,000  -->  00:05:53,040
You can use the application user interface
168

168

00:05:53,040  -->  00:05:54,510
which identifies input streams
169

169

00:05:54,510  -->  00:05:56,130
that are accepted by the application,
170

170

00:05:56,130  -->  00:05:59,190
such as an input box or a form or a command line switch
171

171

00:05:59,190  -->  00:06:01,110
and then send information that way.
172

172

00:06:01,110  -->  00:06:03,360
Another way you can do it is by using the protocol
173

173

00:06:03,360  -->  00:06:05,430
and you can transmit the manipulated packets
174

174

00:06:05,430  -->  00:06:06,840
into the application.
175

175

00:06:06,840  -->  00:06:08,820
For instance, maybe you're used to accepting things
176

176

00:06:08,820  -->  00:06:11,610
over the web so I can go ahead and modify the headers
177

177

00:06:11,610  -->  00:06:14,250
or the payloads and see if that'll crash you.
178

178

00:06:14,250  -->  00:06:16,830
And then the third way is to use a different file format.
179

179

00:06:16,830  -->  00:06:18,120
Now when you're doing a file format,
180

180

00:06:18,120  -->  00:06:19,860
we're going to try to open some kind of file
181

181

00:06:19,860  -->  00:06:21,720
but we're going to manipulate that file.
182

182

00:06:21,720  -->  00:06:24,360
So you might think that you're uploading a PNG file
183

183

00:06:24,360  -->  00:06:27,030
and when I actually send it to you, it's labeled as a PNG
184

184

00:06:27,030  -->  00:06:28,290
but it might be an executable
185

185

00:06:28,290  -->  00:06:30,390
and we'll see if it causes issues with your system.
186

186

00:06:30,390  -->  00:06:33,960
Now, fuzzers may craft the input using semi-random input
187

187

00:06:33,960  -->  00:06:35,640
or specific inputs.
188

188

00:06:35,640  -->  00:06:37,170
If we use semi random input,
189

189

00:06:37,170  -->  00:06:38,700
we call this a dumb fuzzer.
190

190

00:06:38,700  -->  00:06:40,830
If we use specific inputs on the other hand,
191

191

00:06:40,830  -->  00:06:43,050
we're using things based on what we know works
192

192

00:06:43,050  -->  00:06:44,730
based on other exploit vectors
193

193

00:06:44,730  -->  00:06:45,720
or certain vulnerabilities
194

194

00:06:45,720  -->  00:06:48,165
that we're trying to target specifically.
195

195

00:06:48,165  -->  00:06:50,340
We're not just using anything that's random in that case.
196

196

00:06:50,340  -->  00:06:52,470
Now, one of the examples of a fuzzer
197

197

00:06:52,470  -->  00:06:54,300
is what's known as Peach Fuzzer.
198

198

00:06:54,300  -->  00:06:56,130
The Peach Fuzzer platform is one
199

199

00:06:56,130  -->  00:06:58,500
of the most advanced commercial fuzzers out there.
200

200

00:06:58,500  -->  00:07:00,570
It is used by a lot of people in the industry.
201

201

00:07:00,570  -->  00:07:01,920
Now if you want to play with it,
202

202

00:07:01,920  -->  00:07:03,780
there's also a free community version,
203

203

00:07:03,780  -->  00:07:05,400
like a lot of the tools we've talked about.
204

204

00:07:05,400  -->  00:07:07,350
There's the commercial side that makes the money
205

205

00:07:07,350  -->  00:07:08,820
and then they have these free tools
206

206

00:07:08,820  -->  00:07:10,170
for us to use as we're learning
207

207

00:07:10,170  -->  00:07:12,720
and protecting our own home-based networks.
208

208

00:07:12,720  -->  00:07:14,430
Now as you go and use something like this,
209

209

00:07:14,430  -->  00:07:16,710
you can use it against your own systems.
210

210

00:07:16,710  -->  00:07:17,543
Don't take this
211

211

00:07:17,543  -->  00:07:19,860
and target other people's websites without their permission.
212

212

00:07:19,860  -->  00:07:20,700
That's hacking.
213

213

00:07:20,700  -->  00:07:22,320
That can land you in jail.
214

214

00:07:22,320  -->  00:07:24,690
Instead, you can target your own websites
215

215

00:07:24,690  -->  00:07:26,640
or sites you've placed in your lab.
216

216

00:07:26,640  -->  00:07:29,430
Now this platform has a lot of built-in test cases.
217

217

00:07:29,430  -->  00:07:32,070
Now test cases are these different preconfigured things
218

218

00:07:32,070  -->  00:07:33,090
that we're going to work against
219

219

00:07:33,090  -->  00:07:34,950
different types of products and systems.
220

220

00:07:34,950  -->  00:07:36,420
So we have some test cases that will go
221

221

00:07:36,420  -->  00:07:37,710
against network appliances.
222

222

00:07:37,710  -->  00:07:40,110
We have test cases that go against web applications.
223

223

00:07:40,110  -->  00:07:42,480
We have test cases that go against financial data,
224

224

00:07:42,480  -->  00:07:44,400
test cases that go against healthcare
225

225

00:07:44,400  -->  00:07:46,920
and we can use these to test these different applications
226

226

00:07:46,920  -->  00:07:48,300
and they have different data sets
227

227

00:07:48,300  -->  00:07:49,890
that we would expect to use
228

228

00:07:49,890  -->  00:07:52,790
and different things that we would expect to cause issues.
