WEBVTT - This file was automatically generated by VIMEO

0
00:00:08.050 --> 00:00:12.590
Hi, and welcome back to section four Netcat Penetration Test.

1
00:00:13.490 --> 00:00:18.270
In this video we are going to talk in more details to work with files and data

2
00:00:18.350 --> 00:00:22.240
exfiltration in Netcat. In the last video,

3
00:00:22.740 --> 00:00:26.480
we saw the basic operation of transferring files with Netcat.

4
00:00:27.210 --> 00:00:32.150
We saw that the basic format to transfer data with Netcat is to start a server

5
00:00:32.570 --> 00:00:33.403
and a client.

6
00:00:33.770 --> 00:00:38.590
And we have to specify a port to start the communication as we see

7
00:00:38.650 --> 00:00:43.650
in the example for transferring. And we have a server, a lesson,

8
00:00:43.930 --> 00:00:46.370
a lesson, uh, net trans lesson app.

9
00:00:46.370 --> 00:00:50.930
Listen port and pass a file and a client that will receive this

10
00:00:51.600 --> 00:00:54.210
file, this content and make a local copy.

11
00:00:55.650 --> 00:01:00.350
An auto operation is to create a dump file during a communication.

12
00:01:00.810 --> 00:01:02.670
As we see in the exact example,

13
00:01:04.030 --> 00:01:08.410
we have a communication in the same structure about server and client,

14
00:01:08.990 --> 00:01:11.580
but at this time we have uh,

15
00:01:11.730 --> 00:01:16.660
dash o option to create like a dump file to record every formation

16
00:01:16.810 --> 00:01:18.900
that the connection is passing.

17
00:01:19.170 --> 00:01:23.860
This information is another example of using and creating all the

18
00:01:23.860 --> 00:01:24.860
manipulation file.

19
00:01:24.930 --> 00:01:29.810
With Netcat route operation that we could do with file is to check

20
00:01:30.110 --> 00:01:33.210
its integrity after the file transfer. For example,

21
00:01:33.790 --> 00:01:38.410
we could use the common line MD five five some for example.

22
00:01:38.410 --> 00:01:41.970
These tool is available in Mac Linux. Uh,

23
00:01:41.970 --> 00:01:43.730
to check the hash of the file,

24
00:01:44.610 --> 00:01:48.920
these tool will compute and check the MD five hash file.

25
00:01:49.760 --> 00:01:53.040
MD five stands for Message Digest five,

26
00:01:53.900 --> 00:01:58.880
and they have commonly used algorithms that are considering secure.

27
00:02:00.370 --> 00:02:05.290
A hash is a result of a mathematical computation performance on a set of

28
00:02:05.290 --> 00:02:06.123
data.

29
00:02:06.200 --> 00:02:10.970
This is a 128 beat check sum and it's used to verify

30
00:02:11.030 --> 00:02:11.530
the integrity,

31
00:02:11.530 --> 00:02:16.130
integrity of the file and have this format we gonna,

32
00:02:16.160 --> 00:02:21.020
that we see in the example here we call

33
00:02:21.040 --> 00:02:23.100
the common and pass a file.

34
00:02:24.490 --> 00:02:28.520
And when we have this file transfer from another place,

35
00:02:28.860 --> 00:02:33.680
we as execute the same common in this file and we can check the integrity

36
00:02:33.790 --> 00:02:35.640
between these, these two files.

37
00:02:36.650 --> 00:02:40.460
Data exploitation is known true as data extraction,

38
00:02:41.130 --> 00:02:44.020
data exportation or datat.

39
00:02:45.300 --> 00:02:49.950
This could be defined as a transfer of data from a computer or another

40
00:02:50.410 --> 00:02:51.243
device.

41
00:02:51.370 --> 00:02:56.350
And this transfer is taken sensible data in unauthorized way

42
00:02:57.320 --> 00:02:58.460
and unauthorized way.

43
00:02:58.460 --> 00:03:03.000
You can start assessing the target device and then start a remote shell.

44
00:03:03.630 --> 00:03:08.360
This allows our incoming client to connect to the net cat directly shell access.

45
00:03:09.090 --> 00:03:13.720
There is no user identification or authentication process

46
00:03:13.770 --> 00:03:15.200
associated with this access.

47
00:03:16.130 --> 00:03:20.750
One example of sensitive data in aex filtration is the formation

48
00:03:20.750 --> 00:03:24.190
present in password folders or log files.

49
00:03:25.050 --> 00:03:29.590
In Linux we have the log files in dash var dash log.

50
00:03:30.240 --> 00:03:32.870
These a special directory for storing logs.

51
00:03:33.340 --> 00:03:37.670
This directory contains logs from the operation system services

52
00:03:38.130 --> 00:03:42.670
and various apps running on the operational system in Microsoft Windows.

53
00:03:43.040 --> 00:03:47.950
Those log files are present at C dash windows dash C 22

54
00:03:48.140 --> 00:03:49.870
dash config in Linux.

55
00:03:50.090 --> 00:03:54.030
The password files are present in a composing of two files,

56
00:03:55.130 --> 00:03:59.910
PE W V D and shadow in the folder dash

57
00:04:00.620 --> 00:04:05.190
attc dash pe, wv d and dash a TC dash shadow.

58
00:04:06.440 --> 00:04:08.740
In past w d file,

59
00:04:09.480 --> 00:04:13.660
it contains the user's public information u I D

60
00:04:15.800 --> 00:04:18.860
for name home directory.

61
00:04:19.350 --> 00:04:23.980
While the shadow file contains the hash password and the

62
00:04:24.500 --> 00:04:26.900
password expiring data,

63
00:04:27.500 --> 00:04:32.220
a good and efficient way to copy a collection of files is using the tar

64
00:04:32.220 --> 00:04:33.053
command.

65
00:04:33.520 --> 00:04:37.300
Tar command is a type archive and it can be used

66
00:04:38.180 --> 00:04:43.080
easily to achieve large collections of files into a single file.

67
00:04:43.740 --> 00:04:48.720
The example here we have this common, we have in the first line,

68
00:04:49.340 --> 00:04:51.930
we have a dark command, uses some options,

69
00:04:52.590 --> 00:04:57.470
CV and Z C is for create new file

70
00:04:58.390 --> 00:05:02.790
V is for the verbose mode, and Z is for compact file.

71
00:05:03.290 --> 00:05:07.980
So the command will compact l file in this folder.

72
00:05:08.850 --> 00:05:11.740
Then we have the pipe common, the pipe.

73
00:05:11.860 --> 00:05:16.740
That's mean that what we have in the left will be the input for what we have

74
00:05:16.800 --> 00:05:17.633
in the left.

75
00:05:18.000 --> 00:05:22.620
So all the files will be compacted and sent to

76
00:05:22.920 --> 00:05:27.860
our instance of net cat that we have a connection in this port 4, 4, 4 4.

77
00:05:28.280 --> 00:05:32.780
In the second line we have net cat running in several modes.

78
00:05:32.800 --> 00:05:35.940
So the net cat is lessened in the port four,

79
00:05:35.940 --> 00:05:40.220
four for four and we have a pipe again that's mean that

80
00:05:41.020 --> 00:05:42.960
the, the client will be, uh,

81
00:05:42.960 --> 00:05:47.640
listen all the content that is coming from this port and all

82
00:05:48.150 --> 00:05:52.080
this will be file compacted by tar command.

83
00:05:52.830 --> 00:05:53.663
This input,

84
00:05:54.110 --> 00:05:58.880
this content will be the input for the another command in left of the

85
00:05:58.880 --> 00:06:03.120
pipe. So the file, the net cat in the server mode, we,

86
00:06:03.260 --> 00:06:06.040
we receive a file, a compacted file.

87
00:06:06.630 --> 00:06:10.800
Then you pass this to tar command,

88
00:06:11.100 --> 00:06:15.400
entire command you view with some options.

89
00:06:17.540 --> 00:06:22.400
ZX is for extract file V for reverse mode Z for

90
00:06:22.400 --> 00:06:26.000
compact file and p for preserve the permission of the files.

91
00:06:26.460 --> 00:06:31.340
So the result of this will be transfer of data in a high

92
00:06:31.770 --> 00:06:32.740
optimized way.

93
00:06:33.690 --> 00:06:38.100
Here I have a environment and we are gonna show some

94
00:06:38.260 --> 00:06:41.260
examples for work with files using Net cat.

95
00:06:42.670 --> 00:06:45.050
So we have two terminal here,

96
00:06:45.440 --> 00:06:49.690
here to make a simulation of the DIS transfer. All the,

97
00:06:49.690 --> 00:06:52.890
the transfer file are used in my local environment here

98
00:06:55.200 --> 00:06:59.500
and net CAT works fine for for this. So for example, in this terminal here,

99
00:06:59.620 --> 00:07:00.740
I will start a server.

100
00:07:01.610 --> 00:07:06.460
I'll simulate a chat system and in the first terminal here,

101
00:07:06.580 --> 00:07:08.740
I will start a net CAT in the server mode.

102
00:07:09.040 --> 00:07:12.900
So I use like this example here,

103
00:07:13.320 --> 00:07:18.290
net cat dash vv to get more s

104
00:07:18.360 --> 00:07:22.470
details, spec information. So V,

105
00:07:22.670 --> 00:07:26.900
L P L for lesson P for a port

106
00:07:28.010 --> 00:07:29.030
for four, for four.

107
00:07:29.470 --> 00:07:34.150
I will use our option dash o to create adapt file and i u uh,

108
00:07:34.460 --> 00:07:39.330
call this as dump version two

109
00:07:40.210 --> 00:07:41.970
X for example. Okay.

110
00:07:42.960 --> 00:07:47.940
And the right side I'll create a instance of net cat a client to connect with

111
00:07:47.940 --> 00:07:52.140
this server that i, I created before. So I will use um,

112
00:07:52.400 --> 00:07:56.220
net cat dash netv. I use local host

113
00:07:57.840 --> 00:07:59.080
'cause I have to specify a host.

114
00:07:59.140 --> 00:08:03.080
So it's a local host here and use the same port.

115
00:08:03.920 --> 00:08:08.920
Now I use start the server. I'll start the client. Okay,

116
00:08:08.920 --> 00:08:11.690
connection's. Good. So the client say

117
00:08:13.230 --> 00:08:15.480
hello the server,

118
00:08:15.860 --> 00:08:20.060
we receive the messaging and answer the quick writtens.

119
00:08:22.820 --> 00:08:27.320
Okay, so we have enough information. So because I use it, uh,

120
00:08:27.320 --> 00:08:31.200
dash vg, I have this information here for all the, the bytes that I,

121
00:08:31.760 --> 00:08:35.870
I receive it and I send it and I sent,

122
00:08:36.210 --> 00:08:40.290
so this is okay, the file, it's here,

123
00:08:42.200 --> 00:08:46.120
damp V2 x and we have the option to get

124
00:08:48.150 --> 00:08:51.090
all the information, all the information that we have. So we have,

125
00:08:51.090 --> 00:08:55.410
because I use the dash o, I have the ax more information here, here.

126
00:08:55.540 --> 00:08:58.840
And I have the string format information here.

127
00:08:58.860 --> 00:09:02.010
So we have more details of this file. Okay?

128
00:09:02.390 --> 00:09:05.850
Now we have another operation is for transfer file.

129
00:09:06.590 --> 00:09:10.480
So now we have a file to be transferred. So

130
00:09:12.320 --> 00:09:15.330
I'll use the same structure. I will, first of all,

131
00:09:16.370 --> 00:09:18.300
I'll create a new folder.

132
00:09:20.460 --> 00:09:24.510
So for example, that the three

133
00:09:26.140 --> 00:09:30.230
enter in this folder, okay?

134
00:09:30.260 --> 00:09:34.630
This file is new, a new folder. We don't have files here to, I will clear,

135
00:09:36.000 --> 00:09:40.980
uh, and I will use the same structure to uh,

136
00:09:41.610 --> 00:09:46.380
pass this file from another direction to transfer the file

137
00:09:46.490 --> 00:09:50.160
from one point to another point. So here I use,

138
00:09:50.800 --> 00:09:55.720
I will start in this terminal here, a NETCAT server and a net cat client here.

139
00:09:55.980 --> 00:10:00.800
So I use net CAT DV option to get more details about all

140
00:10:00.820 --> 00:10:03.610
the information. Listen,

141
00:10:03.990 --> 00:10:07.610
and p i you specify a port or four or four.

142
00:10:08.450 --> 00:10:13.170
I use the option to put a timeout that when a file,

143
00:10:14.310 --> 00:10:17.640
when a transmission file is over is done,

144
00:10:18.830 --> 00:10:23.370
we have five seconds of timeout and then the connection it's over. Okay?

145
00:10:23.470 --> 00:10:28.470
So W five and I will specify a file that

146
00:10:28.510 --> 00:10:32.990
I want to transfer. That will be dump V two X. Okay?

147
00:10:33.520 --> 00:10:34.950
These will be our server.

148
00:10:36.000 --> 00:10:39.190
Our client will follows the same structure.

149
00:10:39.410 --> 00:10:42.890
So we'll be netcat dash,

150
00:10:43.510 --> 00:10:47.380
VV W five. I will put the same output.

151
00:10:47.980 --> 00:10:49.140
I have to specify a host.

152
00:10:49.320 --> 00:10:54.190
So we'll be a local host port for four

153
00:10:54.290 --> 00:10:55.123
for four.

154
00:10:55.490 --> 00:10:59.970
And I have to specify a name of a file that,

155
00:11:00.240 --> 00:11:04.690
that we create for copy the, the file. So I'll use, uh,

156
00:11:04.910 --> 00:11:09.610
the copy of X, okay, X.

157
00:11:10.350 --> 00:11:15.290
So now I'll start our server and start a client.

158
00:11:15.910 --> 00:11:18.750
So we have a connection here.

159
00:11:20.020 --> 00:11:24.280
The content of the file has been, was being, uh,

160
00:11:25.180 --> 00:11:28.400
copied. Now the connection is done. Okay?

161
00:11:28.460 --> 00:11:32.760
So the server send this co the side of buy and the

162
00:11:33.180 --> 00:11:37.440
client receive this is the same quantity. That's mean, that's a, is a good sign,

163
00:11:37.950 --> 00:11:42.920
okay? Uh, aim to check the integrity of the file.

164
00:11:43.020 --> 00:11:47.080
We have a command is MD five son. So this command,

165
00:11:47.180 --> 00:11:49.520
you check the i the integrity of the file

166
00:11:51.800 --> 00:11:55.680
we use for calculate the dump of the,

167
00:11:57.970 --> 00:12:00.470
of the file. So here we have, uh,

168
00:12:00.590 --> 00:12:03.260
a hash as we saw before.

169
00:12:03.330 --> 00:12:08.220
Hash is a medical computation to arrive from

170
00:12:08.480 --> 00:12:09.313
the calculation.

171
00:12:09.570 --> 00:12:14.000
This will arrive number and to check the end,

172
00:12:14.000 --> 00:12:17.120
we can compare this number to the number two. Check the,

173
00:12:17.440 --> 00:12:20.960
i I think of the file. The file is here in,

174
00:12:20.960 --> 00:12:25.410
in our folder. And I use the same common,

175
00:12:26.280 --> 00:12:30.930
uh, with this file in this, in this side. So I use MD five stand.

176
00:12:34.740 --> 00:12:38.840
So we, we are able to see that the hash is the same.

177
00:12:39.620 --> 00:12:44.370
So that's mean that the integrity the file is okay.

178
00:12:44.550 --> 00:12:47.450
So is the same file, okay, we have a different names,

179
00:12:48.030 --> 00:12:52.250
but the content is the same. That's mean that the is the same file.

180
00:12:52.960 --> 00:12:53.793
Okay?

181
00:12:54.300 --> 00:12:59.090
So now you see an example of data exfiltration.

182
00:12:59.750 --> 00:13:04.060
So we have folder in some files that we have

183
00:13:04.570 --> 00:13:06.860
that we want to copy these files.

184
00:13:08.200 --> 00:13:10.710
Those files are sensitive files. So

185
00:13:12.960 --> 00:13:17.570
we have interesting common combination of commons to

186
00:13:17.930 --> 00:13:19.290
optimize the copy of this file.

187
00:13:20.300 --> 00:13:24.960
We don't need to copy every file in single operations to copy one file

188
00:13:25.220 --> 00:13:27.160
by by file one by one. No,

189
00:13:27.180 --> 00:13:32.170
we have some options to get more quantity of files that, uh, we want.

190
00:13:34.340 --> 00:13:38.360
So let me check my actual folder path.

191
00:13:40.630 --> 00:13:45.580
Oh, okay, I'm in, uh, my current, uh, user. So are you,

192
00:13:45.680 --> 00:13:46.513
you

193
00:13:47.780 --> 00:13:52.770
you gone in the root folder and we saw that a

194
00:13:52.770 --> 00:13:57.010
very interesting folder that contains sensitive folder

195
00:13:57.580 --> 00:14:02.200
files is this log. Okay,

196
00:14:02.200 --> 00:14:06.390
so lemme enter. I don't have to be in this, this folder,

197
00:14:09.410 --> 00:14:14.290
copy the, this folder. Okay? I wanna pass the path of the folder.

198
00:14:14.630 --> 00:14:16.370
And this works the same.

199
00:14:17.630 --> 00:14:22.170
So I will build a structure of my client and my server

200
00:14:22.550 --> 00:14:26.250
netcat. Okay? So in this side here, let me,

201
00:14:26.910 --> 00:14:27.743
for the client,

202
00:14:28.290 --> 00:14:32.570
I will create another folder that will be N card D.

203
00:14:33.580 --> 00:14:37.580
Okay, dear. For example, log

204
00:14:39.080 --> 00:14:42.240
files, lemme enter in this folder,

205
00:14:44.150 --> 00:14:49.150
okay? There's no file in this folder. Okay? Lemme clear

206
00:14:51.530 --> 00:14:54.930
terminal. Okay, let me clear the terminal here. Okay,

207
00:14:54.950 --> 00:14:59.170
so the task here is to copy files. That's right.

208
00:14:59.830 --> 00:15:04.130
So let me mount this structure. The structure here will be,

209
00:15:04.200 --> 00:15:07.930
I'll use the command tar. Okay? I, I create

210
00:15:10.780 --> 00:15:15.750
and v to get more details in Z for

211
00:15:15.750 --> 00:15:19.860
compact. The file, the file here

212
00:15:21.820 --> 00:15:24.550
will be var dash log.

213
00:15:26.110 --> 00:15:27.870
I use the pipe common.

214
00:15:29.140 --> 00:15:33.240
That's mean that what we have in the left will be the input

215
00:15:33.980 --> 00:15:35.400
for what we have in the right.

216
00:15:36.680 --> 00:15:39.750
I'll start common netcat

217
00:15:41.520 --> 00:15:45.740
and these will be post in this case local host.

218
00:15:48.170 --> 00:15:52.120
I specify a port of four and I will specify two

219
00:15:54.470 --> 00:15:58.290
option to get a, a timeout. That's good.

220
00:15:58.710 --> 00:16:00.690
So this will be the client, the client I will,

221
00:16:00.810 --> 00:16:03.530
I will run the client in this terminal in here,

222
00:16:04.750 --> 00:16:09.210
my destiny folder I you create an instance

223
00:16:10.690 --> 00:16:14.430
for the server that we'll, we'll receive the, the information.

224
00:16:14.850 --> 00:16:19.270
So here I use netcat dash v lp,

225
00:16:21.030 --> 00:16:24.840
this server, you listen in the port for four four,

226
00:16:25.510 --> 00:16:28.410
I'll specify a timeout here

227
00:16:30.310 --> 00:16:32.330
and I'll use the pipe again.

228
00:16:33.120 --> 00:16:36.870
So I'll use the tar file, uh, uh,

229
00:16:36.870 --> 00:16:39.440
command that the tar,

230
00:16:40.190 --> 00:16:44.280
this tar common here will receive the compact folder

231
00:16:45.030 --> 00:16:47.080
file that I created here. Okay?

232
00:16:49.220 --> 00:16:52.240
And I'll use the XV z p,

233
00:16:52.830 --> 00:16:57.200
it's mean that the tar here will extract all the file and we'll extract

234
00:16:57.700 --> 00:17:02.170
in this folder here. So the flow is like this,

235
00:17:03.800 --> 00:17:05.280
I view in this command here,

236
00:17:05.880 --> 00:17:10.680
I will create a compact file with the content of this folder here.

237
00:17:11.110 --> 00:17:14.830
Okay? I use net cat to,

238
00:17:15.330 --> 00:17:17.950
is is like a pipe, okay? Like a Bridget,

239
00:17:18.470 --> 00:17:21.990
I use net cat to connect here in this direction here.

240
00:17:22.650 --> 00:17:24.990
And the file that I created here,

241
00:17:25.700 --> 00:17:28.630
I'll receive here and I'll, uh, this,

242
00:17:30.610 --> 00:17:31.660
okay, this is the logic.

243
00:17:32.040 --> 00:17:36.820
So now let me start my server and inside my client,

244
00:17:38.660 --> 00:17:40.190
okay, we saw that

245
00:17:41.750 --> 00:17:46.040
we have a lot of files here, okay?

246
00:17:46.390 --> 00:17:49.320
Some files, it was okay to copy.

247
00:17:50.030 --> 00:17:54.880
Another ones was not copied because the permission was denied. Okay?

248
00:17:55.560 --> 00:18:00.180
But this is very interesting because I don't need to have the root password

249
00:18:00.530 --> 00:18:04.860
cations to copy some files. So these files are very important too.

250
00:18:05.490 --> 00:18:09.730
Okay? If I had a password is okay, but is either,

251
00:18:09.730 --> 00:18:13.690
either I don't have, there's no problem because some files are very interesting.

252
00:18:14.700 --> 00:18:19.660
So now my destination folder here,

253
00:18:19.760 --> 00:18:23.660
10 log file. If I use the command to list all, all the files,

254
00:18:25.100 --> 00:18:26.610
let's see, uh, let's, right,

255
00:18:26.890 --> 00:18:31.410
I have my Avar folder var,

256
00:18:32.500 --> 00:18:36.550
I have a log folder and now I, I have the files.

257
00:18:37.630 --> 00:18:41.050
So this is very interesting because we don't have, uh, for example,

258
00:18:41.790 --> 00:18:45.930
to copy one single file per time. No,

259
00:18:46.080 --> 00:18:47.170
with this command here,

260
00:18:48.540 --> 00:18:51.390
this is instructor here that we saw here.

261
00:18:52.810 --> 00:18:57.790
We was able to copy big quantity of files in

262
00:18:57.810 --> 00:19:01.990
one single common. So this is very interesting. This is very useful

263
00:19:03.530 --> 00:19:05.550
for the question of data exfiltration.

264
00:19:06.250 --> 00:19:11.180
In this video we saw about more details to work with

265
00:19:11.180 --> 00:19:15.420
files and data exfiltration with Netcat. The next video,

266
00:19:16.070 --> 00:19:20.460
we'll take a look about persistence using netcat and I hope to see you there.
