Lesson 7 - Chapter 4: Scripting Basics Flashcards

1
Q

What is a script?

A

a script is a small program used to automate computing actions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Where are scripts written in and executed from? (2)

A
  1. Scripts are written in a plain text-based editor like Notepad
  2. Executed from a command prompt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is scripting?

A

powerful kind of programming that makes repetitive data manipulation and machine configuration easier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Scripts are stored as ___ files

A

text files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 6 scripting languages?

A

1) .bat
2) .ps1
3) .vbs
4) .sh
5) .js
6) .py

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are 3 characteristics of a .bat file extension (scripting language)?

also known as a batch file

A
  1. Runs commands in sequence
  2. Displays each command as it runs using echo
  3. Includes remarks that explain the purpose of the file using REM
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the .bat file extension used by?

A

Command Prompt (originally developed for MS-DOS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The .ps1 file extension is used by what?

A

PowerShell scripts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is PowerShell?

A

PowerShell is an object-oriented scripting language built into Win10/11

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

PowerShell includes support for what 4 things?

v, l, c, c

A
  1. variables
  2. looping
  3. cmdlets
  4. consistent syntax using a verb-noun command structure (Get-Help)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are cmdlets?

A

small .NET-based apps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The .vbs file extension is used for? (2 names it’s known as)

A
  1. Visual Basic Script
  2. VBScript
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What’s a warning about .bat files?

A

There are no restrictions on .bat files so a harmful .bat file can be run without being blocked by Windows (view the contents of the file before running it)

[.bat files can be edited using Notepad or a word processing program because they’re plain-text files]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is VBScript? Derived from what? What editor does it use? (2)

A
  1. a Microsoft scripting language derived from Visual Basic
  2. uses any plain-text editor to create/edit VBScript files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The macro functions of Excel and other Office apps with macro support use what file extension instead of .vbs?

A

.vba (Visual Basic for Applications)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What 2 ways can you execute a VBScript file?

A
  1. wscript.exe interpreter (by default, displays output of script in a window or box)
  2. Windows Script Host
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What file extension is used for Bash shell files?

A

.sh

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are Bash shell files?

A

a type of executable file used originally on UNIX systems, now used on Linux/macOS in Terminal mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

The .js extension is used for what?

A

JavaScript scripts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is JavaScript widely used in? (6)

A
  1. Web development
  2. Web applications
  3. Web servers
  4. Server apps
  5. Smartwatch apps
  6. Mobile apps
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What type of language is JavaScript?

A

It’s an object-based, interpreted language (with no connection to Java programming language)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the .py extension used for?

A

Python scripts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is Python? What OS is it included on? (2)

A
  1. a versatile scripting and programming language
  2. included in macOS and most Linux distros (but available for Windows)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

The Python IDLE combines what?

A

a text editor with a Python interpreter (but can also be executed in a browser at websites like CodeAcademy)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Some scripting languages include….. (3)… that can be used to edit and run scripts

I, I, I

A
  1. IDE - Integrated Development Environment
  2. IDLE - Integrated Development and Learning Environment
  3. ISE - Integrated scripting environment
26
Q

Scripts allow a series of built-in commands to be used as an algorithm to….? (3)

A
  1. perform a task
  2. calculate a result
  3. measure and report system conditions

(among many others)

27
Q

What does API stand for?

A

Application Programming Interfaces

28
Q

JavaScript and Python use the API (application programming interfaces) of….

A

the host OS (which already perform all or some of a function)

29
Q

What makes a script usually easier and more efficient than writing a compile program?

A

a script is interpreted

30
Q

What PowerShell cmdlet restarts the OS on local and remote computers?

A

Restart-Computer (with parameters)

31
Q

What Linux command will restart the system?

A

shutdown -r

(though Linux systems require far fewer restarts than Windows)

32
Q

On Windows OS, what are drive mappings?

A

Assigning a drive an alphabetic identifier (like F: or C:)

33
Q

What is another term for mounted?

A

mapped

34
Q

Why would drives need to be remapped? (2)

A
  1. a drive is removed from the system (unmapped) and messes up the sequence
  2. a software app requires a particular drive alphabet ID

(common on larger networks)

35
Q

A mapped drive provides a connection between… (2)

A

A mapped drive provides a connection between a local drive and a shared directory/file on a remote device

36
Q

In a Windows script, what 2 commands are used for drive mapping? One is a PS command

A
  1. net use
  2. New-PSDrive (PS command)
37
Q

On Linux, drive mapping doesn’t exist as file systems are mounted to the ___ ___ ___

A

root file system (without a specific drive ID)

38
Q

What should you find if you want to create a text-formatted script file to install software silently?

A

find the silent mode parameter/switch for the setup/installer for each of the applications

39
Q

What are the 2 ways Installers are typically implemented on Windows?

A
  1. .exe files
  2. Windows Installer packages (.MSI)
40
Q

What does the syntax look like when you want to execute the setup.exe utility for a new app in silent mode and add an icon for the app on the Desktop?

Directory that contains the .exe = NewAppFiles

A

C:\NewAppFiles\setup.exe /S /desktopicon=yes

41
Q

What does the syntax look like to use the Windows Installer to add an app from a script in silent /qn?

Command: ?
Directory with installer: NewAppFiles

A

msiexec C:\NewAppFiles\install.msi /qn

42
Q

What is the cmdlet in PowerShell to run installs?

A

Start-Process

(more installation control, error-handling options)

43
Q

What 2 commands does Linux use with scripts to compile apps from source code?

A
  1. apt
  2. yum
44
Q

What can you use to run a simple type of backup?

A

ordinary file-copy tools (such as Robocopy in Windows)

45
Q

If you want to run a backup with a specific set of directories/files, what would be a better choice?

A

A script

46
Q

What can be run automatically using the Windows Task Scheduler or Linux cron setting? (for what purpose?)

A

a script (like any executable)

like when doing automated backups

47
Q

What PowerShell cmdlet do you use to capture the log file from a single app or apps in an install script?

A

Get-AppPackageLog

48
Q

____ has hundreds of ____ that can be used to access and return configuration and status information from Windows subsystems

A

PowerShell has hundreds of Get- cmdlets that can be used to access and return configuration/status information from Windows

49
Q

What scripting languages, commands or software can you use for:

  1. Restarting Machines (2)
  2. Remapping Network Drives (2)
  3. Installing Applications (4)
  4. Automated Backups (2)
  5. Information Gathering (1)
  6. Initiating Updates (3)
A
  1. Restarting Machines:
    -PowerShell (Restart-Computer)
    -Linux (shutdown -r)
  2. Remapping Network Drives:
    -Windows script (net use)
    -PowerShell (New-PSDrive)
  3. Installing Applications:
    -Windows script (write path to installer and switches)
    -Windows Installer (msiexec and switch)
    -PowerShell (Start-Process)
    -Linux (apt-get/apt or yum)
  4. Automated Backups:
    -Robocopy (simple)
    -Scripts (Windows Task Scheduler, Linux cron)
  5. Information Gathering:
    -PowerShell (Get- cmdlets)
  6. Initiating Updates:
    -Command Prompt (wusa.exe initiated from script)
    -PowerShell (Install-Module)
    -Linux (apt-get/apt or yum)
50
Q

On a Windows 10/11 system command prompt, what installer can be initiated from a script and used to complete routine update tasks?

A

Windows Update Standalone Installer (wusa.exe)

51
Q

Besides wusa.exe (Windows Update Standalone Installer), what else can you use to manage the update process?

A

PowerShell cmdlet Install-Module

52
Q

On Linux systems, what 3 commands can be executed within a Bash script to install an app and as well as update it?

A
  1. apt-get
  2. apt
  3. yum
53
Q

What are 3 general drawbacks to using scripts?

A
  1. scripting languages are open-source
  2. require the installation of an interpreter
  3. slower than a compiled program (depending on scope of the script)
54
Q

How can an attacker use a script to introduce malware?

A

A customized script can be accessed and altered and used to install malware or launch a privilege escalation attack

55
Q

Besides rigorous testing, new system scripts should be run with…?

A

the lowest level of privileges necessary

56
Q

Unintentional malware is primarily poorly written script statements that provide access to…. (2)

A

system information or user accounts

57
Q

How can non-malicious scripts affect a system negatively? (3)

may, open, disable

A
  1. may shut down a software firewall
  2. open port settings
  3. disable anti-malware software
58
Q

A poorly constructed script can cause errors by possibly mishandling….?

A

the system’s resources

(can cause conditions that conflict with the normal actions of the CPU or OS from cmdlets that target a system resource)

59
Q

What is an “elevated command prompt”?

A

One with admin privileges

60
Q

Each command has its own syntax; what do you use on Windows and Linux to get instructions for a command? (2)

A
  1. Windows = help
  2. Linux = man