Chapter 07: Programming for Security Professionals
39. Takes you from one area of a program (a function) to another area
40. Writing programs in this language is easier than in machine language
41. What is the difference between the = and = = operators in C?
Many beginning C programmers make the mistake of using a single equal sign (=) instead of the double equal
sign (= =) when attempting to test the value of a variable. A single equal sign (the assignment operator) is used
to assign a value to a variable. For example, a = 5 assigns the value of 5 to the variable a. To test the value of
variable a, you could use the command “if (a = = 5)”. If you mistakenly wrote the statement as “if (a = 5)”, the
value of 5 is assigned to the variable a, and then the statement is evaluated as true. This is because any value
not equal to zero is evaluated as true, and a zero value is evaluated as false.
42. How does C’s for loop work?
The for loop is one of C’s most interesting pieces of code. In the following for loop, the first part initializes the
counter variable to 1, and then the second part tests a condition. It continues looping as long as the counter
variable’s value is equal to or less than 10. The last part of the for loop increments the counter variable by 1.
43. How is branching performed in Perl? Give an example.
In a Perl program, to go from one function to another, you simply call the function by entering the function
name in your source code. In the following example, the &name_best_guitarist line branches the program to
the sub name_best_guitarist function:
# Perl program illustrating the branching function
# Documentation is important
# Initialize variables
$first_name = “Jimi”;
$last_name = “Hendrix”;
&name_best_guitarist;
sub name_best_guitarist
{
printf “%s %s %s”, $first_name, $last_name, “was the best!”;
}
44. The Win32 class contains many functions you can call from your Perl script. How can attackers use these
functions, and should security professionals become proficient at using them in a program?
Attackers and security professionals can use these functions to discover information about a remote computer.
Although these functions aren’t difficult to understand, becoming proficient at using them in a program takes
After an algorithm is created a programmer would then convert this algorithm into pseudocode. Pseudocode