In this demonstration,
we'll use a Python script
to validate the results of a network scan.
Now, this scan will take the output from an nmap scan
and validate whether specific ports
that are open against a predefined list,
which could indicate potential security issues, right?
So, we're going to just use a nmap scan
and we're going to save it into just a text string, right?
Typically, you could save this when you do a real nmap scan
to output file and then import it.
But for the sake of this example, we're just going
to capture a little bit of it
and save it into the string, right?
And then we're going to compare the list against a
predefined list of ports
and services that should be flagged for potential issues.
All right, now as we go along,
we're going to define a function
to actually perform the scan.
So we scroll down here, so we have a function
and we define a function as validate the scan results.
And we're going to use a regular expression
to find all of the open ports.
So it's going to go through the scan result
string that we have up here.
All right, and then it's going to convert any
of the ports to numbers, right?
So it's easy to compare numbers versus strings,
so that just makes things a little bit easier for us.
And then we're going to simply check if any
of the ports are in the list of potential risk.
So Ports 22 for SSH, and Port 330 for MySQL.
Now, if there's no risk found, we're going
to print out no potential risk are found in the scan.
All right, so again, we're going
to use this regular expression
to go through and sort things out.
We're going to convert them to numbers
and then we're going to print out if there's a potential
risk or if there's no potential risk, we'll put,
there's no potential risk found on the scan.
And then we're going to call the function
'cause we've defined it here.
In Python scripts, we have to call the function after
and then we will see our results based off these printouts.
All right?
All right, perfect.
So now, we need to just run this script.
Now, we need to make sure that this is properly executable.
So we're going to look
at the
so I have it named 'validate_scan_results.py,'
so it's a Python script.
All right, so we just had to make sure that we
have executable rights.
So we do have that.
So we're good to go there.
And for Python, we're going to do Python 3,
and then we're going to validate the
_scan_results.py script.
Okay, very simple.
All right, perfect, so we see, based off of the nmap scan,
we did have Ports 22 open and Port 3306.
This is a simple way
to validate the scan results against the organization's
predefined list that we've identified as risk.
Just because you have a scan
and something says it's vulnerable, it doesn't mean
that it's vulnerable for your particular organization.
So, that's why we need to validate these scan results,
based off our organization and the services
and needs that we have.
I hope you enjoyed this simple demonstration
and I'll see you in the next one.