1
1

00:00:00,210  -->  00:00:02,220
<v Instructor>Network segmentation.</v>
2

2

00:00:02,220  -->  00:00:03,930
In this lesson, we're going to go through
3

3

00:00:03,930  -->  00:00:05,520
and do a little bit of configuration
4

4

00:00:05,520  -->  00:00:07,410
of how you would do network segmentation
5

5

00:00:07,410  -->  00:00:09,600
and security within your network.
6

6

00:00:09,600  -->  00:00:11,070
Now, to do this, I'm going to be using
7

7

00:00:11,070  -->  00:00:13,500
an open source unified threat management appliance
8

8

00:00:13,500  -->  00:00:15,390
known as pfSense.
9

9

00:00:15,390  -->  00:00:16,710
You can download this yourself
10

10

00:00:16,710  -->  00:00:20,550
and install it in your own network at pfsense.org.
11

11

00:00:20,550  -->  00:00:22,950
Now, this lab is going to be focused on the installation
12

12

00:00:22,950  -->  00:00:25,260
and configuration issues that you might come across
13

13

00:00:25,260  -->  00:00:27,060
when you're doing this in the real world.
14

14

00:00:27,060  -->  00:00:29,280
To get started, I'm going to go into my lab environment,
15

15

00:00:29,280  -->  00:00:32,190
and I'm going to enter into the web application interface
16

16

00:00:32,190  -->  00:00:34,890
for this particular unified threat management system.
17

17

00:00:34,890  -->  00:00:36,960
I'm going to log in with my username and password,
18

18

00:00:36,960  -->  00:00:40,410
which in my case is admin, and the password of "Password."
19

19

00:00:40,410  -->  00:00:42,480
Now, once I'm in here, I want to go forward
20

20

00:00:42,480  -->  00:00:44,940
and look at the firewall ACLs.
21

21

00:00:44,940  -->  00:00:47,760
This firewall that we have has two different interfaces.
22

22

00:00:47,760  -->  00:00:50,490
It has an external one and an internal one.
23

23

00:00:50,490  -->  00:00:52,020
This might act like a router.
24

24

00:00:52,020  -->  00:00:53,610
On the external side, I have the internet.
25

25

00:00:53,610  -->  00:00:56,190
On the internal side, I have my local area network.
26

26

00:00:56,190  -->  00:00:57,810
This firewall is going to be screening
27

27

00:00:57,810  -->  00:01:00,030
any traffic coming in from the external network
28

28

00:01:00,030  -->  00:01:02,610
before it gets into my local network segment.
29

29

00:01:02,610  -->  00:01:04,080
This means that any traffic
30

30

00:01:04,080  -->  00:01:06,810
that matches my access control list can get through,
31

31

00:01:06,810  -->  00:01:09,180
and anything that's denied by my access control list
32

32

00:01:09,180  -->  00:01:10,470
will be rejected.
33

33

00:01:10,470  -->  00:01:13,470
So let's take a look at what rules we already have here.
34

34

00:01:13,470  -->  00:01:16,980
First, we're going to click on "Firewall," and then "Rules."
35

35

00:01:16,980  -->  00:01:19,320
From here, we can see on the WAN tab
36

36

00:01:19,320  -->  00:01:20,580
that there are several different types
37

37

00:01:20,580  -->  00:01:22,050
of traffic that's permitted.
38

38

00:01:22,050  -->  00:01:25,020
We have things like ICMP, which is ping traffic.
39

39

00:01:25,020  -->  00:01:27,960
We have DNS, which does domain name resolution.
40

40

00:01:27,960  -->  00:01:30,240
We have HTTP and HTTPS,
41

41

00:01:30,240  -->  00:01:31,830
which is going to allow web browsing.
42

42

00:01:31,830  -->  00:01:35,190
And we have SMTP, which is going to allow outbound email.
43

43

00:01:35,190  -->  00:01:36,960
Now notice all of these things
44

44

00:01:36,960  -->  00:01:39,060
are things that you would normally expect to see,
45

45

00:01:39,060  -->  00:01:40,710
and they all have forwarding rules.
46

46

00:01:40,710  -->  00:01:42,480
That means that traffic from these ports
47

47

00:01:42,480  -->  00:01:45,480
is going to be directed to a host inside the LAN.
48

48

00:01:45,480  -->  00:01:47,790
Now, all of these, except for ICMP that is.
49

49

00:01:47,790  -->  00:01:51,240
ICMP just has an allow rule, not a forwarding rule.
50

50

00:01:51,240  -->  00:01:53,280
Now, why are these forwarding rules in place?
51

51

00:01:53,280  -->  00:01:56,310
Well, because I'm setting up a DMZ.
52

52

00:01:56,310  -->  00:01:58,770
And so I'm going to have people from outside the network
53

53

00:01:58,770  -->  00:02:01,860
being able to go into my network using that forwarding,
54

54

00:02:01,860  -->  00:02:05,220
and then get to my DNS server or my HTTP server,
55

55

00:02:05,220  -->  00:02:08,850
or my HTTPS server, or my SMTP server.
56

56

00:02:08,850  -->  00:02:10,740
So now let's click on the LAN tab,
57

57

00:02:10,740  -->  00:02:12,270
which is the internal network.
58

58

00:02:12,270  -->  00:02:14,250
This is where I'm hosting those servers.
59

59

00:02:14,250  -->  00:02:16,620
Now notice here there is no egress filtering,
60

60

00:02:16,620  -->  00:02:18,000
which means there's nothing blocking
61

61

00:02:18,000  -->  00:02:19,680
anything from going out.
62

62

00:02:19,680  -->  00:02:21,960
Any type of traffic from a host on the LAN
63

63

00:02:21,960  -->  00:02:23,850
can go to any other endpoint,
64

64

00:02:23,850  -->  00:02:25,830
unless there's going to be a deny rule put in place
65

65

00:02:25,830  -->  00:02:27,960
by a higher level ACL.
66

66

00:02:27,960  -->  00:02:30,750
Now, if I click on the Firewall and click on NAT,
67

67

00:02:30,750  -->  00:02:31,583
you can see the host
68

68

00:02:31,583  -->  00:02:33,420
that I'm going to be sending this traffic to.
69

69

00:02:33,420  -->  00:02:35,550
Remember, I had that NAT forwarding going on.
70

70

00:02:35,550  -->  00:02:38,190
So here you see DNS is going to go to the server
71

71

00:02:38,190  -->  00:02:41,250
located at 10.1.0.1.
72

72

00:02:41,250  -->  00:02:44,130
If you look at the web, HTTP and HTTPS,
73

73

00:02:44,130  -->  00:02:47,747
this is going to my Apache web server at 10.1.0.10,
74

74

00:02:47,747  -->  00:02:52,747
and my SMTP is going to go to my email server at 10.1.0.2.
75

75

00:02:53,820  -->  00:02:56,430
So is there any issues with this?
76

76

00:02:56,430  -->  00:02:58,200
Well, there is an issue here.
77

77

00:02:58,200  -->  00:03:01,470
Putting all these things in the same segment is pretty risky
78

78

00:03:01,470  -->  00:03:03,660
because a web server, for instance, is going to be exposed
79

79

00:03:03,660  -->  00:03:05,730
to a large number of vulnerabilities and exploits
80

80

00:03:05,730  -->  00:03:08,310
because they can have things like cross-site scripting.
81

81

00:03:08,310  -->  00:03:10,350
They can have things like remote code execution
82

82

00:03:10,350  -->  00:03:12,180
and all sorts of other exploits.
83

83

00:03:12,180  -->  00:03:15,000
So if somebody was able to compromise that one server,
84

84

00:03:15,000  -->  00:03:17,400
they can then pivot over to the SMTP server,
85

85

00:03:17,400  -->  00:03:20,670
or over to the DNS server and take advantage of those too.
86

86

00:03:20,670  -->  00:03:23,190
So we probably want to add some segmentation,
87

87

00:03:23,190  -->  00:03:24,300
and that's what we're going to focus on
88

88

00:03:24,300  -->  00:03:26,370
here through the rest of this lab.
89

89

00:03:26,370  -->  00:03:29,040
Now, to configure this firewall so that my web server
90

90

00:03:29,040  -->  00:03:31,740
is put into an isolated demilitarized zone,
91

91

00:03:31,740  -->  00:03:33,900
I need to be able to separate it from the other hosts,
92

92

00:03:33,900  -->  00:03:34,733
and I'm going to do this
93

93

00:03:34,733  -->  00:03:37,470
by creating a third interface on the firewall.
94

94

00:03:37,470  -->  00:03:39,480
Now, to do this within pfSense,
95

95

00:03:39,480  -->  00:03:42,240
I'm going to go to "Interfaces" and then "Assignments."
96

96

00:03:42,240  -->  00:03:44,130
From here, I'm going to click the "Add" button,
97

97

00:03:44,130  -->  00:03:45,871
next to the unused interface.
98

98

00:03:45,871  -->  00:03:47,340
Now from the menu bar,
99

99

00:03:47,340  -->  00:03:51,780
I can select interfaces and then OPT1 for option one.
100

100

00:03:51,780  -->  00:03:54,210
I'm going to check the enable interface box,
101

101

00:03:54,210  -->  00:03:57,270
and I'm going to go in and select "Static IPv4"
102

102

00:03:57,270  -->  00:04:00,000
for my IPv4 configuration type.
103

103

00:04:00,000  -->  00:04:02,700
When I go down there, I'm going to put in the IPv4 address
104

104

00:04:02,700  -->  00:04:06,450
of 10.1.254.254,
105

105

00:04:06,450  -->  00:04:09,510
and I'm going to select 24 from the list box.
106

106

00:04:09,510  -->  00:04:12,360
Now I'm going to save my changes and apply those changes.
107

107

00:04:12,360  -->  00:04:14,640
This is going to enable that interface
108

108

00:04:14,640  -->  00:04:17,730
on the firewall using that IP address.
109

109

00:04:17,730  -->  00:04:20,550
Next I'm going to go to firewall and then click "Nat."
110

110

00:04:20,550  -->  00:04:22,320
And here I'm going to click the edit button,
111

111

00:04:22,320  -->  00:04:25,890
that pen icon, on the HTTP forwarding rule.
112

112

00:04:25,890  -->  00:04:30,780
I want to redirect that IP value to 10.1.254.10,
113

113

00:04:30,780  -->  00:04:33,630
and change my description of HTTP forwarding
114

114

00:04:33,630  -->  00:04:36,510
to the DMZ and then save it.
115

115

00:04:36,510  -->  00:04:39,390
Next, I'm going to edit the HTTPS forwarding rule.
116

116

00:04:39,390  -->  00:04:43,120
Again, I'm going to type in 10.1.254.10,
117

117

00:04:43,120  -->  00:04:45,600
and I'm going to change the description to HTTPS forwarding
118

118

00:04:45,600  -->  00:04:49,290
to the DMZ and click "Save," and then apply changes.
119

119

00:04:49,290  -->  00:04:51,000
So at this point,
120

120

00:04:51,000  -->  00:04:53,400
you can now see we have a couple of rules here.
121

121

00:04:53,400  -->  00:04:57,810
You can see we have the SMTP rule going to 10.1.0.2.
122

122

00:04:57,810  -->  00:04:59,040
It's using forwarding.
123

123

00:04:59,040  -->  00:05:03,523
Then we have HTTPS and HTTP both going to 10.1.254.10,
124

124

00:05:04,560  -->  00:05:07,050
using that forwarding rule to the DMZ.
125

125

00:05:07,050  -->  00:05:09,060
And finally, we have DNS still going
126

126

00:05:09,060  -->  00:05:12,330
to the DNS server located at 10.1.0.1.
127

127

00:05:12,330  -->  00:05:14,220
Next, I need to set up my logging.
128

128

00:05:14,220  -->  00:05:17,100
So anything that's going through this firewall gets logged.
129

129

00:05:17,100  -->  00:05:18,390
So what am I going to log?
130

130

00:05:18,390  -->  00:05:19,470
Well, let's go up here
131

131

00:05:19,470  -->  00:05:23,160
and click on "Status," "System Logs," and "Settings."
132

132

00:05:23,160  -->  00:05:24,540
Then scroll down,
133

133

00:05:24,540  -->  00:05:26,587
and click the check button next to
134

134

00:05:26,587  -->  00:05:29,160
"Log packets matched from the default block rules"
135

135

00:05:29,160  -->  00:05:30,390
in the rule set.
136

136

00:05:30,390  -->  00:05:32,910
This means anything that's blocked is going to get logged.
137

137

00:05:32,910  -->  00:05:34,890
All right, so everything's looking good now,
138

138

00:05:34,890  -->  00:05:36,930
but we still have one more step.
139

139

00:05:36,930  -->  00:05:39,690
We haven't configured the web server to move itself
140

140

00:05:39,690  -->  00:05:42,570
into the DMZ, because we changed the IP address,
141

141

00:05:42,570  -->  00:05:45,390
so now we have to give that web server that new IP address
142

142

00:05:45,390  -->  00:05:47,802
of 10.1.254.10.
143

143

00:05:47,802  -->  00:05:50,580
To do this, I'm going to log into my web server.
144

144

00:05:50,580  -->  00:05:52,200
I'm going to click on the network icon,
145

145

00:05:52,200  -->  00:05:55,560
and then select the wired connected, and the wired settings.
146

146

00:05:55,560  -->  00:05:58,440
From here, I'm going to turn the wired connection off,
147

147

00:05:58,440  -->  00:06:01,140
click the cog icon to be able to go into settings,
148

148

00:06:01,140  -->  00:06:05,250
and then set IPv4 tab to set static manual IP address.
149

149

00:06:05,250  -->  00:06:10,230
And I'm going to give the address of 10.1.254.10/24,
150

150

00:06:11,160  -->  00:06:15,420
with a default gateway of 10.1.254.254.
151

151

00:06:15,420  -->  00:06:17,910
Once I've done that, I can click that slider button
152

152

00:06:17,910  -->  00:06:19,740
to turn the wired connection back on
153

153

00:06:19,740  -->  00:06:21,450
and close the connection window.
154

154

00:06:21,450  -->  00:06:24,990
All right, at this point, we should have our DMZ configured
155

155

00:06:24,990  -->  00:06:28,320
with the web server sitting in the DMZ, the DNS server
156

156

00:06:28,320  -->  00:06:31,050
and the SMTP server sitting on the internal network,
157

157

00:06:31,050  -->  00:06:33,420
and the external network, being the internet,
158

158

00:06:33,420  -->  00:06:35,250
out on that external interface.
159

159

00:06:35,250  -->  00:06:37,650
Let's go ahead and test our segmentation.
160

160

00:06:37,650  -->  00:06:38,760
First, I'm going to verify
161

161

00:06:38,760  -->  00:06:41,640
that we can browse the server as normal if we're doing this
162

162

00:06:41,640  -->  00:06:45,540
from our PC, which is inside of that local area network.
163

163

00:06:45,540  -->  00:06:47,190
Well, to do this, I'm going to go to
164

164

00:06:47,190  -->  00:06:52,190
www.515support.com/dvwa, and www.515support.com/multitilde.
165

165

00:06:57,720  -->  00:07:01,170
Notice both of these browse with no issues at all.
166

166

00:07:01,170  -->  00:07:03,630
Next, I'm going to see if this server is vulnerable
167

167

00:07:03,630  -->  00:07:05,730
to a reverse shell attack vector.
168

168

00:07:05,730  -->  00:07:08,040
To do this, I'm going to go into Metasploit,
169

169

00:07:08,040  -->  00:07:09,510
like I've used in other lessons,
170

170

00:07:09,510  -->  00:07:12,240
and I'm going to use the exploit multi handler.
171

171

00:07:12,240  -->  00:07:14,430
And then I'm going to type in "Exploit."
172

172

00:07:14,430  -->  00:07:16,590
From here, I'm going to run the "Curl" command
173

173

00:07:16,590  -->  00:07:18,930
and see if I can establish a reverse shell.
174

174

00:07:18,930  -->  00:07:22,140
So if I type in "curl --user"
175

175

00:07:22,140  -->  00:07:23,310
and then the user I'm going to use,
176

176

00:07:23,310  -->  00:07:26,790
in this case sam:password,
177

177

00:07:26,790  -->  00:07:28,200
and the site I'm trying to do this to,
178

178

00:07:28,200  -->  00:07:33,200
http://www.515support.com/webdev/get.php.
179

179

00:07:36,540  -->  00:07:38,940
Now, this is not going to work this time.
180

180

00:07:38,940  -->  00:07:41,520
This means there's no interpreter shells being open,
181

181

00:07:41,520  -->  00:07:44,280
because our ACL should have been configured
182

182

00:07:44,280  -->  00:07:47,100
to only allow incoming connections on each interface.
183

183

00:07:47,100  -->  00:07:50,100
So it's going to block OPT1 when the web server
184

184

00:07:50,100  -->  00:07:52,440
is trying to initiate a new connection to it.
185

185

00:07:52,440  -->  00:07:54,750
However, it can reply to web sessions
186

186

00:07:54,750  -->  00:07:56,520
that external hosts have started.
187

187

00:07:56,520  -->  00:07:59,340
So when I tried to access it to the web browser,
188

188

00:07:59,340  -->  00:08:01,800
I made a request and then it responded.
189

189

00:08:01,800  -->  00:08:03,720
But in this case, with the curl command,
190

190

00:08:03,720  -->  00:08:06,930
I'm trying to have the server send that out initially
191

191

00:08:06,930  -->  00:08:09,660
without a request coming, and that is why we're showing
192

192

00:08:09,660  -->  00:08:12,030
that this reverse shell is not going to work.
193

193

00:08:12,030  -->  00:08:12,863
All right,
194

194

00:08:12,863  -->  00:08:15,030
let's go back and take a look at our firewall logs now.
195

195

00:08:15,030  -->  00:08:16,470
If I go back into my firewall,
196

196

00:08:16,470  -->  00:08:20,400
I can click on "Status," "System Logs," and then "Firewall."
197

197

00:08:20,400  -->  00:08:22,980
Note here you can see the log view has been configured
198

198

00:08:22,980  -->  00:08:25,530
with the most recent events at the top.
199

199

00:08:25,530  -->  00:08:28,560
Observe the rule at the top for regular HTTP browsing.
200

200

00:08:28,560  -->  00:08:32,670
This came from 192.168.2.192,
201

201

00:08:32,670  -->  00:08:37,670
and it went to the web server at 10.1.254.10 over port 80.
202

202

00:08:37,830  -->  00:08:40,500
Now, observe the default blocking rule that we saw here.
203

203

00:08:40,500  -->  00:08:44,670
10.1.254.10 is not allowed to establish a connection
204

204

00:08:44,670  -->  00:08:49,670
to 192.168.2.192 over port 8080.
205

205

00:08:50,160  -->  00:08:52,860
This is what we try to do when I use that curl command.
206

206

00:08:52,860  -->  00:08:55,170
Essentially, I was trying to go from the web server
207

207

00:08:55,170  -->  00:08:58,260
over to the client PC in the internal network,
208

208

00:08:58,260  -->  00:09:01,230
and because of this DMZ rule, it's going to block that.
209

209

00:09:01,230  -->  00:09:02,760
Now, if I click on that cross,
210

210

00:09:02,760  -->  00:09:06,570
I can see additional details about this hidden default rule.
211

211

00:09:06,570  -->  00:09:07,680
So as you can see here,
212

212

00:09:07,680  -->  00:09:09,930
we have successfully isolated our web server
213

213

00:09:09,930  -->  00:09:12,300
from other hosts on the internal network,
214

214

00:09:12,300  -->  00:09:14,010
while still allowing it to have access
215

215

00:09:14,010  -->  00:09:16,800
from those hosts to the web server when they need it
216

216

00:09:16,800  -->  00:09:18,090
but preventing the web server
217

217

00:09:18,090  -->  00:09:20,310
from getting back to those hosts.
218

218

00:09:20,310  -->  00:09:23,487
So you can see how we can add segmentation here to make sure
219

219

00:09:23,487  -->  00:09:26,190
that the devices in the internal network are protected
220

220

00:09:26,190  -->  00:09:29,850
from the external network and from that untrusted DMZ.
221

221

00:09:29,850  -->  00:09:32,160
Now, we've talked about jump boxes as well,
222

222

00:09:32,160  -->  00:09:34,680
and you could configure a jump box on the DMZ
223

223

00:09:34,680  -->  00:09:36,450
as the single point of entry.
224

224

00:09:36,450  -->  00:09:39,930
Essentially, you would get SSH access into that jump box
225

225

00:09:39,930  -->  00:09:42,840
in the DMZ, and then from that jump box in the DMZ
226

226

00:09:42,840  -->  00:09:44,550
you could access all of the other hosts
227

227

00:09:44,550  -->  00:09:47,850
inside the DMZ because it's in that environment already.
228

228

00:09:47,850  -->  00:09:49,410
This would be a good way to set things up,
229

229

00:09:49,410  -->  00:09:52,050
especially if you configure a forward proxy connection
230

230

00:09:52,050  -->  00:09:54,360
to those different application servers.
231

231

00:09:54,360  -->  00:09:56,430
All right, so I hope you've enjoyed this lesson
232

232

00:09:56,430  -->  00:09:59,580
as we got a little hands-on using unified threat management
233

233

00:09:59,580  -->  00:10:00,450
and firewalls,
234

234

00:10:00,450  -->  00:10:03,200
and going through some configurations for segmentation.
