WEBVTT - This file was automatically generated by VIMEO

0
00:00:07.100 --> 00:00:10.500
In this video, you will learn how to determine where the

1
00:00:10.500 --> 00:00:13.400
 offset exists and how we could leverage it.

2
00:00:13.400 --> 00:00:16.300
 I hope you're excited. So let's dive on

3
00:00:16.300 --> 00:00:16.400
 in.

4
00:00:17.400 --> 00:00:20.900
In our previous video you have learned how to perform spiking and

5
00:00:20.900 --> 00:00:23.100
 Frozen in this video. We will

6
00:00:23.100 --> 00:00:27.400
 take a look at finding the offset value the offset

7
00:00:26.400 --> 00:00:29.400
 simply helps us determine where

8
00:00:29.400 --> 00:00:32.900
 exactly the crashes actually happen within memory

9
00:00:32.900 --> 00:00:35.300
 and we can leverage a control

10
00:00:35.300 --> 00:00:38.100
 of the EIP register which is

11
00:00:38.100 --> 00:00:41.900
 simply the extended instructions pointer register. We

12
00:00:41.900 --> 00:00:44.200
 can use it tool on Kali Lennox, which

13
00:00:44.200 --> 00:00:47.400
 is from Metasploit and this tool will allow us

14
00:00:47.400 --> 00:00:50.600
 to generate specific patterns. Then we

15
00:00:50.600 --> 00:00:53.000
 can use these patterns injected into the

16
00:00:53.600 --> 00:00:56.300
 buffer and we could determine way exactly the

17
00:00:56.300 --> 00:00:57.600
 crashes actually happen.

18
00:00:58.600 --> 00:01:01.500
So let's get started simply open the terminal

19
00:01:01.500 --> 00:01:05.200
 like so and let's use the pattern

20
00:01:04.200 --> 00:01:06.800
 create tool from a display.

21
00:01:09.500 --> 00:01:13.100
Then we'll type - common L. And

22
00:01:12.100 --> 00:01:15.800
 if you remember in the previous video my

23
00:01:15.800 --> 00:01:19.800
 crush actually happened at 6,100 bytes.

24
00:01:19.800 --> 00:01:22.800
 Now, let's increase it a

25
00:01:22.800 --> 00:01:25.400
 little more so we can get a better idea on

26
00:01:25.400 --> 00:01:28.500
 where the crashes actually happening. Let's increase

27
00:01:28.500 --> 00:01:31.400
 this to let's say an even

28
00:01:31.400 --> 00:01:34.600
 number so I will increase it to 6600 or

29
00:01:34.600 --> 00:01:35.800
 6,600.

30
00:01:36.500 --> 00:01:37.600
Simply hit enter.

31
00:01:38.400 --> 00:01:41.800
And as you can see, it generated it long list

32
00:01:41.800 --> 00:01:42.600
 of patterns.

33
00:01:43.800 --> 00:01:46.200
Simply copy all the patterns from your

34
00:01:46.200 --> 00:01:46.500
 screen.

35
00:01:47.400 --> 00:01:48.000
like so

36
00:01:55.500 --> 00:01:59.900
and now let's open up our fuzz1 python

37
00:01:58.900 --> 00:02:00.200
 script.

38
00:02:00.900 --> 00:02:02.600
Let's click on a text editor.

39
00:02:03.400 --> 00:02:04.300
Let's click on file.

40
00:02:05.300 --> 00:02:09.000
Let's click on ub1. I left select or

41
00:02:08.500 --> 00:02:10.500
 false one python script.

42
00:02:13.000 --> 00:02:13.500
Great.

43
00:02:14.800 --> 00:02:17.200
We are going to modify this file and let's

44
00:02:17.200 --> 00:02:20.300
 create a new version of it. Simply click on file.

45
00:02:21.100 --> 00:02:22.000
Save us.

46
00:02:22.700 --> 00:02:26.000
Let's change the name the false 2.py

47
00:02:25.500 --> 00:02:28.100
 like so and click on

48
00:02:28.100 --> 00:02:28.500
 Save.

49
00:02:30.100 --> 00:02:32.900
Now, let's modify our script a little bit.

50
00:02:33.800 --> 00:02:35.300
Let's delete line 5.

51
00:02:36.400 --> 00:02:38.600
And let's replace it with offset.

52
00:02:39.400 --> 00:02:40.200
equals

53
00:02:41.100 --> 00:02:44.700
Open quotation marks simply paste your

54
00:02:44.700 --> 00:02:46.500
 set value like so.

55
00:02:47.200 --> 00:02:48.900
and close quotation marks

56
00:02:53.500 --> 00:02:56.800
screw it on Photo. Let's remove our y

57
00:02:56.800 --> 00:02:57.800
 Loop like so

58
00:02:59.700 --> 00:03:01.800
and let's adjust exception.

59
00:03:03.100 --> 00:03:03.400
Great.

60
00:03:04.700 --> 00:03:08.100
Next let's make some modifications to our

61
00:03:07.100 --> 00:03:08.500
 script.

62
00:03:13.500 --> 00:03:16.500
A line 11. Let's replace the with buffer

63
00:03:16.500 --> 00:03:17.900
 with offset.

64
00:03:19.200 --> 00:03:19.800
and now

65
00:03:20.700 --> 00:03:21.500
let us remove.

66
00:03:22.400 --> 00:03:26.000
lines 15 online 16 like so

67
00:03:34.200 --> 00:03:37.700
Lastly let's modify our print

68
00:03:37.700 --> 00:03:38.000
 command.

69
00:03:47.900 --> 00:03:48.200
Great.

70
00:03:51.500 --> 00:03:52.700
simply click on file

71
00:03:54.300 --> 00:03:56.200
And click on Save excellent.

72
00:04:03.800 --> 00:04:06.200
Let's make first to executable.

73
00:04:07.100 --> 00:04:08.600
simply type chmod

74
00:04:09.600 --> 00:04:12.300
Plus x + 2.pui.

75
00:04:15.800 --> 00:04:19.300
Before we execute a script. Let's restart

76
00:04:18.300 --> 00:04:22.200
 all server on our

77
00:04:21.200 --> 00:04:24.600
 Windows machine and reattach it

78
00:04:24.600 --> 00:04:25.600
 to immunity debugger.

79
00:04:43.900 --> 00:04:45.600
Now let's click on file.

80
00:04:46.500 --> 00:04:47.100
attach

81
00:04:47.700 --> 00:04:49.900
and let's select the volsovo.

82
00:04:50.500 --> 00:04:52.700
process and click on a touch

83
00:04:54.400 --> 00:04:56.300
Lastly let's click on plea.

84
00:04:57.700 --> 00:04:59.500
Great. So the application is running.

85
00:05:02.800 --> 00:05:05.400
I'm going to open Kali Linux, but I'm gonna

86
00:05:05.400 --> 00:05:09.100
 sort of scale it down so we can see both Kali

87
00:05:08.100 --> 00:05:11.500
 Lennox and Immunity debugger

88
00:05:11.500 --> 00:05:12.500
 running at the same time.

89
00:05:20.600 --> 00:05:20.900
Great.

90
00:05:22.100 --> 00:05:25.800
Now, let's execute fuzz2.py. Let's

91
00:05:25.800 --> 00:05:26.900
 type Python 3.

92
00:05:28.600 --> 00:05:31.800
First two dot py like so and

93
00:05:31.800 --> 00:05:32.400
 hit enter.

94
00:05:34.200 --> 00:05:37.600
And notice the application has pause and

95
00:05:37.600 --> 00:05:40.100
 there's an access violation which are good.

96
00:05:40.700 --> 00:05:43.600
This simply means the application has crushed.

97
00:05:44.400 --> 00:05:47.600
Let's be closer tension to the registers.

98
00:05:48.500 --> 00:05:51.900
Notice, the eex register is

99
00:05:51.900 --> 00:05:54.800
 filled with ASCII characters strong followed by

100
00:05:54.800 --> 00:05:57.800
 /.colon slash and

101
00:05:57.800 --> 00:05:59.300
 the patterns of ease.

102
00:06:00.800 --> 00:06:02.500
the ESP register

103
00:06:03.400 --> 00:06:06.600
also contains the ASCII characters which indicates

104
00:06:07.300 --> 00:06:10.500
the patterns also written to the ESP register.

105
00:06:11.600 --> 00:06:14.300
Next look in closer we can see the

106
00:06:14.300 --> 00:06:17.900
 EIP register is written with a

107
00:06:17.900 --> 00:06:20.900
 value. 386 F

108
00:06:20.900 --> 00:06:23.600
 4 3 3 7.

109
00:06:23.600 --> 00:06:26.700
 Let's record this value. This value

110
00:06:26.700 --> 00:06:30.200
 will be very important for us to help determine whether

111
00:06:29.200 --> 00:06:33.100
 or set actually exist within

112
00:06:32.100 --> 00:06:33.700
 the patterns.

113
00:06:35.600 --> 00:06:38.400
Let's close immunity debugger like so.

114
00:06:39.300 --> 00:06:42.100
Let's head over back to our Kali Linux virtual machine.

115
00:06:46.900 --> 00:06:50.300
Let's use another module within Metasploit,

116
00:06:49.300 --> 00:06:53.000
 which is called pattern offset.rb.

117
00:06:57.600 --> 00:07:00.100
next let's type - common l

118
00:07:00.900 --> 00:07:01.400
followed by

119
00:07:03.600 --> 00:07:06.400
the crash value which we use before which

120
00:07:06.400 --> 00:07:07.800
 is 6600.

121
00:07:08.900 --> 00:07:12.100
Followed by Dash common Q common cue

122
00:07:11.100 --> 00:07:14.200
 simply allows us the indicate or

123
00:07:14.200 --> 00:07:17.400
 specify the EIP value with an EIP

124
00:07:17.400 --> 00:07:17.900
 register.

125
00:07:22.100 --> 00:07:24.700
simply enter the EIP value like so

126
00:07:25.300 --> 00:07:26.200
and hit enter

127
00:07:27.400 --> 00:07:30.200
Great. Currently the pattern all said

128
00:07:30.200 --> 00:07:33.300
 that RV script indicates the exact match of

129
00:07:33.300 --> 00:07:38.000
 where the crash actually happened is at 2003

130
00:07:36.000 --> 00:07:38.500
 bytes.

131
00:07:39.200 --> 00:07:42.800
This information is very important to us simply because

132
00:07:42.800 --> 00:07:45.700
 it will allow us to control the EIP

133
00:07:45.700 --> 00:07:48.900
 register within the valsilver application.

134
00:07:50.900 --> 00:07:53.200
Now that we know the exact match of the

135
00:07:53.200 --> 00:07:57.100
 offset, let's attempt to override the EIP register.

136
00:07:57.600 --> 00:08:00.700
The thing is the EIP register. It

137
00:08:00.700 --> 00:08:03.200
 is 4 bytes and Link and we

138
00:08:03.200 --> 00:08:07.100
 know the offset value is 2003 bytes.

139
00:08:08.700 --> 00:08:11.800
To do this. Let us modify our existent

140
00:08:11.800 --> 00:08:12.800
 python script

141
00:08:13.600 --> 00:08:16.000
Let's open the text editor like so.

142
00:08:17.800 --> 00:08:19.000
Let's click on file.

143
00:08:19.700 --> 00:08:21.000
Let's click on ubon.

144
00:08:21.500 --> 00:08:23.900
and select fuzz2.by

145
00:08:29.900 --> 00:08:32.300
On this python script, let's create a

146
00:08:32.300 --> 00:08:34.700
 new version of it. Let's click on file.

147
00:08:35.800 --> 00:08:36.800
Save us.

148
00:08:37.500 --> 00:08:40.400
Let's call this fuzz3.py.

149
00:08:41.400 --> 00:08:42.400
and click on Save

150
00:08:43.100 --> 00:08:43.500
great.

151
00:08:44.500 --> 00:08:47.400
Let's make some modifications to all python script.

152
00:08:48.200 --> 00:08:51.500
Our first modification let's delete this entire

153
00:08:51.500 --> 00:08:53.700
 or set value on its contents.

154
00:09:02.900 --> 00:09:05.300
Great. Let's create a new variable.

155
00:09:06.100 --> 00:09:08.300
let's call the Shell Code like so

156
00:09:09.200 --> 00:09:10.800
we'll specify equal.

157
00:09:11.700 --> 00:09:15.300
Open quotations Mark a close quotation

158
00:09:14.300 --> 00:09:15.700
 marks.

159
00:09:16.500 --> 00:09:18.900
a series 2003

160
00:09:20.300 --> 00:09:22.300
which is where the crash actually happened.

161
00:09:23.800 --> 00:09:26.900
Then we'll add 4 B's so we'll

162
00:09:26.900 --> 00:09:27.300
 say Plus.

163
00:09:28.400 --> 00:09:31.200
Open quotation marks place the B

164
00:09:31.200 --> 00:09:32.900
 and close the quotation marks.

165
00:09:33.900 --> 00:09:34.800
asterisk 4

166
00:09:35.900 --> 00:09:38.800
so this shell could it will generate two thousand

167
00:09:38.800 --> 00:09:39.800
 and three is

168
00:09:40.600 --> 00:09:43.800
and afterwards it will generate four bees.

169
00:09:46.500 --> 00:09:50.300
Next let's modify line 11 where

170
00:09:49.300 --> 00:09:52.600
 it says peel loot. Let's change the

171
00:09:52.600 --> 00:09:56.000
 word offset to call our new variable shellcode.

172
00:09:56.700 --> 00:09:57.400
like so

173
00:10:01.800 --> 00:10:04.100
once you're all set simply click file.

174
00:10:05.300 --> 00:10:07.400
And let's click on see if great.

175
00:10:08.600 --> 00:10:10.600
Now, let's close our text editor.

176
00:10:11.100 --> 00:10:14.500
And now let's head over back to our terminal.

177
00:10:15.500 --> 00:10:18.300
Let's head over back to our Windows machine.

178
00:10:19.500 --> 00:10:22.500
And run the ball server and reattach

179
00:10:22.500 --> 00:10:25.700
 it to immunity debugger and then we'll execute our

180
00:10:25.700 --> 00:10:27.300
 new python script.

181
00:10:38.600 --> 00:10:40.100
Next we will click on file.

182
00:10:41.200 --> 00:10:41.800
attach

183
00:10:42.600 --> 00:10:45.900
and we'll select all server process.

184
00:10:47.600 --> 00:10:49.100
And now we'll click on plea.

185
00:10:51.000 --> 00:10:51.300
Great.

186
00:10:54.400 --> 00:10:56.900
I'm going to upon Kali lanox on the side.

187
00:10:57.600 --> 00:10:58.100
like so

188
00:11:00.100 --> 00:11:03.000
and this time I'm going to type chmod.

189
00:11:04.100 --> 00:11:04.700
like so

190
00:11:10.300 --> 00:11:12.400
then I'm going to type Python 3.

191
00:11:18.600 --> 00:11:20.500
phase 3 Dot py

192
00:11:21.500 --> 00:11:22.300
and hit enter

193
00:11:23.600 --> 00:11:26.400
and notice the application has crush on

194
00:11:26.400 --> 00:11:27.500
 immunity debugger.

195
00:11:28.400 --> 00:11:31.900
The application pause and we have received an access violation

196
00:11:31.900 --> 00:11:34.200
 when executed for to

197
00:11:34.200 --> 00:11:36.800
 four to four two four two.

198
00:11:39.500 --> 00:11:41.500
Let's look at a registers once more.

199
00:11:42.600 --> 00:11:45.400
the eax register contains all

200
00:11:45.400 --> 00:11:45.900
 these

201
00:11:47.600 --> 00:11:51.400
the EBP register also contains 4

202
00:11:50.400 --> 00:11:51.800
 is

203
00:11:52.500 --> 00:11:55.100
simply because e in ASCII is

204
00:11:55.100 --> 00:11:58.200
 represented as four one and hexadecimal values.

205
00:11:59.800 --> 00:12:02.500
Looking at the EIP register we can

206
00:12:02.500 --> 00:12:05.700
 see 42, which is simply the

207
00:12:05.700 --> 00:12:08.500
 B and there are four B's with an EIP

208
00:12:08.500 --> 00:12:09.100
 register.

209
00:12:09.800 --> 00:12:12.600
This means we now have control of the

210
00:12:12.600 --> 00:12:15.300
 EIP register. The next step

211
00:12:15.300 --> 00:12:18.600
 is to simplifying any sort of Bad characters

212
00:12:18.600 --> 00:12:21.000
 when we are generating our shell good.

213
00:12:21.900 --> 00:12:24.700
In this video you have learned how to find all set

214
00:12:24.700 --> 00:12:24.900
 value.

215
00:12:26.600 --> 00:12:29.800
On in the next video, you will learn how to find Bad characters.

216
00:12:29.800 --> 00:12:32.400
 I hope this video has been informative for

217
00:12:32.400 --> 00:12:34.200
 you and I will see you in the next one.
