[No audio]
You've already learned a little bit about scripting,
and little bit about how to write
Python programs, which are often called scripts.
But there are other languages out there as well.
It's important to at least have an awareness of
Perl and JavaScript. Knowing a little bit about
those languages will allow you to write more
scripts that will fill more needs, and most
importantly, you'll be able to read scripts that
other developers wrote. So let's take a quick look
at Perl and JavaScript. First is Perl. Now Perl
is a flexible general purpose scripting language.
Actually, it's a family of two languages. The
original Perl which matured at Perl version 5
is still just called Perl. The newer version, Perl
version 6 is now called Raku. So they're really
two separate languages, and they've taken a
divergent path. So they're becoming less and less
a clone of one another, but they still have a
common heritage, and they also share a lot of new
ideas. So if a new feature is rolled out in Perl,
you may see it in Raku as well. Perl was
originally developed as a UNIX scripting language
for report processing. But now both Perl and Raku
run on most operating systems, and do a lot more
than just report processing. Another important
scripting language is JavaScript. It's a high
level, just in time compiled language. Now not
every version of JavaScript you'll run into is
compiled just in time, which basically means that
it is compiled right at the moment that you need
to execute the code. But most of today's
implementations are the JIT or just in time
compilation model. They're very popular in web
applications. In fact, it stated that 97% of all
websites out there have some JavaScript in them.
It's so popular that almost every web browser has
a built in JavaScript engine. So most people think
that JavaScript is for web applications only. But
that's really not true. It's just very popular in web
applications. But it's a flexible and powerful
standalone language as well. If you want to run
JavaScript code without being in the context of a
web application, the most popular approach or the
most popular runtime environment is Node.js. It's
an open source JavaScript runtime environment
that runs on many different operating systems. So
if you're going to use JavaScript in a pen
testing environment, there's a good chance you're
probably going to fire up the Node.js environment,
and then run your JavaScript code from with a
node, again as opposed to a web browser. If you
want to learn more about Perl and JavaScript,
there are lots of additional resources, here are
just a few links that will take you directly to
the Perl home website and the JavaScript website,
as well as some other resources here that talk
about how to invoke pen testing, or how to write
pen testing scripts in both languages. So dig
through these resources, and you probably learn
a lot about both languages. If you're wondering
what Perl or JavaScript code looks like, let's
take a look at a program in each one of the
languages. Now I tend to use the term program and
script interchangeably. Technically, these are
scripts. So a Perl script looks something like
this. Now, if you read through, you'll notice that
what the script is doing is it's asking the user
to input an IP address, a starting value and an
ending value. Well, what it's really doing is, it
is going to take the IP address and scan for the
ports from the starting value to the ending value.
So basically, this is a port scanner. You seen
it in other languages, and this is what it would
look like in Perl. Now you notice, there are
libraries in Perl, specifically, we use the IO,
Socket library to do all of the dirty work, and
all that we're doing is we're basically scanning through
from the beginning start or beginning port to
the end port, and asking is the port open. If it
is, say it's open, otherwise, do nothing and move
on. We can also create a port scanner in
JavaScript. Now when I say create, it's a little
bit of a misnomer because I'm really not creating
a port scanner at all. All I'm doing is I am using
a pre written library called portscanner. So once
I access that library, all I have to do is call
'portscanner.' some method. So in this case,
findAPortNotInUse, and I'm going to scan from
port 3000 to 3010, and what will happen is the
first port that is not in use in that range will
come back and send a message to the log or the
console rather, which basically just means print
it out at the bottom of the screen, this port is
available, and it tells me what port it found. Now
when I ran this on my computer port 3000 was
available so it immediately returned. But that
gives you an idea of what Perl script code looks
like in the previous slide and what JavaScript
code looks like in this slide. If you're
interested in either of these languages, follow
the resources. There's a lot of tutorials online
that'll teach you how to code in Perl, JavaScript.
[No audio]