1
1

00:00:00,360  -->  00:00:01,770
<v Tutor>Scripting.</v>
2

2

00:00:01,770  -->  00:00:04,200
In this lesson, we're going to talk about scripting
3

3

00:00:04,200  -->  00:00:05,940
because it is so important
4

4

00:00:05,940  -->  00:00:07,740
to be able to automate things.
5

5

00:00:07,740  -->  00:00:09,090
Now, when it comes to automation,
6

6

00:00:09,090  -->  00:00:11,160
one of the best places to use automation
7

7

00:00:11,160  -->  00:00:12,750
is within the cloud.
8

8

00:00:12,750  -->  00:00:14,310
Now, when you use cloud automation,
9

9

00:00:14,310  -->  00:00:17,250
this is the completion of cloud-related administrative tasks
10

10

00:00:17,250  -->  00:00:19,170
without human intervention.
11

11

00:00:19,170  -->  00:00:20,880
Now, essentially, this allows us
12

12

00:00:20,880  -->  00:00:22,860
to do lots and lots of things
13

13

00:00:22,860  -->  00:00:26,010
without even being awake or noticing that it's happening,
14

14

00:00:26,010  -->  00:00:27,960
we let the computers do it for us.
15

15

00:00:27,960  -->  00:00:29,760
Now, when we deal with cloud automation,
16

16

00:00:29,760  -->  00:00:32,280
this can occur through the graphical user interface,
17

17

00:00:32,280  -->  00:00:33,300
through the command line,
18

18

00:00:33,300  -->  00:00:36,210
or through APIs like we just talked about.
19

19

00:00:36,210  -->  00:00:38,280
Now, let me give you a good example of this.
20

20

00:00:38,280  -->  00:00:39,660
Here is a script.
21

21

00:00:39,660  -->  00:00:42,600
This simple script is less than 50 lines of code.
22

22

00:00:42,600  -->  00:00:44,070
Now, you don't have to read the whole script,
23

23

00:00:44,070  -->  00:00:46,950
but if you want to pause the video and look at it, feel free.
24

24

00:00:46,950  -->  00:00:49,110
Now, this script, what is it doing?
25

25

00:00:49,110  -->  00:00:49,980
It's going to go through
26

26

00:00:49,980  -->  00:00:53,190
and find every cloud instance in your AWS region.
27

27

00:00:53,190  -->  00:00:56,520
In this case, it's set up for the US East 1 Region.
28

28

00:00:56,520  -->  00:00:59,130
Now, this is going to be any instance that's owned
29

29

00:00:59,130  -->  00:01:00,120
by your company,
30

30

00:01:00,120  -->  00:01:02,760
and label this production within this environment.
31

31

00:01:02,760  -->  00:01:04,860
Then, it's going to take a snapshot of them.
32

32

00:01:04,860  -->  00:01:07,170
Now, that doesn't sound like a real big deal, right?
33

33

00:01:07,170  -->  00:01:09,060
If I only have one instance in the cloud,
34

34

00:01:09,060  -->  00:01:10,680
this isn't really helping me that much
35

35

00:01:10,680  -->  00:01:11,700
because I could log in,
36

36

00:01:11,700  -->  00:01:13,920
I could take my own snapshot, and move on.
37

37

00:01:13,920  -->  00:01:16,020
But let's think if you were a large company,
38

38

00:01:16,020  -->  00:01:18,390
let's say you worked for the US government, for instance,
39

39

00:01:18,390  -->  00:01:21,750
they have hundreds and thousands of cloud instances
40

40

00:01:21,750  -->  00:01:23,280
sitting in that region,
41

41

00:01:23,280  -->  00:01:24,900
and so they can do this script
42

42

00:01:24,900  -->  00:01:26,310
and set up so that once a day
43

43

00:01:26,310  -->  00:01:28,680
it will go through and take snapshots for them.
44

44

00:01:28,680  -->  00:01:31,200
Thousands of instances all at once.
45

45

00:01:31,200  -->  00:01:32,940
This means no people have to think about it,
46

46

00:01:32,940  -->  00:01:33,990
there's no manual labor,
47

47

00:01:33,990  -->  00:01:36,300
and it's being done every single time
48

48

00:01:36,300  -->  00:01:37,410
because the code will run
49

49

00:01:37,410  -->  00:01:40,110
and do it seamlessly, every single time.
50

50

00:01:40,110  -->  00:01:42,270
That's the benefit of doing automation.
51

51

00:01:42,270  -->  00:01:43,830
Now, when it comes to cloud automation
52

52

00:01:43,830  -->  00:01:44,910
this is really important
53

53

00:01:44,910  -->  00:01:47,610
because if we don't have cloud automation and scripting,
54

54

00:01:47,610  -->  00:01:50,940
we can't actually do things like rapid elasticity
55

55

00:01:50,940  -->  00:01:53,820
because if I have to go and turn on a server myself
56

56

00:01:53,820  -->  00:01:56,640
and then install the software and then deploy it,
57

57

00:01:56,640  -->  00:02:00,150
that takes away all the benefits of this cloud elasticity.
58

58

00:02:00,150  -->  00:02:02,790
And so scripting is inherently necessary
59

59

00:02:02,790  -->  00:02:04,530
anytime you want to do orchestration
60

60

00:02:04,530  -->  00:02:06,780
and be able to do cloud automation.
61

61

00:02:06,780  -->  00:02:08,580
Now, what can you do with scripting?
62

62

00:02:08,580  -->  00:02:10,350
I just showed you a very simple script
63

63

00:02:10,350  -->  00:02:11,340
to be able to take a snapshot,
64

64

00:02:11,340  -->  00:02:12,930
but you can do so much more.
65

65

00:02:12,930  -->  00:02:15,180
Scripting can be used to provision resources,
66

66

00:02:15,180  -->  00:02:17,250
add accounts, assign permissions,
67

67

00:02:17,250  -->  00:02:18,990
and perform many other tasks,
68

68

00:02:18,990  -->  00:02:21,810
including backup, recovery, and scaling.
69

69

00:02:21,810  -->  00:02:23,580
It can provision, it can deprovision,
70

70

00:02:23,580  -->  00:02:25,350
it can do all sorts of stuff.
71

71

00:02:25,350  -->  00:02:27,150
It all depends on how creative you want to be
72

72

00:02:27,150  -->  00:02:29,100
and how you want to create your scripts.
73

73

00:02:29,100  -->  00:02:30,540
Now, when you create your script,
74

74

00:02:30,540  -->  00:02:32,820
you have to include several different elements.
75

75

00:02:32,820  -->  00:02:34,770
For instance, you have to have the parameters.
76

76

00:02:34,770  -->  00:02:36,780
What will that script take as input?
77

77

00:02:36,780  -->  00:02:38,730
You have to have the logic statements,
78

78

00:02:38,730  -->  00:02:41,370
what things are going to alter the flow of the execution?
79

79

00:02:41,370  -->  00:02:44,880
These are the if, then, else, do, while,
80

80

00:02:44,880  -->  00:02:47,310
all those things, all come down to logic.
81

81

00:02:47,310  -->  00:02:48,780
Then we have validation.
82

82

00:02:48,780  -->  00:02:50,970
We have to be able to validate input that's coming in
83

83

00:02:50,970  -->  00:02:52,530
that we're going to get through the script
84

84

00:02:52,530  -->  00:02:53,490
and make sure it's good,
85

85

00:02:53,490  -->  00:02:54,840
and then if we have something bad,
86

86

00:02:54,840  -->  00:02:56,340
we need to handle those errors,
87

87

00:02:56,340  -->  00:02:58,110
doing proper error handling.
88

88

00:02:58,110  -->  00:02:59,010
And at the end of this,
89

89

00:02:59,010  -->  00:03:00,660
we also need to do unit testing
90

90

00:03:00,660  -->  00:03:01,950
because if I create a script,
91

91

00:03:01,950  -->  00:03:04,770
I need to make sure I test it and it works flawlessly
92

92

00:03:04,770  -->  00:03:06,540
because if I'm going to spin something up
93

93

00:03:06,540  -->  00:03:09,210
and tell it to do it against a thousand instances
94

94

00:03:09,210  -->  00:03:11,880
if I do it wrong on one, that's kind of bad.
95

95

00:03:11,880  -->  00:03:13,560
But if I do it wrong on a thousand things,
96

96

00:03:13,560  -->  00:03:14,670
that's really bad.
97

97

00:03:14,670  -->  00:03:16,830
And it takes me a long time to clean that up.
98

98

00:03:16,830  -->  00:03:18,120
Now, when you're creating scripting,
99

99

00:03:18,120  -->  00:03:19,650
you have to do it in a language
100

100

00:03:19,650  -->  00:03:21,900
and there are lots of different languages you can use.
101

101

00:03:21,900  -->  00:03:24,270
For instance, you can write your scripts in JavaScript,
102

102

00:03:24,270  -->  00:03:26,430
Python, Ruby, Go,
103

103

00:03:26,430  -->  00:03:28,710
and there are numerous other ones out there.
104

104

00:03:28,710  -->  00:03:30,090
Now, which one should you use?
105

105

00:03:30,090  -->  00:03:32,250
Well, that depends on you and your use case.
106

106

00:03:32,250  -->  00:03:35,310
For me, Python is by far my favorite language.
107

107

00:03:35,310  -->  00:03:38,010
Most of the automation I do is written in Python.
108

108

00:03:38,010  -->  00:03:39,150
It's easy to learn.
109

109

00:03:39,150  -->  00:03:40,620
It's extremely useful for scripting
110

110

00:03:40,620  -->  00:03:41,970
as a system administrator,
111

111

00:03:41,970  -->  00:03:43,440
or as a cybersecurity analyst,
112

112

00:03:43,440  -->  00:03:45,360
or as a penetration tester.
113

113

00:03:45,360  -->  00:03:47,640
If you continue upward in the field of cybersecurity,
114

114

00:03:47,640  -->  00:03:48,750
I would recommend that you take
115

115

00:03:48,750  -->  00:03:51,030
at least a basic Python course
116

116

00:03:51,030  -->  00:03:52,920
so you can learn how to use it in the real world
117

117

00:03:52,920  -->  00:03:55,050
to make your job easier in the long run.
118

118

00:03:55,050  -->  00:03:57,930
Now, for the exam, one quick tip.
119

119

00:03:57,930  -->  00:04:00,270
You do not need to know how to create scripts,
120

120

00:04:00,270  -->  00:04:02,490
that is not within the objectives of this exam,
121

121

00:04:02,490  -->  00:04:05,520
but if you do decide to move on to the PenTest+ curriculum
122

122

00:04:05,520  -->  00:04:07,740
and that certification after CISA,
123

123

00:04:07,740  -->  00:04:10,050
be prepared to learn some basic scripting.
124

124

00:04:10,050  -->  00:04:11,100
On that exam,
125

125

00:04:11,100  -->  00:04:15,030
you do need to know Python, Ruby, PowerShell, and Bash.
126

126

00:04:15,030  -->  00:04:16,110
You don't have to be an expert,
127

127

00:04:16,110  -->  00:04:17,790
but you do need to be able to read those scripts
128

128

00:04:17,790  -->  00:04:19,140
and understand what they're doing
129

129

00:04:19,140  -->  00:04:21,690
because as a pen tester or a cybersecurity analyst,
130

130

00:04:21,690  -->  00:04:23,490
you will be analyzing scripts often,
131

131

00:04:23,490  -->  00:04:25,290
and sometimes even writing your own.
