Okay, so let's run our script.
OSPF p y hopefully what we'll see are ospf passwords and there you go.
OSPF password is cisco now on the Cisco router?
Once again, I could change that password.
So interface gigabit is zero zero ip ospf authentication key.
Let's set it to ospf poss.
What should happen is our python script should show us the new OSPF password.
This has been captured off the wire in real time.
And there you go.
OSPF pass.
So my simple Python script.
And I'll Katyusha.
OSPF dot p y.
This simple Python script is capturing packets off the wire and then displaying the password.
Now, you may want to save that to a file rather than.
Have it just print to the screen.
So as an example, Nano or SPF, JPY, let's rather than just print it to the screen, save it to a
file.
So I'll create a variable called my file.
I'll open up a file called and let's make this OSPF passwords text.
This is going to be a ratable file.
So basically I'm opening up a file with this name.
I don't have to use text.
I'll just use that to be consistent with, say, what Windows does.
It's a read write file and then I'm going to write the output to this file.
Now that's actually writing the packet.
So let's not do that.
Let's say write.
OSPF pass equals this.
So equals the OSPF password string plus the actual password.
And then I'm going to write the OSPF pass here.
And if you concerned that it's actually the same word, I'll just change it here to something else.
So this is just a variable called OSPF password that equals OSPF password, plus the actual password
that's captured.
We're opening up a file and then we're going to save that to the file.
And actually, what I will do here is I don't want to open the file up every time because it'll override
it.
I'll open up the file there and then write to the file per that output.
So it'll write the password consistently to the file.
Now I'm coding this on the fly, so hopefully my code isn't that bad.
So let's give it a go.
I'll run the script.
We won't see anything because we're not writing to the screen.
In this example, I'm just saving the information to a file.
But hopefully we'll stop that script now.
Hopefully we've got a file called OSPF Password, which we do.
And if I get that which is basically reading it, notice we can see ospf password is ospf poss ospf
password and then we get a prompt.
Now that's not such a great way to do it.
So like all things when it comes to coding, you iterate, you iterate what you, what you do.
So what I'll do is write that, but put a carriage return after it and let's see what that does.
So run it again.
Python three ospf.
P.
Very simple script.
Didn't like that.
Let's see what I did wrong here.
Let's add that like that.
Okay.
That looks better.
This is the thing with coding.
You know, start with a small script.
Try something.
See if it works.
Then try something else.
See if that works.
Keep iterating and keep improving your scripts.
So that should be long enough.
Clear the screen.
Ellis shows us our files.
Cat ospf password txt.
Notice there's our password with the carriage returns after it.
Okay.
So just to make the point, I'll run that again and then what I'll do here is clear the process.
But then I'll go onto the.
Interface and change the password to something else.
So let's set it to.
Hello?
One, two, three.
So that should display in our text file.
Now again, you could use cron to schedule this.
I'll end that now rather than running it interactively.
Just schedule this to run in the background and notice there's our password.
Hello?
One, two, three.
So I could, as an example, do this.
Notice I've started this script.
It's running in the background and I've got my terminal prompt.
Now, if I type top.
So notice top shows us that T Chalk is running in the background.
So is Python three.
So that script is busy running in the background.
What I could do is kill the process.
So let's kill t shock kill process.
One, two, four, eight.
And notice we see some output that the script is done.
So clear the screen.
Liz shows us our files.
Let's read that OSPF password file.
Notice there's the password written to the file.
Now, you could get fancy with your scripts.
You could get cron to kick start that script and then run it for a period of time.
So let's run it for half an hour.
We'll run it for a day or for a period of time.
You could get your script to email you.
The passwords do all kinds of things.
The moral of the story here is you can leverage Python and T shark to capture packets off the wire and
then do things.
So let me show you another example.
In the next video, I'll show you how to use this to capture, for instance, FTP passwords.