1
1

00:00:00,360  -->  00:00:02,010
<v Instructor>Pivoting.</v>
2

2

00:00:02,010  -->  00:00:03,570
Now, as I mentioned previously,
3

3

00:00:03,570  -->  00:00:06,660
there is a difference between pivoting and lateral movement.
4

4

00:00:06,660  -->  00:00:07,680
And so in this lesson,
5

5

00:00:07,680  -->  00:00:10,230
we are going to focus on exactly what pivoting is
6

6

00:00:10,230  -->  00:00:13,200
and how it distinctly is different from lateral movement.
7

7

00:00:13,200  -->  00:00:14,700
Now, when we talk about pivoting,
8

8

00:00:14,700  -->  00:00:18,090
this is when an attacker uses a compromised host, the pivot,
9

9

00:00:18,090  -->  00:00:20,100
as a platform from which to spread an attack
10

10

00:00:20,100  -->  00:00:22,020
to other points in the network.
11

11

00:00:22,020  -->  00:00:23,850
When I talk more about lateral movement,
12

12

00:00:23,850  -->  00:00:25,560
this is more focused on when an attacker
13

13

00:00:25,560  -->  00:00:27,120
hops from one host to another
14

14

00:00:27,120  -->  00:00:29,580
in search of vulnerabilities for them to exploit.
15

15

00:00:29,580  -->  00:00:32,580
But once they start running those attacks from one point,
16

16

00:00:32,580  -->  00:00:34,530
that is the pivot point.
17

17

00:00:34,530  -->  00:00:37,200
Now again, let me give you a quick word of warning here.
18

18

00:00:37,200  -->  00:00:38,820
Lateral movement and pivoting,
19

19

00:00:38,820  -->  00:00:39,810
while they are different
20

20

00:00:39,810  -->  00:00:42,810
and we talk about them as separate concepts in this lesson,
21

21

00:00:42,810  -->  00:00:44,310
they are used interchangeably
22

22

00:00:44,310  -->  00:00:46,710
by a lot of cybersecurity professionals.
23

23

00:00:46,710  -->  00:00:48,660
So when you're talking about this in the field,
24

24

00:00:48,660  -->  00:00:50,940
people will say lateral movement or pivoting
25

25

00:00:50,940  -->  00:00:52,890
to mean the same thing oftentimes,
26

26

00:00:52,890  -->  00:00:55,020
but for the exam, there is a difference.
27

27

00:00:55,020  -->  00:00:56,250
And so you need to remember,
28

28

00:00:56,250  -->  00:00:57,810
the difference really comes down to,
29

29

00:00:57,810  -->  00:01:00,090
if you have an attack point established
30

30

00:01:00,090  -->  00:01:01,440
and then you're conducting your attacks
31

31

00:01:01,440  -->  00:01:05,010
from that point in the network, that is your pivot point,
32

32

00:01:05,010  -->  00:01:07,770
and I'll go into that a little bit more in this lesson.
33

33

00:01:07,770  -->  00:01:09,180
Now, when we do pivoting,
34

34

00:01:09,180  -->  00:01:10,800
one of the main things we have to do
35

35

00:01:10,800  -->  00:01:12,690
is we use port forwarding.
36

36

00:01:12,690  -->  00:01:13,620
With port forwarding,
37

37

00:01:13,620  -->  00:01:16,530
this allows the attacker to use a host as a pivot
38

38

00:01:16,530  -->  00:01:17,850
and then we'll be able to access
39

39

00:01:17,850  -->  00:01:21,990
one of its open TCP ports to send traffic from this port
40

40

00:01:21,990  -->  00:01:25,050
to the port of another host on a different subnet.
41

41

00:01:25,050  -->  00:01:26,910
Now, I know that sounds a little complicated,
42

42

00:01:26,910  -->  00:01:29,160
so I'm going to go ahead and show you graphically
43

43

00:01:29,160  -->  00:01:30,423
what this means.
44

44

00:01:31,260  -->  00:01:33,090
First, we have a host.
45

45

00:01:33,090  -->  00:01:35,730
This is host A inside the victim network.
46

46

00:01:35,730  -->  00:01:39,330
As an attacker, I'm going to find some way to exploit host A
47

47

00:01:39,330  -->  00:01:40,500
through some kind of exploit.
48

48

00:01:40,500  -->  00:01:42,360
Maybe I used a phishing campaign,
49

49

00:01:42,360  -->  00:01:44,880
or maybe I found a vulnerability that I was able to exploit
50

50

00:01:44,880  -->  00:01:47,580
with some kind of zero-day code or something like that.
51

51

00:01:47,580  -->  00:01:50,520
However, I got in, let's just say host A
52

52

00:01:50,520  -->  00:01:54,630
has been had by an attacker and is now victimized.
53

53

00:01:54,630  -->  00:01:56,100
Then we have host B.
54

54

00:01:56,100  -->  00:01:57,960
The attacker might be conducting reconnaissance
55

55

00:01:57,960  -->  00:01:59,580
and identifying another target.
56

56

00:01:59,580  -->  00:02:02,130
So as I got into host A, I now start looking around
57

57

00:02:02,130  -->  00:02:04,500
and identified there's this other host, B.
58

58

00:02:04,500  -->  00:02:07,500
This is my looking out as a way of looking forward
59

59

00:02:07,500  -->  00:02:09,930
as the lateral movement that I may want to achieve later.
60

60

00:02:09,930  -->  00:02:10,950
And then I keep searching
61

61

00:02:10,950  -->  00:02:12,870
and I find that there's also this host C
62

62

00:02:12,870  -->  00:02:14,490
depicted here as a server,
63

63

00:02:14,490  -->  00:02:16,890
and so I have access to host A
64

64

00:02:16,890  -->  00:02:18,300
because I have control over it
65

65

00:02:18,300  -->  00:02:20,280
due to my initial exploitation.
66

66

00:02:20,280  -->  00:02:22,260
Then as part of my reconnaissance,
67

67

00:02:22,260  -->  00:02:24,450
I might find that I can reach host B,
68

68

00:02:24,450  -->  00:02:27,360
but I can't reach host C because it's on a different subnet.
69

69

00:02:27,360  -->  00:02:31,410
If this is the case, I may decide to exploit host B instead.
70

70

00:02:31,410  -->  00:02:34,590
By doing this, I now can have some kind of an exploit shell
71

71

00:02:34,590  -->  00:02:36,210
between host A and B.
72

72

00:02:36,210  -->  00:02:38,220
For instance, I may have gotten into host B
73

73

00:02:38,220  -->  00:02:39,510
and set up a listener on it
74

74

00:02:39,510  -->  00:02:42,720
and then had a Netcat connection between host A and B.
75

75

00:02:42,720  -->  00:02:44,550
Now that doesn't give me access to C yet,
76

76

00:02:44,550  -->  00:02:46,860
but I might be able to find that host B
77

77

00:02:46,860  -->  00:02:49,020
is on the same subnet as host C
78

78

00:02:49,020  -->  00:02:50,400
and has the ability to reach it
79

79

00:02:50,400  -->  00:02:52,290
because of its network configuration.
80

80

00:02:52,290  -->  00:02:54,840
For example, the firewall might trust host B,
81

81

00:02:54,840  -->  00:02:56,220
but doesn't trust host A,
82

82

00:02:56,220  -->  00:02:58,500
so host B can get into that subnet.
83

83

00:02:58,500  -->  00:03:02,040
Now, as the attacker, I want to be able to get into host C.
84

84

00:03:02,040  -->  00:03:03,390
So how can I do that?
85

85

00:03:03,390  -->  00:03:06,810
Well, maybe I'm going to set up a port forwarder on host B.
86

86

00:03:06,810  -->  00:03:08,820
For example, if I wanted to use RDP,
87

87

00:03:08,820  -->  00:03:10,530
the remote desktop protocol,
88

88

00:03:10,530  -->  00:03:14,550
I would set up a port forwarder of 3389 on host B.
89

89

00:03:14,550  -->  00:03:19,320
That will forward the port 3389 from B over to C.
90

90

00:03:19,320  -->  00:03:21,690
Now, I would have the ability from B
91

91

00:03:21,690  -->  00:03:23,130
to establish a connection,
92

92

00:03:23,130  -->  00:03:25,590
but that still won't get it all the way back to host A,
93

93

00:03:25,590  -->  00:03:27,900
which is where I actually have my footprint.
94

94

00:03:27,900  -->  00:03:31,080
So I would want to set up a listener on host A
95

95

00:03:31,080  -->  00:03:34,380
for port 3389, which again is RDP.
96

96

00:03:34,380  -->  00:03:38,250
This way, anything received on host B for port 3389
97

97

00:03:38,250  -->  00:03:40,860
will get forwarded from B over to C,
98

98

00:03:40,860  -->  00:03:41,693
and we're going to use it
99

99

00:03:41,693  -->  00:03:44,430
as a pass-through point or a pivot point.
100

100

00:03:44,430  -->  00:03:47,400
So now as an attacker, I can initiate an RDP session
101

101

00:03:47,400  -->  00:03:51,450
with host C from host A by going through host B
102

102

00:03:51,450  -->  00:03:53,130
and, essentially, I'm playing a telephone game.
103

103

00:03:53,130  -->  00:03:56,190
Anything I send to B is going to get redirected to C.
104

104

00:03:56,190  -->  00:03:59,280
Anything that goes from C to B gets redirected back to A,
105

105

00:03:59,280  -->  00:04:02,310
and so we're just passing through B on our way to C.
106

106

00:04:02,310  -->  00:04:04,740
This allows the attacker to successfully pivot
107

107

00:04:04,740  -->  00:04:08,250
from host A through host B into host C,
108

108

00:04:08,250  -->  00:04:11,370
and that way we have a full RDP connection ongoing.
109

109

00:04:11,370  -->  00:04:12,540
Now, that's the way it looks
110

110

00:04:12,540  -->  00:04:15,690
when you're doing this inside of a network graphically,
111

111

00:04:15,690  -->  00:04:18,120
and again, this is a very simplified diagram,
112

112

00:04:18,120  -->  00:04:19,200
but it gives you the idea
113

113

00:04:19,200  -->  00:04:21,540
of going through one host to another,
114

114

00:04:21,540  -->  00:04:23,250
and we're pivoting through that host
115

115

00:04:23,250  -->  00:04:25,050
by doing that port forwarding.
116

116

00:04:25,050  -->  00:04:25,883
In addition to that,
117

117

00:04:25,883  -->  00:04:29,040
we can do this instead of using RDP, we could use SSH.
118

118

00:04:29,040  -->  00:04:32,070
With SSH, it's actually really easy to use it for pivoting
119

119

00:04:32,070  -->  00:04:34,110
because you can use the -D flag,
120

120

00:04:34,110  -->  00:04:37,140
which sets up a local proxy and port forwarding
121

121

00:04:37,140  -->  00:04:38,340
on a given target.
122

122

00:04:38,340  -->  00:04:41,640
And so this is something that is used a lot by attackers.
123

123

00:04:41,640  -->  00:04:44,580
For instance, you might have, again, host A,
124

124

00:04:44,580  -->  00:04:46,320
host B and host C.
125

125

00:04:46,320  -->  00:04:47,880
Now, host A can't get to host C
126

126

00:04:47,880  -->  00:04:49,620
because it's being blocked by the firewall,
127

127

00:04:49,620  -->  00:04:51,570
but host B can get to host C.
128

128

00:04:51,570  -->  00:04:53,040
So what will we do?
129

129

00:04:53,040  -->  00:04:56,520
Well, we'll create an SSH channel between A to B,
130

130

00:04:56,520  -->  00:04:58,980
and then we'll pivot from B through the firewall
131

131

00:04:58,980  -->  00:05:00,150
over to host C,
132

132

00:05:00,150  -->  00:05:01,170
creating that connection
133

133

00:05:01,170  -->  00:05:04,860
and allowing host A to connect to host C through host B.
134

134

00:05:04,860  -->  00:05:06,480
Now, in both of my examples,
135

135

00:05:06,480  -->  00:05:08,910
I showed you where we used a single pivot point,
136

136

00:05:08,910  -->  00:05:10,830
but attackers can actually chain
137

137

00:05:10,830  -->  00:05:12,300
their proxy servers together
138

138

00:05:12,300  -->  00:05:14,610
in order to continue pivoting from host to host
139

139

00:05:14,610  -->  00:05:17,520
until they reach a mission critical host or server.
140

140

00:05:17,520  -->  00:05:19,920
For example, in one network I worked in,
141

141

00:05:19,920  -->  00:05:22,290
we had a very complex network setup
142

142

00:05:22,290  -->  00:05:23,760
with multiple different subnets
143

143

00:05:23,760  -->  00:05:25,950
where only certain ones could trust each other,
144

144

00:05:25,950  -->  00:05:26,850
and we had an attacker
145

145

00:05:26,850  -->  00:05:28,350
that actually found their way through
146

146

00:05:28,350  -->  00:05:30,390
three or four different subnetworks
147

147

00:05:30,390  -->  00:05:32,250
pivoting through until they got to the thing
148

148

00:05:32,250  -->  00:05:33,420
they were looking for.
149

149

00:05:33,420  -->  00:05:35,850
For example, some networks may be built
150

150

00:05:35,850  -->  00:05:37,470
in a very complex manner,
151

151

00:05:37,470  -->  00:05:38,880
and you may have certain areas
152

152

00:05:38,880  -->  00:05:40,290
that are dedicated on certain subnets,
153

153

00:05:40,290  -->  00:05:41,820
like the accounting subnet,
154

154

00:05:41,820  -->  00:05:43,410
your credit card databases,
155

155

00:05:43,410  -->  00:05:45,180
maybe you have some ICS or SCADA
156

156

00:05:45,180  -->  00:05:46,650
that's going to be on another network
157

157

00:05:46,650  -->  00:05:48,000
and an attacker can actually pivot
158

158

00:05:48,000  -->  00:05:49,680
through multiple pivot points
159

159

00:05:49,680  -->  00:05:52,290
until they get into the particular networks they need to
160

160

00:05:52,290  -->  00:05:53,940
for the attack they're trying to run.
161

161

00:05:53,940  -->  00:05:55,440
And so this is important to consider
162

162

00:05:55,440  -->  00:05:57,900
as people start chaining these proxy servers together
163

163

00:05:57,900  -->  00:06:00,350
to reach their end goal and into their end state.
