79
E XERCISES
Before you move on to Chapter 8, try out the skills you learned from this chapter
by completing the following exercises:
1. View all of your environment variables with the more command.
2. Use the echo command to view the HOSTNAME variable.
3. Find a method to change the slash (/) to a backslash (\) in the faux
Microsoft cmd PS1 example (see Listing 7-2).
4. Create a variable named MYNEWVARIABLE and put your name in it.
5. Use echo to view the contents of MYNEWVARIABLE.
6. Export MYNEWVARIABLE so that it’s available in all environments.
7. Use the echo command to view the contents of the PATH variable.
8. Add your home directory to the PATH variable so that any binaries in your
home directory can be used in any directory.
9. Change your PS1 variable to "World's Greatest Hacker:".
8
B A S H S C R I P T I N G
Any self-respecting hacker must be able
to write scripts. For that matter, any self-
respecting Linux administrator must be
able to script. Hackers often need to automate
commands, sometimes from multiple tools, and this
is most efficiently done through short programs they
write themselves.
In this chapter, we build a few simple bash shell scripts to start you off
with scripting. We’ll add capabilities and features as we progress, eventually
building a script capable of finding potential attack targets over a range of
IP addresses.
To become an elite hacker, you also need the ability to script in one of
the widely used scripting languages, such as Ruby (Metasploit exploits are
written in Ruby), Python (many hacking tools are Python scripts), or Perl
(Perl is the best text-manipulation scripting language). I give a brief intro-
duction to Python scripting in Chapter 17.
|